buildlib: make better CC and CFLAGS guesses
[blocksruntime.git] / config.h
blob106419519d34c0d4732bae1b6c9434c0b8d8a146
1 #ifndef _CONFIG_H_
2 #define _CONFIG_H_
4 #ifdef __APPLE__
6 #define HAVE_AVAILABILITY_MACROS_H 1
7 #define HAVE_TARGET_CONDITIONALS_H 1
8 #define HAVE_OSATOMIC_COMPARE_AND_SWAP_INT 1
9 #define HAVE_OSATOMIC_COMPARE_AND_SWAP_LONG 1
10 #define HAVE_LIBKERN_OSATOMIC_H
12 /* Be sneaky and turn OSAtomicCompareAndSwapInt into OSAtomicCompareAndSwap32
13 * and OSAtomicCompareAndSwapLong into either OSAtomicCompareAndSwap32
14 * or OSAtomicCompareAndSwap64 (depending on __LP64__) so that the library
15 * is Tiger compatible!
17 #include <libkern/OSAtomic.h>
18 #undef OSAtomicCompareAndSwapInt
19 #undef OSAtomicCompareAndSwapLong
20 #define OSAtomicCompareAndSwapInt(o,n,v) OSAtomicCompareAndSwap32Compat(o,n,v)
21 #ifdef __LP64__
22 #define OSAtomicCompareAndSwapLong(o,n,v) OSAtomicCompareAndSwap64Compat(o,n,v)
23 #else
24 #define OSAtomicCompareAndSwapLong(o,n,v) OSAtomicCompareAndSwap32Compat(o,n,v)
25 #endif
27 static __inline bool OSAtomicCompareAndSwap32Compat(int32_t o, int32_t n, volatile int32_t *v)
28 {return OSAtomicCompareAndSwap32(o,n,(int32_t *)v);}
29 #ifdef __LP64__
30 static __inline bool OSAtomicCompareAndSwap64Compat(int64_t o, int64_t n, volatile int64_t *v)
31 {return OSAtomicCompareAndSwap64(o,n,(int64_t *)v);}
32 #endif
34 #else /* !__APPLE__ */
36 #if defined(__WIN32__) || defined(_WIN32)
38 /* Poor runtime.c code causes warnings calling InterlockedCompareExchange */
39 #define _CRT_SECURE_NO_WARNINGS 1
40 #include <windows.h>
41 static __inline int InterlockedCompareExchangeCompat(volatile void *v, long n, long o)
42 {return (int)InterlockedCompareExchange((LONG *)v, (LONG)n, (LONG)o);}
43 #undef InterlockedCompareExchange
44 #define InterlockedCompareExchange(v,n,o) InterlockedCompareExchangeCompat(v,n,o)
46 #elif defined(__GNUC__) /* && !defined(__WIN32__) && !defined(_WIN32) */
48 #if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 1) /* GCC >= 4.1 */
50 /* runtime.c ignores these if __WIN32__ or _WIN32 is defined */
51 #define HAVE_SYNC_BOOL_COMPARE_AND_SWAP_INT 1
52 #define HAVE_SYNC_BOOL_COMPARE_AND_SWAP_LONG 1
54 #else /* GCC earlier than version 4.1 */
56 #error GCC version 4.1 (or compatible) or later is required on non-apple, non-w32 targets
58 #endif /* GCC earlier than version 4.1 */
60 #endif /* !defined(__GNUC__) && !defined(__WIN32__) && !defined(_WIN32) */
62 #endif /* !__APPLE__ */
64 #endif /* _CONFIG_H_ */