85 #endif // LINUX || _ALLBSD_SOURCE 86 87 // 4810578: varargs unsafe on 32-bit integer/64-bit pointer architectures 88 // When __cplusplus is defined, NULL is defined as 0 (32-bit constant) in 89 // system header files. On 32-bit architectures, there is no problem. 90 // On 64-bit architectures, defining NULL as a 32-bit constant can cause 91 // problems with varargs functions: C++ integral promotion rules say for 92 // varargs, we pass the argument 0 as an int. So, if NULL was passed to a 93 // varargs function it will remain 32-bits. Depending on the calling 94 // convention of the machine, if the argument is passed on the stack then 95 // only 32-bits of the "NULL" pointer may be initialized to zero. The 96 // other 32-bits will be garbage. If the varargs function is expecting a 97 // pointer when it extracts the argument, then we have a problem. 98 // 99 // Solution: For 64-bit architectures, redefine NULL as 64-bit constant 0. 100 // 101 // Note: this fix doesn't work well on Linux because NULL will be overwritten 102 // whenever a system header file is included. Linux handles NULL correctly 103 // through a special type '__null'. 104 #ifdef SOLARIS 105 #ifdef _LP64 106 #undef NULL 107 #define NULL 0L 108 #else 109 #ifndef NULL 110 #define NULL 0 111 #endif 112 #endif 113 #endif 114 115 // NULL vs NULL_WORD: 116 // On Linux NULL is defined as a special type '__null'. Assigning __null to 117 // integer variable will cause gcc warning. Use NULL_WORD in places where a 118 // pointer is stored as integer value. On some platforms, sizeof(intptr_t) > 119 // sizeof(void*), so here we want something which is integer type, but has the 120 // same size as a pointer. 121 #ifdef __GNUC__ 122 #ifdef _LP64 123 #define NULL_WORD 0L 124 #else 125 // Cast 0 to intptr_t rather than int32_t since they are not the same type 126 // on platforms such as Mac OS X. 127 #define NULL_WORD ((intptr_t)0) 128 #endif 129 #else 130 #define NULL_WORD NULL 131 #endif 132 133 #if !defined(LINUX) && !defined(_ALLBSD_SOURCE) 134 // Compiler-specific primitive types 135 typedef unsigned short uint16_t; 136 #ifndef _UINT32_T 137 #define _UINT32_T 138 typedef unsigned int uint32_t; 139 #endif // _UINT32_T 140 141 #if !defined(_SYS_INT_TYPES_H) 142 #ifndef _UINT64_T 143 #define _UINT64_T 144 typedef unsigned long long uint64_t; 145 #endif // _UINT64_T 146 // %%%% how to access definition of intptr_t portably in 5.5 onward? 147 typedef int intptr_t; 148 typedef unsigned int uintptr_t; 269 #define PRAGMA_DIAG_PUSH _Pragma("GCC diagnostic push") 270 #define PRAGMA_DIAG_POP _Pragma("GCC diagnostic pop") 271 272 // Hack to deal with gcc yammering about non-security format stuff 273 #else 274 // Old versions of gcc don't do push/pop, also do not cope with this pragma within a function 275 // One method does so much varied printing that it is decorated with both internal and external 276 // versions of the macro-pragma to obtain better checking with newer compilers. 277 #define PRAGMA_DIAG_PUSH 278 #define PRAGMA_DIAG_POP 279 #endif 280 281 #if (__GNUC__ == 2) && (__GNUC_MINOR__ < 95) 282 #define TEMPLATE_TABLE_BUG 283 #endif 284 #if (__GNUC__ == 2) && (__GNUC_MINOR__ >= 96) 285 #define CONST_SDM_BUG 286 #endif 287 288 // Formatting. 289 #ifdef _LP64 290 #define FORMAT64_MODIFIER "l" 291 #else // !_LP64 292 #define FORMAT64_MODIFIER "ll" 293 #endif // _LP64 294 295 // HACK: gcc warns about applying offsetof() to non-POD object or calculating 296 // offset directly when base address is NULL. Use 16 to get around the 297 // warning. gcc-3.4 has an option -Wno-invalid-offsetof to suppress 298 // this warning. 299 #define offset_of(klass,field) (size_t)((intx)&(((klass*)16)->field) - 16) 300 301 #ifdef offsetof 302 # undef offsetof 303 #endif 304 #define offsetof(klass,field) offset_of(klass,field) 305 306 #if defined(_LP64) && defined(__APPLE__) 307 #define JLONG_FORMAT "%ld" 308 #endif // _LP64 && __APPLE__ 309 310 #ifndef USE_LIBRARY_BASED_TLS_ONLY 311 #define THREAD_LOCAL_DECL __thread 312 #endif 313 314 // Inlining support 315 #define NOINLINE __attribute__ ((noinline)) 316 #define ALWAYSINLINE inline __attribute__ ((always_inline)) 317 318 #endif // SHARE_VM_UTILITIES_GLOBALDEFINITIONS_GCC_HPP | 85 #endif // LINUX || _ALLBSD_SOURCE 86 87 // 4810578: varargs unsafe on 32-bit integer/64-bit pointer architectures 88 // When __cplusplus is defined, NULL is defined as 0 (32-bit constant) in 89 // system header files. On 32-bit architectures, there is no problem. 90 // On 64-bit architectures, defining NULL as a 32-bit constant can cause 91 // problems with varargs functions: C++ integral promotion rules say for 92 // varargs, we pass the argument 0 as an int. So, if NULL was passed to a 93 // varargs function it will remain 32-bits. Depending on the calling 94 // convention of the machine, if the argument is passed on the stack then 95 // only 32-bits of the "NULL" pointer may be initialized to zero. The 96 // other 32-bits will be garbage. If the varargs function is expecting a 97 // pointer when it extracts the argument, then we have a problem. 98 // 99 // Solution: For 64-bit architectures, redefine NULL as 64-bit constant 0. 100 // 101 // Note: this fix doesn't work well on Linux because NULL will be overwritten 102 // whenever a system header file is included. Linux handles NULL correctly 103 // through a special type '__null'. 104 #ifdef SOLARIS 105 #undef NULL 106 #define NULL 0L 107 #endif 108 109 // NULL vs NULL_WORD: 110 // On Linux NULL is defined as a special type '__null'. Assigning __null to 111 // integer variable will cause gcc warning. Use NULL_WORD in places where a 112 // pointer is stored as integer value. On some platforms, sizeof(intptr_t) > 113 // sizeof(void*), so here we want something which is integer type, but has the 114 // same size as a pointer. 115 #ifdef __GNUC__ 116 #define NULL_WORD 0L 117 #else 118 #define NULL_WORD NULL 119 #endif 120 121 #if !defined(LINUX) && !defined(_ALLBSD_SOURCE) 122 // Compiler-specific primitive types 123 typedef unsigned short uint16_t; 124 #ifndef _UINT32_T 125 #define _UINT32_T 126 typedef unsigned int uint32_t; 127 #endif // _UINT32_T 128 129 #if !defined(_SYS_INT_TYPES_H) 130 #ifndef _UINT64_T 131 #define _UINT64_T 132 typedef unsigned long long uint64_t; 133 #endif // _UINT64_T 134 // %%%% how to access definition of intptr_t portably in 5.5 onward? 135 typedef int intptr_t; 136 typedef unsigned int uintptr_t; 257 #define PRAGMA_DIAG_PUSH _Pragma("GCC diagnostic push") 258 #define PRAGMA_DIAG_POP _Pragma("GCC diagnostic pop") 259 260 // Hack to deal with gcc yammering about non-security format stuff 261 #else 262 // Old versions of gcc don't do push/pop, also do not cope with this pragma within a function 263 // One method does so much varied printing that it is decorated with both internal and external 264 // versions of the macro-pragma to obtain better checking with newer compilers. 265 #define PRAGMA_DIAG_PUSH 266 #define PRAGMA_DIAG_POP 267 #endif 268 269 #if (__GNUC__ == 2) && (__GNUC_MINOR__ < 95) 270 #define TEMPLATE_TABLE_BUG 271 #endif 272 #if (__GNUC__ == 2) && (__GNUC_MINOR__ >= 96) 273 #define CONST_SDM_BUG 274 #endif 275 276 // Formatting. 277 #define FORMAT64_MODIFIER "l" 278 279 // HACK: gcc warns about applying offsetof() to non-POD object or calculating 280 // offset directly when base address is NULL. Use 16 to get around the 281 // warning. gcc-3.4 has an option -Wno-invalid-offsetof to suppress 282 // this warning. 283 #define offset_of(klass,field) (size_t)((intx)&(((klass*)16)->field) - 16) 284 285 #ifdef offsetof 286 # undef offsetof 287 #endif 288 #define offsetof(klass,field) offset_of(klass,field) 289 290 #if defined(__APPLE__) 291 #define JLONG_FORMAT "%ld" 292 #endif // __APPLE__ 293 294 #ifndef USE_LIBRARY_BASED_TLS_ONLY 295 #define THREAD_LOCAL_DECL __thread 296 #endif 297 298 // Inlining support 299 #define NOINLINE __attribute__ ((noinline)) 300 #define ALWAYSINLINE inline __attribute__ ((always_inline)) 301 302 #endif // SHARE_VM_UTILITIES_GLOBALDEFINITIONS_GCC_HPP |