1 2 //metadoc Common copyright Steve Dekorte 2002 3 //metadoc Common license BSD revised 4 /*metadoc Common description 5 You may need to add an entry for your C compiler. 6 */ 7 8 /* 9 Trick to get inlining to work with various compilers 10 Kudos to Daniel A. Koepke 11 */ 12 13 /* 14 #if !defined(NS_INLINE) 15 #if defined(__GNUC__) 16 #define NS_INLINE static __inline__ __attribute__((always_inline)) 17 #elif defined(__MWERKS__) || defined(__cplusplus) 18 #define NS_INLINE static inline 19 #elif defined(_MSC_VER) 20 #define NS_INLINE static __inline 21 #elif TARGET_OS_WIN32 22 #define NS_INLINE static __inline__ 23 #endif 24 #endif 25 */ 26 27 #undef IO_DECLARE_INLINES 28 #undef IOINLINE 29 #undef IOINLINE_RECURSIVE 30 31 /* 32 #if defined(__cplusplus) 33 #ifdef IO_IN_C_FILE 34 #else 35 #define IO_DECLARE_INLINES 36 #define IOINLINE extern inline 37 #endif 38 #else 39 */ 40 41 /* 42 43 44 #if defined __XCODE__ && (TARGET_ASPEN_SIMULATOR || TARGET_OS_ASPEN) 45 #define NON_EXTERN_INLINES 1 46 #else 47 #if defined __GNUC__ && __GNUC__ >= 4 48 #define NON_EXTERN_INLINES 1 49 #endif 50 #endif 51 */ 52 53 54 #if defined(__APPLE__) 55 56 #ifndef NS_INLINE 57 #define NS_INLINE static __inline__ __attribute__((always_inline)) 58 #endif 59 60 #define IO_DECLARE_INLINES 61 #define IOINLINE NS_INLINE 62 63 /* clang is smart enough to handle inlining recursive functions, 64 * so defer to the value defined by NS_INLINE; GCC is not, so 65 * fall back to static inline for it. 66 */ 67 #ifdef __clang__ 68 #define IOINLINE_RECURSIVE NS_INLINE 69 #else 70 #define IOINLINE_RECURSIVE static inline 71 #endif 72 73 /* 74 #include "TargetConditionals.h" 75 76 77 //#if defined(__llvm__) && 78 #if defined(__XCODE__) 79 //__GNUC__ && __GNUC__ >= 4 80 //#warning inline for xcode 81 #ifdef IO_IN_C_FILE 82 // in .c 83 #define IO_DECLARE_INLINES 84 #define IOINLINE 85 #else 86 // in .h 87 #define IO_DECLARE_INLINES 88 #define IOINLINE inline 89 #endif 90 #else 91 //#warning inline for NON-xcode 92 #ifdef IO_IN_C_FILE 93 // in .c 94 #define IO_DECLARE_INLINES 95 #define IOINLINE inline 96 #else 97 // in .h 98 #define IO_DECLARE_INLINES 99 #define IOINLINE extern inline 100 #endif 101 102 #endif 103 */ 104 105 #elif (defined(__MINGW32__) || defined(_MSC_VER)) && !defined(__MINGW64__) 106 107 #ifdef IO_IN_C_FILE 108 // in .c 109 #define IO_DECLARE_INLINES 110 #define IOINLINE inline 111 #define IOINLINE_RECURSIVE inline 112 #else 113 // in .h 114 #define IO_DECLARE_INLINES 115 #define IOINLINE static inline 116 #define IOINLINE_RECURSIVE static inline 117 #endif 118 119 #elif defined(__MINGW64__) 120 121 #define IO_DECLARE_INLINES 122 #define IOINLINE static inline 123 #define IOINLINE_RECURSIVE static inline 124 125 #elif defined(__linux__) || defined(__OpenBSD__) || defined(__NetBSD__) || defined(__FreeBSD__) 126 #ifdef __GNUC_STDC_INLINE__ 127 #ifdef IO_IN_C_FILE 128 // in .c 129 #define IO_DECLARE_INLINES 130 #define IOINLINE 131 #define IOINLINE_RECURSIVE 132 #else 133 // in .h 134 #define IO_DECLARE_INLINES 135 #define IOINLINE inline 136 #define IOINLINE_RECURSIVE inline 137 #endif 138 #else 139 #ifdef IO_IN_C_FILE 140 // in .c 141 #define IO_DECLARE_INLINES 142 #define IOINLINE inline 143 #define IOINLINE_RECURSIVE inline 144 #else 145 // in .h 146 #define IO_DECLARE_INLINES 147 #define IOINLINE extern inline 148 #define IOINLINE_RECURSIVE extern inline 149 #endif 150 #endif 151 #else 152 153 #ifdef IO_IN_C_FILE 154 // in .c 155 #define IO_DECLARE_INLINES 156 #define IOINLINE 157 #define IOINLINE_RECURSIVE 158 #else 159 // in .h 160 #define IO_DECLARE_INLINES 161 #define IOINLINE inline 162 #define IOINLINE_RECURSIVE inline 163 #endif 164 165 #endif 166