Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/openj9
Path: blob/master/runtime/include/j9vmls.h
5986 views
1
/*******************************************************************************
2
* Copyright (c) 1991, 2020 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
* @file
25
* @ingroup VMLS
26
* @brief VM Local Storage Header
27
*/
28
29
#ifndef J9VMLS_H
30
#define J9VMLS_H
31
32
/* @ddr_namespace: default */
33
#ifdef __cplusplus
34
extern "C" {
35
#endif
36
37
#include "j9comp.h"
38
#include "j9cfg.h"
39
#include "jni.h"
40
41
#define J9VMLS_MAX_KEYS 256
42
43
/**
44
* @struct J9VMLSFunctionTable
45
* The VM local storage function table.
46
*/
47
typedef struct J9VMLSFunctionTable {
48
UDATA (JNICALL *J9VMLSAllocKeys)(JNIEnv * env, UDATA * pInitCount, ...) ;
49
void (JNICALL *J9VMLSFreeKeys)(JNIEnv * env, UDATA * pInitCount, ...) ;
50
void* (JNICALL *J9VMLSGet)(JNIEnv * env, void * key) ;
51
void* (JNICALL *J9VMLSSet)(JNIEnv * env, void ** pKey, void * value) ;
52
} J9VMLSFunctionTable;
53
54
/**
55
* @fn J9VMLSFunctionTable::J9VMLSAllocKeys
56
* Allocate one or more slots of VM local storage.
57
*
58
* @code UDATA JNICALL J9VMLSAllocKeys(JNIEnv * env, UDATA * pInitCount, ...); @endcode
59
*
60
* @param[in] env A JNIEnv pointer
61
* @param[in] pInitCount Pointer to the reference count for these slots
62
* @param[out] ... Locations to store the allocated keys
63
*
64
* @return 0 on success, 1 on failure.
65
*
66
* @note Newly allocated VMLS slots contain NULL in all VMs.
67
*/
68
69
/**
70
* @fn J9VMLSFunctionTable::J9VMLSFreeKeys
71
* Destroy one or more slots of VM local storage.
72
*
73
* @code void JNICALL J9VMLSFreeKeys(JNIEnv * env, UDATA * pInitCount, ...); @endcode
74
*
75
* @param[in] env A JNIEnv pointer
76
* @param[in] pInitCount Pointer to the reference count for these slots
77
* @param[out] ... Pointers to the allocated keys
78
*/
79
80
/**
81
* @fn J9VMLSFunctionTable::J9VMLSGet
82
* Retrieve the value in a VM local storage slot.
83
*
84
* @code void* JNICALL J9VMLSGet(JNIEnv * env, void * key); @endcode
85
*
86
* @param[in] env JNIEnv pointer
87
* @param[in] key The VMLS key
88
*
89
* @return The contents of the VM local storage slot in the VM that contains the specified env
90
*/
91
92
/**
93
* @fn J9VMLSFunctionTable::J9VMLSSet
94
* Store a value into a VM local storage slot.
95
*
96
* @code void* JNICALL J9VMLSSet(JNIEnv * env, void ** pKey, void * value); @endcode
97
*
98
* @param[in] env JNIEnv pointer
99
* @param[in] pKey Pointer to the VM local storage key
100
* @param[in] value Value to store
101
*
102
* @return The value stored
103
*/
104
105
#define J9VMLS_FNTBL(env) ((J9VMLSFunctionTable *) ((((void ***) (env))[offsetof(J9VMThread,javaVM)/sizeof(UDATA)])[offsetof(J9JavaVM,vmLocalStorageFunctions)/sizeof(UDATA)]))
106
107
#ifdef J9VM_OPT_MULTI_VM
108
#define J9VMLS_GET(env, key) (J9VMLS_FNTBL(env)->J9VMLSGet(env, (key)))
109
#define J9VMLS_SET(env, key, value) (J9VMLS_FNTBL(env)->J9VMLSSet(env, &(key), (void *) (value)))
110
#else
111
#define J9VMLS_GET(env, key) (key)
112
#define J9VMLS_SET(env, key, value) ((key) = (void *) (value))
113
#endif
114
115
#ifdef __cplusplus
116
}
117
#endif
118
119
#endif /* J9VMLS_H */
120
121