author | stefank |
Tue, 28 Nov 2017 21:43:45 +0100 | |
changeset 48157 | 7c4d43c26352 |
parent 47659 | a8e9aff89f7b |
child 49392 | 2956d0ece7a9 |
permissions | -rw-r--r-- |
1 | 1 |
/* |
46560
388aa8d67c80
8181449: Fix debug.hpp / globalDefinitions.hpp dependency inversion
kbarrett
parents:
42061
diff
changeset
|
2 |
* Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved. |
1 | 3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 |
* |
|
5 |
* This code is free software; you can redistribute it and/or modify it |
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
|
7 |
* published by the Free Software Foundation. |
|
8 |
* |
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
13 |
* accompanied this code). |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License version |
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
18 |
* |
|
5547
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
2105
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
2105
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
2105
diff
changeset
|
21 |
* questions. |
1 | 22 |
* |
23 |
*/ |
|
24 |
||
7397 | 25 |
#ifndef SHARE_VM_UTILITIES_GLOBALDEFINITIONS_SPARCWORKS_HPP |
26 |
#define SHARE_VM_UTILITIES_GLOBALDEFINITIONS_SPARCWORKS_HPP |
|
27 |
||
47659 | 28 |
#include "jni.h" |
7397 | 29 |
|
1 | 30 |
// This file holds compiler-dependent includes, |
31 |
// globally used constants & types, class (forward) |
|
32 |
// declarations and a few frequently used utility functions. |
|
33 |
||
34 |
||
35 |
# include <ctype.h> |
|
36 |
# include <string.h> |
|
37 |
# include <strings.h> // for bsd'isms |
|
38 |
# include <stdarg.h> |
|
39 |
# include <stddef.h> // for offsetof |
|
40 |
# include <stdio.h> |
|
41 |
# include <stdlib.h> |
|
42 |
# include <wchar.h> |
|
43 |
# include <stdarg.h> |
|
223
5c3b023117d9
6452081: 3/4 Allow for Linux builds with Sun Studio Linux compilers
dcubed
parents:
1
diff
changeset
|
44 |
#ifdef SOLARIS |
1 | 45 |
# include <ieeefp.h> |
223
5c3b023117d9
6452081: 3/4 Allow for Linux builds with Sun Studio Linux compilers
dcubed
parents:
1
diff
changeset
|
46 |
#endif |
1 | 47 |
# include <math.h> |
48 |
# include <time.h> |
|
49 |
# include <fcntl.h> |
|
50 |
# include <dlfcn.h> |
|
51 |
# include <pthread.h> |
|
223
5c3b023117d9
6452081: 3/4 Allow for Linux builds with Sun Studio Linux compilers
dcubed
parents:
1
diff
changeset
|
52 |
#ifdef SOLARIS |
1 | 53 |
# include <thread.h> |
223
5c3b023117d9
6452081: 3/4 Allow for Linux builds with Sun Studio Linux compilers
dcubed
parents:
1
diff
changeset
|
54 |
#endif |
1 | 55 |
# include <limits.h> |
56 |
# include <errno.h> |
|
223
5c3b023117d9
6452081: 3/4 Allow for Linux builds with Sun Studio Linux compilers
dcubed
parents:
1
diff
changeset
|
57 |
#ifdef SOLARIS |
1 | 58 |
# include <sys/trap.h> |
59 |
# include <sys/regset.h> |
|
60 |
# include <sys/procset.h> |
|
61 |
# include <ucontext.h> |
|
62 |
# include <setjmp.h> |
|
223
5c3b023117d9
6452081: 3/4 Allow for Linux builds with Sun Studio Linux compilers
dcubed
parents:
1
diff
changeset
|
63 |
#endif |
1 | 64 |
# ifdef SOLARIS_MUTATOR_LIBTHREAD |
65 |
# include <sys/procfs.h> |
|
66 |
# endif |
|
10565 | 67 |
|
68 |
#include <inttypes.h> |
|
69 |
||
70 |
// Solaris 8 doesn't provide definitions of these |
|
71 |
#ifdef SOLARIS |
|
72 |
#ifndef PRIdPTR |
|
73 |
#if defined(_LP64) |
|
74 |
#define PRIdPTR "ld" |
|
75 |
#define PRIuPTR "lu" |
|
76 |
#define PRIxPTR "lx" |
|
77 |
#else |
|
78 |
#define PRIdPTR "d" |
|
79 |
#define PRIuPTR "u" |
|
80 |
#define PRIxPTR "x" |
|
81 |
#endif |
|
82 |
#endif |
|
83 |
#endif |
|
84 |
||
223
5c3b023117d9
6452081: 3/4 Allow for Linux builds with Sun Studio Linux compilers
dcubed
parents:
1
diff
changeset
|
85 |
#ifdef LINUX |
5c3b023117d9
6452081: 3/4 Allow for Linux builds with Sun Studio Linux compilers
dcubed
parents:
1
diff
changeset
|
86 |
# include <signal.h> |
5c3b023117d9
6452081: 3/4 Allow for Linux builds with Sun Studio Linux compilers
dcubed
parents:
1
diff
changeset
|
87 |
# include <ucontext.h> |
5c3b023117d9
6452081: 3/4 Allow for Linux builds with Sun Studio Linux compilers
dcubed
parents:
1
diff
changeset
|
88 |
# include <sys/time.h> |
5c3b023117d9
6452081: 3/4 Allow for Linux builds with Sun Studio Linux compilers
dcubed
parents:
1
diff
changeset
|
89 |
#endif |
5c3b023117d9
6452081: 3/4 Allow for Linux builds with Sun Studio Linux compilers
dcubed
parents:
1
diff
changeset
|
90 |
|
1 | 91 |
|
92 |
// 4810578: varargs unsafe on 32-bit integer/64-bit pointer architectures |
|
93 |
// When __cplusplus is defined, NULL is defined as 0 (32-bit constant) in |
|
94 |
// system header files. On 32-bit architectures, there is no problem. |
|
95 |
// On 64-bit architectures, defining NULL as a 32-bit constant can cause |
|
96 |
// problems with varargs functions: C++ integral promotion rules say for |
|
97 |
// varargs, we pass the argument 0 as an int. So, if NULL was passed to a |
|
98 |
// varargs function it will remain 32-bits. Depending on the calling |
|
99 |
// convention of the machine, if the argument is passed on the stack then |
|
100 |
// only 32-bits of the "NULL" pointer may be initialized to zero. The |
|
101 |
// other 32-bits will be garbage. If the varargs function is expecting a |
|
102 |
// pointer when it extracts the argument, then we have a problem. |
|
103 |
// |
|
104 |
// Solution: For 64-bit architectures, redefine NULL as 64-bit constant 0. |
|
223
5c3b023117d9
6452081: 3/4 Allow for Linux builds with Sun Studio Linux compilers
dcubed
parents:
1
diff
changeset
|
105 |
// |
5c3b023117d9
6452081: 3/4 Allow for Linux builds with Sun Studio Linux compilers
dcubed
parents:
1
diff
changeset
|
106 |
// Note: this fix doesn't work well on Linux because NULL will be overwritten |
5c3b023117d9
6452081: 3/4 Allow for Linux builds with Sun Studio Linux compilers
dcubed
parents:
1
diff
changeset
|
107 |
// whenever a system header file is included. Linux handles NULL correctly |
5c3b023117d9
6452081: 3/4 Allow for Linux builds with Sun Studio Linux compilers
dcubed
parents:
1
diff
changeset
|
108 |
// through a special type '__null'. |
5c3b023117d9
6452081: 3/4 Allow for Linux builds with Sun Studio Linux compilers
dcubed
parents:
1
diff
changeset
|
109 |
#ifdef SOLARIS |
1 | 110 |
#ifdef _LP64 |
111 |
#undef NULL |
|
112 |
#define NULL 0L |
|
113 |
#else |
|
114 |
#ifndef NULL |
|
115 |
#define NULL 0 |
|
116 |
#endif |
|
117 |
#endif |
|
223
5c3b023117d9
6452081: 3/4 Allow for Linux builds with Sun Studio Linux compilers
dcubed
parents:
1
diff
changeset
|
118 |
#endif |
1 | 119 |
|
120 |
// NULL vs NULL_WORD: |
|
121 |
// On Linux NULL is defined as a special type '__null'. Assigning __null to |
|
122 |
// integer variable will cause gcc warning. Use NULL_WORD in places where a |
|
223
5c3b023117d9
6452081: 3/4 Allow for Linux builds with Sun Studio Linux compilers
dcubed
parents:
1
diff
changeset
|
123 |
// pointer is stored as integer value. On some platforms, sizeof(intptr_t) > |
5c3b023117d9
6452081: 3/4 Allow for Linux builds with Sun Studio Linux compilers
dcubed
parents:
1
diff
changeset
|
124 |
// sizeof(void*), so here we want something which is integer type, but has the |
5c3b023117d9
6452081: 3/4 Allow for Linux builds with Sun Studio Linux compilers
dcubed
parents:
1
diff
changeset
|
125 |
// same size as a pointer. |
5c3b023117d9
6452081: 3/4 Allow for Linux builds with Sun Studio Linux compilers
dcubed
parents:
1
diff
changeset
|
126 |
#ifdef LINUX |
5c3b023117d9
6452081: 3/4 Allow for Linux builds with Sun Studio Linux compilers
dcubed
parents:
1
diff
changeset
|
127 |
#ifdef _LP64 |
5c3b023117d9
6452081: 3/4 Allow for Linux builds with Sun Studio Linux compilers
dcubed
parents:
1
diff
changeset
|
128 |
#define NULL_WORD 0L |
5c3b023117d9
6452081: 3/4 Allow for Linux builds with Sun Studio Linux compilers
dcubed
parents:
1
diff
changeset
|
129 |
#else |
1888
bbf498fb4354
6787106: Hotspot 32 bit build fails on platforms having different definitions for intptr_t & int32_t
xlu
parents:
670
diff
changeset
|
130 |
// Cast 0 to intptr_t rather than int32_t since they are not the same type |
bbf498fb4354
6787106: Hotspot 32 bit build fails on platforms having different definitions for intptr_t & int32_t
xlu
parents:
670
diff
changeset
|
131 |
// on some platforms. |
bbf498fb4354
6787106: Hotspot 32 bit build fails on platforms having different definitions for intptr_t & int32_t
xlu
parents:
670
diff
changeset
|
132 |
#define NULL_WORD ((intptr_t)0) |
223
5c3b023117d9
6452081: 3/4 Allow for Linux builds with Sun Studio Linux compilers
dcubed
parents:
1
diff
changeset
|
133 |
#endif |
5c3b023117d9
6452081: 3/4 Allow for Linux builds with Sun Studio Linux compilers
dcubed
parents:
1
diff
changeset
|
134 |
#else |
5c3b023117d9
6452081: 3/4 Allow for Linux builds with Sun Studio Linux compilers
dcubed
parents:
1
diff
changeset
|
135 |
#define NULL_WORD NULL |
5c3b023117d9
6452081: 3/4 Allow for Linux builds with Sun Studio Linux compilers
dcubed
parents:
1
diff
changeset
|
136 |
#endif |
1 | 137 |
|
223
5c3b023117d9
6452081: 3/4 Allow for Linux builds with Sun Studio Linux compilers
dcubed
parents:
1
diff
changeset
|
138 |
#ifndef LINUX |
1 | 139 |
// Compiler-specific primitive types |
140 |
typedef unsigned short uint16_t; |
|
141 |
#ifndef _UINT32_T |
|
142 |
#define _UINT32_T |
|
143 |
typedef unsigned int uint32_t; |
|
144 |
#endif |
|
145 |
#if !defined(_SYS_INT_TYPES_H) |
|
146 |
#ifndef _UINT64_T |
|
147 |
#define _UINT64_T |
|
148 |
typedef unsigned long long uint64_t; |
|
149 |
#endif |
|
150 |
// %%%% how to access definition of intptr_t portably in 5.5 onward? |
|
151 |
typedef int intptr_t; |
|
152 |
typedef unsigned int uintptr_t; |
|
153 |
// If this gets an error, figure out a symbol XXX that implies the |
|
154 |
// prior definition of intptr_t, and add "&& !defined(XXX)" above. |
|
155 |
#endif |
|
223
5c3b023117d9
6452081: 3/4 Allow for Linux builds with Sun Studio Linux compilers
dcubed
parents:
1
diff
changeset
|
156 |
#endif |
1 | 157 |
|
8481
42a79b703814
6878713: Verifier heap corruption, relating to backward jsrs
kamg
parents:
7397
diff
changeset
|
158 |
// On solaris 8, UINTPTR_MAX is defined as empty. |
42a79b703814
6878713: Verifier heap corruption, relating to backward jsrs
kamg
parents:
7397
diff
changeset
|
159 |
// Everywhere else it's an actual value. |
42a79b703814
6878713: Verifier heap corruption, relating to backward jsrs
kamg
parents:
7397
diff
changeset
|
160 |
#if UINTPTR_MAX - 1 == -1 |
42a79b703814
6878713: Verifier heap corruption, relating to backward jsrs
kamg
parents:
7397
diff
changeset
|
161 |
#undef UINTPTR_MAX |
42a79b703814
6878713: Verifier heap corruption, relating to backward jsrs
kamg
parents:
7397
diff
changeset
|
162 |
#ifdef _LP64 |
42a79b703814
6878713: Verifier heap corruption, relating to backward jsrs
kamg
parents:
7397
diff
changeset
|
163 |
#define UINTPTR_MAX UINT64_MAX |
42a79b703814
6878713: Verifier heap corruption, relating to backward jsrs
kamg
parents:
7397
diff
changeset
|
164 |
#else |
42a79b703814
6878713: Verifier heap corruption, relating to backward jsrs
kamg
parents:
7397
diff
changeset
|
165 |
#define UINTPTR_MAX UINT32_MAX |
42a79b703814
6878713: Verifier heap corruption, relating to backward jsrs
kamg
parents:
7397
diff
changeset
|
166 |
#endif /* ifdef _LP64 */ |
42a79b703814
6878713: Verifier heap corruption, relating to backward jsrs
kamg
parents:
7397
diff
changeset
|
167 |
#endif |
42a79b703814
6878713: Verifier heap corruption, relating to backward jsrs
kamg
parents:
7397
diff
changeset
|
168 |
|
1 | 169 |
// Additional Java basic types |
170 |
||
171 |
typedef unsigned char jubyte; |
|
172 |
typedef unsigned short jushort; |
|
173 |
typedef unsigned int juint; |
|
174 |
typedef unsigned long long julong; |
|
175 |
||
176 |
||
223
5c3b023117d9
6452081: 3/4 Allow for Linux builds with Sun Studio Linux compilers
dcubed
parents:
1
diff
changeset
|
177 |
#ifdef SOLARIS |
1 | 178 |
// ANSI C++ fixes |
179 |
// NOTE:In the ANSI committee's continuing attempt to make each version |
|
180 |
// of C++ incompatible with the previous version, you can no longer cast |
|
181 |
// pointers to functions without specifying linkage unless you want to get |
|
182 |
// warnings. |
|
183 |
// |
|
184 |
// This also means that pointers to functions can no longer be "hidden" |
|
185 |
// in opaque types like void * because at the invokation point warnings |
|
186 |
// will be generated. While this makes perfect sense from a type safety |
|
187 |
// point of view it causes a lot of warnings on old code using C header |
|
188 |
// files. Here are some typedefs to make the job of silencing warnings |
|
189 |
// a bit easier. |
|
190 |
// |
|
191 |
// The final kick in the teeth is that you can only have extern "C" linkage |
|
192 |
// specified at file scope. So these typedefs are here rather than in the |
|
193 |
// .hpp for the class (os:Solaris usually) that needs them. |
|
194 |
||
195 |
extern "C" { |
|
196 |
typedef int (*int_fnP_thread_t_iP_uP_stack_tP_gregset_t)(thread_t, int*, unsigned *, stack_t*, gregset_t); |
|
197 |
typedef int (*int_fnP_thread_t_i_gregset_t)(thread_t, int, gregset_t); |
|
198 |
typedef int (*int_fnP_thread_t_i)(thread_t, int); |
|
199 |
typedef int (*int_fnP_thread_t)(thread_t); |
|
200 |
||
201 |
typedef int (*int_fnP_cond_tP_mutex_tP_timestruc_tP)(cond_t *cv, mutex_t *mx, timestruc_t *abst); |
|
202 |
typedef int (*int_fnP_cond_tP_mutex_tP)(cond_t *cv, mutex_t *mx); |
|
203 |
||
204 |
// typedef for missing API in libc |
|
205 |
typedef int (*int_fnP_mutex_tP_i_vP)(mutex_t *, int, void *); |
|
206 |
typedef int (*int_fnP_mutex_tP)(mutex_t *); |
|
207 |
typedef int (*int_fnP_cond_tP_i_vP)(cond_t *cv, int scope, void *arg); |
|
208 |
typedef int (*int_fnP_cond_tP)(cond_t *cv); |
|
209 |
}; |
|
223
5c3b023117d9
6452081: 3/4 Allow for Linux builds with Sun Studio Linux compilers
dcubed
parents:
1
diff
changeset
|
210 |
#endif |
1 | 211 |
|
212 |
// checking for nanness |
|
223
5c3b023117d9
6452081: 3/4 Allow for Linux builds with Sun Studio Linux compilers
dcubed
parents:
1
diff
changeset
|
213 |
#ifdef SOLARIS |
1 | 214 |
#ifdef SPARC |
215 |
inline int g_isnan(float f) { return isnanf(f); } |
|
216 |
#else |
|
217 |
// isnanf() broken on Intel Solaris use isnand() |
|
218 |
inline int g_isnan(float f) { return isnand(f); } |
|
219 |
#endif |
|
220 |
||
221 |
inline int g_isnan(double f) { return isnand(f); } |
|
223
5c3b023117d9
6452081: 3/4 Allow for Linux builds with Sun Studio Linux compilers
dcubed
parents:
1
diff
changeset
|
222 |
#elif LINUX |
5c3b023117d9
6452081: 3/4 Allow for Linux builds with Sun Studio Linux compilers
dcubed
parents:
1
diff
changeset
|
223 |
inline int g_isnan(float f) { return isnanf(f); } |
5c3b023117d9
6452081: 3/4 Allow for Linux builds with Sun Studio Linux compilers
dcubed
parents:
1
diff
changeset
|
224 |
inline int g_isnan(double f) { return isnan(f); } |
5c3b023117d9
6452081: 3/4 Allow for Linux builds with Sun Studio Linux compilers
dcubed
parents:
1
diff
changeset
|
225 |
#else |
5c3b023117d9
6452081: 3/4 Allow for Linux builds with Sun Studio Linux compilers
dcubed
parents:
1
diff
changeset
|
226 |
#error "missing platform-specific definition here" |
5c3b023117d9
6452081: 3/4 Allow for Linux builds with Sun Studio Linux compilers
dcubed
parents:
1
diff
changeset
|
227 |
#endif |
1 | 228 |
|
229 |
// Checking for finiteness |
|
230 |
||
231 |
inline int g_isfinite(jfloat f) { return finite(f); } |
|
232 |
inline int g_isfinite(jdouble f) { return finite(f); } |
|
233 |
||
234 |
||
235 |
// Wide characters |
|
236 |
||
237 |
inline int wcslen(const jchar* x) { return wcslen((const wchar_t*)x); } |
|
238 |
||
239 |
// Portability macros |
|
240 |
#define PRAGMA_INTERFACE |
|
241 |
#define PRAGMA_IMPLEMENTATION |
|
242 |
#define PRAGMA_IMPLEMENTATION_(arg) |
|
243 |
#define VALUE_OBJ_CLASS_SPEC : public _ValueObj |
|
244 |
||
245 |
// Formatting. |
|
246 |
#ifdef _LP64 |
|
247 |
#define FORMAT64_MODIFIER "l" |
|
248 |
#else // !_LP64 |
|
249 |
#define FORMAT64_MODIFIER "ll" |
|
250 |
#endif // _LP64 |
|
251 |
||
252 |
#define offset_of(klass,field) offsetof(klass,field) |
|
7397 | 253 |
|
34633
2a6c7c7b30a7
8132510: Replace ThreadLocalStorage with compiler/language-based thread-local variables
dholmes
parents:
32393
diff
changeset
|
254 |
#ifndef USE_LIBRARY_BASED_TLS_ONLY |
2a6c7c7b30a7
8132510: Replace ThreadLocalStorage with compiler/language-based thread-local variables
dholmes
parents:
32393
diff
changeset
|
255 |
#define THREAD_LOCAL_DECL __thread |
2a6c7c7b30a7
8132510: Replace ThreadLocalStorage with compiler/language-based thread-local variables
dholmes
parents:
32393
diff
changeset
|
256 |
#endif |
2a6c7c7b30a7
8132510: Replace ThreadLocalStorage with compiler/language-based thread-local variables
dholmes
parents:
32393
diff
changeset
|
257 |
|
37092
0e56e3c9d545
8151593: Cleanup definition/usage of INLINE/NOINLINE macros and add xlC support
simonis
parents:
34633
diff
changeset
|
258 |
// Inlining support |
0e56e3c9d545
8151593: Cleanup definition/usage of INLINE/NOINLINE macros and add xlC support
simonis
parents:
34633
diff
changeset
|
259 |
#define NOINLINE |
39405
314741ca98d5
8153743: AllocateHeap() and ReallocateHeap() should use ALWAYSINLINE macro
ysuenaga
parents:
37092
diff
changeset
|
260 |
#define ALWAYSINLINE inline __attribute__((always_inline)) |
37092
0e56e3c9d545
8151593: Cleanup definition/usage of INLINE/NOINLINE macros and add xlC support
simonis
parents:
34633
diff
changeset
|
261 |
|
7397 | 262 |
#endif // SHARE_VM_UTILITIES_GLOBALDEFINITIONS_SPARCWORKS_HPP |