/*******************************************************************************1* Copyright (c) 2002, 2018 IBM Corp. and others2*3* This program and the accompanying materials are made available under4* the terms of the Eclipse Public License 2.0 which accompanies this5* distribution and is available at https://www.eclipse.org/legal/epl-2.0/6* or the Apache License, Version 2.0 which accompanies this distribution and7* is available at https://www.apache.org/licenses/LICENSE-2.0.8*9* This Source Code may also be made available under the following10* Secondary Licenses when the conditions for such availability set11* forth in the Eclipse Public License, v. 2.0 are satisfied: GNU12* General Public License, version 2 with the GNU Classpath13* Exception [1] and GNU General Public License, version 2 with the14* OpenJDK Assembly Exception [2].15*16* [1] https://www.gnu.org/software/classpath/license.html17* [2] http://openjdk.java.net/legal/assembly-exception.html18*19* 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-exception20*******************************************************************************/212223#ifndef jvm_h24#define jvm_h2526#ifdef __cplusplus27extern "C" {28#endif2930#if defined(IBM_MVS)31/* J2SE class libraries include jvm.h but don't define J9ZOS390. We do that here on their behalf. */32#ifndef J9ZOS39033#define J9ZOS39034#endif35#endif363738#ifdef WIN323940#ifdef BOOLEAN41/* There is a collision between J9's definition of BOOLEAN and WIN32 headers */42#define BOOLEAN_COLLISION_DETECTED BOOLEAN43#undef BOOLEAN44#endif /* #ifdef BOOLEAN */4546/* Undefine the winsockapi because winsock2 defines it. Removes warnings. */47#if defined(_WINSOCKAPI_) && !defined(_WINSOCK2API_)48#undef _WINSOCKAPI_49#endif50#include <winsock2.h>51#define PATH_MAX MAX_PATH5253#ifdef BOOLEAN_COLLISION_DETECTED54#define BOOLEAN UDATA55#undef BOOLEAN_COLLISION_DETECTED56#endif /* #ifdef BOOLEAN_COLLISION_DETECTED */5758#endif /* WIN32 */5960#ifdef J9ZOS39061#include <ctype.h>62#include <unistd.h>63#include <dirent.h>64#define PATH_MAX 102365#endif /* J9ZOS390 */6667#include <errno.h>68#include <limits.h>69#include <stdlib.h>70#include <string.h>71#include <fcntl.h>72#include <sys/stat.h>73#include <signal.h>74#include <setjmp.h>7576#include <jni.h>77#include "j9comp.h" /* for definition */7879#if defined(J9UNIX)80#ifndef __USE_LARGEFILE6481#define __USE_LARGEFILE6482#endif83#include <unistd.h>84#include <sys/param.h>85#include <dirent.h>86#endif /* defined(J9UNIX) */8788/* AIX has a #define for MAXPATHLEN in /usr/include/param.h which defines MAXPATHLEN as PATH_MAX+1 */89#ifndef MAXPATHLEN90#ifdef AIX91#define MAXPATHLEN (PATH_MAX+1)92#else93#define MAXPATHLEN PATH_MAX94#endif95#endif9697#ifndef O_TEMPORARY98#define O_TEMPORARY 0x10000 /* non-standard flag on Unix */99#endif100101/*102* JVM constants103*/104#define JVM_INTERFACE_VERSION 4105106#define JVM_MAXPATHLEN PATH_MAX107108#define JVM_IO_OK 0109#define JVM_IO_ERR -1110#define JVM_IO_INTR -2111112#define JVM_O_RDWR O_RDWR113#define JVM_O_CREAT O_CREAT114#define JVM_O_EXCL O_EXCL115#define JVM_O_DELETE O_TEMPORARY116117#define JVM_EEXIST -100118119#define JVM_SIGTERM SIGTERM120121#define J9_SIDECAR_MAX_OBJECT_INSPECTION_AGE 10000L122123#define JVM_ZIP_HOOK_STATE_OPEN 1124#define JVM_ZIP_HOOK_STATE_CLOSED 2125#define JVM_ZIP_HOOK_STATE_RESET 3126127#if defined(J9UNIX)128typedef sigjmp_buf* pre_block_t;129#else /* defined(J9UNIX) */130typedef void* pre_block_t;131#endif /* defined(J9UNIX) */132133struct sockaddr; /* suppress warning messages */134135#ifndef LAUNCHERS136#define J9MALLOC_STRINGIFY(X) #X137#define J9MALLOC_TOSTRING(X) J9MALLOC_STRINGIFY(X)138139#if !defined(CURRENT_MEMORY_CATEGORY)140#define CURRENT_MEMORY_CATEGORY J9MEM_CATEGORY_SUN_JCL141#endif142#define malloc(a) JVM_RawAllocateInCategory( (a), __FILE__ ":" J9MALLOC_TOSTRING(__LINE__), CURRENT_MEMORY_CATEGORY )143#define realloc(p, a) JVM_RawReallocInCategory( (p), (a), __FILE__ ":" J9MALLOC_TOSTRING(__LINE__), CURRENT_MEMORY_CATEGORY )144#define calloc(n, a) JVM_RawCallocInCategory( (n), (a), __FILE__ ":" J9MALLOC_TOSTRING(__LINE__), CURRENT_MEMORY_CATEGORY )145#define free(a) JVM_RawFree( (a) )146#endif147148/*149* JVM methods150*/151/* ---------------- jvm.c ---------------- */152153/**154* @brief155* @param env156* @param instr157* @param outstr158* @param outlen159* @param encoding160* @return jint161*/162jint163GetStringPlatform(JNIEnv* env, jstring instr, char* outstr, jint outlen, const char* encoding);164165166/**167* @brief168* @param env169* @param instr170* @param outlen171* @param encoding172* @return jint173*/174jint175GetStringPlatformLength(JNIEnv* env, jstring instr, jint* outlen, const char* encoding);176177/**178* @brief179* @param *dir180* @param *file181* @return int182*/183int isFileInDir(char *dir, char *file);184185/**186* @brief187* @param stream188* @param format189* @param ...190* @return int191*/192int193jio_fprintf(FILE * stream, const char * format, ...);194195196/**197* @brief198* @param str199* @param n200* @param format201* @param ...202* @return int203*/204int205jio_snprintf(char * str, int n, const char * format, ...);206207struct sockaddr;208209210/**211* @brief212* @param (*func)(void)213* @return void214*/215void JNICALL216JVM_OnExit(void (*func)(void));217218219/**220* @brief221* @param **pvm222* @param **penv223* @param *vm_args224* @return jint225*/226jint JNICALL227JNI_CreateJavaVM(JavaVM **pvm, void **penv, void *vm_args);228229230/**231* @brief232* @param **vmBuf233* @param bufLen234* @param *nVMs235* @return jint236*/237jint JNICALL238JNI_GetCreatedJavaVMs(JavaVM **vmBuf, jsize bufLen, jsize *nVMs);239240241/**242* @brief243* @param *vm_args244* @return jint245*/246jint JNICALL247JNI_GetDefaultJavaVMInitArgs(void *vm_args);248249250/* JVM functions are prototyped in the redirector/forwarders.ftl file251* which allows us to keep prototypes and forwarders in sync. */252#include "generated.h"253254#ifdef __cplusplus255}256#endif257258#endif /* jvm_h */259260261262263