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