Path: blob/aarch64-shenandoah-jdk8u272-b10/hotspot/src/share/vm/utilities/globalDefinitions_sparcWorks.hpp
32285 views
/*1* Copyright (c) 1997, 2015, 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_SPARCWORKS_HPP25#define SHARE_VM_UTILITIES_GLOBALDEFINITIONS_SPARCWORKS_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.323334# include <ctype.h>35#define __USE_LEGACY_PROTOTYPES__36# include <dirent.h>37#undef __USE_LEGACY_PROTOTYPES__38# include <string.h>39# include <strings.h> // for bsd'isms40# include <stdarg.h>41# include <stddef.h> // for offsetof42# include <stdio.h>43# include <stdlib.h>44# include <wchar.h>45# include <stdarg.h>46#ifdef SOLARIS47# include <ieeefp.h>48#endif49# include <math.h>50# include <time.h>51# include <fcntl.h>52# include <dlfcn.h>53# include <pthread.h>54#ifdef SOLARIS55# include <thread.h>56#endif57# include <limits.h>58# include <errno.h>59#ifdef SOLARIS60# include <sys/trap.h>61# include <sys/regset.h>62# include <sys/procset.h>63# include <ucontext.h>64# include <setjmp.h>65#endif66# ifdef SOLARIS_MUTATOR_LIBTHREAD67# include <sys/procfs.h>68# endif6970#include <inttypes.h>7172// Solaris 8 doesn't provide definitions of these73#ifdef SOLARIS74#ifndef PRIdPTR75#if defined(_LP64)76#define PRIdPTR "ld"77#define PRIuPTR "lu"78#define PRIxPTR "lx"79#else80#define PRIdPTR "d"81#define PRIuPTR "u"82#define PRIxPTR "x"83#endif84#endif85#endif8687#ifdef LINUX88# include <signal.h>89# include <ucontext.h>90# include <sys/time.h>91#endif929394// 4810578: varargs unsafe on 32-bit integer/64-bit pointer architectures95// When __cplusplus is defined, NULL is defined as 0 (32-bit constant) in96// system header files. On 32-bit architectures, there is no problem.97// On 64-bit architectures, defining NULL as a 32-bit constant can cause98// problems with varargs functions: C++ integral promotion rules say for99// varargs, we pass the argument 0 as an int. So, if NULL was passed to a100// varargs function it will remain 32-bits. Depending on the calling101// convention of the machine, if the argument is passed on the stack then102// only 32-bits of the "NULL" pointer may be initialized to zero. The103// other 32-bits will be garbage. If the varargs function is expecting a104// pointer when it extracts the argument, then we have a problem.105//106// Solution: For 64-bit architectures, redefine NULL as 64-bit constant 0.107//108// Note: this fix doesn't work well on Linux because NULL will be overwritten109// whenever a system header file is included. Linux handles NULL correctly110// through a special type '__null'.111#ifdef SOLARIS112#ifdef _LP64113#undef NULL114#define NULL 0L115#else116#ifndef NULL117#define NULL 0118#endif119#endif120#endif121122// NULL vs NULL_WORD:123// On Linux NULL is defined as a special type '__null'. Assigning __null to124// integer variable will cause gcc warning. Use NULL_WORD in places where a125// pointer is stored as integer value. On some platforms, sizeof(intptr_t) >126// sizeof(void*), so here we want something which is integer type, but has the127// same size as a pointer.128#ifdef LINUX129#ifdef _LP64130#define NULL_WORD 0L131#else132// Cast 0 to intptr_t rather than int32_t since they are not the same type133// on some platforms.134#define NULL_WORD ((intptr_t)0)135#endif136#else137#define NULL_WORD NULL138#endif139140#ifndef LINUX141// Compiler-specific primitive types142typedef unsigned short uint16_t;143#ifndef _UINT32_T144#define _UINT32_T145typedef unsigned int uint32_t;146#endif147#if !defined(_SYS_INT_TYPES_H)148#ifndef _UINT64_T149#define _UINT64_T150typedef unsigned long long uint64_t;151#endif152// %%%% how to access definition of intptr_t portably in 5.5 onward?153typedef int intptr_t;154typedef unsigned int uintptr_t;155// If this gets an error, figure out a symbol XXX that implies the156// prior definition of intptr_t, and add "&& !defined(XXX)" above.157#endif158#endif159160// On solaris 8, UINTPTR_MAX is defined as empty.161// Everywhere else it's an actual value.162#if UINTPTR_MAX - 1 == -1163#undef UINTPTR_MAX164#ifdef _LP64165#define UINTPTR_MAX UINT64_MAX166#else167#define UINTPTR_MAX UINT32_MAX168#endif /* ifdef _LP64 */169#endif170171// Additional Java basic types172173typedef unsigned char jubyte;174typedef unsigned short jushort;175typedef unsigned int juint;176typedef unsigned long long julong;177178179//----------------------------------------------------------------------------------------------------180// Constant for jlong (specifying an long long constant is C++ compiler specific)181182// Build a 64bit integer constant183#define CONST64(x) (x ## LL)184#define UCONST64(x) (x ## ULL)185186const jlong min_jlong = CONST64(0x8000000000000000);187const jlong max_jlong = CONST64(0x7fffffffffffffff);188189#ifdef SOLARIS190//----------------------------------------------------------------------------------------------------191// ANSI C++ fixes192// NOTE:In the ANSI committee's continuing attempt to make each version193// of C++ incompatible with the previous version, you can no longer cast194// pointers to functions without specifying linkage unless you want to get195// warnings.196//197// This also means that pointers to functions can no longer be "hidden"198// in opaque types like void * because at the invokation point warnings199// will be generated. While this makes perfect sense from a type safety200// point of view it causes a lot of warnings on old code using C header201// files. Here are some typedefs to make the job of silencing warnings202// a bit easier.203//204// The final kick in the teeth is that you can only have extern "C" linkage205// specified at file scope. So these typedefs are here rather than in the206// .hpp for the class (os:Solaris usually) that needs them.207208extern "C" {209typedef int (*int_fnP_thread_t_iP_uP_stack_tP_gregset_t)(thread_t, int*, unsigned *, stack_t*, gregset_t);210typedef int (*int_fnP_thread_t_i_gregset_t)(thread_t, int, gregset_t);211typedef int (*int_fnP_thread_t_i)(thread_t, int);212typedef int (*int_fnP_thread_t)(thread_t);213214typedef int (*int_fnP_cond_tP_mutex_tP_timestruc_tP)(cond_t *cv, mutex_t *mx, timestruc_t *abst);215typedef int (*int_fnP_cond_tP_mutex_tP)(cond_t *cv, mutex_t *mx);216217// typedef for missing API in libc218typedef int (*int_fnP_mutex_tP_i_vP)(mutex_t *, int, void *);219typedef int (*int_fnP_mutex_tP)(mutex_t *);220typedef int (*int_fnP_cond_tP_i_vP)(cond_t *cv, int scope, void *arg);221typedef int (*int_fnP_cond_tP)(cond_t *cv);222};223#endif224225//----------------------------------------------------------------------------------------------------226// Debugging227228#define DEBUG_EXCEPTION ::abort();229230extern "C" void breakpoint();231#define BREAKPOINT ::breakpoint()232233// checking for nanness234#ifdef SOLARIS235#ifdef SPARC236inline int g_isnan(float f) { return isnanf(f); }237#else238// isnanf() broken on Intel Solaris use isnand()239inline int g_isnan(float f) { return isnand(f); }240#endif241242inline int g_isnan(double f) { return isnand(f); }243#elif LINUX244inline int g_isnan(float f) { return isnanf(f); }245inline int g_isnan(double f) { return isnan(f); }246#else247#error "missing platform-specific definition here"248#endif249250// Checking for finiteness251252inline int g_isfinite(jfloat f) { return finite(f); }253inline int g_isfinite(jdouble f) { return finite(f); }254255256// Wide characters257258inline int wcslen(const jchar* x) { return wcslen((const wchar_t*)x); }259260261// Misc262// NOTE: This one leads to an infinite recursion on Linux263#ifndef LINUX264int local_vsnprintf(char* buf, size_t count, const char* fmt, va_list argptr);265#define vsnprintf local_vsnprintf266#endif267268// Portability macros269#define PRAGMA_INTERFACE270#define PRAGMA_IMPLEMENTATION271#define PRAGMA_IMPLEMENTATION_(arg)272#define VALUE_OBJ_CLASS_SPEC : public _ValueObj273274// Formatting.275#ifdef _LP64276#define FORMAT64_MODIFIER "l"277#else // !_LP64278#define FORMAT64_MODIFIER "ll"279#endif // _LP64280281#define offset_of(klass,field) offsetof(klass,field)282283// Inlining support284#define NOINLINE285#define ALWAYSINLINE inline __attribute__((always_inline))286287#endif // SHARE_VM_UTILITIES_GLOBALDEFINITIONS_SPARCWORKS_HPP288289290