Spaces:
Running
Running
| /** | |
| * @file incbin.h | |
| * @author Dale Weiler | |
| * @brief Utility for including binary files | |
| * | |
| * Facilities for including binary files into the current translation unit and | |
| * making use from them externally in other translation units. | |
| */ | |
| /* Lookup table of (1 << n) where `n' is `INCBIN_ALIGNMENT_INDEX' */ | |
| /* Actual alignment value */ | |
| /* Stringize */ | |
| /* Concatenate */ | |
| /* Deferred macro expansion */ | |
| /* Variable argument count for overloading by arity */ | |
| /* Green Hills uses a different directive for including binary data */ | |
| /* Or consider the ".myrawdata" entry in the ld file */ | |
| /* Utilize .balign where supported */ | |
| /* | |
| * On arm assemblers, the alignment value is calculated as (1 << n) where `n' is | |
| * the shift count. This is the value passed to `.align' | |
| */ | |
| /* We assume other inline assembler's treat `.align' as `.balign' */ | |
| /* INCBIN_CONST is used by incbin.c generated files */ | |
| /** | |
| * @brief Optionally override the linker section into which size and data is | |
| * emitted. | |
| * | |
| * @warning If you use this facility, you might have to deal with | |
| * platform-specific linker output section naming on your own. | |
| */ | |
| /** | |
| * @brief Optionally override the linker section into which data is emitted. | |
| * | |
| * @warning If you use this facility, you might have to deal with | |
| * platform-specific linker output section naming on your own. | |
| */ | |
| /** | |
| * @brief Optionally override the linker section into which size is emitted. | |
| * | |
| * @warning If you use this facility, you might have to deal with | |
| * platform-specific linker output section naming on your own. | |
| * | |
| * @note This is useful for Harvard architectures where program memory cannot | |
| * be directly read from the program without special instructions. With this you | |
| * can chose to put the size variable in RAM rather than ROM. | |
| */ | |
| /* The directives are different for Apple branded compilers */ | |
| /* On arm assemblers, `@' is used as a line comment token */ | |
| /* Mingw doesn't support this directive either */ | |
| /* It's safe to use `@' on other architectures */ | |
| /* List of style types used for symbol names */ | |
| /** | |
| * @brief Specify the prefix to use for symbol names. | |
| * | |
| * @note By default this is "g". | |
| * | |
| * @code | |
| * #define INCBIN_PREFIX incbin | |
| * #include "incbin.h" | |
| * INCBIN(Foo, "foo.txt"); | |
| * | |
| * // Now you have the following symbols instead: | |
| * // const unsigned char incbinFoo<data>[]; | |
| * // const unsigned char *const incbinFoo<end>; | |
| * // const unsigned int incbinFoo<size>; | |
| * @endcode | |
| */ | |
| /** | |
| * @brief Specify the style used for symbol names. | |
| * | |
| * Possible options are | |
| * - INCBIN_STYLE_CAMEL "CamelCase" | |
| * - INCBIN_STYLE_SNAKE "snake_case" | |
| * | |
| * @note By default this is INCBIN_STYLE_CAMEL | |
| * | |
| * @code | |
| * #define INCBIN_STYLE INCBIN_STYLE_SNAKE | |
| * #include "incbin.h" | |
| * INCBIN(foo, "foo.txt"); | |
| * | |
| * // Now you have the following symbols: | |
| * // const unsigned char <prefix>foo_data[]; | |
| * // const unsigned char *const <prefix>foo_end; | |
| * // const unsigned int <prefix>foo_size; | |
| * @endcode | |
| */ | |
| /* Style lookup tables */ | |
| /* Style lookup: returning identifier */ | |
| /* Style lookup: returning string literal */ | |
| /* Generate the global labels by indirectly invoking the macro with our style | |
| * type and concatenating the name against them. */ | |
| /** | |
| * @brief Externally reference binary data included in another translation unit. | |
| * | |
| * Produces three external symbols that reference the binary data included in | |
| * another translation unit. | |
| * | |
| * The symbol names are a concatenation of `INCBIN_PREFIX' before *NAME*; with | |
| * "Data", as well as "End" and "Size" after. An example is provided below. | |
| * | |
| * @param TYPE Optional array type. Omitting this picks a default of `unsigned char`. | |
| * @param NAME The name given for the binary data | |
| * | |
| * @code | |
| * INCBIN_EXTERN(Foo); | |
| * | |
| * // Now you have the following symbols: | |
| * // extern const unsigned char <prefix>Foo<data>[]; | |
| * // extern const unsigned char *const <prefix>Foo<end>; | |
| * // extern const unsigned int <prefix>Foo<size>; | |
| * @endcode | |
| * | |
| * You may specify a custom optional data type as well as the first argument. | |
| * @code | |
| * INCBIN_EXTERN(custom_type, Foo); | |
| * | |
| * // Now you have the following symbols: | |
| * // extern const custom_type <prefix>Foo<data>[]; | |
| * // extern const custom_type *const <prefix>Foo<end>; | |
| * // extern const unsigned int <prefix>Foo<size>; | |
| * @endcode | |
| */ | |
| /** | |
| * @brief Externally reference textual data included in another translation unit. | |
| * | |
| * Produces three external symbols that reference the textual data included in | |
| * another translation unit. | |
| * | |
| * The symbol names are a concatenation of `INCBIN_PREFIX' before *NAME*; with | |
| * "Data", as well as "End" and "Size" after. An example is provided below. | |
| * | |
| * @param NAME The name given for the textual data | |
| * | |
| * @code | |
| * INCBIN_EXTERN(Foo); | |
| * | |
| * // Now you have the following symbols: | |
| * // extern const char <prefix>Foo<data>[]; | |
| * // extern const char *const <prefix>Foo<end>; | |
| * // extern const unsigned int <prefix>Foo<size>; | |
| * @endcode | |
| */ | |
| /** | |
| * @brief Include a binary file into the current translation unit. | |
| * | |
| * Includes a binary file into the current translation unit, producing three symbols | |
| * for objects that encode the data and size respectively. | |
| * | |
| * The symbol names are a concatenation of `INCBIN_PREFIX' before *NAME*; with | |
| * "Data", as well as "End" and "Size" after. An example is provided below. | |
| * | |
| * @param TYPE Optional array type. Omitting this picks a default of `unsigned char`. | |
| * @param NAME The name to associate with this binary data (as an identifier.) | |
| * @param FILENAME The file to include (as a string literal.) | |
| * | |
| * @code | |
| * INCBIN(Icon, "icon.png"); | |
| * | |
| * // Now you have the following symbols: | |
| * // const unsigned char <prefix>Icon<data>[]; | |
| * // const unsigned char *const <prefix>Icon<end>; | |
| * // const unsigned int <prefix>Icon<size>; | |
| * @endcode | |
| * | |
| * You may specify a custom optional data type as well as the first argument. | |
| * These macros are specialized by arity. | |
| * @code | |
| * INCBIN(custom_type, Icon, "icon.png"); | |
| * | |
| * // Now you have the following symbols: | |
| * // const custom_type <prefix>Icon<data>[]; | |
| * // const custom_type *const <prefix>Icon<end>; | |
| * // const unsigned int <prefix>Icon<size>; | |
| * @endcode | |
| * | |
| * @warning This must be used in global scope | |
| * @warning The identifiers may be different if INCBIN_STYLE is not default | |
| * | |
| * To externally reference the data included by this in another translation unit | |
| * please @see INCBIN_EXTERN. | |
| */ | |
| /** | |
| * @brief Include a textual file into the current translation unit. | |
| * | |
| * This behaves the same as INCBIN except it produces char compatible arrays | |
| * and implicitly adds a null-terminator byte, thus the size of data included | |
| * by this is one byte larger than that of INCBIN. | |
| * | |
| * Includes a textual file into the current translation unit, producing three | |
| * symbols for objects that encode the data and size respectively. | |
| * | |
| * The symbol names are a concatenation of `INCBIN_PREFIX' before *NAME*; with | |
| * "Data", as well as "End" and "Size" after. An example is provided below. | |
| * | |
| * @param NAME The name to associate with this binary data (as an identifier.) | |
| * @param FILENAME The file to include (as a string literal.) | |
| * | |
| * @code | |
| * INCTXT(Readme, "readme.txt"); | |
| * | |
| * // Now you have the following symbols: | |
| * // const char <prefix>Readme<data>[]; | |
| * // const char *const <prefix>Readme<end>; | |
| * // const unsigned int <prefix>Readme<size>; | |
| * @endcode | |
| * | |
| * @warning This must be used in global scope | |
| * @warning The identifiers may be different if INCBIN_STYLE is not default | |
| * | |
| * To externally reference the data included by this in another translation unit | |
| * please @see INCBIN_EXTERN. | |
| */ | |