comparison src/share/vm/utilities/globalDefinitions_sparcWorks.hpp @ 50:485d403e94e1

6452081: 3/4 Allow for Linux builds with Sun Studio Linux compilers Summary: (for Serguei) Allow for Linux builds with Sun Studio Linux compilers Reviewed-by: sspitsyn, ohair
author dcubed
date Wed, 12 Mar 2008 18:37:03 -0700
parents a61af66fc99e
children d1605aabd0a1
comparison
equal deleted inserted replaced
49:31000d79ec71 50:485d403e94e1
35 # include <stddef.h> // for offsetof 35 # include <stddef.h> // for offsetof
36 # include <stdio.h> 36 # include <stdio.h>
37 # include <stdlib.h> 37 # include <stdlib.h>
38 # include <wchar.h> 38 # include <wchar.h>
39 # include <stdarg.h> 39 # include <stdarg.h>
40 #ifdef SOLARIS
40 # include <ieeefp.h> 41 # include <ieeefp.h>
42 #endif
41 # include <math.h> 43 # include <math.h>
44 #ifdef LINUX
45 #ifndef FP_PZERO
46 // Linux doesn't have positive/negative zero
47 #define FP_PZERO FP_ZERO
48 #endif
49 #ifndef fpclass
50 #define fpclass fpclassify
51 #endif
52 #endif
42 # include <time.h> 53 # include <time.h>
43 # include <fcntl.h> 54 # include <fcntl.h>
44 # include <dlfcn.h> 55 # include <dlfcn.h>
45 # include <pthread.h> 56 # include <pthread.h>
57 #ifdef SOLARIS
46 # include <thread.h> 58 # include <thread.h>
59 #endif
47 # include <limits.h> 60 # include <limits.h>
48 # include <errno.h> 61 # include <errno.h>
62 #ifdef SOLARIS
49 # include <sys/trap.h> 63 # include <sys/trap.h>
50 # include <sys/regset.h> 64 # include <sys/regset.h>
51 # include <sys/procset.h> 65 # include <sys/procset.h>
52 # include <ucontext.h> 66 # include <ucontext.h>
53 # include <setjmp.h> 67 # include <setjmp.h>
68 #endif
54 # ifdef SOLARIS_MUTATOR_LIBTHREAD 69 # ifdef SOLARIS_MUTATOR_LIBTHREAD
55 # include <sys/procfs.h> 70 # include <sys/procfs.h>
56 # endif 71 # endif
72 #ifdef LINUX
73 # include <inttypes.h>
74 # include <signal.h>
75 # include <ucontext.h>
76 # include <sys/time.h>
77 #endif
78
57 79
58 // 4810578: varargs unsafe on 32-bit integer/64-bit pointer architectures 80 // 4810578: varargs unsafe on 32-bit integer/64-bit pointer architectures
59 // When __cplusplus is defined, NULL is defined as 0 (32-bit constant) in 81 // When __cplusplus is defined, NULL is defined as 0 (32-bit constant) in
60 // system header files. On 32-bit architectures, there is no problem. 82 // system header files. On 32-bit architectures, there is no problem.
61 // On 64-bit architectures, defining NULL as a 32-bit constant can cause 83 // On 64-bit architectures, defining NULL as a 32-bit constant can cause
66 // only 32-bits of the "NULL" pointer may be initialized to zero. The 88 // only 32-bits of the "NULL" pointer may be initialized to zero. The
67 // other 32-bits will be garbage. If the varargs function is expecting a 89 // other 32-bits will be garbage. If the varargs function is expecting a
68 // pointer when it extracts the argument, then we have a problem. 90 // pointer when it extracts the argument, then we have a problem.
69 // 91 //
70 // Solution: For 64-bit architectures, redefine NULL as 64-bit constant 0. 92 // Solution: For 64-bit architectures, redefine NULL as 64-bit constant 0.
93 //
94 // Note: this fix doesn't work well on Linux because NULL will be overwritten
95 // whenever a system header file is included. Linux handles NULL correctly
96 // through a special type '__null'.
97 #ifdef SOLARIS
71 #ifdef _LP64 98 #ifdef _LP64
72 #undef NULL 99 #undef NULL
73 #define NULL 0L 100 #define NULL 0L
74 #else 101 #else
75 #ifndef NULL 102 #ifndef NULL
76 #define NULL 0 103 #define NULL 0
77 #endif 104 #endif
78 #endif 105 #endif
106 #endif
79 107
80 // NULL vs NULL_WORD: 108 // NULL vs NULL_WORD:
81 // On Linux NULL is defined as a special type '__null'. Assigning __null to 109 // On Linux NULL is defined as a special type '__null'. Assigning __null to
82 // integer variable will cause gcc warning. Use NULL_WORD in places where a 110 // integer variable will cause gcc warning. Use NULL_WORD in places where a
83 // pointer is stored as integer value. 111 // pointer is stored as integer value. On some platforms, sizeof(intptr_t) >
84 #define NULL_WORD NULL 112 // sizeof(void*), so here we want something which is integer type, but has the
85 113 // same size as a pointer.
114 #ifdef LINUX
115 #ifdef _LP64
116 #define NULL_WORD 0L
117 #else
118 #define NULL_WORD 0
119 #endif
120 #else
121 #define NULL_WORD NULL
122 #endif
123
124 #ifndef LINUX
86 // Compiler-specific primitive types 125 // Compiler-specific primitive types
87 typedef unsigned short uint16_t; 126 typedef unsigned short uint16_t;
88 #ifndef _UINT32_T 127 #ifndef _UINT32_T
89 #define _UINT32_T 128 #define _UINT32_T
90 typedef unsigned int uint32_t; 129 typedef unsigned int uint32_t;
98 typedef int intptr_t; 137 typedef int intptr_t;
99 typedef unsigned int uintptr_t; 138 typedef unsigned int uintptr_t;
100 // If this gets an error, figure out a symbol XXX that implies the 139 // If this gets an error, figure out a symbol XXX that implies the
101 // prior definition of intptr_t, and add "&& !defined(XXX)" above. 140 // prior definition of intptr_t, and add "&& !defined(XXX)" above.
102 #endif 141 #endif
142 #endif
103 143
104 // Additional Java basic types 144 // Additional Java basic types
105 145
106 typedef unsigned char jubyte; 146 typedef unsigned char jubyte;
107 typedef unsigned short jushort; 147 typedef unsigned short jushort;
126 #define UCONST64(x) (x ## ULL) 166 #define UCONST64(x) (x ## ULL)
127 167
128 const jlong min_jlong = CONST64(0x8000000000000000); 168 const jlong min_jlong = CONST64(0x8000000000000000);
129 const jlong max_jlong = CONST64(0x7fffffffffffffff); 169 const jlong max_jlong = CONST64(0x7fffffffffffffff);
130 170
131 171 #ifdef SOLARIS
132 //---------------------------------------------------------------------------------------------------- 172 //----------------------------------------------------------------------------------------------------
133 // ANSI C++ fixes 173 // ANSI C++ fixes
134 // NOTE:In the ANSI committee's continuing attempt to make each version 174 // NOTE:In the ANSI committee's continuing attempt to make each version
135 // of C++ incompatible with the previous version, you can no longer cast 175 // of C++ incompatible with the previous version, you can no longer cast
136 // pointers to functions without specifying linkage unless you want to get 176 // pointers to functions without specifying linkage unless you want to get
160 typedef int (*int_fnP_mutex_tP_i_vP)(mutex_t *, int, void *); 200 typedef int (*int_fnP_mutex_tP_i_vP)(mutex_t *, int, void *);
161 typedef int (*int_fnP_mutex_tP)(mutex_t *); 201 typedef int (*int_fnP_mutex_tP)(mutex_t *);
162 typedef int (*int_fnP_cond_tP_i_vP)(cond_t *cv, int scope, void *arg); 202 typedef int (*int_fnP_cond_tP_i_vP)(cond_t *cv, int scope, void *arg);
163 typedef int (*int_fnP_cond_tP)(cond_t *cv); 203 typedef int (*int_fnP_cond_tP)(cond_t *cv);
164 }; 204 };
165 205 #endif
166 206
167 //---------------------------------------------------------------------------------------------------- 207 //----------------------------------------------------------------------------------------------------
168 // Debugging 208 // Debugging
169 209
170 #define DEBUG_EXCEPTION ::abort(); 210 #define DEBUG_EXCEPTION ::abort();
171 211
172 extern "C" void breakpoint(); 212 extern "C" void breakpoint();
173 #define BREAKPOINT ::breakpoint() 213 #define BREAKPOINT ::breakpoint()
174 214
175 // checking for nanness 215 // checking for nanness
176 216 #ifdef SOLARIS
177 #ifdef SPARC 217 #ifdef SPARC
178 inline int g_isnan(float f) { return isnanf(f); } 218 inline int g_isnan(float f) { return isnanf(f); }
179 #else 219 #else
180 // isnanf() broken on Intel Solaris use isnand() 220 // isnanf() broken on Intel Solaris use isnand()
181 inline int g_isnan(float f) { return isnand(f); } 221 inline int g_isnan(float f) { return isnand(f); }
182 #endif 222 #endif
183 223
184 inline int g_isnan(double f) { return isnand(f); } 224 inline int g_isnan(double f) { return isnand(f); }
225 #elif LINUX
226 inline int g_isnan(float f) { return isnanf(f); }
227 inline int g_isnan(double f) { return isnan(f); }
228 #else
229 #error "missing platform-specific definition here"
230 #endif
185 231
186 // Checking for finiteness 232 // Checking for finiteness
187 233
188 inline int g_isfinite(jfloat f) { return finite(f); } 234 inline int g_isfinite(jfloat f) { return finite(f); }
189 inline int g_isfinite(jdouble f) { return finite(f); } 235 inline int g_isfinite(jdouble f) { return finite(f); }
193 239
194 inline int wcslen(const jchar* x) { return wcslen((const wchar_t*)x); } 240 inline int wcslen(const jchar* x) { return wcslen((const wchar_t*)x); }
195 241
196 242
197 // Misc 243 // Misc
244 // NOTE: This one leads to an infinite recursion on Linux
245 #ifndef LINUX
198 int local_vsnprintf(char* buf, size_t count, const char* fmt, va_list argptr); 246 int local_vsnprintf(char* buf, size_t count, const char* fmt, va_list argptr);
199 #define vsnprintf local_vsnprintf 247 #define vsnprintf local_vsnprintf
200 248 #endif
201 249
202 // Portability macros 250 // Portability macros
203 #define PRAGMA_INTERFACE 251 #define PRAGMA_INTERFACE
204 #define PRAGMA_IMPLEMENTATION 252 #define PRAGMA_IMPLEMENTATION
205 #define PRAGMA_IMPLEMENTATION_(arg) 253 #define PRAGMA_IMPLEMENTATION_(arg)