annotate src/share/vm/utilities/globalDefinitions_sparcWorks.hpp @ 4834:74d14a44c398

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