author | kbarrett |
Wed, 04 Apr 2018 18:19:46 -0400 | |
changeset 49676 | 0bb0c2f27ca9 |
parent 49392 | 2956d0ece7a9 |
child 50120 | 9da00197ff72 |
permissions | -rw-r--r-- |
1 | 1 |
/* |
49040
079d100b3d0e
8197859: VS2017 Complains about UINTPTR_MAX definition in globalDefinitions_VisCPP.hpp
kbarrett
parents:
47659
diff
changeset
|
2 |
* Copyright (c) 1997, 2018, 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:
3261
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
3261
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:
3261
diff
changeset
|
21 |
* questions. |
1 | 22 |
* |
23 |
*/ |
|
24 |
||
7397 | 25 |
#ifndef SHARE_VM_UTILITIES_GLOBALDEFINITIONS_VISCPP_HPP |
26 |
#define SHARE_VM_UTILITIES_GLOBALDEFINITIONS_VISCPP_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 |
# include <ctype.h> |
|
35 |
# include <string.h> |
|
36 |
# include <stdarg.h> |
|
37 |
# include <stdlib.h> |
|
49040
079d100b3d0e
8197859: VS2017 Complains about UINTPTR_MAX definition in globalDefinitions_VisCPP.hpp
kbarrett
parents:
47659
diff
changeset
|
38 |
# include <stdint.h> |
1 | 39 |
# include <stddef.h>// for offsetof |
40 |
# include <io.h> // for stream.cpp |
|
41 |
# include <float.h> // for _isnan |
|
42 |
# include <stdio.h> // for va_list |
|
43 |
# include <time.h> |
|
44 |
# include <fcntl.h> |
|
8481
42a79b703814
6878713: Verifier heap corruption, relating to backward jsrs
kamg
parents:
7397
diff
changeset
|
45 |
# include <limits.h> |
49040
079d100b3d0e
8197859: VS2017 Complains about UINTPTR_MAX definition in globalDefinitions_VisCPP.hpp
kbarrett
parents:
47659
diff
changeset
|
46 |
# include <inttypes.h> |
1 | 47 |
// Need this on windows to get the math constants (e.g., M_PI). |
48 |
#define _USE_MATH_DEFINES |
|
49 |
# include <math.h> |
|
50 |
||
51 |
// 4810578: varargs unsafe on 32-bit integer/64-bit pointer architectures |
|
52 |
// When __cplusplus is defined, NULL is defined as 0 (32-bit constant) in |
|
53 |
// system header files. On 32-bit architectures, there is no problem. |
|
54 |
// On 64-bit architectures, defining NULL as a 32-bit constant can cause |
|
55 |
// problems with varargs functions: C++ integral promotion rules say for |
|
56 |
// varargs, we pass the argument 0 as an int. So, if NULL was passed to a |
|
57 |
// varargs function it will remain 32-bits. Depending on the calling |
|
58 |
// convention of the machine, if the argument is passed on the stack then |
|
59 |
// only 32-bits of the "NULL" pointer may be initialized to zero. The |
|
60 |
// other 32-bits will be garbage. If the varargs function is expecting a |
|
61 |
// pointer when it extracts the argument, then we may have a problem. |
|
62 |
// |
|
63 |
// Solution: For 64-bit architectures, redefine NULL as 64-bit constant 0. |
|
64 |
#ifdef _LP64 |
|
65 |
#undef NULL |
|
66 |
// 64-bit Windows uses a P64 data model (not LP64, although we define _LP64) |
|
67 |
// Since longs are 32-bit we cannot use 0L here. Use the Visual C++ specific |
|
42061
67176803a846
8168490: Use the LL/ULL suffixes to define 64-bit integer literals on Windows
simonis
parents:
37092
diff
changeset
|
68 |
// 64-bit integer-suffix (LL) instead. |
67176803a846
8168490: Use the LL/ULL suffixes to define 64-bit integer literals on Windows
simonis
parents:
37092
diff
changeset
|
69 |
#define NULL 0LL |
1 | 70 |
#else |
71 |
#ifndef NULL |
|
72 |
#define NULL 0 |
|
73 |
#endif |
|
74 |
#endif |
|
75 |
||
76 |
// NULL vs NULL_WORD: |
|
77 |
// On Linux NULL is defined as a special type '__null'. Assigning __null to |
|
78 |
// integer variable will cause gcc warning. Use NULL_WORD in places where a |
|
79 |
// pointer is stored as integer value. |
|
80 |
#define NULL_WORD NULL |
|
81 |
||
82 |
#ifdef _WIN64 |
|
49040
079d100b3d0e
8197859: VS2017 Complains about UINTPTR_MAX definition in globalDefinitions_VisCPP.hpp
kbarrett
parents:
47659
diff
changeset
|
83 |
typedef int64_t ssize_t; |
1 | 84 |
#else |
49040
079d100b3d0e
8197859: VS2017 Complains about UINTPTR_MAX definition in globalDefinitions_VisCPP.hpp
kbarrett
parents:
47659
diff
changeset
|
85 |
typedef int32_t ssize_t; |
8481
42a79b703814
6878713: Verifier heap corruption, relating to backward jsrs
kamg
parents:
7397
diff
changeset
|
86 |
#endif |
42a79b703814
6878713: Verifier heap corruption, relating to backward jsrs
kamg
parents:
7397
diff
changeset
|
87 |
|
1 | 88 |
// Additional Java basic types |
89 |
||
49040
079d100b3d0e
8197859: VS2017 Complains about UINTPTR_MAX definition in globalDefinitions_VisCPP.hpp
kbarrett
parents:
47659
diff
changeset
|
90 |
typedef uint8_t jubyte; |
079d100b3d0e
8197859: VS2017 Complains about UINTPTR_MAX definition in globalDefinitions_VisCPP.hpp
kbarrett
parents:
47659
diff
changeset
|
91 |
typedef uint16_t jushort; |
079d100b3d0e
8197859: VS2017 Complains about UINTPTR_MAX definition in globalDefinitions_VisCPP.hpp
kbarrett
parents:
47659
diff
changeset
|
92 |
typedef uint32_t juint; |
079d100b3d0e
8197859: VS2017 Complains about UINTPTR_MAX definition in globalDefinitions_VisCPP.hpp
kbarrett
parents:
47659
diff
changeset
|
93 |
typedef uint64_t julong; |
1 | 94 |
|
95 |
// Non-standard stdlib-like stuff: |
|
96 |
inline int strcasecmp(const char *s1, const char *s2) { return _stricmp(s1,s2); } |
|
11596
3b9802e6c6a2
7131346: Parsing of boolean arguments to diagnostic commands is broken
fparain
parents:
10565
diff
changeset
|
97 |
inline int strncasecmp(const char *s1, const char *s2, size_t n) { |
3b9802e6c6a2
7131346: Parsing of boolean arguments to diagnostic commands is broken
fparain
parents:
10565
diff
changeset
|
98 |
return _strnicmp(s1,s2,n); |
3b9802e6c6a2
7131346: Parsing of boolean arguments to diagnostic commands is broken
fparain
parents:
10565
diff
changeset
|
99 |
} |
1 | 100 |
|
101 |
// Checking for nanness |
|
102 |
||
103 |
inline int g_isnan(jfloat f) { return _isnan(f); } |
|
104 |
inline int g_isnan(jdouble f) { return _isnan(f); } |
|
105 |
||
106 |
// Checking for finiteness |
|
107 |
||
108 |
inline int g_isfinite(jfloat f) { return _finite(f); } |
|
109 |
inline int g_isfinite(jdouble f) { return _finite(f); } |
|
110 |
||
111 |
// Miscellaneous |
|
112 |
||
113 |
// Visual Studio 2005 deprecates POSIX names - use ISO C++ names instead |
|
2257
d8e6e11e7f32
6816308: Changes to allow builds with latest Windows SDK 6.1 on 64bit Windows 2003
kvn
parents:
1
diff
changeset
|
114 |
#if _MSC_VER >= 1400 |
1 | 115 |
#define open _open |
116 |
#define close _close |
|
117 |
#define read _read |
|
118 |
#define write _write |
|
119 |
#define lseek _lseek |
|
120 |
#define unlink _unlink |
|
121 |
#define strdup _strdup |
|
122 |
#endif |
|
123 |
||
33759
8a0e9139a9c5
8141134: Remove unnecessary pragma warning(disable:4355) from GC code
tschatzl
parents:
33137
diff
changeset
|
124 |
#if _MSC_VER < 1800 |
33137
81433d2db1c9
8137329: [windows] Build broken on VS2010 after "8046148: JEP 158: Unified JVM Logging"
stuefe
parents:
32393
diff
changeset
|
125 |
// Visual Studio 2013 introduced strtoull(); before, one has to use _strtoui64() instead. |
81433d2db1c9
8137329: [windows] Build broken on VS2010 after "8046148: JEP 158: Unified JVM Logging"
stuefe
parents:
32393
diff
changeset
|
126 |
#define strtoull _strtoui64 |
36183
15d5045f46c2
8150079: MSVC prior to VS 2013 doesn't know the 'va_copy' macro
simonis
parents:
34633
diff
changeset
|
127 |
// Visual Studio prior to 2013 had no va_copy, but could safely copy va_list by assignement |
15d5045f46c2
8150079: MSVC prior to VS 2013 doesn't know the 'va_copy' macro
simonis
parents:
34633
diff
changeset
|
128 |
#define va_copy(dest, src) dest = src |
33759
8a0e9139a9c5
8141134: Remove unnecessary pragma warning(disable:4355) from GC code
tschatzl
parents:
33137
diff
changeset
|
129 |
// Fixes some wrong warnings about 'this' : used in base member initializer list |
8a0e9139a9c5
8141134: Remove unnecessary pragma warning(disable:4355) from GC code
tschatzl
parents:
33137
diff
changeset
|
130 |
#pragma warning( disable : 4355 ) |
33137
81433d2db1c9
8137329: [windows] Build broken on VS2010 after "8046148: JEP 158: Unified JVM Logging"
stuefe
parents:
32393
diff
changeset
|
131 |
#endif |
81433d2db1c9
8137329: [windows] Build broken on VS2010 after "8046148: JEP 158: Unified JVM Logging"
stuefe
parents:
32393
diff
changeset
|
132 |
|
81433d2db1c9
8137329: [windows] Build broken on VS2010 after "8046148: JEP 158: Unified JVM Logging"
stuefe
parents:
32393
diff
changeset
|
133 |
|
1 | 134 |
#pragma warning( disable : 4100 ) // unreferenced formal parameter |
135 |
#pragma warning( disable : 4127 ) // conditional expression is constant |
|
136 |
#pragma warning( disable : 4514 ) // unreferenced inline function has been removed |
|
137 |
#pragma warning( disable : 4244 ) // possible loss of data |
|
138 |
#pragma warning( disable : 4512 ) // assignment operator could not be generated |
|
139 |
#pragma warning( disable : 4201 ) // nonstandard extension used : nameless struct/union (needed in windows.h) |
|
140 |
#pragma warning( disable : 4511 ) // copy constructor could not be generated |
|
141 |
#pragma warning( disable : 4291 ) // no matching operator delete found; memory will not be freed if initialization thows an exception |
|
49676
0bb0c2f27ca9
8200630: Globally suppress Visual Studio warning C4351
kbarrett
parents:
49392
diff
changeset
|
142 |
#pragma warning( disable : 4351 ) // new behavior: elements of array ... will be default initialized |
20282
7f9cbdf89af2
7195622: CheckUnhandledOops has limited usefulness now
hseigel
parents:
13963
diff
changeset
|
143 |
#ifdef CHECK_UNHANDLED_OOPS |
7f9cbdf89af2
7195622: CheckUnhandledOops has limited usefulness now
hseigel
parents:
13963
diff
changeset
|
144 |
#pragma warning( disable : 4521 ) // class has multiple copy ctors of a single type |
7f9cbdf89af2
7195622: CheckUnhandledOops has limited usefulness now
hseigel
parents:
13963
diff
changeset
|
145 |
#pragma warning( disable : 4522 ) // class has multiple assignment operators of a single type |
7f9cbdf89af2
7195622: CheckUnhandledOops has limited usefulness now
hseigel
parents:
13963
diff
changeset
|
146 |
#endif // CHECK_UNHANDLED_OOPS |
2271
ff6d122287cb
6812297: update project creation for Visual Studio 2005-2008
ikrylov
parents:
2257
diff
changeset
|
147 |
#if _MSC_VER >= 1400 |
ff6d122287cb
6812297: update project creation for Visual Studio 2005-2008
ikrylov
parents:
2257
diff
changeset
|
148 |
#pragma warning( disable : 4996 ) // unsafe string functions. Same as define _CRT_SECURE_NO_WARNINGS/_CRT_SECURE_NO_DEPRICATE |
ff6d122287cb
6812297: update project creation for Visual Studio 2005-2008
ikrylov
parents:
2257
diff
changeset
|
149 |
#endif |
ff6d122287cb
6812297: update project creation for Visual Studio 2005-2008
ikrylov
parents:
2257
diff
changeset
|
150 |
|
1 | 151 |
// Portability macros |
152 |
#define PRAGMA_INTERFACE |
|
153 |
#define PRAGMA_IMPLEMENTATION |
|
154 |
#define PRAGMA_IMPLEMENTATION_(arg) |
|
155 |
||
156 |
// Formatting. |
|
157 |
#define FORMAT64_MODIFIER "I64" |
|
158 |
||
159 |
#define offset_of(klass,field) offsetof(klass,field) |
|
7397 | 160 |
|
34633
2a6c7c7b30a7
8132510: Replace ThreadLocalStorage with compiler/language-based thread-local variables
dholmes
parents:
33759
diff
changeset
|
161 |
#ifndef USE_LIBRARY_BASED_TLS_ONLY |
2a6c7c7b30a7
8132510: Replace ThreadLocalStorage with compiler/language-based thread-local variables
dholmes
parents:
33759
diff
changeset
|
162 |
#define THREAD_LOCAL_DECL __declspec( thread ) |
2a6c7c7b30a7
8132510: Replace ThreadLocalStorage with compiler/language-based thread-local variables
dholmes
parents:
33759
diff
changeset
|
163 |
#endif |
2a6c7c7b30a7
8132510: Replace ThreadLocalStorage with compiler/language-based thread-local variables
dholmes
parents:
33759
diff
changeset
|
164 |
|
37092
0e56e3c9d545
8151593: Cleanup definition/usage of INLINE/NOINLINE macros and add xlC support
simonis
parents:
36183
diff
changeset
|
165 |
// Inlining support |
0e56e3c9d545
8151593: Cleanup definition/usage of INLINE/NOINLINE macros and add xlC support
simonis
parents:
36183
diff
changeset
|
166 |
// MSVC has '__declspec(noinline)' but according to the official documentation |
0e56e3c9d545
8151593: Cleanup definition/usage of INLINE/NOINLINE macros and add xlC support
simonis
parents:
36183
diff
changeset
|
167 |
// it only applies to member functions. There are reports though which pretend |
0e56e3c9d545
8151593: Cleanup definition/usage of INLINE/NOINLINE macros and add xlC support
simonis
parents:
36183
diff
changeset
|
168 |
// that it also works for freestanding functions. |
0e56e3c9d545
8151593: Cleanup definition/usage of INLINE/NOINLINE macros and add xlC support
simonis
parents:
36183
diff
changeset
|
169 |
#define NOINLINE __declspec(noinline) |
0e56e3c9d545
8151593: Cleanup definition/usage of INLINE/NOINLINE macros and add xlC support
simonis
parents:
36183
diff
changeset
|
170 |
#define ALWAYSINLINE __forceinline |
0e56e3c9d545
8151593: Cleanup definition/usage of INLINE/NOINLINE macros and add xlC support
simonis
parents:
36183
diff
changeset
|
171 |
|
7397 | 172 |
#endif // SHARE_VM_UTILITIES_GLOBALDEFINITIONS_VISCPP_HPP |