|
1.10
|
9#ifndef EGT_DETAIL_INCBIN_H
10#define EGT_DETAIL_INCBIN_H
12#if defined(__AVX512BW__) || \
13 defined(__AVX512CD__) || \
14 defined(__AVX512DQ__) || \
15 defined(__AVX512ER__) || \
16 defined(__AVX512PF__) || \
17 defined(__AVX512VL__) || \
19# define INCBIN_ALIGNMENT_INDEX 6
20#elif defined(__AVX__) || \
22# define INCBIN_ALIGNMENT_INDEX 5
23#elif defined(__SSE__) || \
24 defined(__SSE2__) || \
25 defined(__SSE3__) || \
26 defined(__SSSE3__) || \
27 defined(__SSE4_1__) || \
28 defined(__SSE4_2__) || \
30# define INCBIN_ALIGNMENT_INDEX 4
31#elif ULONG_MAX != 0xffffffffu
32# define INCBIN_ALIGNMENT_INDEX 3
34# define INCBIN_ALIGNMENT_INDEX 2
38#define INCBIN_ALIGN_SHIFT_0 1
39#define INCBIN_ALIGN_SHIFT_1 2
40#define INCBIN_ALIGN_SHIFT_2 4
41#define INCBIN_ALIGN_SHIFT_3 8
42#define INCBIN_ALIGN_SHIFT_4 16
43#define INCBIN_ALIGN_SHIFT_5 32
44#define INCBIN_ALIGN_SHIFT_6 64
47#define INCBIN_ALIGNMENT \
49 INCBIN_CONCATENATE(INCBIN_ALIGN_SHIFT, _), \
50 INCBIN_ALIGNMENT_INDEX)
53#define INCBIN_STR(X) \
55#define INCBIN_STRINGIZE(X) \
58#define INCBIN_CAT(X, Y) \
60#define INCBIN_CONCATENATE(X, Y) \
63#define INCBIN_EVAL(X) \
65#define INCBIN_INVOKE(N, ...) \
66 INCBIN_EVAL(N(__VA_ARGS__))
71# define INCBIN_MACRO ".file"
74# define INCBIN_MACRO "\tINCBIN"
77# define INCBIN_MACRO ".incbin"
81# define INCBIN_ALIGN \
82 __attribute__((aligned(INCBIN_ALIGNMENT)))
84# define INCBIN_ALIGN __declspec(align(INCBIN_ALIGNMENT))
87#if defined(__arm__) || \
95# define INCBIN_ALIGN_HOST ".balign " INCBIN_STRINGIZE(INCBIN_ALIGNMENT) "\n"
96# define INCBIN_ALIGN_BYTE ".balign 1\n"
97#elif defined(INCBIN_ARM)
102# define INCBIN_ALIGN_HOST ".align " INCBIN_STRINGIZE(INCBIN_ALIGNMENT_INDEX) "\n"
103# define INCBIN_ALIGN_BYTE ".align 0\n"
106# define INCBIN_ALIGN_HOST ".align " INCBIN_STRINGIZE(INCBIN_ALIGNMENT) "\n"
107# define INCBIN_ALIGN_BYTE ".align 1\n"
111#if defined(__cplusplus)
112# define INCBIN_EXTERNAL extern "C"
113# define INCBIN_CONST extern const
115# define INCBIN_EXTERNAL extern
116# define INCBIN_CONST const
133#if !defined(INCBIN_OUTPUT_SECTION)
134# if defined(__APPLE__)
135# define INCBIN_OUTPUT_SECTION ".const_data"
137# define INCBIN_OUTPUT_SECTION ".rodata"
141#if defined(__APPLE__)
143# define INCBIN_SECTION INCBIN_OUTPUT_SECTION "\n"
144# define INCBIN_GLOBAL(NAME) ".globl " INCBIN_MANGLE INCBIN_STRINGIZE(INCBIN_PREFIX) #NAME "\n"
145# define INCBIN_INT ".long "
146# define INCBIN_MANGLE "_"
147# define INCBIN_BYTE ".byte "
148# define INCBIN_TYPE(...)
150# define INCBIN_SECTION ".section " INCBIN_OUTPUT_SECTION "\n"
151# define INCBIN_GLOBAL(NAME) ".global " INCBIN_STRINGIZE(INCBIN_PREFIX) #NAME "\n"
153# define INCBIN_INT ".word "
155# define INCBIN_INT ".int "
157# if defined(__USER_LABEL_PREFIX__)
158# define INCBIN_MANGLE INCBIN_STRINGIZE(__USER_LABEL_PREFIX__)
160# define INCBIN_MANGLE ""
162# if defined(INCBIN_ARM)
164# define INCBIN_TYPE(NAME) ".type " INCBIN_STRINGIZE(INCBIN_PREFIX) #NAME ", %object\n"
165# elif defined(__MINGW32__) || defined(__MINGW64__)
167# define INCBIN_TYPE(NAME)
170# define INCBIN_TYPE(NAME) ".type " INCBIN_STRINGIZE(INCBIN_PREFIX) #NAME ", @object\n"
172# define INCBIN_BYTE ".byte "
176#define INCBIN_STYLE_CAMEL 0
177#define INCBIN_STYLE_SNAKE 1
205#if !defined(INCBIN_PREFIX)
206# define INCBIN_PREFIX g
239#if !defined(INCBIN_STYLE)
240# define INCBIN_STYLE INCBIN_STYLE_CAMEL
244#define INCBIN_STYLE_0_DATA Data
245#define INCBIN_STYLE_0_END End
246#define INCBIN_STYLE_0_SIZE Size
247#define INCBIN_STYLE_1_DATA _data
248#define INCBIN_STYLE_1_END _end
249#define INCBIN_STYLE_1_SIZE _size
252#define INCBIN_STYLE_IDENT(TYPE) \
253 INCBIN_CONCATENATE( \
255 INCBIN_CONCATENATE( \
256 INCBIN_EVAL(INCBIN_STYLE), \
257 INCBIN_CONCATENATE(_, TYPE)))
260#define INCBIN_STYLE_STRING(TYPE) \
262 INCBIN_STYLE_IDENT(TYPE)) \
266#define INCBIN_GLOBAL_LABELS(NAME, TYPE) \
269 INCBIN_CONCATENATE( \
272 INCBIN_STYLE_IDENT, \
276 INCBIN_CONCATENATE( \
279 INCBIN_STYLE_IDENT, \
302#define INCBIN_EXTERN(NAME) \
303 INCBIN_EXTERNAL const INCBIN_ALIGN unsigned char \
304 INCBIN_CONCATENATE( \
305 INCBIN_CONCATENATE(INCBIN_PREFIX, NAME), \
306 INCBIN_STYLE_IDENT(DATA))[]; \
307 INCBIN_EXTERNAL const INCBIN_ALIGN unsigned char *const \
308 INCBIN_CONCATENATE( \
309 INCBIN_CONCATENATE(INCBIN_PREFIX, NAME), \
310 INCBIN_STYLE_IDENT(END)); \
311 INCBIN_EXTERNAL const unsigned int \
312 INCBIN_CONCATENATE( \
313 INCBIN_CONCATENATE(INCBIN_PREFIX, NAME), \
314 INCBIN_STYLE_IDENT(SIZE))
344#define INCBIN(NAME, FILENAME) \
347#define INCBIN(NAME, FILENAME) \
348 __asm__(INCBIN_SECTION \
349 INCBIN_GLOBAL_LABELS(NAME, DATA) \
351 INCBIN_MANGLE INCBIN_STRINGIZE(INCBIN_PREFIX) #NAME INCBIN_STYLE_STRING(DATA) ":\n" \
352 INCBIN_MACRO " \"" FILENAME "\"\n" \
353 INCBIN_GLOBAL_LABELS(NAME, END) \
355 INCBIN_MANGLE INCBIN_STRINGIZE(INCBIN_PREFIX) #NAME INCBIN_STYLE_STRING(END) ":\n" \
357 INCBIN_GLOBAL_LABELS(NAME, SIZE) \
359 INCBIN_MANGLE INCBIN_STRINGIZE(INCBIN_PREFIX) #NAME INCBIN_STYLE_STRING(SIZE) ":\n" \
360 INCBIN_INT INCBIN_MANGLE INCBIN_STRINGIZE(INCBIN_PREFIX) #NAME INCBIN_STYLE_STRING(END) " - " \
361 INCBIN_MANGLE INCBIN_STRINGIZE(INCBIN_PREFIX) #NAME INCBIN_STYLE_STRING(DATA) "\n" \