annotate src/share/vm/utilities/globalDefinitions_visCPP.hpp @ 1972:f95d63e2154a

6989984: Use standard include model for Hospot Summary: Replaced MakeDeps and the includeDB files with more standardized solutions. Reviewed-by: coleenp, kvn, kamg
author stefank
date Tue, 23 Nov 2010 13:22:55 -0800
parents c18cbe5936b8
children 4a9604cd7c5f
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1 /*
1972
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
2 * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
a61af66fc99e Initial load
duke
parents:
diff changeset
4 *
a61af66fc99e Initial load
duke
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
a61af66fc99e Initial load
duke
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
a61af66fc99e Initial load
duke
parents:
diff changeset
7 * published by the Free Software Foundation.
a61af66fc99e Initial load
duke
parents:
diff changeset
8 *
a61af66fc99e Initial load
duke
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
a61af66fc99e Initial load
duke
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
a61af66fc99e Initial load
duke
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
a61af66fc99e Initial load
duke
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
a61af66fc99e Initial load
duke
parents:
diff changeset
13 * accompanied this code).
a61af66fc99e Initial load
duke
parents:
diff changeset
14 *
a61af66fc99e Initial load
duke
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
a61af66fc99e Initial load
duke
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
a61af66fc99e Initial load
duke
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
a61af66fc99e Initial load
duke
parents:
diff changeset
18 *
1552
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 844
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 844
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 844
diff changeset
21 * questions.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
22 *
a61af66fc99e Initial load
duke
parents:
diff changeset
23 */
a61af66fc99e Initial load
duke
parents:
diff changeset
24
1972
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
25 #ifndef SHARE_VM_UTILITIES_GLOBALDEFINITIONS_VISCPP_HPP
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
26 #define SHARE_VM_UTILITIES_GLOBALDEFINITIONS_VISCPP_HPP
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
27
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
28 #include "prims/jni.h"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
29
0
a61af66fc99e Initial load
duke
parents:
diff changeset
30 // This file holds compiler-dependent includes,
a61af66fc99e Initial load
duke
parents:
diff changeset
31 // globally used constants & types, class (forward)
a61af66fc99e Initial load
duke
parents:
diff changeset
32 // declarations and a few frequently used utility functions.
a61af66fc99e Initial load
duke
parents:
diff changeset
33
a61af66fc99e Initial load
duke
parents:
diff changeset
34 # include <ctype.h>
a61af66fc99e Initial load
duke
parents:
diff changeset
35 # include <string.h>
a61af66fc99e Initial load
duke
parents:
diff changeset
36 # include <stdarg.h>
a61af66fc99e Initial load
duke
parents:
diff changeset
37 # include <stdlib.h>
a61af66fc99e Initial load
duke
parents:
diff changeset
38 # include <stddef.h>// for offsetof
a61af66fc99e Initial load
duke
parents:
diff changeset
39 # include <io.h> // for stream.cpp
a61af66fc99e Initial load
duke
parents:
diff changeset
40 # include <float.h> // for _isnan
a61af66fc99e Initial load
duke
parents:
diff changeset
41 # include <stdio.h> // for va_list
a61af66fc99e Initial load
duke
parents:
diff changeset
42 # include <time.h>
a61af66fc99e Initial load
duke
parents:
diff changeset
43 # include <fcntl.h>
a61af66fc99e Initial load
duke
parents:
diff changeset
44 // Need this on windows to get the math constants (e.g., M_PI).
a61af66fc99e Initial load
duke
parents:
diff changeset
45 #define _USE_MATH_DEFINES
a61af66fc99e Initial load
duke
parents:
diff changeset
46 # include <math.h>
a61af66fc99e Initial load
duke
parents:
diff changeset
47
a61af66fc99e Initial load
duke
parents:
diff changeset
48 // 4810578: varargs unsafe on 32-bit integer/64-bit pointer architectures
a61af66fc99e Initial load
duke
parents:
diff changeset
49 // When __cplusplus is defined, NULL is defined as 0 (32-bit constant) in
a61af66fc99e Initial load
duke
parents:
diff changeset
50 // system header files. On 32-bit architectures, there is no problem.
a61af66fc99e Initial load
duke
parents:
diff changeset
51 // On 64-bit architectures, defining NULL as a 32-bit constant can cause
a61af66fc99e Initial load
duke
parents:
diff changeset
52 // problems with varargs functions: C++ integral promotion rules say for
a61af66fc99e Initial load
duke
parents:
diff changeset
53 // varargs, we pass the argument 0 as an int. So, if NULL was passed to a
a61af66fc99e Initial load
duke
parents:
diff changeset
54 // varargs function it will remain 32-bits. Depending on the calling
a61af66fc99e Initial load
duke
parents:
diff changeset
55 // convention of the machine, if the argument is passed on the stack then
a61af66fc99e Initial load
duke
parents:
diff changeset
56 // only 32-bits of the "NULL" pointer may be initialized to zero. The
a61af66fc99e Initial load
duke
parents:
diff changeset
57 // other 32-bits will be garbage. If the varargs function is expecting a
a61af66fc99e Initial load
duke
parents:
diff changeset
58 // pointer when it extracts the argument, then we may have a problem.
a61af66fc99e Initial load
duke
parents:
diff changeset
59 //
a61af66fc99e Initial load
duke
parents:
diff changeset
60 // Solution: For 64-bit architectures, redefine NULL as 64-bit constant 0.
a61af66fc99e Initial load
duke
parents:
diff changeset
61 #ifdef _LP64
a61af66fc99e Initial load
duke
parents:
diff changeset
62 #undef NULL
a61af66fc99e Initial load
duke
parents:
diff changeset
63 // 64-bit Windows uses a P64 data model (not LP64, although we define _LP64)
a61af66fc99e Initial load
duke
parents:
diff changeset
64 // Since longs are 32-bit we cannot use 0L here. Use the Visual C++ specific
a61af66fc99e Initial load
duke
parents:
diff changeset
65 // 64-bit integer-suffix (i64) instead.
a61af66fc99e Initial load
duke
parents:
diff changeset
66 #define NULL 0i64
a61af66fc99e Initial load
duke
parents:
diff changeset
67 #else
a61af66fc99e Initial load
duke
parents:
diff changeset
68 #ifndef NULL
a61af66fc99e Initial load
duke
parents:
diff changeset
69 #define NULL 0
a61af66fc99e Initial load
duke
parents:
diff changeset
70 #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
71 #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
72
a61af66fc99e Initial load
duke
parents:
diff changeset
73 // NULL vs NULL_WORD:
a61af66fc99e Initial load
duke
parents:
diff changeset
74 // On Linux NULL is defined as a special type '__null'. Assigning __null to
a61af66fc99e Initial load
duke
parents:
diff changeset
75 // integer variable will cause gcc warning. Use NULL_WORD in places where a
a61af66fc99e Initial load
duke
parents:
diff changeset
76 // pointer is stored as integer value.
a61af66fc99e Initial load
duke
parents:
diff changeset
77 #define NULL_WORD NULL
a61af66fc99e Initial load
duke
parents:
diff changeset
78
a61af66fc99e Initial load
duke
parents:
diff changeset
79 // Compiler-specific primitive types
a61af66fc99e Initial load
duke
parents:
diff changeset
80 typedef unsigned __int8 uint8_t;
a61af66fc99e Initial load
duke
parents:
diff changeset
81 typedef unsigned __int16 uint16_t;
a61af66fc99e Initial load
duke
parents:
diff changeset
82 typedef unsigned __int32 uint32_t;
a61af66fc99e Initial load
duke
parents:
diff changeset
83 typedef unsigned __int64 uint64_t;
a61af66fc99e Initial load
duke
parents:
diff changeset
84
a61af66fc99e Initial load
duke
parents:
diff changeset
85 #ifdef _WIN64
a61af66fc99e Initial load
duke
parents:
diff changeset
86 typedef unsigned __int64 uintptr_t;
a61af66fc99e Initial load
duke
parents:
diff changeset
87 #else
a61af66fc99e Initial load
duke
parents:
diff changeset
88 typedef unsigned int uintptr_t;
a61af66fc99e Initial load
duke
parents:
diff changeset
89 #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
90 typedef signed __int8 int8_t;
a61af66fc99e Initial load
duke
parents:
diff changeset
91 typedef signed __int16 int16_t;
a61af66fc99e Initial load
duke
parents:
diff changeset
92 typedef signed __int32 int32_t;
a61af66fc99e Initial load
duke
parents:
diff changeset
93 typedef signed __int64 int64_t;
a61af66fc99e Initial load
duke
parents:
diff changeset
94 #ifdef _WIN64
a61af66fc99e Initial load
duke
parents:
diff changeset
95 typedef signed __int64 intptr_t;
a61af66fc99e Initial load
duke
parents:
diff changeset
96 typedef signed __int64 ssize_t;
a61af66fc99e Initial load
duke
parents:
diff changeset
97 #else
a61af66fc99e Initial load
duke
parents:
diff changeset
98 typedef signed int intptr_t;
a61af66fc99e Initial load
duke
parents:
diff changeset
99 typedef signed int ssize_t;
a61af66fc99e Initial load
duke
parents:
diff changeset
100 #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
101
a61af66fc99e Initial load
duke
parents:
diff changeset
102 //----------------------------------------------------------------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
103 // Additional Java basic types
a61af66fc99e Initial load
duke
parents:
diff changeset
104
a61af66fc99e Initial load
duke
parents:
diff changeset
105 typedef unsigned char jubyte;
a61af66fc99e Initial load
duke
parents:
diff changeset
106 typedef unsigned short jushort;
a61af66fc99e Initial load
duke
parents:
diff changeset
107 typedef unsigned int juint;
a61af66fc99e Initial load
duke
parents:
diff changeset
108 typedef unsigned __int64 julong;
a61af66fc99e Initial load
duke
parents:
diff changeset
109
a61af66fc99e Initial load
duke
parents:
diff changeset
110 //----------------------------------------------------------------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
111 // Special (possibly not-portable) casts
a61af66fc99e Initial load
duke
parents:
diff changeset
112 // Cast floats into same-size integers and vice-versa w/o changing bit-pattern
a61af66fc99e Initial load
duke
parents:
diff changeset
113
a61af66fc99e Initial load
duke
parents:
diff changeset
114 inline jint jint_cast (jfloat x) { return *(jint* )&x; }
a61af66fc99e Initial load
duke
parents:
diff changeset
115 inline jlong jlong_cast (jdouble x) { return *(jlong* )&x; }
a61af66fc99e Initial load
duke
parents:
diff changeset
116
a61af66fc99e Initial load
duke
parents:
diff changeset
117 inline jfloat jfloat_cast (jint x) { return *(jfloat* )&x; }
a61af66fc99e Initial load
duke
parents:
diff changeset
118 inline jdouble jdouble_cast(jlong x) { return *(jdouble*)&x; }
a61af66fc99e Initial load
duke
parents:
diff changeset
119
a61af66fc99e Initial load
duke
parents:
diff changeset
120
a61af66fc99e Initial load
duke
parents:
diff changeset
121 //----------------------------------------------------------------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
122 // Non-standard stdlib-like stuff:
a61af66fc99e Initial load
duke
parents:
diff changeset
123 inline int strcasecmp(const char *s1, const char *s2) { return _stricmp(s1,s2); }
a61af66fc99e Initial load
duke
parents:
diff changeset
124
a61af66fc99e Initial load
duke
parents:
diff changeset
125
a61af66fc99e Initial load
duke
parents:
diff changeset
126 //----------------------------------------------------------------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
127 // Debugging
a61af66fc99e Initial load
duke
parents:
diff changeset
128
a61af66fc99e Initial load
duke
parents:
diff changeset
129 #if _WIN64
a61af66fc99e Initial load
duke
parents:
diff changeset
130 extern "C" void breakpoint();
a61af66fc99e Initial load
duke
parents:
diff changeset
131 #define BREAKPOINT ::breakpoint()
a61af66fc99e Initial load
duke
parents:
diff changeset
132 #else
a61af66fc99e Initial load
duke
parents:
diff changeset
133 #define BREAKPOINT __asm { int 3 }
a61af66fc99e Initial load
duke
parents:
diff changeset
134 #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
135
a61af66fc99e Initial load
duke
parents:
diff changeset
136 //----------------------------------------------------------------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
137 // Checking for nanness
a61af66fc99e Initial load
duke
parents:
diff changeset
138
a61af66fc99e Initial load
duke
parents:
diff changeset
139 inline int g_isnan(jfloat f) { return _isnan(f); }
a61af66fc99e Initial load
duke
parents:
diff changeset
140 inline int g_isnan(jdouble f) { return _isnan(f); }
a61af66fc99e Initial load
duke
parents:
diff changeset
141
a61af66fc99e Initial load
duke
parents:
diff changeset
142 //----------------------------------------------------------------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
143 // Checking for finiteness
a61af66fc99e Initial load
duke
parents:
diff changeset
144
a61af66fc99e Initial load
duke
parents:
diff changeset
145 inline int g_isfinite(jfloat f) { return _finite(f); }
a61af66fc99e Initial load
duke
parents:
diff changeset
146 inline int g_isfinite(jdouble f) { return _finite(f); }
a61af66fc99e Initial load
duke
parents:
diff changeset
147
a61af66fc99e Initial load
duke
parents:
diff changeset
148 //----------------------------------------------------------------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
149 // Constant for jlong (specifying an long long constant is C++ compiler specific)
a61af66fc99e Initial load
duke
parents:
diff changeset
150
a61af66fc99e Initial load
duke
parents:
diff changeset
151 // Build a 64bit integer constant on with Visual C++
a61af66fc99e Initial load
duke
parents:
diff changeset
152 #define CONST64(x) (x ## i64)
a61af66fc99e Initial load
duke
parents:
diff changeset
153 #define UCONST64(x) ((uint64_t)CONST64(x))
a61af66fc99e Initial load
duke
parents:
diff changeset
154
a61af66fc99e Initial load
duke
parents:
diff changeset
155 const jlong min_jlong = CONST64(0x8000000000000000);
a61af66fc99e Initial load
duke
parents:
diff changeset
156 const jlong max_jlong = CONST64(0x7fffffffffffffff);
a61af66fc99e Initial load
duke
parents:
diff changeset
157
a61af66fc99e Initial load
duke
parents:
diff changeset
158 //----------------------------------------------------------------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
159 // Miscellaneous
a61af66fc99e Initial load
duke
parents:
diff changeset
160
a61af66fc99e Initial load
duke
parents:
diff changeset
161 // Visual Studio 2005 deprecates POSIX names - use ISO C++ names instead
645
c3a720eefe82 6816308: Changes to allow builds with latest Windows SDK 6.1 on 64bit Windows 2003
kvn
parents: 0
diff changeset
162 #if _MSC_VER >= 1400
0
a61af66fc99e Initial load
duke
parents:
diff changeset
163 #define open _open
a61af66fc99e Initial load
duke
parents:
diff changeset
164 #define close _close
a61af66fc99e Initial load
duke
parents:
diff changeset
165 #define read _read
a61af66fc99e Initial load
duke
parents:
diff changeset
166 #define write _write
a61af66fc99e Initial load
duke
parents:
diff changeset
167 #define lseek _lseek
a61af66fc99e Initial load
duke
parents:
diff changeset
168 #define unlink _unlink
a61af66fc99e Initial load
duke
parents:
diff changeset
169 #define strdup _strdup
a61af66fc99e Initial load
duke
parents:
diff changeset
170 #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
171
a61af66fc99e Initial load
duke
parents:
diff changeset
172 #pragma warning( disable : 4100 ) // unreferenced formal parameter
a61af66fc99e Initial load
duke
parents:
diff changeset
173 #pragma warning( disable : 4127 ) // conditional expression is constant
a61af66fc99e Initial load
duke
parents:
diff changeset
174 #pragma warning( disable : 4514 ) // unreferenced inline function has been removed
a61af66fc99e Initial load
duke
parents:
diff changeset
175 #pragma warning( disable : 4244 ) // possible loss of data
a61af66fc99e Initial load
duke
parents:
diff changeset
176 #pragma warning( disable : 4512 ) // assignment operator could not be generated
a61af66fc99e Initial load
duke
parents:
diff changeset
177 #pragma warning( disable : 4201 ) // nonstandard extension used : nameless struct/union (needed in windows.h)
a61af66fc99e Initial load
duke
parents:
diff changeset
178 #pragma warning( disable : 4511 ) // copy constructor could not be generated
a61af66fc99e Initial load
duke
parents:
diff changeset
179 #pragma warning( disable : 4291 ) // no matching operator delete found; memory will not be freed if initialization thows an exception
659
520d43965b1f 6812297: update project creation for Visual Studio 2005-2008
ikrylov
parents: 645
diff changeset
180 #if _MSC_VER >= 1400
520d43965b1f 6812297: update project creation for Visual Studio 2005-2008
ikrylov
parents: 645
diff changeset
181 #pragma warning( disable : 4996 ) // unsafe string functions. Same as define _CRT_SECURE_NO_WARNINGS/_CRT_SECURE_NO_DEPRICATE
520d43965b1f 6812297: update project creation for Visual Studio 2005-2008
ikrylov
parents: 645
diff changeset
182 #endif
520d43965b1f 6812297: update project creation for Visual Studio 2005-2008
ikrylov
parents: 645
diff changeset
183
520d43965b1f 6812297: update project creation for Visual Studio 2005-2008
ikrylov
parents: 645
diff changeset
184 inline int vsnprintf(char* buf, size_t count, const char* fmt, va_list argptr) {
520d43965b1f 6812297: update project creation for Visual Studio 2005-2008
ikrylov
parents: 645
diff changeset
185 // If number of characters written == count, Windows doesn't write a
520d43965b1f 6812297: update project creation for Visual Studio 2005-2008
ikrylov
parents: 645
diff changeset
186 // terminating NULL, so we do it ourselves.
520d43965b1f 6812297: update project creation for Visual Studio 2005-2008
ikrylov
parents: 645
diff changeset
187 int ret = _vsnprintf(buf, count, fmt, argptr);
520d43965b1f 6812297: update project creation for Visual Studio 2005-2008
ikrylov
parents: 645
diff changeset
188 if (count > 0) buf[count-1] = '\0';
520d43965b1f 6812297: update project creation for Visual Studio 2005-2008
ikrylov
parents: 645
diff changeset
189 return ret;
520d43965b1f 6812297: update project creation for Visual Studio 2005-2008
ikrylov
parents: 645
diff changeset
190 }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
191
a61af66fc99e Initial load
duke
parents:
diff changeset
192 // Portability macros
a61af66fc99e Initial load
duke
parents:
diff changeset
193 #define PRAGMA_INTERFACE
a61af66fc99e Initial load
duke
parents:
diff changeset
194 #define PRAGMA_IMPLEMENTATION
a61af66fc99e Initial load
duke
parents:
diff changeset
195 #define PRAGMA_IMPLEMENTATION_(arg)
a61af66fc99e Initial load
duke
parents:
diff changeset
196 #define VALUE_OBJ_CLASS_SPEC : public _ValueObj
a61af66fc99e Initial load
duke
parents:
diff changeset
197
a61af66fc99e Initial load
duke
parents:
diff changeset
198 // Formatting.
a61af66fc99e Initial load
duke
parents:
diff changeset
199 #define FORMAT64_MODIFIER "I64"
a61af66fc99e Initial load
duke
parents:
diff changeset
200
a61af66fc99e Initial load
duke
parents:
diff changeset
201 #define offset_of(klass,field) offsetof(klass,field)
1972
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
202
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
203 #endif // SHARE_VM_UTILITIES_GLOBALDEFINITIONS_VISCPP_HPP