diff --git a/include/stddef.h b/include/stddef.h index f856119..773006f 100644 --- a/include/stddef.h +++ b/include/stddef.h @@ -17,7 +17,7 @@ typedef union { long long __ll; long double __ld; } max_align_t; typedef signed char int8_t; typedef signed short int int16_t; typedef signed int int32_t; -#ifdef __LP64__ +#if defined(__LP64__) && !defined(__APPLE__) typedef signed long int int64_t; #else typedef signed long long int int64_t; @@ -25,7 +25,7 @@ typedef signed long long int int64_t; typedef unsigned char uint8_t; typedef unsigned short int uint16_t; typedef unsigned int uint32_t; -#ifdef __LP64__ +#if defined(__LP64__) && !defined(__APPLE__) typedef unsigned long int uint64_t; #else typedef unsigned long long int uint64_t; @@ -36,6 +36,7 @@ typedef unsigned long long int uint64_t; #define NULL ((void*)0) #endif +#undef offsetof #define offsetof(type, field) ((size_t)&((type *)0)->field) void *alloca(size_t size); diff --git a/lib/alloca86_64.S b/lib/alloca86_64.S index a4aa173..bb03233 100644 --- a/lib/alloca86_64.S +++ b/lib/alloca86_64.S @@ -1,6 +1,9 @@ /* ---------------------------------------------- */ /* alloca86_64.S */ +#ifdef __APPLE__ +#define alloca _alloca +#endif .globl alloca alloca: diff --git a/libtcc.c b/libtcc.c index 256dfb6..8f95ace 100644 --- a/libtcc.c +++ b/libtcc.c @@ -943,6 +943,7 @@ LIBTCCAPI TCCState *tcc_new(void) /* emulate APPLE-GCC to make libc's headerfiles compile: */ tcc_define_symbol(s, "__APPLE__", "1"); tcc_define_symbol(s, "__GNUC__", "4"); /* darwin emits warning on GCC<4 */ + tcc_define_symbol(s, "__APPLE_CC__", "1"); /* for */ /* avoids usage of GCC/clang specific builtins in libc-headerfiles: */ tcc_define_symbol(s, "__FINITE_MATH_ONLY__", "1");