duke@435: /* stefank@2314: * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved. duke@435: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. duke@435: * duke@435: * This code is free software; you can redistribute it and/or modify it duke@435: * under the terms of the GNU General Public License version 2 only, as duke@435: * published by the Free Software Foundation. duke@435: * duke@435: * This code is distributed in the hope that it will be useful, but WITHOUT duke@435: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or duke@435: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License duke@435: * version 2 for more details (a copy is included in the LICENSE file that duke@435: * accompanied this code). duke@435: * duke@435: * You should have received a copy of the GNU General Public License version duke@435: * 2 along with this work; if not, write to the Free Software Foundation, duke@435: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. duke@435: * trims@1907: * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA trims@1907: * or visit www.oracle.com if you need additional information or have any trims@1907: * questions. duke@435: * duke@435: */ duke@435: stefank@2314: #ifndef SHARE_VM_LIBADT_PORT_HPP stefank@2314: #define SHARE_VM_LIBADT_PORT_HPP stefank@2314: stefank@2314: #include "utilities/top.hpp" stefank@2314: duke@435: // Typedefs for portable compiling duke@435: duke@435: #if defined(__GNUC__) duke@435: duke@435: #define INTERFACE #pragma interface duke@435: #define IMPLEMENTATION #pragma implementation duke@435: //INTERFACE duke@435: #include duke@435: #include duke@435: #include duke@435: duke@435: // Access to the C++ class virtual function pointer duke@435: // Put the class in the macro duke@435: typedef void *VPTR; duke@435: // G++ puts it at the end of the base class duke@435: #define ACCESS_VPTR(class) VPTR&vptr(){return*(VPTR*)((char*)this+sizeof(class)-sizeof(void*));} duke@435: duke@435: #elif defined(__TURBOC__) duke@435: duke@435: #include duke@435: #include duke@435: extern "C" int stricmp(const char *, const char *); duke@435: inline void bcopy(const void *s, void *d, int l) { memmove(d,s,l); } duke@435: inline void bzero(void *p, int l) { memset(p,0,l); } duke@435: inline int bcmp(const void *s, const void *d, int l) { return memcmp(s,d,l); } duke@435: inline int min( int a, int b) { return a < b ? a : b; } duke@435: inline int max( int a, int b) { return a > b ? a : b; } duke@435: //strcasecmp moved to globalDefinitions_visCPP.hpp duke@435: //inline int strcasecmp(const char *s1, const char *s2) { return stricmp(s1,s2); } duke@435: inline long abs( long x ) { return x < 0 ? -x : x; } duke@435: // Access to the C++ class virtual function pointer duke@435: // Put the class in the macro duke@435: typedef void near *VPTR; duke@435: // BorlandC puts it up front duke@435: #define ACCESS_VPTR(class) VPTR&vptr(){return*(VPTR*)this;} duke@435: duke@435: #elif defined(__hpux) duke@435: duke@435: #define INTERFACE duke@435: #define IMPLEMENTATION duke@435: #define signed duke@435: #include duke@435: #include duke@435: inline long min( long a, long b) { return a < b ? a : b; } duke@435: inline long max( long a, long b) { return a > b ? a : b; } duke@435: inline int min( int a, int b) { return a < b ? a : b; } duke@435: inline int max( int a, int b) { return a > b ? a : b; } duke@435: inline long abs( long x ) { return x < 0 ? -x : x; } duke@435: duke@435: #elif defined(__MOTO__) duke@435: // Motorola's mcc duke@435: #define INTERFACE duke@435: #define IMPLEMENTATION duke@435: #include duke@435: #include duke@435: inline int min( int a, int b) { return a < b ? a : b; } duke@435: inline int max( int a, int b) { return a > b ? a : b; } duke@435: duke@435: #elif defined(_AIX) duke@435: // IBM's xlC compiler duke@435: #define INTERFACE duke@435: #define IMPLEMENTATION duke@435: #include duke@435: #include duke@435: inline int min( int a, int b) { return a < b ? a : b; } duke@435: inline int max( int a, int b) { return a > b ? a : b; } duke@435: duke@435: #elif defined(_MSC_VER) duke@435: // Microsoft Visual C++ duke@435: //#define INTERFACE duke@435: #define IMPLEMENTATION duke@435: #include duke@435: #undef small duke@435: //strcasecmp moved to globalDefinitions_visCPP.hpp duke@435: //inline int strcasecmp(const char *s1, const char *s2) { return stricmp(s1,s2); } duke@435: duke@435: duke@435: #elif defined(SPARC_WORKS) duke@435: duke@435: #define INTERFACE duke@435: #define IMPLEMENTATION duke@435: duke@435: #include duke@435: #include duke@435: #include duke@435: duke@435: #elif defined(SOLARIS) duke@435: duke@435: #define INTERFACE duke@435: #define IMPLEMENTATION duke@435: duke@435: #include duke@435: #include duke@435: #include duke@435: duke@435: duke@435: #elif defined(__TANDEM) duke@435: duke@435: // This case is for the Tandem Business Unit of Compaq Computer Corporation. duke@435: // The Tandem case must precede the AT&T case, duke@435: // because the Tandem c89 compiler also defines __cplusplus. duke@435: duke@435: #include "port_tandem.hpp" duke@435: duke@435: #elif defined(__cplusplus) duke@435: // AT&Ts cfront duke@435: #define INTERFACE duke@435: #define IMPLEMENTATION duke@435: #include duke@435: #define signed duke@435: // #include duke@435: inline int min( int a, int b) { return a < b ? a : b; } duke@435: inline int max( int a, int b) { return a > b ? a : b; } duke@435: duke@435: #else // All other machines duke@435: duke@435: #define signed duke@435: extern "C" void bcopy(void *b1, void *b2, int len); duke@435: inline int min( int a, int b) { return a < b ? a : b; } duke@435: inline int max( int a, int b) { return a > b ? a : b; } duke@435: duke@435: #endif duke@435: duke@435: //----------------------------------------------------------------------------- duke@435: // Safer memory allocations duke@435: #ifdef SAFE_MEMORY duke@435: #define malloc(size) safe_malloc(__FILE__,__LINE__,size) duke@435: #define free(ptr) safe_free(__FILE__,__LINE__,ptr) duke@435: #define realloc(ptr,size) safe_realloc(__FILE__,__LINE__,ptr,size) duke@435: #define calloc(nitems,size) safe_calloc(__FILE__,__LINE__,nitems,size) duke@435: #define strdup(ptr) safe_strdup(__FILE__,__LINE__,ptr) duke@435: extern void *safe_malloc (const char *file, unsigned line, unsigned size); duke@435: extern void safe_free (const char *file, unsigned line, void *ptr); duke@435: extern void *safe_calloc (const char *file, unsigned line, unsigned nitems, unsigned size); duke@435: extern void *safe_realloc(const char *file, unsigned line, void *ptr, unsigned size); duke@435: extern char *safe_strdup (const char *file, unsigned line, const char *src); duke@435: inline void *operator new( size_t size ) { return malloc(size); } duke@435: inline void operator delete( void *ptr ) { free(ptr); } duke@435: #endif duke@435: duke@435: //----------------------------------------------------------------------------- duke@435: // And now, the bit-size-specified integer sizes duke@435: typedef signed char int8; duke@435: typedef unsigned char uint8; duke@435: typedef unsigned char byte; duke@435: duke@435: // All uses of *int16 changed to 32-bit to speed up compiler on Intel duke@435: //typedef signed short int16; // Exactly 16bits signed duke@435: //typedef unsigned short uint16; // Exactly 16bits unsigned duke@435: //const unsigned int min_uint16 = 0x0000; // smallest uint16 duke@435: //const unsigned int max_uint16 = 0xFFFF; // largest uint16 duke@435: duke@435: typedef unsigned int uint; // When you need a fast >=16bit unsigned value duke@435: /*typedef int int; */ // When you need a fast >=16bit value duke@435: const unsigned int max_uint = (uint)-1; duke@435: typedef int32_t int32; // Exactly 32bits signed duke@435: typedef uint32_t uint32; // Exactly 32bits unsigned duke@435: duke@435: // Bit-sized floating point and long thingies duke@435: #ifndef __TANDEM duke@435: // Do not define these for Tandem, because they conflict with typedefs in softieee.h. duke@435: typedef float float32; // 32-bit float duke@435: typedef double float64; // 64-bit float duke@435: #endif // __TANDEM duke@435: duke@435: typedef jlong int64; // Java long for my 64-bit type duke@435: typedef julong uint64; // Java long for my 64-bit type duke@435: duke@435: //----------------------------------------------------------------------------- duke@435: // Nice constants duke@435: uint32 gcd( uint32 x, uint32 y ); duke@435: int ff1( uint32 mask ); duke@435: int fh1( uint32 mask ); duke@435: uint32 rotate32( uint32 x, int32 cnt ); duke@435: duke@435: duke@435: //----------------------------------------------------------------------------- duke@435: extern uint32 heap_totalmem; // Current total memory allocation duke@435: extern uint32 heap_highwater; // Highwater mark to date for memory usage duke@435: stefank@2314: #endif // SHARE_VM_LIBADT_PORT_HPP