본문 바로가기

전체 글35

CMake에서 외부 패키지 가져오기 https://cmake.org/cmake/help/latest/module/FetchContent.html#id5 FetchContent — CMake 4.3.1 DocumentationContents This module provides commands to populate content at configure time or as part of the calling script. Load this module in CMake with: Note The Using Dependencies Guide provides a high-level introduction to this general topic. It provides a broadercmake.org FetchContent를 통해, vcpkg나 co.. 2026. 4. 5.
커널스페이스와 유저스페이스 리눅스에서는 CPU모드를 2가지로 나누어 실행한다커널모드에선 프로세서 명령어 집합, 메모리, 입출력 영역에 무제한 접근이 가능하다. 유저모드 프로세스에서는 시스템 호출을 통해 디바이스 드라이버, 커널모드로 요청을 전달한다. 커널모드에선 프로세스 문맥과 인터럽트 문맥으로 다시 나뉜다.프로세스 문맥은 유저모드의 어플리케이션이 요청한 시스템 호출을 처리한다. 인터럽트 문맥은 인터럽트를 처리한다.인터럽트 문맥은 비선점형으로 동작하며, 프로세스 문맥은 선점형으로 동작한다. 중요한 임계영역이라면 spin_lock_irq_save, spin_unlock_irq_restore를 사용하고, 인터럽트가 다루는 영역이 아니라면 spin_lock, spin_unlock을 사용하면 된다. 임베디드 개발자를 위한 코드로 읽는.. 2026. 3. 26.
C/C++] gcc 최적화 옵션 https://gcc.gnu.org/onlinedocs/gcc/Optimize-Options.html Optimize Options (Using the GNU Compiler Collection (GCC))Allow the built-in functions ceil, floor, round and trunc, and their float and long double variants, to generate code that raises the “inexact” floating-point exception for noninteger arguments. ISO C99 and C11 allow these functions to raise the “inegcc.gnu.org모든 최적화 플래그에 대해 다루지는 않으.. 2026. 3. 18.
C/C++] always_inline gcc에서 __attribute__((always_inline))을 작성하여, 컴파일러에게 인라인 함수를 권고하는 대신 강제하도록 할 수 있다. https://slowcloud.tistory.com/34 템플릿 메타 프로그래밍템플릿으로 typename을 활용하여 제네릭처럼 활용하는 경우가 많지만, 일반적인 자료형을 활용하여 메타프로그래밍을 진행할 수 있다. template int factorial() { if constexpr(n () * n; }}위와 같이 단순히 상slowcloud.tistory.com상단의 글에서 작성한 코드를 그대로 활용하되, inline을 강제하도록 작성했다.우측 어셈블리 코드를 보면, 재귀호출을 하는 대신 한 함수 안에 기능이 모두 구현되어 있는 것을 확인할 수 있다. 2026. 3. 6.
C++] 템플릿 메타 프로그래밍 템플릿으로 typename을 활용하여 제네릭처럼 활용하는 경우가 많지만, 일반적인 자료형을 활용하여 메타프로그래밍을 진행할 수 있다. template int factorial() { if constexpr(n () * n; }}위와 같이 단순히 상수를 넘겨받는 식으로 템플릿을 작성할 수 있으며, 재귀적으로 템플릿 함수를 호출하여 코드를 생성할 수 있다. 위는 코드를 컴파일했을 때 생성된 어셈블리 코드를 보여주는 사이트이다.상단의 코드를 좌측과 같이 작성했을 때, 우측의 어셈블리 코드에서 10 이하에 대한 팩토리얼 코드가 작성되는 것을 확인할 수 있다. 템플릿을 활용하면 컴파일 타임에 연산을 수행하여 더 빠르게 작동하는 프로그램을 작성할 수 있다. 상단은 컴파일 최적화 옵션을 넣고 컴파일한 결과.. 2026. 3. 6.
cmake 기본 활용 https://cmake.org/cmake/help/latest/guide/tutorial/index.html CMake Tutorial — CMake 4.3.0-rc2 DocumentationIntroduction The CMake tutorial provides a step-by-step guide that covers common build system issues that CMake helps address. Seeing how various topics all work together in an example project can be very helpful.cmake.org cmake는 메타 빌드 작성 도구이다. cmake를 통해 빌드시스템을 구성할 수 있다. 일반적으로는 make를 사용할 수.. 2026. 3. 6.