globalDefinitions_xlc.hpp revision 5969:666e6ce3976c
185587Sobrien/* 285587Sobrien * Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved. 385587Sobrien * Copyright 2012, 2013 SAP AG. All rights reserved. 485587Sobrien * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 585587Sobrien * 685587Sobrien * This code is free software; you can redistribute it and/or modify it 785587Sobrien * under the terms of the GNU General Public License version 2 only, as 885587Sobrien * published by the Free Software Foundation. 985587Sobrien * 1085587Sobrien * This code is distributed in the hope that it will be useful, but WITHOUT 1185587Sobrien * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 1285587Sobrien * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 1385587Sobrien * version 2 for more details (a copy is included in the LICENSE file that 1485587Sobrien * accompanied this code). 1585587Sobrien * 1685587Sobrien * You should have received a copy of the GNU General Public License version 1785587Sobrien * 2 along with this work; if not, write to the Free Software Foundation, 1885587Sobrien * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 1985587Sobrien * 2085587Sobrien * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 2185587Sobrien * or visit www.oracle.com if you need additional information or have any 2285587Sobrien * questions. 2385587Sobrien * 2485587Sobrien */ 2585587Sobrien 2685587Sobrien#ifndef SHARE_VM_UTILITIES_GLOBALDEFINITIONS_XLC_HPP 2785587Sobrien#define SHARE_VM_UTILITIES_GLOBALDEFINITIONS_XLC_HPP 2885587Sobrien 2985587Sobrien#include "prims/jni.h" 3085587Sobrien 3185587Sobrien// This file holds compiler-dependent includes, 3285587Sobrien// globally used constants & types, class (forward) 3385587Sobrien// declarations and a few frequently used utility functions. 3485587Sobrien 3585587Sobrien#include <ctype.h> 3685587Sobrien#include <string.h> 3785587Sobrien#include <stdarg.h> 3885587Sobrien#include <stddef.h> 3985587Sobrien#include <stdio.h> 4085587Sobrien#include <stdlib.h> 4185587Sobrien#include <wchar.h> 4285587Sobrien 4385587Sobrien#include <math.h> 4485587Sobrien#ifndef FP_PZERO 4585587Sobrien// Linux doesn't have positive/negative zero 4685587Sobrien#define FP_PZERO FP_ZERO 4785587Sobrien#endif 4885587Sobrien#if (!defined fpclass) 4985587Sobrien#define fpclass fpclassify 5085587Sobrien#endif 5185587Sobrien 5285587Sobrien#include <time.h> 5385587Sobrien#include <fcntl.h> 54146299Sru#include <dlfcn.h> 5585587Sobrien#include <pthread.h> 5685587Sobrien 5785587Sobrien#include <limits.h> 5885587Sobrien#include <errno.h> 5985587Sobrien 6085587Sobrien#include <stdint.h> 6185587Sobrien 6285587Sobrien// Use XLC compiler builtins instead of inline assembler 6385587Sobrien#define USE_XLC_BUILTINS 6485587Sobrien#ifdef USE_XLC_BUILTINS 6585587Sobrien#include <builtins.h> 6685587Sobrien #if __IBMCPP__ < 1000 6785587Sobrien // the funtion prototype for __dcbtst(void *) is missing in XLC V8.0 6885587Sobrien // I could compile a little test, where I provided the prototype. 6985587Sobrien // The generated code was correct there. This is the prototype: 7085587Sobrien // extern "builtin" void __dcbtst (void *); 7185587Sobrien // For now we don't make use of it when compiling with XLC V8.0 7285587Sobrien #else 7385587Sobrien // __IBMCPP__ >= 1000 7485587Sobrien // XLC V10 provides the prototype for __dcbtst (void *); 7585587Sobrien #define USE_XLC_PREFETCH_WRITE_BUILTIN 7685587Sobrien #endif 77146299Sru#endif // USE_XLC_BUILTINS 78146299Sru 7985587Sobrien// NULL vs NULL_WORD: 8085587Sobrien// On Linux NULL is defined as a special type '__null'. Assigning __null to 8185587Sobrien// integer variable will cause gcc warning. Use NULL_WORD in places where a 8285587Sobrien// pointer is stored as integer value. On some platforms, sizeof(intptr_t) > 8385587Sobrien// sizeof(void*), so here we want something which is integer type, but has the 8485587Sobrien// same size as a pointer. 8585587Sobrien#ifdef __GNUC__ 8685587Sobrien #error XLC and __GNUC__? 8785587Sobrien#else 8885587Sobrien #define NULL_WORD NULL 8985587Sobrien#endif 9085587Sobrien 9185587Sobrien// AIX also needs a 64 bit NULL to work as a null address pointer. 9285587Sobrien// Most system includes on AIX would define it as an int 0 if not already defined with one 9385587Sobrien// exception: /usr/include/dirent.h will unconditionally redefine NULL to int 0 again. 9485587Sobrien// In this case you need to copy the following defines to a position after #include <dirent.h> 9585587Sobrien// (see jmv_aix.h). 9685587Sobrien#ifdef AIX 9785587Sobrien #ifdef _LP64 9885587Sobrien #undef NULL 9985587Sobrien #define NULL 0L 10085587Sobrien #else 10185587Sobrien #ifndef NULL 10285587Sobrien #define NULL 0 10385587Sobrien #endif 10485587Sobrien #endif 10585587Sobrien#endif // AIX 10685587Sobrien 10785587Sobrien// Compiler-specific primitive types 10885587Sobrien// All defs of int (uint16_6 etc) are defined in AIX' /usr/include/stdint.h 10985587Sobrien 11085587Sobrien// Additional Java basic types 11185587Sobrien 11285587Sobrientypedef uint8_t jubyte; 11385587Sobrientypedef uint16_t jushort; 11485587Sobrientypedef uint32_t juint; 11585587Sobrientypedef uint64_t julong; 11685587Sobrien 11785587Sobrien//---------------------------------------------------------------------------------------------------- 11885587Sobrien// Special (possibly not-portable) casts 11985587Sobrien// Cast floats into same-size integers and vice-versa w/o changing bit-pattern 12085587Sobrien// %%%%%% These seem like standard C++ to me--how about factoring them out? - Ungar 12185587Sobrien 12285587Sobrieninline jint jint_cast (jfloat x) { return *(jint* )&x; } 12385587Sobrieninline jlong jlong_cast (jdouble x) { return *(jlong* )&x; } 12485587Sobrien 12585587Sobrieninline jfloat jfloat_cast (jint x) { return *(jfloat* )&x; } 12685587Sobrieninline jdouble jdouble_cast(jlong x) { return *(jdouble*)&x; } 12785587Sobrien 12885587Sobrien//---------------------------------------------------------------------------------------------------- 12985587Sobrien// Constant for jlong (specifying an long long canstant is C++ compiler specific) 13085587Sobrien 13185587Sobrien// Build a 64bit integer constant 13285587Sobrien#define CONST64(x) (x ## LL) 13385587Sobrien#define UCONST64(x) (x ## ULL) 13485587Sobrien 13585587Sobrienconst jlong min_jlong = CONST64(0x8000000000000000); 13685587Sobrienconst jlong max_jlong = CONST64(0x7fffffffffffffff); 13785587Sobrien 13885587Sobrien//---------------------------------------------------------------------------------------------------- 13985587Sobrien// Debugging 14085587Sobrien 14185587Sobrien#define DEBUG_EXCEPTION ::abort(); 14285587Sobrien 14385587Sobrienextern "C" void breakpoint(); 14485587Sobrien#define BREAKPOINT ::breakpoint() 14585587Sobrien 14685587Sobrien// checking for nanness 14785587Sobrien#ifdef AIX 14885587Sobrieninline int g_isnan(float f) { return isnan(f); } 14985587Sobrieninline int g_isnan(double f) { return isnan(f); } 15085587Sobrien#else 15185587Sobrien#error "missing platform-specific definition here" 15285587Sobrien#endif 15385587Sobrien 15485587Sobrien// Checking for finiteness 15585587Sobrien 15685587Sobrieninline int g_isfinite(jfloat f) { return finite(f); } 15785587Sobrieninline int g_isfinite(jdouble f) { return finite(f); } 15885587Sobrien 15985587Sobrien 16085587Sobrien// Wide characters 16185587Sobrien 16285587Sobrieninline int wcslen(const jchar* x) { return wcslen((const wchar_t*)x); } 16385587Sobrien 16485587Sobrien 16585587Sobrien// Portability macros 16685587Sobrien#define PRAGMA_INTERFACE #pragma interface 16785587Sobrien#define PRAGMA_IMPLEMENTATION #pragma implementation 16885587Sobrien#define VALUE_OBJ_CLASS_SPEC 16985587Sobrien 17085587Sobrien// Formatting. 17185587Sobrien#ifdef _LP64 17285587Sobrien#define FORMAT64_MODIFIER "l" 17385587Sobrien#else // !_LP64 17485587Sobrien#define FORMAT64_MODIFIER "ll" 17590902Sdes#endif // _LP64 17685587Sobrien 177301289Spfg// Cannot use xlc's offsetof as implementation of hotspot's 17885587Sobrien// offset_of(), because xlc warns about applying offsetof() to non-POD 17990902Sdes// object and xlc cannot compile the expression offsetof(DataLayout, 18090902Sdes// _cells[index]) in DataLayout::cell_offset() . Therefore we define 18185587Sobrien// offset_of as it is defined for gcc. 18285587Sobrien#define offset_of(klass,field) (size_t)((intx)&(((klass*)16)->field) - 16) 18385587Sobrien 18485587Sobrien// Some constant sizes used throughout the AIX port 185107806Sobrien#define SIZE_1K ((uint64_t) 0x400ULL) 18685587Sobrien#define SIZE_4K ((uint64_t) 0x1000ULL) 18785587Sobrien#define SIZE_64K ((uint64_t) 0x10000ULL) 18885587Sobrien#define SIZE_1M ((uint64_t) 0x100000ULL) 18985587Sobrien#define SIZE_4M ((uint64_t) 0x400000ULL) 19085587Sobrien#define SIZE_8M ((uint64_t) 0x800000ULL) 19185587Sobrien#define SIZE_16M ((uint64_t) 0x1000000ULL) 19285587Sobrien#define SIZE_256M ((uint64_t) 0x10000000ULL) 19385587Sobrien#define SIZE_1G ((uint64_t) 0x40000000ULL) 19485587Sobrien#define SIZE_2G ((uint64_t) 0x80000000ULL) 19585587Sobrien#define SIZE_4G ((uint64_t) 0x100000000ULL) 19685587Sobrien#define SIZE_16G ((uint64_t) 0x400000000ULL) 19785587Sobrien#define SIZE_32G ((uint64_t) 0x800000000ULL) 19885587Sobrien#define SIZE_64G ((uint64_t) 0x1000000000ULL) 19985587Sobrien#define SIZE_1T ((uint64_t) 0x10000000000ULL) 20085587Sobrien 20185587Sobrien 20285587Sobrien#endif // SHARE_VM_UTILITIES_GLOBALDEFINITIONS_XLC_HPP 20385587Sobrien