Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/openj9
Path: blob/master/runtime/j9vm/jvm.h
5985 views
1
/*******************************************************************************
2
* Copyright (c) 2002, 2018 IBM Corp. and others
3
*
4
* This program and the accompanying materials are made available under
5
* the terms of the Eclipse Public License 2.0 which accompanies this
6
* distribution and is available at https://www.eclipse.org/legal/epl-2.0/
7
* or the Apache License, Version 2.0 which accompanies this distribution and
8
* is available at https://www.apache.org/licenses/LICENSE-2.0.
9
*
10
* This Source Code may also be made available under the following
11
* Secondary Licenses when the conditions for such availability set
12
* forth in the Eclipse Public License, v. 2.0 are satisfied: GNU
13
* General Public License, version 2 with the GNU Classpath
14
* Exception [1] and GNU General Public License, version 2 with the
15
* OpenJDK Assembly Exception [2].
16
*
17
* [1] https://www.gnu.org/software/classpath/license.html
18
* [2] http://openjdk.java.net/legal/assembly-exception.html
19
*
20
* SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 OR LicenseRef-GPL-2.0 WITH Assembly-exception
21
*******************************************************************************/
22
23
24
#ifndef jvm_h
25
#define jvm_h
26
27
#ifdef __cplusplus
28
extern "C" {
29
#endif
30
31
#if defined(IBM_MVS)
32
/* J2SE class libraries include jvm.h but don't define J9ZOS390. We do that here on their behalf. */
33
#ifndef J9ZOS390
34
#define J9ZOS390
35
#endif
36
#endif
37
38
39
#ifdef WIN32
40
41
#ifdef BOOLEAN
42
/* There is a collision between J9's definition of BOOLEAN and WIN32 headers */
43
#define BOOLEAN_COLLISION_DETECTED BOOLEAN
44
#undef BOOLEAN
45
#endif /* #ifdef BOOLEAN */
46
47
/* Undefine the winsockapi because winsock2 defines it. Removes warnings. */
48
#if defined(_WINSOCKAPI_) && !defined(_WINSOCK2API_)
49
#undef _WINSOCKAPI_
50
#endif
51
#include <winsock2.h>
52
#define PATH_MAX MAX_PATH
53
54
#ifdef BOOLEAN_COLLISION_DETECTED
55
#define BOOLEAN UDATA
56
#undef BOOLEAN_COLLISION_DETECTED
57
#endif /* #ifdef BOOLEAN_COLLISION_DETECTED */
58
59
#endif /* WIN32 */
60
61
#ifdef J9ZOS390
62
#include <ctype.h>
63
#include <unistd.h>
64
#include <dirent.h>
65
#define PATH_MAX 1023
66
#endif /* J9ZOS390 */
67
68
#include <errno.h>
69
#include <limits.h>
70
#include <stdlib.h>
71
#include <string.h>
72
#include <fcntl.h>
73
#include <sys/stat.h>
74
#include <signal.h>
75
#include <setjmp.h>
76
77
#include <jni.h>
78
#include "j9comp.h" /* for definition */
79
80
#if defined(J9UNIX)
81
#ifndef __USE_LARGEFILE64
82
#define __USE_LARGEFILE64
83
#endif
84
#include <unistd.h>
85
#include <sys/param.h>
86
#include <dirent.h>
87
#endif /* defined(J9UNIX) */
88
89
/* AIX has a #define for MAXPATHLEN in /usr/include/param.h which defines MAXPATHLEN as PATH_MAX+1 */
90
#ifndef MAXPATHLEN
91
#ifdef AIX
92
#define MAXPATHLEN (PATH_MAX+1)
93
#else
94
#define MAXPATHLEN PATH_MAX
95
#endif
96
#endif
97
98
#ifndef O_TEMPORARY
99
#define O_TEMPORARY 0x10000 /* non-standard flag on Unix */
100
#endif
101
102
/*
103
* JVM constants
104
*/
105
#define JVM_INTERFACE_VERSION 4
106
107
#define JVM_MAXPATHLEN PATH_MAX
108
109
#define JVM_IO_OK 0
110
#define JVM_IO_ERR -1
111
#define JVM_IO_INTR -2
112
113
#define JVM_O_RDWR O_RDWR
114
#define JVM_O_CREAT O_CREAT
115
#define JVM_O_EXCL O_EXCL
116
#define JVM_O_DELETE O_TEMPORARY
117
118
#define JVM_EEXIST -100
119
120
#define JVM_SIGTERM SIGTERM
121
122
#define J9_SIDECAR_MAX_OBJECT_INSPECTION_AGE 10000L
123
124
#define JVM_ZIP_HOOK_STATE_OPEN 1
125
#define JVM_ZIP_HOOK_STATE_CLOSED 2
126
#define JVM_ZIP_HOOK_STATE_RESET 3
127
128
#if defined(J9UNIX)
129
typedef sigjmp_buf* pre_block_t;
130
#else /* defined(J9UNIX) */
131
typedef void* pre_block_t;
132
#endif /* defined(J9UNIX) */
133
134
struct sockaddr; /* suppress warning messages */
135
136
#ifndef LAUNCHERS
137
#define J9MALLOC_STRINGIFY(X) #X
138
#define J9MALLOC_TOSTRING(X) J9MALLOC_STRINGIFY(X)
139
140
#if !defined(CURRENT_MEMORY_CATEGORY)
141
#define CURRENT_MEMORY_CATEGORY J9MEM_CATEGORY_SUN_JCL
142
#endif
143
#define malloc(a) JVM_RawAllocateInCategory( (a), __FILE__ ":" J9MALLOC_TOSTRING(__LINE__), CURRENT_MEMORY_CATEGORY )
144
#define realloc(p, a) JVM_RawReallocInCategory( (p), (a), __FILE__ ":" J9MALLOC_TOSTRING(__LINE__), CURRENT_MEMORY_CATEGORY )
145
#define calloc(n, a) JVM_RawCallocInCategory( (n), (a), __FILE__ ":" J9MALLOC_TOSTRING(__LINE__), CURRENT_MEMORY_CATEGORY )
146
#define free(a) JVM_RawFree( (a) )
147
#endif
148
149
/*
150
* JVM methods
151
*/
152
/* ---------------- jvm.c ---------------- */
153
154
/**
155
* @brief
156
* @param env
157
* @param instr
158
* @param outstr
159
* @param outlen
160
* @param encoding
161
* @return jint
162
*/
163
jint
164
GetStringPlatform(JNIEnv* env, jstring instr, char* outstr, jint outlen, const char* encoding);
165
166
167
/**
168
* @brief
169
* @param env
170
* @param instr
171
* @param outlen
172
* @param encoding
173
* @return jint
174
*/
175
jint
176
GetStringPlatformLength(JNIEnv* env, jstring instr, jint* outlen, const char* encoding);
177
178
/**
179
* @brief
180
* @param *dir
181
* @param *file
182
* @return int
183
*/
184
int isFileInDir(char *dir, char *file);
185
186
/**
187
* @brief
188
* @param stream
189
* @param format
190
* @param ...
191
* @return int
192
*/
193
int
194
jio_fprintf(FILE * stream, const char * format, ...);
195
196
197
/**
198
* @brief
199
* @param str
200
* @param n
201
* @param format
202
* @param ...
203
* @return int
204
*/
205
int
206
jio_snprintf(char * str, int n, const char * format, ...);
207
208
struct sockaddr;
209
210
211
/**
212
* @brief
213
* @param (*func)(void)
214
* @return void
215
*/
216
void JNICALL
217
JVM_OnExit(void (*func)(void));
218
219
220
/**
221
* @brief
222
* @param **pvm
223
* @param **penv
224
* @param *vm_args
225
* @return jint
226
*/
227
jint JNICALL
228
JNI_CreateJavaVM(JavaVM **pvm, void **penv, void *vm_args);
229
230
231
/**
232
* @brief
233
* @param **vmBuf
234
* @param bufLen
235
* @param *nVMs
236
* @return jint
237
*/
238
jint JNICALL
239
JNI_GetCreatedJavaVMs(JavaVM **vmBuf, jsize bufLen, jsize *nVMs);
240
241
242
/**
243
* @brief
244
* @param *vm_args
245
* @return jint
246
*/
247
jint JNICALL
248
JNI_GetDefaultJavaVMInitArgs(void *vm_args);
249
250
251
/* JVM functions are prototyped in the redirector/forwarders.ftl file
252
* which allows us to keep prototypes and forwarders in sync. */
253
#include "generated.h"
254
255
#ifdef __cplusplus
256
}
257
#endif
258
259
#endif /* jvm_h */
260
261
262
263