Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/hotspot/jtreg/gc/libCriticalNative.c
40930 views
1
/*
2
* Copyright (c) 2018, Red Hat, Inc. and/or its affiliates.
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
#include "jni.h"
26
27
JNIEXPORT jlong JNICALL JavaCritical_gc_CriticalNative_sum1
28
(jint length, jlong* a) {
29
jlong sum = 0;
30
jint index;
31
for (index = 0; index < length; index ++) {
32
sum += a[index];
33
}
34
35
return sum;
36
}
37
38
JNIEXPORT jlong JNICALL JavaCritical_gc_CriticalNative_sum2
39
(jlong a1, jint a2_length, jint* a2, jint a4_length, jint* a4, jint a6_length, jlong* a6, jint a8_length, jint* a8) {
40
jlong sum = a1;
41
jint index;
42
for (index = 0; index < a2_length; index ++) {
43
sum += a2[index];
44
}
45
46
for (index = 0; index < a4_length; index ++) {
47
sum += a4[index];
48
}
49
50
for (index = 0; index < a6_length; index ++) {
51
sum += a6[index];
52
}
53
54
for (index = 0; index < a8_length; index ++) {
55
sum += a8[index];
56
}
57
return sum;
58
}
59
60
JNIEXPORT jlong JNICALL Java_gc_CriticalNative_sum1
61
(JNIEnv *env, jclass jclazz, jlongArray a) {
62
jlong sum = 0;
63
jsize len = (*env)->GetArrayLength(env, a);
64
jsize index;
65
jlong* arr = (jlong*)(*env)->GetPrimitiveArrayCritical(env, a, 0);
66
for (index = 0; index < len; index ++) {
67
sum += arr[index];
68
}
69
70
(*env)->ReleasePrimitiveArrayCritical(env, a, arr, 0);
71
return sum;
72
}
73
74
JNIEXPORT jlong JNICALL Java_gc_CriticalNative_sum2
75
(JNIEnv *env, jclass jclazz, jlong a1, jintArray a2, jintArray a3, jlongArray a4, jintArray a5) {
76
jlong sum = a1;
77
jsize index;
78
jsize len;
79
jint* a2_arr;
80
jint* a3_arr;
81
jlong* a4_arr;
82
jint* a5_arr;
83
84
len = (*env)->GetArrayLength(env, a2);
85
a2_arr = (jint*)(*env)->GetPrimitiveArrayCritical(env, a2, 0);
86
for (index = 0; index < len; index ++) {
87
sum += a2_arr[index];
88
}
89
(*env)->ReleasePrimitiveArrayCritical(env, a2, a2_arr, 0);
90
91
len = (*env)->GetArrayLength(env, a3);
92
a3_arr = (jint*)(*env)->GetPrimitiveArrayCritical(env, a3, 0);
93
for (index = 0; index < len; index ++) {
94
sum += a3_arr[index];
95
}
96
(*env)->ReleasePrimitiveArrayCritical(env, a3, a3_arr, 0);
97
98
len = (*env)->GetArrayLength(env, a4);
99
a4_arr = (jlong*)(*env)->GetPrimitiveArrayCritical(env, a4, 0);
100
for (index = 0; index < len; index ++) {
101
sum += a4_arr[index];
102
}
103
(*env)->ReleasePrimitiveArrayCritical(env, a4, a4_arr, 0);
104
105
len = (*env)->GetArrayLength(env, a5);
106
a5_arr = (jint*)(*env)->GetPrimitiveArrayCritical(env, a5, 0);
107
for (index = 0; index < len; index ++) {
108
sum += a5_arr[index];
109
}
110
(*env)->ReleasePrimitiveArrayCritical(env, a5, a5_arr, 0);
111
112
return sum;
113
}
114
115
116
JNIEXPORT jboolean JNICALL JavaCritical_gc_CriticalNative_isNull
117
(jint length, jint* a) {
118
return (a == NULL) && (length == 0);
119
}
120
121
JNIEXPORT jboolean JNICALL Java_gc_CriticalNative_isNull
122
(JNIEnv *env, jclass jclazz, jintArray a) {
123
if (a == NULL) return JNI_TRUE;
124
jsize len = (*env)->GetArrayLength(env, a);
125
jint* arr = (jint*)(*env)->GetPrimitiveArrayCritical(env, a, 0);
126
jboolean is_null = (arr == NULL) && (len == 0);
127
(*env)->ReleasePrimitiveArrayCritical(env, a, arr, 0);
128
return is_null;
129
}
130
131
132