src/share/vm/utilities/globalDefinitions_gcc.hpp
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File 7089790_full Sdiff src/share/vm/utilities

src/share/vm/utilities/globalDefinitions_gcc.hpp

Print this page
rev 2695 : shared changes


  59 
  60 #ifdef SOLARIS
  61 #include <thread.h>
  62 #endif // SOLARIS
  63 
  64 #include <limits.h>
  65 #include <errno.h>
  66 
  67 #ifdef SOLARIS
  68 #include <sys/trap.h>
  69 #include <sys/regset.h>
  70 #include <sys/procset.h>
  71 #include <ucontext.h>
  72 #include <setjmp.h>
  73 #endif // SOLARIS
  74 
  75 # ifdef SOLARIS_MUTATOR_LIBTHREAD
  76 # include <sys/procfs.h>
  77 # endif
  78 
  79 #ifdef LINUX
  80 #ifndef __STDC_LIMIT_MACROS
  81 #define __STDC_LIMIT_MACROS
  82 #endif // __STDC_LIMIT_MACROS
  83 #include <inttypes.h>
  84 #include <signal.h>

  85 #include <ucontext.h>












  86 #include <sys/time.h>
  87 #endif // LINUX
  88 
  89 // 4810578: varargs unsafe on 32-bit integer/64-bit pointer architectures
  90 // When __cplusplus is defined, NULL is defined as 0 (32-bit constant) in
  91 // system header files.  On 32-bit architectures, there is no problem.
  92 // On 64-bit architectures, defining NULL as a 32-bit constant can cause
  93 // problems with varargs functions: C++ integral promotion rules say for
  94 // varargs, we pass the argument 0 as an int.  So, if NULL was passed to a
  95 // varargs function it will remain 32-bits.  Depending on the calling
  96 // convention of the machine, if the argument is passed on the stack then
  97 // only 32-bits of the "NULL" pointer may be initialized to zero.  The
  98 // other 32-bits will be garbage.  If the varargs function is expecting a
  99 // pointer when it extracts the argument, then we have a problem.
 100 //
 101 // Solution: For 64-bit architectures, redefine NULL as 64-bit constant 0.
 102 //
 103 // Note: this fix doesn't work well on Linux because NULL will be overwritten
 104 // whenever a system header file is included. Linux handles NULL correctly
 105 // through a special type '__null'.
 106 #ifdef SOLARIS
 107   #ifdef _LP64
 108     #undef NULL
 109     #define NULL 0L
 110   #else
 111     #ifndef NULL
 112       #define NULL 0
 113     #endif
 114   #endif
 115 #endif
 116 
 117 // NULL vs NULL_WORD:
 118 // On Linux NULL is defined as a special type '__null'. Assigning __null to
 119 // integer variable will cause gcc warning. Use NULL_WORD in places where a
 120 // pointer is stored as integer value.  On some platforms, sizeof(intptr_t) >
 121 // sizeof(void*), so here we want something which is integer type, but has the
 122 // same size as a pointer.
 123 #ifdef LINUX
 124   #ifdef _LP64
 125     #define NULL_WORD  0L
 126   #else
 127     // Cast 0 to intptr_t rather than int32_t since they are not the same type
 128     // on platforms such as Mac OS X.
 129     #define NULL_WORD  ((intptr_t)0)
 130   #endif
 131 #else
 132   #define NULL_WORD  NULL
 133 #endif
 134 
 135 #ifndef LINUX
 136 // Compiler-specific primitive types
 137 typedef unsigned short     uint16_t;
 138 #ifndef _UINT32_T
 139 #define _UINT32_T
 140 typedef unsigned int       uint32_t;
 141 #endif // _UINT32_T
 142 
 143 #if !defined(_SYS_INT_TYPES_H)
 144 #ifndef _UINT64_T
 145 #define _UINT64_T
 146 typedef unsigned long long uint64_t;
 147 #endif // _UINT64_T
 148 // %%%% how to access definition of intptr_t portably in 5.5 onward?
 149 typedef int                     intptr_t;
 150 typedef unsigned int            uintptr_t;
 151 // If this gets an error, figure out a symbol XXX that implies the
 152 // prior definition of intptr_t, and add "&& !defined(XXX)" above.
 153 #endif // _SYS_INT_TYPES_H
 154 
 155 #endif // !LINUX
 156 
 157 // Additional Java basic types
 158 
 159 typedef uint8_t  jubyte;
 160 typedef uint16_t jushort;
 161 typedef uint32_t juint;
 162 typedef uint64_t julong;
 163 
 164 //----------------------------------------------------------------------------------------------------
 165 // Special (possibly not-portable) casts
 166 // Cast floats into same-size integers and vice-versa w/o changing bit-pattern
 167 // %%%%%% These seem like standard C++ to me--how about factoring them out? - Ungar
 168 
 169 inline jint    jint_cast   (jfloat  x)           { return *(jint*   )&x; }
 170 inline jlong   jlong_cast  (jdouble x)           { return *(jlong*  )&x; }
 171 
 172 inline jfloat  jfloat_cast (jint    x)           { return *(jfloat* )&x; }
 173 inline jdouble jdouble_cast(jlong   x)           { return *(jdouble*)&x; }
 174 
 175 //----------------------------------------------------------------------------------------------------


 227 #ifdef ARM
 228 #ifdef SOLARIS
 229 #define BREAKPOINT __asm__ volatile (".long 0xe1200070")
 230 #else
 231 #define BREAKPOINT __asm__ volatile (".long 0xe7f001f0")
 232 #endif
 233 #else
 234 extern "C" void breakpoint();
 235 #define BREAKPOINT ::breakpoint()
 236 #endif
 237 
 238 // checking for nanness
 239 #ifdef SOLARIS
 240 #ifdef SPARC
 241 inline int g_isnan(float  f) { return isnanf(f); }
 242 #else
 243 // isnanf() broken on Intel Solaris use isnand()
 244 inline int g_isnan(float  f) { return isnand(f); }
 245 #endif
 246 inline int g_isnan(double f) { return isnand(f); }
 247 #elif LINUX


 248 inline int g_isnan(float  f) { return isnanf(f); }
 249 inline int g_isnan(double f) { return isnan(f); }
 250 #else
 251 #error "missing platform-specific definition here"
 252 #endif
 253 
 254 // GCC 4.3 does not allow 0.0/0.0 to produce a NAN value
 255 #if (__GNUC__ == 4) && (__GNUC_MINOR__ > 2)
 256 #define CAN_USE_NAN_DEFINE 1
 257 #endif
 258 
 259 
 260 // Checking for finiteness
 261 
 262 inline int g_isfinite(jfloat  f)                 { return finite(f); }
 263 inline int g_isfinite(jdouble f)                 { return finite(f); }
 264 
 265 
 266 // Wide characters
 267 




  59 
  60 #ifdef SOLARIS
  61 #include <thread.h>
  62 #endif // SOLARIS
  63 
  64 #include <limits.h>
  65 #include <errno.h>
  66 
  67 #ifdef SOLARIS
  68 #include <sys/trap.h>
  69 #include <sys/regset.h>
  70 #include <sys/procset.h>
  71 #include <ucontext.h>
  72 #include <setjmp.h>
  73 #endif // SOLARIS
  74 
  75 # ifdef SOLARIS_MUTATOR_LIBTHREAD
  76 # include <sys/procfs.h>
  77 # endif
  78 
  79 #if defined(LINUX) || defined(_ALLBSD_SOURCE)
  80 #ifndef __STDC_LIMIT_MACROS
  81 #define __STDC_LIMIT_MACROS
  82 #endif // __STDC_LIMIT_MACROS
  83 #include <inttypes.h>
  84 #include <signal.h>
  85 #ifndef __OpenBSD__
  86 #include <ucontext.h>
  87 #endif
  88 #ifdef __APPLE__
  89   #include <AvailabilityMacros.h>
  90   #if (MAC_OS_X_VERSION_MAX_ALLOWED <= MAC_OS_X_VERSION_10_4)
  91     // Mac OS X 10.4 defines EFL_AC and EFL_ID,
  92     // which conflict with hotspot variable names.
  93     //
  94     // This has been fixed in Mac OS X 10.5.
  95     #undef EFL_AC
  96     #undef EFL_ID
  97   #endif
  98 #endif
  99 #include <sys/time.h>
 100 #endif // LINUX || _ALLBSD_SOURCE
 101 
 102 // 4810578: varargs unsafe on 32-bit integer/64-bit pointer architectures
 103 // When __cplusplus is defined, NULL is defined as 0 (32-bit constant) in
 104 // system header files.  On 32-bit architectures, there is no problem.
 105 // On 64-bit architectures, defining NULL as a 32-bit constant can cause
 106 // problems with varargs functions: C++ integral promotion rules say for
 107 // varargs, we pass the argument 0 as an int.  So, if NULL was passed to a
 108 // varargs function it will remain 32-bits.  Depending on the calling
 109 // convention of the machine, if the argument is passed on the stack then
 110 // only 32-bits of the "NULL" pointer may be initialized to zero.  The
 111 // other 32-bits will be garbage.  If the varargs function is expecting a
 112 // pointer when it extracts the argument, then we have a problem.
 113 //
 114 // Solution: For 64-bit architectures, redefine NULL as 64-bit constant 0.
 115 //
 116 // Note: this fix doesn't work well on Linux because NULL will be overwritten
 117 // whenever a system header file is included. Linux handles NULL correctly
 118 // through a special type '__null'.
 119 #ifdef SOLARIS
 120   #ifdef _LP64
 121     #undef NULL
 122     #define NULL 0L
 123   #else
 124     #ifndef NULL
 125       #define NULL 0
 126     #endif
 127   #endif
 128 #endif
 129 
 130 // NULL vs NULL_WORD:
 131 // On Linux NULL is defined as a special type '__null'. Assigning __null to
 132 // integer variable will cause gcc warning. Use NULL_WORD in places where a
 133 // pointer is stored as integer value.  On some platforms, sizeof(intptr_t) >
 134 // sizeof(void*), so here we want something which is integer type, but has the
 135 // same size as a pointer.
 136 #ifdef __GNUC__
 137   #ifdef _LP64
 138     #define NULL_WORD  0L
 139   #else
 140     // Cast 0 to intptr_t rather than int32_t since they are not the same type
 141     // on platforms such as Mac OS X.
 142     #define NULL_WORD  ((intptr_t)0)
 143   #endif
 144 #else
 145   #define NULL_WORD  NULL
 146 #endif
 147 
 148 #if !defined(LINUX) && !defined(_ALLBSD_SOURCE)
 149 // Compiler-specific primitive types
 150 typedef unsigned short     uint16_t;
 151 #ifndef _UINT32_T
 152 #define _UINT32_T
 153 typedef unsigned int       uint32_t;
 154 #endif // _UINT32_T
 155 
 156 #if !defined(_SYS_INT_TYPES_H)
 157 #ifndef _UINT64_T
 158 #define _UINT64_T
 159 typedef unsigned long long uint64_t;
 160 #endif // _UINT64_T
 161 // %%%% how to access definition of intptr_t portably in 5.5 onward?
 162 typedef int                     intptr_t;
 163 typedef unsigned int            uintptr_t;
 164 // If this gets an error, figure out a symbol XXX that implies the
 165 // prior definition of intptr_t, and add "&& !defined(XXX)" above.
 166 #endif // _SYS_INT_TYPES_H
 167 
 168 #endif // !LINUX && !_ALLBSD_SOURCE
 169 
 170 // Additional Java basic types
 171 
 172 typedef uint8_t  jubyte;
 173 typedef uint16_t jushort;
 174 typedef uint32_t juint;
 175 typedef uint64_t julong;
 176 
 177 //----------------------------------------------------------------------------------------------------
 178 // Special (possibly not-portable) casts
 179 // Cast floats into same-size integers and vice-versa w/o changing bit-pattern
 180 // %%%%%% These seem like standard C++ to me--how about factoring them out? - Ungar
 181 
 182 inline jint    jint_cast   (jfloat  x)           { return *(jint*   )&x; }
 183 inline jlong   jlong_cast  (jdouble x)           { return *(jlong*  )&x; }
 184 
 185 inline jfloat  jfloat_cast (jint    x)           { return *(jfloat* )&x; }
 186 inline jdouble jdouble_cast(jlong   x)           { return *(jdouble*)&x; }
 187 
 188 //----------------------------------------------------------------------------------------------------


 240 #ifdef ARM
 241 #ifdef SOLARIS
 242 #define BREAKPOINT __asm__ volatile (".long 0xe1200070")
 243 #else
 244 #define BREAKPOINT __asm__ volatile (".long 0xe7f001f0")
 245 #endif
 246 #else
 247 extern "C" void breakpoint();
 248 #define BREAKPOINT ::breakpoint()
 249 #endif
 250 
 251 // checking for nanness
 252 #ifdef SOLARIS
 253 #ifdef SPARC
 254 inline int g_isnan(float  f) { return isnanf(f); }
 255 #else
 256 // isnanf() broken on Intel Solaris use isnand()
 257 inline int g_isnan(float  f) { return isnand(f); }
 258 #endif
 259 inline int g_isnan(double f) { return isnand(f); }
 260 #elif defined(__APPLE__)
 261 inline int g_isnan(double f) { return isnan(f); }
 262 #elif defined(LINUX) || defined(_ALLBSD_SOURCE)
 263 inline int g_isnan(float  f) { return isnanf(f); }
 264 inline int g_isnan(double f) { return isnan(f); }
 265 #else
 266 #error "missing platform-specific definition here"
 267 #endif
 268 
 269 // GCC 4.3 does not allow 0.0/0.0 to produce a NAN value
 270 #if (__GNUC__ == 4) && (__GNUC_MINOR__ > 2)
 271 #define CAN_USE_NAN_DEFINE 1
 272 #endif
 273 
 274 
 275 // Checking for finiteness
 276 
 277 inline int g_isfinite(jfloat  f)                 { return finite(f); }
 278 inline int g_isfinite(jdouble f)                 { return finite(f); }
 279 
 280 
 281 // Wide characters
 282 


src/share/vm/utilities/globalDefinitions_gcc.hpp
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File