Tue, 29 Jul 2014 13:54:16 +0200
8040121: Load variable through a pointer of an incompatible type in src/hotspot/src/share/vm: opto/output.cpp, runtime/sharedRuntimeTrans.cpp, utilities/globalDefinitions_visCPP.hpp
Summary: Fixed parfait warnings in globalDefinitions files by using a union for casts.
Reviewed-by: kvn
duke@435 | 1 | /* |
mikael@6198 | 2 | * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. |
duke@435 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
duke@435 | 4 | * |
duke@435 | 5 | * This code is free software; you can redistribute it and/or modify it |
duke@435 | 6 | * under the terms of the GNU General Public License version 2 only, as |
duke@435 | 7 | * published by the Free Software Foundation. |
duke@435 | 8 | * |
duke@435 | 9 | * This code is distributed in the hope that it will be useful, but WITHOUT |
duke@435 | 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
duke@435 | 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
duke@435 | 12 | * version 2 for more details (a copy is included in the LICENSE file that |
duke@435 | 13 | * accompanied this code). |
duke@435 | 14 | * |
duke@435 | 15 | * You should have received a copy of the GNU General Public License version |
duke@435 | 16 | * 2 along with this work; if not, write to the Free Software Foundation, |
duke@435 | 17 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
duke@435 | 18 | * |
trims@1907 | 19 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
trims@1907 | 20 | * or visit www.oracle.com if you need additional information or have any |
trims@1907 | 21 | * questions. |
duke@435 | 22 | * |
duke@435 | 23 | */ |
duke@435 | 24 | |
stefank@2314 | 25 | #ifndef SHARE_VM_UTILITIES_GLOBALDEFINITIONS_VISCPP_HPP |
stefank@2314 | 26 | #define SHARE_VM_UTILITIES_GLOBALDEFINITIONS_VISCPP_HPP |
stefank@2314 | 27 | |
stefank@2314 | 28 | #include "prims/jni.h" |
stefank@2314 | 29 | |
duke@435 | 30 | // This file holds compiler-dependent includes, |
duke@435 | 31 | // globally used constants & types, class (forward) |
duke@435 | 32 | // declarations and a few frequently used utility functions. |
duke@435 | 33 | |
duke@435 | 34 | # include <ctype.h> |
duke@435 | 35 | # include <string.h> |
duke@435 | 36 | # include <stdarg.h> |
duke@435 | 37 | # include <stdlib.h> |
duke@435 | 38 | # include <stddef.h>// for offsetof |
duke@435 | 39 | # include <io.h> // for stream.cpp |
duke@435 | 40 | # include <float.h> // for _isnan |
duke@435 | 41 | # include <stdio.h> // for va_list |
duke@435 | 42 | # include <time.h> |
duke@435 | 43 | # include <fcntl.h> |
kamg@2589 | 44 | # include <limits.h> |
duke@435 | 45 | // Need this on windows to get the math constants (e.g., M_PI). |
duke@435 | 46 | #define _USE_MATH_DEFINES |
duke@435 | 47 | # include <math.h> |
duke@435 | 48 | |
duke@435 | 49 | // 4810578: varargs unsafe on 32-bit integer/64-bit pointer architectures |
duke@435 | 50 | // When __cplusplus is defined, NULL is defined as 0 (32-bit constant) in |
duke@435 | 51 | // system header files. On 32-bit architectures, there is no problem. |
duke@435 | 52 | // On 64-bit architectures, defining NULL as a 32-bit constant can cause |
duke@435 | 53 | // problems with varargs functions: C++ integral promotion rules say for |
duke@435 | 54 | // varargs, we pass the argument 0 as an int. So, if NULL was passed to a |
duke@435 | 55 | // varargs function it will remain 32-bits. Depending on the calling |
duke@435 | 56 | // convention of the machine, if the argument is passed on the stack then |
duke@435 | 57 | // only 32-bits of the "NULL" pointer may be initialized to zero. The |
duke@435 | 58 | // other 32-bits will be garbage. If the varargs function is expecting a |
duke@435 | 59 | // pointer when it extracts the argument, then we may have a problem. |
duke@435 | 60 | // |
duke@435 | 61 | // Solution: For 64-bit architectures, redefine NULL as 64-bit constant 0. |
duke@435 | 62 | #ifdef _LP64 |
duke@435 | 63 | #undef NULL |
duke@435 | 64 | // 64-bit Windows uses a P64 data model (not LP64, although we define _LP64) |
duke@435 | 65 | // Since longs are 32-bit we cannot use 0L here. Use the Visual C++ specific |
duke@435 | 66 | // 64-bit integer-suffix (i64) instead. |
duke@435 | 67 | #define NULL 0i64 |
duke@435 | 68 | #else |
duke@435 | 69 | #ifndef NULL |
duke@435 | 70 | #define NULL 0 |
duke@435 | 71 | #endif |
duke@435 | 72 | #endif |
duke@435 | 73 | |
duke@435 | 74 | // NULL vs NULL_WORD: |
duke@435 | 75 | // On Linux NULL is defined as a special type '__null'. Assigning __null to |
duke@435 | 76 | // integer variable will cause gcc warning. Use NULL_WORD in places where a |
duke@435 | 77 | // pointer is stored as integer value. |
duke@435 | 78 | #define NULL_WORD NULL |
duke@435 | 79 | |
duke@435 | 80 | // Compiler-specific primitive types |
duke@435 | 81 | typedef unsigned __int8 uint8_t; |
duke@435 | 82 | typedef unsigned __int16 uint16_t; |
duke@435 | 83 | typedef unsigned __int32 uint32_t; |
duke@435 | 84 | typedef unsigned __int64 uint64_t; |
duke@435 | 85 | |
duke@435 | 86 | #ifdef _WIN64 |
duke@435 | 87 | typedef unsigned __int64 uintptr_t; |
duke@435 | 88 | #else |
duke@435 | 89 | typedef unsigned int uintptr_t; |
duke@435 | 90 | #endif |
duke@435 | 91 | typedef signed __int8 int8_t; |
duke@435 | 92 | typedef signed __int16 int16_t; |
duke@435 | 93 | typedef signed __int32 int32_t; |
duke@435 | 94 | typedef signed __int64 int64_t; |
duke@435 | 95 | #ifdef _WIN64 |
duke@435 | 96 | typedef signed __int64 intptr_t; |
duke@435 | 97 | typedef signed __int64 ssize_t; |
duke@435 | 98 | #else |
duke@435 | 99 | typedef signed int intptr_t; |
duke@435 | 100 | typedef signed int ssize_t; |
duke@435 | 101 | #endif |
duke@435 | 102 | |
kamg@2589 | 103 | #ifndef UINTPTR_MAX |
kamg@2589 | 104 | #ifdef _WIN64 |
kamg@2589 | 105 | #define UINTPTR_MAX _UI64_MAX |
kamg@2589 | 106 | #else |
kamg@2589 | 107 | #define UINTPTR_MAX _UI32_MAX |
kamg@2589 | 108 | #endif |
kamg@2589 | 109 | #endif |
kamg@2589 | 110 | |
duke@435 | 111 | //---------------------------------------------------------------------------------------------------- |
duke@435 | 112 | // Additional Java basic types |
duke@435 | 113 | |
duke@435 | 114 | typedef unsigned char jubyte; |
duke@435 | 115 | typedef unsigned short jushort; |
duke@435 | 116 | typedef unsigned int juint; |
duke@435 | 117 | typedef unsigned __int64 julong; |
duke@435 | 118 | |
duke@435 | 119 | |
duke@435 | 120 | //---------------------------------------------------------------------------------------------------- |
duke@435 | 121 | // Non-standard stdlib-like stuff: |
duke@435 | 122 | inline int strcasecmp(const char *s1, const char *s2) { return _stricmp(s1,s2); } |
fparain@3476 | 123 | inline int strncasecmp(const char *s1, const char *s2, size_t n) { |
fparain@3476 | 124 | return _strnicmp(s1,s2,n); |
fparain@3476 | 125 | } |
duke@435 | 126 | |
duke@435 | 127 | |
duke@435 | 128 | //---------------------------------------------------------------------------------------------------- |
duke@435 | 129 | // Debugging |
duke@435 | 130 | |
duke@435 | 131 | #if _WIN64 |
duke@435 | 132 | extern "C" void breakpoint(); |
duke@435 | 133 | #define BREAKPOINT ::breakpoint() |
duke@435 | 134 | #else |
duke@435 | 135 | #define BREAKPOINT __asm { int 3 } |
duke@435 | 136 | #endif |
duke@435 | 137 | |
duke@435 | 138 | //---------------------------------------------------------------------------------------------------- |
duke@435 | 139 | // Checking for nanness |
duke@435 | 140 | |
duke@435 | 141 | inline int g_isnan(jfloat f) { return _isnan(f); } |
duke@435 | 142 | inline int g_isnan(jdouble f) { return _isnan(f); } |
duke@435 | 143 | |
duke@435 | 144 | //---------------------------------------------------------------------------------------------------- |
duke@435 | 145 | // Checking for finiteness |
duke@435 | 146 | |
duke@435 | 147 | inline int g_isfinite(jfloat f) { return _finite(f); } |
duke@435 | 148 | inline int g_isfinite(jdouble f) { return _finite(f); } |
duke@435 | 149 | |
duke@435 | 150 | //---------------------------------------------------------------------------------------------------- |
duke@435 | 151 | // Constant for jlong (specifying an long long constant is C++ compiler specific) |
duke@435 | 152 | |
duke@435 | 153 | // Build a 64bit integer constant on with Visual C++ |
duke@435 | 154 | #define CONST64(x) (x ## i64) |
duke@435 | 155 | #define UCONST64(x) ((uint64_t)CONST64(x)) |
duke@435 | 156 | |
duke@435 | 157 | const jlong min_jlong = CONST64(0x8000000000000000); |
duke@435 | 158 | const jlong max_jlong = CONST64(0x7fffffffffffffff); |
duke@435 | 159 | |
duke@435 | 160 | //---------------------------------------------------------------------------------------------------- |
duke@435 | 161 | // Miscellaneous |
duke@435 | 162 | |
duke@435 | 163 | // Visual Studio 2005 deprecates POSIX names - use ISO C++ names instead |
kvn@1080 | 164 | #if _MSC_VER >= 1400 |
duke@435 | 165 | #define open _open |
duke@435 | 166 | #define close _close |
duke@435 | 167 | #define read _read |
duke@435 | 168 | #define write _write |
duke@435 | 169 | #define lseek _lseek |
duke@435 | 170 | #define unlink _unlink |
duke@435 | 171 | #define strdup _strdup |
duke@435 | 172 | #endif |
duke@435 | 173 | |
duke@435 | 174 | #pragma warning( disable : 4100 ) // unreferenced formal parameter |
duke@435 | 175 | #pragma warning( disable : 4127 ) // conditional expression is constant |
duke@435 | 176 | #pragma warning( disable : 4514 ) // unreferenced inline function has been removed |
duke@435 | 177 | #pragma warning( disable : 4244 ) // possible loss of data |
duke@435 | 178 | #pragma warning( disable : 4512 ) // assignment operator could not be generated |
duke@435 | 179 | #pragma warning( disable : 4201 ) // nonstandard extension used : nameless struct/union (needed in windows.h) |
duke@435 | 180 | #pragma warning( disable : 4511 ) // copy constructor could not be generated |
duke@435 | 181 | #pragma warning( disable : 4291 ) // no matching operator delete found; memory will not be freed if initialization thows an exception |
hseigel@5784 | 182 | #ifdef CHECK_UNHANDLED_OOPS |
hseigel@5784 | 183 | #pragma warning( disable : 4521 ) // class has multiple copy ctors of a single type |
hseigel@5784 | 184 | #pragma warning( disable : 4522 ) // class has multiple assignment operators of a single type |
hseigel@5784 | 185 | #endif // CHECK_UNHANDLED_OOPS |
ikrylov@1094 | 186 | #if _MSC_VER >= 1400 |
ikrylov@1094 | 187 | #pragma warning( disable : 4996 ) // unsafe string functions. Same as define _CRT_SECURE_NO_WARNINGS/_CRT_SECURE_NO_DEPRICATE |
ikrylov@1094 | 188 | #endif |
ikrylov@1094 | 189 | |
ikrylov@1094 | 190 | inline int vsnprintf(char* buf, size_t count, const char* fmt, va_list argptr) { |
ikrylov@1094 | 191 | // If number of characters written == count, Windows doesn't write a |
ikrylov@1094 | 192 | // terminating NULL, so we do it ourselves. |
ikrylov@1094 | 193 | int ret = _vsnprintf(buf, count, fmt, argptr); |
ikrylov@1094 | 194 | if (count > 0) buf[count-1] = '\0'; |
ikrylov@1094 | 195 | return ret; |
ikrylov@1094 | 196 | } |
duke@435 | 197 | |
duke@435 | 198 | // Portability macros |
duke@435 | 199 | #define PRAGMA_INTERFACE |
duke@435 | 200 | #define PRAGMA_IMPLEMENTATION |
duke@435 | 201 | #define PRAGMA_IMPLEMENTATION_(arg) |
duke@435 | 202 | #define VALUE_OBJ_CLASS_SPEC : public _ValueObj |
duke@435 | 203 | |
duke@435 | 204 | // Formatting. |
duke@435 | 205 | #define FORMAT64_MODIFIER "I64" |
duke@435 | 206 | |
never@3156 | 207 | // Visual Studio doesn't provide inttypes.h so provide appropriate definitions here. |
never@3156 | 208 | // The 32 bits ones might need I32 but seem to work ok without it. |
never@3156 | 209 | #define PRId32 "d" |
never@3156 | 210 | #define PRIu32 "u" |
never@3156 | 211 | #define PRIx32 "x" |
never@3156 | 212 | |
never@3156 | 213 | #define PRId64 "I64d" |
never@3156 | 214 | #define PRIu64 "I64u" |
never@3156 | 215 | #define PRIx64 "I64x" |
never@3156 | 216 | |
dholmes@3830 | 217 | #ifdef _LP64 |
dholmes@3830 | 218 | #define PRIdPTR "I64d" |
dholmes@3830 | 219 | #define PRIuPTR "I64u" |
dholmes@3830 | 220 | #define PRIxPTR "I64x" |
dholmes@3830 | 221 | #else |
never@3156 | 222 | #define PRIdPTR "d" |
never@3156 | 223 | #define PRIuPTR "u" |
never@3156 | 224 | #define PRIxPTR "x" |
dholmes@3830 | 225 | #endif |
never@3156 | 226 | |
duke@435 | 227 | #define offset_of(klass,field) offsetof(klass,field) |
stefank@2314 | 228 | |
stefank@2314 | 229 | #endif // SHARE_VM_UTILITIES_GLOBALDEFINITIONS_VISCPP_HPP |