#ifndef INCBIN_H #define INCBIN_H #define INCBINSTR2(x) #x #define INCBINSTR(x) INCBINSTR2(x) #if OS_WINDOWS # define INCBIN_SECTION ".rdata, \"dr\"" #elif OS_MAC # define INCBIN_SECTION "__TEXT,__const" #else # define INCBIN_SECTION ".rodata" #endif /* Includes raw binary data into the executable. */ /* https://gist.github.com/mmozeiko/ed9655cf50341553d282 */ #define INCBIN_INCLUDE(name, file) \ __asm__(".section " INCBIN_SECTION "\n" \ ".global _incbin_" INCBINSTR(name) "_start\n" \ ".balign 16\n" \ "_incbin_" INCBINSTR(name) "_start:\n" \ ".incbin \"" file "\"\n" \ \ ".global _incbin_" INCBINSTR(name) "_end\n" \ ".balign 1\n" \ "_incbin_" INCBINSTR(name) "_end:\n" \ ); \ extern __attribute((aligned(16))) const char _incbin_ ## name ## _start[]; \ extern const char _incbin_ ## name ## _end[] /* Retrieve a buffer for included data using the name supplied to INCBIN_INCLUDE */ #define INCBIN_GET(name) BUFFER_FROM_POINTERS(_incbin_ ## name ## _start, _incbin_ ## name ## _end) #endif