src/share/vm/libadt/port.hpp

Mon, 09 Mar 2009 13:28:46 -0700

author
xdono
date
Mon, 09 Mar 2009 13:28:46 -0700
changeset 1014
0fbdb4381b99
parent 948
2328d1d3f8cf
child 1907
c18cbe5936b8
permissions
-rw-r--r--

6814575: Update copyright year
Summary: Update copyright for files that have been modified in 2009, up to 03/09
Reviewed-by: katleman, tbell, ohair

duke@435 1 /*
xdono@1014 2 * Copyright 1997-2009 Sun Microsystems, Inc. All Rights Reserved.
duke@435 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
duke@435 4 *
duke@435 5 * This code is free software; you can redistribute it and/or modify it
duke@435 6 * under the terms of the GNU General Public License version 2 only, as
duke@435 7 * published by the Free Software Foundation.
duke@435 8 *
duke@435 9 * This code is distributed in the hope that it will be useful, but WITHOUT
duke@435 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
duke@435 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
duke@435 12 * version 2 for more details (a copy is included in the LICENSE file that
duke@435 13 * accompanied this code).
duke@435 14 *
duke@435 15 * You should have received a copy of the GNU General Public License version
duke@435 16 * 2 along with this work; if not, write to the Free Software Foundation,
duke@435 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
duke@435 18 *
duke@435 19 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
duke@435 20 * CA 95054 USA or visit www.sun.com if you need additional information or
duke@435 21 * have any questions.
duke@435 22 *
duke@435 23 */
duke@435 24
duke@435 25 #ifndef _PORT_
duke@435 26 #define _PORT_
duke@435 27 // Typedefs for portable compiling
duke@435 28
duke@435 29 #if defined(__GNUC__)
duke@435 30
duke@435 31 #define INTERFACE #pragma interface
duke@435 32 #define IMPLEMENTATION #pragma implementation
duke@435 33 //INTERFACE
duke@435 34 #include <stddef.h>
duke@435 35 #include <stdlib.h>
duke@435 36 #include <string.h>
duke@435 37
duke@435 38 // Access to the C++ class virtual function pointer
duke@435 39 // Put the class in the macro
duke@435 40 typedef void *VPTR;
duke@435 41 // G++ puts it at the end of the base class
duke@435 42 #define ACCESS_VPTR(class) VPTR&vptr(){return*(VPTR*)((char*)this+sizeof(class)-sizeof(void*));}
duke@435 43
duke@435 44 #elif defined(__TURBOC__)
duke@435 45
duke@435 46 #include <mem.h>
duke@435 47 #include <string.h>
duke@435 48 extern "C" int stricmp(const char *, const char *);
duke@435 49 inline void bcopy(const void *s, void *d, int l) { memmove(d,s,l); }
duke@435 50 inline void bzero(void *p, int l) { memset(p,0,l); }
duke@435 51 inline int bcmp(const void *s, const void *d, int l) { return memcmp(s,d,l); }
duke@435 52 inline int min( int a, int b) { return a < b ? a : b; }
duke@435 53 inline int max( int a, int b) { return a > b ? a : b; }
duke@435 54 //strcasecmp moved to globalDefinitions_visCPP.hpp
duke@435 55 //inline int strcasecmp(const char *s1, const char *s2) { return stricmp(s1,s2); }
duke@435 56 inline long abs( long x ) { return x < 0 ? -x : x; }
duke@435 57 // Access to the C++ class virtual function pointer
duke@435 58 // Put the class in the macro
duke@435 59 typedef void near *VPTR;
duke@435 60 // BorlandC puts it up front
duke@435 61 #define ACCESS_VPTR(class) VPTR&vptr(){return*(VPTR*)this;}
duke@435 62
duke@435 63 #elif defined(__hpux)
duke@435 64
duke@435 65 #define INTERFACE
duke@435 66 #define IMPLEMENTATION
duke@435 67 #define signed
duke@435 68 #include <strings.h>
duke@435 69 #include <stdlib.h>
duke@435 70 inline long min( long a, long b) { return a < b ? a : b; }
duke@435 71 inline long max( long a, long b) { return a > b ? a : b; }
duke@435 72 inline int min( int a, int b) { return a < b ? a : b; }
duke@435 73 inline int max( int a, int b) { return a > b ? a : b; }
duke@435 74 inline long abs( long x ) { return x < 0 ? -x : x; }
duke@435 75
duke@435 76 #elif defined(__MOTO__)
duke@435 77 // Motorola's mcc
duke@435 78 #define INTERFACE
duke@435 79 #define IMPLEMENTATION
duke@435 80 #include <stdlib.h>
duke@435 81 #include <memory.h>
duke@435 82 inline int min( int a, int b) { return a < b ? a : b; }
duke@435 83 inline int max( int a, int b) { return a > b ? a : b; }
duke@435 84
duke@435 85 #elif defined(_AIX)
duke@435 86 // IBM's xlC compiler
duke@435 87 #define INTERFACE
duke@435 88 #define IMPLEMENTATION
duke@435 89 #include <stdlib.h>
duke@435 90 #include <memory.h>
duke@435 91 inline int min( int a, int b) { return a < b ? a : b; }
duke@435 92 inline int max( int a, int b) { return a > b ? a : b; }
duke@435 93
duke@435 94 #elif defined(_MSC_VER)
duke@435 95 // Microsoft Visual C++
duke@435 96 //#define INTERFACE
duke@435 97 #define IMPLEMENTATION
duke@435 98 #include <stdlib.h>
duke@435 99 #undef small
duke@435 100 //strcasecmp moved to globalDefinitions_visCPP.hpp
duke@435 101 //inline int strcasecmp(const char *s1, const char *s2) { return stricmp(s1,s2); }
duke@435 102
duke@435 103
duke@435 104 #elif defined(SPARC_WORKS)
duke@435 105
duke@435 106 #define INTERFACE
duke@435 107 #define IMPLEMENTATION
duke@435 108
duke@435 109 #include <stddef.h>
duke@435 110 #include <stdlib.h>
duke@435 111 #include <string.h>
duke@435 112
duke@435 113 #elif defined(SOLARIS)
duke@435 114
duke@435 115 #define INTERFACE
duke@435 116 #define IMPLEMENTATION
duke@435 117
duke@435 118 #include <stddef.h>
duke@435 119 #include <stdlib.h>
duke@435 120 #include <string.h>
duke@435 121
duke@435 122
duke@435 123 #elif defined(__TANDEM)
duke@435 124
duke@435 125 // This case is for the Tandem Business Unit of Compaq Computer Corporation.
duke@435 126 // The Tandem case must precede the AT&T case,
duke@435 127 // because the Tandem c89 compiler also defines __cplusplus.
duke@435 128
duke@435 129 #include "port_tandem.hpp"
duke@435 130
duke@435 131 #elif defined(__cplusplus)
duke@435 132 // AT&Ts cfront
duke@435 133 #define INTERFACE
duke@435 134 #define IMPLEMENTATION
duke@435 135 #include <unistd.h>
duke@435 136 #define signed
duke@435 137 // #include <bstring.h>
duke@435 138 inline int min( int a, int b) { return a < b ? a : b; }
duke@435 139 inline int max( int a, int b) { return a > b ? a : b; }
duke@435 140
duke@435 141 #else // All other machines
duke@435 142
duke@435 143 #define signed
duke@435 144 extern "C" void bcopy(void *b1, void *b2, int len);
duke@435 145 inline int min( int a, int b) { return a < b ? a : b; }
duke@435 146 inline int max( int a, int b) { return a > b ? a : b; }
duke@435 147
duke@435 148 #endif
duke@435 149
duke@435 150 //-----------------------------------------------------------------------------
duke@435 151 // Safer memory allocations
duke@435 152 #ifdef SAFE_MEMORY
duke@435 153 #define malloc(size) safe_malloc(__FILE__,__LINE__,size)
duke@435 154 #define free(ptr) safe_free(__FILE__,__LINE__,ptr)
duke@435 155 #define realloc(ptr,size) safe_realloc(__FILE__,__LINE__,ptr,size)
duke@435 156 #define calloc(nitems,size) safe_calloc(__FILE__,__LINE__,nitems,size)
duke@435 157 #define strdup(ptr) safe_strdup(__FILE__,__LINE__,ptr)
duke@435 158 extern void *safe_malloc (const char *file, unsigned line, unsigned size);
duke@435 159 extern void safe_free (const char *file, unsigned line, void *ptr);
duke@435 160 extern void *safe_calloc (const char *file, unsigned line, unsigned nitems, unsigned size);
duke@435 161 extern void *safe_realloc(const char *file, unsigned line, void *ptr, unsigned size);
duke@435 162 extern char *safe_strdup (const char *file, unsigned line, const char *src);
duke@435 163 inline void *operator new( size_t size ) { return malloc(size); }
duke@435 164 inline void operator delete( void *ptr ) { free(ptr); }
duke@435 165 #endif
duke@435 166
duke@435 167 //-----------------------------------------------------------------------------
duke@435 168 // And now, the bit-size-specified integer sizes
duke@435 169 typedef signed char int8;
duke@435 170 typedef unsigned char uint8;
duke@435 171 typedef unsigned char byte;
duke@435 172
duke@435 173 // All uses of *int16 changed to 32-bit to speed up compiler on Intel
duke@435 174 //typedef signed short int16; // Exactly 16bits signed
duke@435 175 //typedef unsigned short uint16; // Exactly 16bits unsigned
duke@435 176 //const unsigned int min_uint16 = 0x0000; // smallest uint16
duke@435 177 //const unsigned int max_uint16 = 0xFFFF; // largest uint16
duke@435 178
duke@435 179 typedef unsigned int uint; // When you need a fast >=16bit unsigned value
duke@435 180 /*typedef int int; */ // When you need a fast >=16bit value
duke@435 181 const unsigned int max_uint = (uint)-1;
duke@435 182 typedef int32_t int32; // Exactly 32bits signed
duke@435 183 typedef uint32_t uint32; // Exactly 32bits unsigned
duke@435 184
duke@435 185 // Bit-sized floating point and long thingies
duke@435 186 #ifndef __TANDEM
duke@435 187 // Do not define these for Tandem, because they conflict with typedefs in softieee.h.
duke@435 188 typedef float float32; // 32-bit float
duke@435 189 typedef double float64; // 64-bit float
duke@435 190 #endif // __TANDEM
duke@435 191
duke@435 192 typedef jlong int64; // Java long for my 64-bit type
duke@435 193 typedef julong uint64; // Java long for my 64-bit type
duke@435 194
duke@435 195 //-----------------------------------------------------------------------------
duke@435 196 // Nice constants
duke@435 197 uint32 gcd( uint32 x, uint32 y );
duke@435 198 int ff1( uint32 mask );
duke@435 199 int fh1( uint32 mask );
duke@435 200 uint32 rotate32( uint32 x, int32 cnt );
duke@435 201
duke@435 202
duke@435 203 //-----------------------------------------------------------------------------
duke@435 204 extern uint32 heap_totalmem; // Current total memory allocation
duke@435 205 extern uint32 heap_highwater; // Highwater mark to date for memory usage
duke@435 206
duke@435 207 #endif // _PORT_

mercurial