Path: blob/aarch64-shenandoah-jdk8u272-b10/hotspot/src/share/vm/utilities/globalDefinitions_visCPP.hpp
32285 views
/*1* Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*22*/2324#ifndef SHARE_VM_UTILITIES_GLOBALDEFINITIONS_VISCPP_HPP25#define SHARE_VM_UTILITIES_GLOBALDEFINITIONS_VISCPP_HPP2627#include "prims/jni.h"2829// This file holds compiler-dependent includes,30// globally used constants & types, class (forward)31// declarations and a few frequently used utility functions.3233# include <ctype.h>34# include <string.h>35# include <stdarg.h>36# include <stdlib.h>37# include <stddef.h>// for offsetof38# include <io.h> // for stream.cpp39# include <float.h> // for _isnan40# include <stdio.h> // for va_list41# include <time.h>42# include <fcntl.h>43# include <limits.h>44// Need this on windows to get the math constants (e.g., M_PI).45#define _USE_MATH_DEFINES46# include <math.h>4748// 4810578: varargs unsafe on 32-bit integer/64-bit pointer architectures49// When __cplusplus is defined, NULL is defined as 0 (32-bit constant) in50// system header files. On 32-bit architectures, there is no problem.51// On 64-bit architectures, defining NULL as a 32-bit constant can cause52// problems with varargs functions: C++ integral promotion rules say for53// varargs, we pass the argument 0 as an int. So, if NULL was passed to a54// varargs function it will remain 32-bits. Depending on the calling55// convention of the machine, if the argument is passed on the stack then56// only 32-bits of the "NULL" pointer may be initialized to zero. The57// other 32-bits will be garbage. If the varargs function is expecting a58// pointer when it extracts the argument, then we may have a problem.59//60// Solution: For 64-bit architectures, redefine NULL as 64-bit constant 0.61#ifdef _LP6462#undef NULL63// 64-bit Windows uses a P64 data model (not LP64, although we define _LP64)64// Since longs are 32-bit we cannot use 0L here. Use the Visual C++ specific65// 64-bit integer-suffix (i64) instead.66#define NULL 0i6467#else68#ifndef NULL69#define NULL 070#endif71#endif7273// NULL vs NULL_WORD:74// On Linux NULL is defined as a special type '__null'. Assigning __null to75// integer variable will cause gcc warning. Use NULL_WORD in places where a76// pointer is stored as integer value.77#define NULL_WORD NULL7879// Compiler-specific primitive types80typedef unsigned __int8 uint8_t;81typedef unsigned __int16 uint16_t;82typedef unsigned __int32 uint32_t;83typedef unsigned __int64 uint64_t;8485#ifdef _WIN6486typedef unsigned __int64 uintptr_t;87#else88typedef unsigned int uintptr_t;89#endif90typedef signed __int8 int8_t;91typedef signed __int16 int16_t;92typedef signed __int32 int32_t;93typedef signed __int64 int64_t;94#ifdef _WIN6495typedef signed __int64 intptr_t;96typedef signed __int64 ssize_t;97#else98typedef signed int intptr_t;99typedef signed int ssize_t;100#endif101102#ifndef UINTPTR_MAX103#ifdef _WIN64104#define UINTPTR_MAX _UI64_MAX105#else106#define UINTPTR_MAX _UI32_MAX107#endif108#endif109110//----------------------------------------------------------------------------------------------------111// Additional Java basic types112113typedef unsigned char jubyte;114typedef unsigned short jushort;115typedef unsigned int juint;116typedef unsigned __int64 julong;117118119//----------------------------------------------------------------------------------------------------120// Non-standard stdlib-like stuff:121inline int strcasecmp(const char *s1, const char *s2) { return _stricmp(s1,s2); }122inline int strncasecmp(const char *s1, const char *s2, size_t n) {123return _strnicmp(s1,s2,n);124}125126127//----------------------------------------------------------------------------------------------------128// Debugging129130#if _WIN64131extern "C" void breakpoint();132#define BREAKPOINT ::breakpoint()133#else134#define BREAKPOINT __asm { int 3 }135#endif136137//----------------------------------------------------------------------------------------------------138// Checking for nanness139140inline int g_isnan(jfloat f) { return _isnan(f); }141inline int g_isnan(jdouble f) { return _isnan(f); }142143//----------------------------------------------------------------------------------------------------144// Checking for finiteness145146inline int g_isfinite(jfloat f) { return _finite(f); }147inline int g_isfinite(jdouble f) { return _finite(f); }148149//----------------------------------------------------------------------------------------------------150// Constant for jlong (specifying an long long constant is C++ compiler specific)151152// Build a 64bit integer constant on with Visual C++153#define CONST64(x) (x ## i64)154#define UCONST64(x) ((uint64_t)CONST64(x))155156const jlong min_jlong = CONST64(0x8000000000000000);157const jlong max_jlong = CONST64(0x7fffffffffffffff);158159//----------------------------------------------------------------------------------------------------160// Miscellaneous161162// Visual Studio 2005 deprecates POSIX names - use ISO C++ names instead163#if _MSC_VER >= 1400164#define open _open165#define close _close166#define read _read167#define write _write168#define lseek _lseek169#define unlink _unlink170#define strdup _strdup171#endif172173#if _MSC_VER < 1800174// Fixes some wrong warnings about 'this' : used in base member initializer list175#pragma warning( disable : 4355 )176#endif177178#pragma warning( disable : 4100 ) // unreferenced formal parameter179#pragma warning( disable : 4127 ) // conditional expression is constant180#pragma warning( disable : 4514 ) // unreferenced inline function has been removed181#pragma warning( disable : 4244 ) // possible loss of data182#pragma warning( disable : 4512 ) // assignment operator could not be generated183#pragma warning( disable : 4201 ) // nonstandard extension used : nameless struct/union (needed in windows.h)184#pragma warning( disable : 4511 ) // copy constructor could not be generated185#pragma warning( disable : 4291 ) // no matching operator delete found; memory will not be freed if initialization thows an exception186#ifdef CHECK_UNHANDLED_OOPS187#pragma warning( disable : 4521 ) // class has multiple copy ctors of a single type188#pragma warning( disable : 4522 ) // class has multiple assignment operators of a single type189#endif // CHECK_UNHANDLED_OOPS190#if _MSC_VER >= 1400191#pragma warning( disable : 4996 ) // unsafe string functions. Same as define _CRT_SECURE_NO_WARNINGS/_CRT_SECURE_NO_DEPRICATE192#endif193194// Portability macros195#define PRAGMA_INTERFACE196#define PRAGMA_IMPLEMENTATION197#define PRAGMA_IMPLEMENTATION_(arg)198#define VALUE_OBJ_CLASS_SPEC : public _ValueObj199200// Formatting.201#define FORMAT64_MODIFIER "I64"202203// Visual Studio doesn't provide inttypes.h so provide appropriate definitions here.204// The 32 bits ones might need I32 but seem to work ok without it.205#define PRId32 "d"206#define PRIu32 "u"207#define PRIx32 "x"208209#define PRId64 "I64d"210#define PRIu64 "I64u"211#define PRIx64 "I64x"212213#ifdef _LP64214#define PRIdPTR "I64d"215#define PRIuPTR "I64u"216#define PRIxPTR "I64x"217#else218#define PRIdPTR "d"219#define PRIuPTR "u"220#define PRIxPTR "x"221#endif222223#define offset_of(klass,field) offsetof(klass,field)224225// Inlining support226// MSVC has '__declspec(noinline)' but according to the official documentation227// it only applies to member functions. There are reports though which pretend228// that it also works for freestanding functions.229#define NOINLINE __declspec(noinline)230#define ALWAYSINLINE __forceinline231232#endif // SHARE_VM_UTILITIES_GLOBALDEFINITIONS_VISCPP_HPP233234235