1 /*******************************************************************************
2 * Copyright (c) 2000, 2010 IBM Corporation and others.
4 * This program and the accompanying materials
5 * are made available under the terms of the Eclipse Public License 2.0
6 * which accompanies this distribution, and is available at
7 * https://www.eclipse.org/legal/epl-2.0/
9 * SPDX-License-Identifier: EPL-2.0
12 * IBM Corporation - initial API and implementation
13 *******************************************************************************/
18 * This file contains the global macro declarations for the
32 extern int IS_JNI_1_2;
36 /* if DEBUG is defined print messages from dlerror */
38 #define CHECK_DLERROR \
39 char* error = dlerror(); \
40 if (error != NULL) { \
41 fprintf(stderr, "dlerror: %s\n", error); \
56 /* int/long defines */
57 #define GetIntLongField GetIntField
58 #define SetIntLongField SetIntField
59 #define GetIntLongArrayElements GetIntArrayElements
60 #define ReleaseIntLongArrayElements ReleaseIntArrayElements
61 #define GetIntLongArrayRegion GetIntArrayRegion
62 #define SetIntLongArrayRegion SetIntArrayRegion
63 #define NewIntLongArray NewIntArray
64 #define CallStaticIntLongMethod CallStaticIntMethod
65 #define CallIntLongMethod CallIntMethod
66 #define CallStaticIntLongMethodV CallStaticIntMethodV
67 #define CallIntLongMethodV CallIntMethodV
68 #define jintLongArray jintArray
73 /* float/double defines */
74 #define GetFloatDoubleField GetFloatField
75 #define SetFloatDoubleField SetFloatField
76 #define GetFloatDoubleArrayElements GetFloatArrayElements
77 #define ReleaseFloatDoubleArrayElements ReleaseFloatArrayElements
78 #define GetFloatDoubleArrayRegion GetFloatArrayRegion
79 #define jfloatDoubleArray jfloatArray
80 #define jfloatDouble jfloat
86 /* int/long defines */
87 #define GetIntLongField GetLongField
88 #define SetIntLongField SetLongField
89 #define GetIntLongArrayElements GetLongArrayElements
90 #define ReleaseIntLongArrayElements ReleaseLongArrayElements
91 #define GetIntLongArrayRegion GetLongArrayRegion
92 #define SetIntLongArrayRegion SetLongArrayRegion
93 #define NewIntLongArray NewLongArray
94 #define CallStaticIntLongMethod CallStaticLongMethod
95 #define CallIntLongMethod CallLongMethod
96 #define CallStaticIntLongMethodV CallStaticLongMethodV
97 #define CallIntLongMethodV CallLongMethodV
98 #define jintLongArray jlongArray
99 #define jintLong jlong
101 #define I_JArray "[J"
103 /* float/double defines */
104 #define GetFloatDoubleField GetDoubleField
105 #define SetFloatDoubleField SetDoubleField
106 #define GetFloatDoubleArrayElements GetDoubleArrayElements
107 #define ReleaseFloatDoubleArrayElements ReleaseDoubleArrayElements
108 #define GetFloatDoubleArrayRegion GetDoubleArrayRegion
109 #define jfloatDoubleArray jdoubleArray
110 #define jfloatDouble jdouble
112 #define F_DArray "[D"
117 #define CALLING_CONVENTION
118 #define LOAD_FUNCTION(var, name) \
119 static int initialized = 0; \
120 static void *var = NULL; \
121 if (!initialized) { \
122 CFBundleRef bundle = CFBundleGetBundleWithIdentifier(CFSTR(name##_LIB)); \
123 if (bundle) var = CFBundleGetFunctionPointerForName(bundle, CFSTR(#name)); \
126 #elif defined (_WIN32) || defined (_WIN32_WCE)
127 #define CALLING_CONVENTION CALLBACK
128 #define LOAD_FUNCTION(var, name) \
129 static int initialized = 0; \
130 static FARPROC var = NULL; \
131 if (!initialized) { \
132 HMODULE hm = LoadLibraryA(name##_LIB); \
133 if (hm) var = GetProcAddress(hm, #name); \
137 #define CALLING_CONVENTION
138 #define LOAD_FLAGS RTLD_LAZY
139 #define LOAD_FUNCTION(var, name) \
140 static int initialized = 0; \
141 static void *var = NULL; \
142 if (!initialized) { \
143 void* handle = dlopen(name##_LIB, LOAD_FLAGS); \
144 if (handle) var = dlsym(handle, #name); \
150 void throwOutOfMemory(JNIEnv *env);
152 #define CHECK_NULL_VOID(ptr) \
153 if ((ptr) == NULL) { \
154 throwOutOfMemory(env); \
158 #define CHECK_NULL(ptr) \
159 if ((ptr) == NULL) { \
160 throwOutOfMemory(env); \
168 #endif /* ifndef INC_swt_H */