diff --git a/libc/docs/dev/code_style.rst b/libc/docs/dev/code_style.rst --- a/libc/docs/dev/code_style.rst +++ b/libc/docs/dev/code_style.rst @@ -27,7 +27,7 @@ Macro style =========== -We define two kinds of macros: **code defined** and **build defined** macros. +We define two kinds of macros: #. **Build defined** macros are generated by `CMake` or `Bazel` and are passed down to the compiler with the ``-D`` command line flag. They start with the @@ -35,15 +35,27 @@ They either denote an action or define a constant. #. **Code defined** macros are defined within the ``src/__support/macros`` - folder. They all start with the ``LIBC_`` prefix. They are of two kinds - - * **Properties** - Build related properties like used compiler, target - architecture or enabled CPU features defined by introspecting compiler - defined preprocessor definitions. e.g., ``LIBC_TARGET_ARCH_IS_ARM``, - ``LIBC_TARGET_CPU_HAS_AVX2``, ``LIBC_COMPILER_IS_CLANG``, ... - * **Attributes** - Compiler agnostic attributes or functions to handle - specific operations. e.g., ``LIBC_INLINE``, ``LIBC_NO_LOOP_UNROLL``, - ``LIBC_LIKELY``, ``LIBC_INLINE_ASM``. + folder. They all start with the ``LIBC_`` prefix. + + * ``src/__support/macros/properties/`` - Build related properties like + target architecture or enabled CPU features defined by introspecting + compiler defined preprocessor defininitions. + + * ``architectures.h`` - Target architecture properties. + e.g., ``LIBC_TARGET_ARCH_IS_ARM``. + * ``compiler.h`` - Host compiler properties. + e.g., ``LIBC_COMPILER_IS_CLANG``. + * ``cpu_features.h`` - Target cpu apu feature availability. + e.g., ``LIBC_TARGET_CPU_HAS_AVX2``. + + * ``src/__support/macros/config.h`` - Important compiler and platform + features. Such macros can be used to produce portable code by + parameterizing compilation based on the presence or lack of a given + feature. e.g., ``LIBC_HAS_BUILTIN`` + * ``src/__support/macros/attributes.h`` - Attributes for functions, types, + and variables. e.g., ``LIBC_UNUSED`` + * ``src/__support/macros/optimization.h`` - Portable macros for performance + optimization. e.g., ``LIBC_LIKELY``, ``LIBC_LOOP_NOUNROLL`` Inline functions and variables defined in header files ======================================================