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