src/share/vm/utilities/globalDefinitions_sparcWorks.hpp

Tue, 17 Oct 2017 12:58:25 +0800

author
aoqi
date
Tue, 17 Oct 2017 12:58:25 +0800
changeset 7994
04ff2f6cd0eb
parent 7638
aefa2e84b424
parent 7535
7ae4e26cb1e0
child 9931
fd44df5e3bc3
permissions
-rw-r--r--

merge

aoqi@0 1 /*
gthornbr@7624 2 * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
aoqi@0 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
aoqi@0 4 *
aoqi@0 5 * This code is free software; you can redistribute it and/or modify it
aoqi@0 6 * under the terms of the GNU General Public License version 2 only, as
aoqi@0 7 * published by the Free Software Foundation.
aoqi@0 8 *
aoqi@0 9 * This code is distributed in the hope that it will be useful, but WITHOUT
aoqi@0 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
aoqi@0 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
aoqi@0 12 * version 2 for more details (a copy is included in the LICENSE file that
aoqi@0 13 * accompanied this code).
aoqi@0 14 *
aoqi@0 15 * You should have received a copy of the GNU General Public License version
aoqi@0 16 * 2 along with this work; if not, write to the Free Software Foundation,
aoqi@0 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
aoqi@0 18 *
aoqi@0 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
aoqi@0 20 * or visit www.oracle.com if you need additional information or have any
aoqi@0 21 * questions.
aoqi@0 22 *
aoqi@0 23 */
aoqi@0 24
aoqi@0 25 #ifndef SHARE_VM_UTILITIES_GLOBALDEFINITIONS_SPARCWORKS_HPP
aoqi@0 26 #define SHARE_VM_UTILITIES_GLOBALDEFINITIONS_SPARCWORKS_HPP
aoqi@0 27
aoqi@0 28 #include "prims/jni.h"
aoqi@0 29
aoqi@0 30 // This file holds compiler-dependent includes,
aoqi@0 31 // globally used constants & types, class (forward)
aoqi@0 32 // declarations and a few frequently used utility functions.
aoqi@0 33
aoqi@0 34
aoqi@0 35 # include <ctype.h>
gthornbr@7624 36 #define __USE_LEGACY_PROTOTYPES__
aoqi@0 37 # include <dirent.h>
gthornbr@7624 38 #undef __USE_LEGACY_PROTOTYPES__
aoqi@0 39 # include <string.h>
aoqi@0 40 # include <strings.h> // for bsd'isms
aoqi@0 41 # include <stdarg.h>
aoqi@0 42 # include <stddef.h> // for offsetof
aoqi@0 43 # include <stdio.h>
aoqi@0 44 # include <stdlib.h>
aoqi@0 45 # include <wchar.h>
aoqi@0 46 # include <stdarg.h>
aoqi@0 47 #ifdef SOLARIS
aoqi@0 48 # include <ieeefp.h>
aoqi@0 49 #endif
aoqi@0 50 # include <math.h>
aoqi@0 51 # include <time.h>
aoqi@0 52 # include <fcntl.h>
aoqi@0 53 # include <dlfcn.h>
aoqi@0 54 # include <pthread.h>
aoqi@0 55 #ifdef SOLARIS
aoqi@0 56 # include <thread.h>
aoqi@0 57 #endif
aoqi@0 58 # include <limits.h>
aoqi@0 59 # include <errno.h>
aoqi@0 60 #ifdef SOLARIS
aoqi@0 61 # include <sys/trap.h>
aoqi@0 62 # include <sys/regset.h>
aoqi@0 63 # include <sys/procset.h>
aoqi@0 64 # include <ucontext.h>
aoqi@0 65 # include <setjmp.h>
aoqi@0 66 #endif
aoqi@0 67 # ifdef SOLARIS_MUTATOR_LIBTHREAD
aoqi@0 68 # include <sys/procfs.h>
aoqi@0 69 # endif
aoqi@0 70
aoqi@0 71 #include <inttypes.h>
aoqi@0 72
aoqi@0 73 // Solaris 8 doesn't provide definitions of these
aoqi@0 74 #ifdef SOLARIS
aoqi@0 75 #ifndef PRIdPTR
aoqi@0 76 #if defined(_LP64)
aoqi@0 77 #define PRIdPTR "ld"
aoqi@0 78 #define PRIuPTR "lu"
aoqi@0 79 #define PRIxPTR "lx"
aoqi@0 80 #else
aoqi@0 81 #define PRIdPTR "d"
aoqi@0 82 #define PRIuPTR "u"
aoqi@0 83 #define PRIxPTR "x"
aoqi@0 84 #endif
aoqi@0 85 #endif
aoqi@0 86 #endif
aoqi@0 87
aoqi@0 88 #ifdef LINUX
aoqi@0 89 # include <signal.h>
aoqi@0 90 # include <ucontext.h>
aoqi@0 91 # include <sys/time.h>
aoqi@0 92 #endif
aoqi@0 93
aoqi@0 94
aoqi@0 95 // 4810578: varargs unsafe on 32-bit integer/64-bit pointer architectures
aoqi@0 96 // When __cplusplus is defined, NULL is defined as 0 (32-bit constant) in
aoqi@0 97 // system header files. On 32-bit architectures, there is no problem.
aoqi@0 98 // On 64-bit architectures, defining NULL as a 32-bit constant can cause
aoqi@0 99 // problems with varargs functions: C++ integral promotion rules say for
aoqi@0 100 // varargs, we pass the argument 0 as an int. So, if NULL was passed to a
aoqi@0 101 // varargs function it will remain 32-bits. Depending on the calling
aoqi@0 102 // convention of the machine, if the argument is passed on the stack then
aoqi@0 103 // only 32-bits of the "NULL" pointer may be initialized to zero. The
aoqi@0 104 // other 32-bits will be garbage. If the varargs function is expecting a
aoqi@0 105 // pointer when it extracts the argument, then we have a problem.
aoqi@0 106 //
aoqi@0 107 // Solution: For 64-bit architectures, redefine NULL as 64-bit constant 0.
aoqi@0 108 //
aoqi@0 109 // Note: this fix doesn't work well on Linux because NULL will be overwritten
aoqi@0 110 // whenever a system header file is included. Linux handles NULL correctly
aoqi@0 111 // through a special type '__null'.
aoqi@0 112 #ifdef SOLARIS
aoqi@0 113 #ifdef _LP64
aoqi@0 114 #undef NULL
aoqi@0 115 #define NULL 0L
aoqi@0 116 #else
aoqi@0 117 #ifndef NULL
aoqi@0 118 #define NULL 0
aoqi@0 119 #endif
aoqi@0 120 #endif
aoqi@0 121 #endif
aoqi@0 122
aoqi@0 123 // NULL vs NULL_WORD:
aoqi@0 124 // On Linux NULL is defined as a special type '__null'. Assigning __null to
aoqi@0 125 // integer variable will cause gcc warning. Use NULL_WORD in places where a
aoqi@0 126 // pointer is stored as integer value. On some platforms, sizeof(intptr_t) >
aoqi@0 127 // sizeof(void*), so here we want something which is integer type, but has the
aoqi@0 128 // same size as a pointer.
aoqi@0 129 #ifdef LINUX
aoqi@0 130 #ifdef _LP64
aoqi@0 131 #define NULL_WORD 0L
aoqi@0 132 #else
aoqi@0 133 // Cast 0 to intptr_t rather than int32_t since they are not the same type
aoqi@0 134 // on some platforms.
aoqi@0 135 #define NULL_WORD ((intptr_t)0)
aoqi@0 136 #endif
aoqi@0 137 #else
aoqi@0 138 #define NULL_WORD NULL
aoqi@0 139 #endif
aoqi@0 140
aoqi@0 141 #ifndef LINUX
aoqi@0 142 // Compiler-specific primitive types
aoqi@0 143 typedef unsigned short uint16_t;
aoqi@0 144 #ifndef _UINT32_T
aoqi@0 145 #define _UINT32_T
aoqi@0 146 typedef unsigned int uint32_t;
aoqi@0 147 #endif
aoqi@0 148 #if !defined(_SYS_INT_TYPES_H)
aoqi@0 149 #ifndef _UINT64_T
aoqi@0 150 #define _UINT64_T
aoqi@0 151 typedef unsigned long long uint64_t;
aoqi@0 152 #endif
aoqi@0 153 // %%%% how to access definition of intptr_t portably in 5.5 onward?
aoqi@0 154 typedef int intptr_t;
aoqi@0 155 typedef unsigned int uintptr_t;
aoqi@0 156 // If this gets an error, figure out a symbol XXX that implies the
aoqi@0 157 // prior definition of intptr_t, and add "&& !defined(XXX)" above.
aoqi@0 158 #endif
aoqi@0 159 #endif
aoqi@0 160
aoqi@0 161 // On solaris 8, UINTPTR_MAX is defined as empty.
aoqi@0 162 // Everywhere else it's an actual value.
aoqi@0 163 #if UINTPTR_MAX - 1 == -1
aoqi@0 164 #undef UINTPTR_MAX
aoqi@0 165 #ifdef _LP64
aoqi@0 166 #define UINTPTR_MAX UINT64_MAX
aoqi@0 167 #else
aoqi@0 168 #define UINTPTR_MAX UINT32_MAX
aoqi@0 169 #endif /* ifdef _LP64 */
aoqi@0 170 #endif
aoqi@0 171
aoqi@0 172 // Additional Java basic types
aoqi@0 173
aoqi@0 174 typedef unsigned char jubyte;
aoqi@0 175 typedef unsigned short jushort;
aoqi@0 176 typedef unsigned int juint;
aoqi@0 177 typedef unsigned long long julong;
aoqi@0 178
aoqi@0 179
aoqi@0 180 //----------------------------------------------------------------------------------------------------
aoqi@0 181 // Constant for jlong (specifying an long long constant is C++ compiler specific)
aoqi@0 182
aoqi@0 183 // Build a 64bit integer constant
aoqi@0 184 #define CONST64(x) (x ## LL)
aoqi@0 185 #define UCONST64(x) (x ## ULL)
aoqi@0 186
aoqi@0 187 const jlong min_jlong = CONST64(0x8000000000000000);
aoqi@0 188 const jlong max_jlong = CONST64(0x7fffffffffffffff);
aoqi@0 189
aoqi@0 190 #ifdef SOLARIS
aoqi@0 191 //----------------------------------------------------------------------------------------------------
aoqi@0 192 // ANSI C++ fixes
aoqi@0 193 // NOTE:In the ANSI committee's continuing attempt to make each version
aoqi@0 194 // of C++ incompatible with the previous version, you can no longer cast
aoqi@0 195 // pointers to functions without specifying linkage unless you want to get
aoqi@0 196 // warnings.
aoqi@0 197 //
aoqi@0 198 // This also means that pointers to functions can no longer be "hidden"
aoqi@0 199 // in opaque types like void * because at the invokation point warnings
aoqi@0 200 // will be generated. While this makes perfect sense from a type safety
aoqi@0 201 // point of view it causes a lot of warnings on old code using C header
aoqi@0 202 // files. Here are some typedefs to make the job of silencing warnings
aoqi@0 203 // a bit easier.
aoqi@0 204 //
aoqi@0 205 // The final kick in the teeth is that you can only have extern "C" linkage
aoqi@0 206 // specified at file scope. So these typedefs are here rather than in the
aoqi@0 207 // .hpp for the class (os:Solaris usually) that needs them.
aoqi@0 208
aoqi@0 209 extern "C" {
aoqi@0 210 typedef int (*int_fnP_thread_t_iP_uP_stack_tP_gregset_t)(thread_t, int*, unsigned *, stack_t*, gregset_t);
aoqi@0 211 typedef int (*int_fnP_thread_t_i_gregset_t)(thread_t, int, gregset_t);
aoqi@0 212 typedef int (*int_fnP_thread_t_i)(thread_t, int);
aoqi@0 213 typedef int (*int_fnP_thread_t)(thread_t);
aoqi@0 214
aoqi@0 215 typedef int (*int_fnP_cond_tP_mutex_tP_timestruc_tP)(cond_t *cv, mutex_t *mx, timestruc_t *abst);
aoqi@0 216 typedef int (*int_fnP_cond_tP_mutex_tP)(cond_t *cv, mutex_t *mx);
aoqi@0 217
aoqi@0 218 // typedef for missing API in libc
aoqi@0 219 typedef int (*int_fnP_mutex_tP_i_vP)(mutex_t *, int, void *);
aoqi@0 220 typedef int (*int_fnP_mutex_tP)(mutex_t *);
aoqi@0 221 typedef int (*int_fnP_cond_tP_i_vP)(cond_t *cv, int scope, void *arg);
aoqi@0 222 typedef int (*int_fnP_cond_tP)(cond_t *cv);
aoqi@0 223 };
aoqi@0 224 #endif
aoqi@0 225
aoqi@0 226 //----------------------------------------------------------------------------------------------------
aoqi@0 227 // Debugging
aoqi@0 228
aoqi@0 229 #define DEBUG_EXCEPTION ::abort();
aoqi@0 230
aoqi@0 231 extern "C" void breakpoint();
aoqi@0 232 #define BREAKPOINT ::breakpoint()
aoqi@0 233
aoqi@0 234 // checking for nanness
aoqi@0 235 #ifdef SOLARIS
aoqi@0 236 #ifdef SPARC
aoqi@0 237 inline int g_isnan(float f) { return isnanf(f); }
aoqi@0 238 #else
aoqi@0 239 // isnanf() broken on Intel Solaris use isnand()
aoqi@0 240 inline int g_isnan(float f) { return isnand(f); }
aoqi@0 241 #endif
aoqi@0 242
aoqi@0 243 inline int g_isnan(double f) { return isnand(f); }
aoqi@0 244 #elif LINUX
aoqi@0 245 inline int g_isnan(float f) { return isnanf(f); }
aoqi@0 246 inline int g_isnan(double f) { return isnan(f); }
aoqi@0 247 #else
aoqi@0 248 #error "missing platform-specific definition here"
aoqi@0 249 #endif
aoqi@0 250
aoqi@0 251 // Checking for finiteness
aoqi@0 252
aoqi@0 253 inline int g_isfinite(jfloat f) { return finite(f); }
aoqi@0 254 inline int g_isfinite(jdouble f) { return finite(f); }
aoqi@0 255
aoqi@0 256
aoqi@0 257 // Wide characters
aoqi@0 258
aoqi@0 259 inline int wcslen(const jchar* x) { return wcslen((const wchar_t*)x); }
aoqi@0 260
aoqi@0 261
aoqi@0 262 // Misc
aoqi@0 263 // NOTE: This one leads to an infinite recursion on Linux
aoqi@0 264 #ifndef LINUX
aoqi@0 265 int local_vsnprintf(char* buf, size_t count, const char* fmt, va_list argptr);
aoqi@0 266 #define vsnprintf local_vsnprintf
aoqi@0 267 #endif
aoqi@0 268
aoqi@0 269 // Portability macros
aoqi@0 270 #define PRAGMA_INTERFACE
aoqi@0 271 #define PRAGMA_IMPLEMENTATION
aoqi@0 272 #define PRAGMA_IMPLEMENTATION_(arg)
aoqi@0 273 #define VALUE_OBJ_CLASS_SPEC : public _ValueObj
aoqi@0 274
aoqi@0 275 // Formatting.
aoqi@0 276 #ifdef _LP64
aoqi@0 277 #define FORMAT64_MODIFIER "l"
aoqi@0 278 #else // !_LP64
aoqi@0 279 #define FORMAT64_MODIFIER "ll"
aoqi@0 280 #endif // _LP64
aoqi@0 281
aoqi@0 282 #define offset_of(klass,field) offsetof(klass,field)
aoqi@0 283
aoqi@0 284 #endif // SHARE_VM_UTILITIES_GLOBALDEFINITIONS_SPARCWORKS_HPP

mercurial