1 /*
2 * Copyright (C) 2014 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17 #include <jni.h>
18 #include <android/log.h>
19
20 #include <stdio.h>
21 #include <stdlib.h>
22 #include <algorithm>
23 #include <math.h>
24 #include <string>
25
26 #include <RenderScript.h>
27
28 #define LOG_TAG "rscpptest"
29 #define LOGI(...) __android_log_print(ANDROID_LOG_INFO, LOG_TAG, __VA_ARGS__)
30 #define LOGE(...) __android_log_print(ANDROID_LOG_ERROR, LOG_TAG, __VA_ARGS__)
31
32 using namespace android::RSC;
33
34 /* This class helps return multiple values to Java. To use:
35 * - define a class in Java,
36 * - have the jni method return a jobject,
37 * - create an instance of this class,
38 * - use Set* to fill the fields,
39 * - return getObject() on exit of the JNI method.
40 */
41 class JavaStruct {
42 private:
43 JNIEnv* mEnv;
44 jclass mClass;
45 jobject mObject;
46
47 /* Returns the id of the named field. Type is one of "F" (float) or "I" (int).
48 * If there's an error, logs a message and returns 0.
49 */
50 jfieldID GetFieldId(const char* name, const char* type);
51
52 public:
53 // Creates an instance of the named Java class.
54 JavaStruct(JNIEnv* env, const std::string& name);
55 // Sets the field of the instance.
56 void SetFloat(const char* name, float value);
57 void SetInt(const char* name, int value);
58 // Returns the instance.
getObject()59 jobject getObject() { return mObject; }
60 };
61
JavaStruct(JNIEnv * env,const std::string & name)62 JavaStruct::JavaStruct(JNIEnv* env, const std::string& name) : mEnv(env), mClass(0), mObject(0) {
63 /* This creates an instance of the specified static inner class of CoreMathVerifier.
64 * To convert this to return a non-static inner class instead, pass
65 * "(Landroid/renderscript/cts/CoreMathVerifier;)V" instead of "()V" go getMethodID
66 * and pass the parent class as a third argument to NewObject.
67 */
68 std::string fullName = "android/renderscript/cts/CoreMathVerifier$" + name;
69 mClass = env->FindClass(fullName.c_str());
70 if (!mClass) {
71 LOGE("Can't find the Java class %s", name.c_str());
72 return;
73 }
74 jmethodID constructor = env->GetMethodID(mClass, "<init>", "()V");
75 if (!constructor) {
76 LOGE("Can't find the constructor of %s", name.c_str());
77 return;
78 }
79 mObject = env->NewObject(mClass, constructor);
80 if (!mObject) {
81 LOGE("Can't construct a %s", name.c_str());
82 }
83 }
84
SetInt(const char * name,int value)85 void JavaStruct::SetInt(const char* name, int value) {
86 jfieldID fieldId = GetFieldId(name, "I");
87 if (fieldId) {
88 mEnv->SetIntField(mObject, fieldId, value);
89 }
90 }
91
SetFloat(const char * name,float value)92 void JavaStruct::SetFloat(const char* name, float value) {
93 jfieldID fieldId = GetFieldId(name, "F");
94 if (fieldId) {
95 mEnv->SetFloatField(mObject, fieldId, value);
96 }
97 }
98
GetFieldId(const char * name,const char * type)99 jfieldID JavaStruct::GetFieldId(const char* name, const char* type) {
100 if (!mClass) {
101 return 0; // We already have logged the error in the constructor.
102 }
103 jfieldID fieldId = mEnv->GetFieldID(mClass, name, type);
104 if (!fieldId) {
105 LOGE("Can't find the field %s", name);
106 return 0;
107 }
108 return fieldId;
109 }
110
111 /* We provide access to many primitive math functions because:
112 * - not all functions are available in Java, notably gamma and erf,
113 * - Java lacks float version of these functions, so we can compare implementations with
114 * similar constraints, and
115 * - handling unsigned integers, especially longs, is painful and error prone in Java.
116 */
117
118 extern "C" JNIEXPORT jfloat JNICALL
Java_android_renderscript_cts_CoreMathVerifier_acos(JNIEnv *,jclass,jfloat x)119 Java_android_renderscript_cts_CoreMathVerifier_acos(JNIEnv*, jclass, jfloat x) {
120 return acosf(x);
121 }
122
123 extern "C" JNIEXPORT jfloat JNICALL
Java_android_renderscript_cts_CoreMathVerifier_acosh(JNIEnv *,jclass,jfloat x)124 Java_android_renderscript_cts_CoreMathVerifier_acosh(JNIEnv*, jclass, jfloat x) {
125 return acoshf(x);
126 }
127
128 extern "C" JNIEXPORT jfloat JNICALL
Java_android_renderscript_cts_CoreMathVerifier_asin(JNIEnv *,jclass,jfloat x)129 Java_android_renderscript_cts_CoreMathVerifier_asin(JNIEnv*, jclass, jfloat x) {
130 return asinf(x);
131 }
132
133 extern "C" JNIEXPORT jfloat JNICALL
Java_android_renderscript_cts_CoreMathVerifier_asinh(JNIEnv *,jclass,jfloat x)134 Java_android_renderscript_cts_CoreMathVerifier_asinh(JNIEnv*, jclass, jfloat x) {
135 return asinhf(x);
136 }
137
138 extern "C" JNIEXPORT jfloat JNICALL
Java_android_renderscript_cts_CoreMathVerifier_atan(JNIEnv *,jclass,jfloat x)139 Java_android_renderscript_cts_CoreMathVerifier_atan(JNIEnv*, jclass, jfloat x) {
140 return atanf(x);
141 }
142
143 extern "C" JNIEXPORT jfloat JNICALL
Java_android_renderscript_cts_CoreMathVerifier_atan2(JNIEnv *,jclass,jfloat x,jfloat y)144 Java_android_renderscript_cts_CoreMathVerifier_atan2(JNIEnv*, jclass, jfloat x, jfloat y) {
145 return atan2f(x, y);
146 }
147
148 extern "C" JNIEXPORT jfloat JNICALL
Java_android_renderscript_cts_CoreMathVerifier_atanh(JNIEnv *,jclass,jfloat x)149 Java_android_renderscript_cts_CoreMathVerifier_atanh(JNIEnv*, jclass, jfloat x) {
150 return atanhf(x);
151 }
152
153 extern "C" JNIEXPORT jfloat JNICALL
Java_android_renderscript_cts_CoreMathVerifier_cbrt(JNIEnv *,jclass,jfloat x)154 Java_android_renderscript_cts_CoreMathVerifier_cbrt(JNIEnv*, jclass, jfloat x) {
155 return cbrtf(x);
156 }
157
158 extern "C" JNIEXPORT jfloat JNICALL
Java_android_renderscript_cts_CoreMathVerifier_ceil(JNIEnv *,jclass,jfloat x)159 Java_android_renderscript_cts_CoreMathVerifier_ceil(JNIEnv*, jclass, jfloat x) {
160 return ceilf(x);
161 }
162
163 extern "C" JNIEXPORT jfloat JNICALL
Java_android_renderscript_cts_CoreMathVerifier_cos(JNIEnv *,jclass,jfloat x)164 Java_android_renderscript_cts_CoreMathVerifier_cos(JNIEnv*, jclass, jfloat x) {
165 return cosf(x);
166 }
167
168 extern "C" JNIEXPORT jfloat JNICALL
Java_android_renderscript_cts_CoreMathVerifier_cosh(JNIEnv *,jclass,jfloat x)169 Java_android_renderscript_cts_CoreMathVerifier_cosh(JNIEnv*, jclass, jfloat x) {
170 return coshf(x);
171 }
172
173 extern "C" JNIEXPORT jfloat JNICALL
Java_android_renderscript_cts_CoreMathVerifier_erf(JNIEnv *,jclass,jfloat x)174 Java_android_renderscript_cts_CoreMathVerifier_erf(JNIEnv*, jclass, jfloat x) {
175 return erff(x);
176 }
177
178 extern "C" JNIEXPORT jfloat JNICALL
Java_android_renderscript_cts_CoreMathVerifier_erfc(JNIEnv *,jclass,jfloat x)179 Java_android_renderscript_cts_CoreMathVerifier_erfc(JNIEnv*, jclass, jfloat x) {
180 return erfcf(x);
181 }
182
183 extern "C" JNIEXPORT jfloat JNICALL
Java_android_renderscript_cts_CoreMathVerifier_exp(JNIEnv *,jclass,jfloat x)184 Java_android_renderscript_cts_CoreMathVerifier_exp(JNIEnv*, jclass, jfloat x) {
185 return expf(x);
186 }
187
188 extern "C" JNIEXPORT jfloat JNICALL
Java_android_renderscript_cts_CoreMathVerifier_exp10(JNIEnv *,jclass,jfloat x)189 Java_android_renderscript_cts_CoreMathVerifier_exp10(JNIEnv*, jclass, jfloat x) {
190 return powf(10.0f, x);
191 }
192
193 extern "C" JNIEXPORT jfloat JNICALL
Java_android_renderscript_cts_CoreMathVerifier_exp2(JNIEnv *,jclass,jfloat x)194 Java_android_renderscript_cts_CoreMathVerifier_exp2(JNIEnv*, jclass, jfloat x) {
195 return powf(2.0f, x);
196 }
197
198 extern "C" JNIEXPORT jfloat JNICALL
Java_android_renderscript_cts_CoreMathVerifier_expm1(JNIEnv *,jclass,jfloat x)199 Java_android_renderscript_cts_CoreMathVerifier_expm1(JNIEnv*, jclass, jfloat x) {
200 return expm1f(x);
201 }
202
203 extern "C" JNIEXPORT jfloat JNICALL
Java_android_renderscript_cts_CoreMathVerifier_floor(JNIEnv *,jclass,jfloat x)204 Java_android_renderscript_cts_CoreMathVerifier_floor(JNIEnv*, jclass, jfloat x) {
205 return floorf(x);
206 }
207
208 extern "C" JNIEXPORT jobject JNICALL
Java_android_renderscript_cts_CoreMathVerifier_frexp(JNIEnv * env,jclass,jfloat x)209 Java_android_renderscript_cts_CoreMathVerifier_frexp(JNIEnv* env, jclass, jfloat x) {
210 JavaStruct result(env, "FrexpResult");
211 int exp = 0;
212 result.SetFloat("significand", frexpf(x, &exp));
213 result.SetInt("exponent", exp);
214 return result.getObject();
215 }
216
217 extern "C" JNIEXPORT jfloat JNICALL
Java_android_renderscript_cts_CoreMathVerifier_hypot(JNIEnv *,jclass,jfloat x,jfloat y)218 Java_android_renderscript_cts_CoreMathVerifier_hypot(JNIEnv*, jclass, jfloat x, jfloat y) {
219 return hypotf(x, y);
220 }
221
222 extern "C" JNIEXPORT jint JNICALL
Java_android_renderscript_cts_CoreMathVerifier_ilogb(JNIEnv *,jclass,jfloat x)223 Java_android_renderscript_cts_CoreMathVerifier_ilogb(JNIEnv*, jclass, jfloat x) {
224 return ilogbf(x);
225 }
226
227 extern "C" JNIEXPORT jfloat JNICALL
Java_android_renderscript_cts_CoreMathVerifier_ldexp(JNIEnv *,jclass,jfloat x,jint exp)228 Java_android_renderscript_cts_CoreMathVerifier_ldexp(JNIEnv*, jclass, jfloat x, jint exp) {
229 return ldexpf(x, exp);
230 }
231
232 extern "C" JNIEXPORT jfloat JNICALL
Java_android_renderscript_cts_CoreMathVerifier_lgamma(JNIEnv *,jclass,jfloat x)233 Java_android_renderscript_cts_CoreMathVerifier_lgamma(JNIEnv*, jclass, jfloat x) {
234 return lgammaf(x);
235 }
236
237 extern "C" JNIEXPORT jobject JNICALL
Java_android_renderscript_cts_CoreMathVerifier_lgamma2(JNIEnv * env,jclass,jfloat x)238 Java_android_renderscript_cts_CoreMathVerifier_lgamma2(JNIEnv* env, jclass, jfloat x) {
239 JavaStruct result(env, "LgammaResult");
240 int sign = 0;
241 result.SetFloat("lgamma", lgammaf_r(x, &sign));
242 result.SetInt("gammaSign", sign);
243 return result.getObject();
244 }
245
246 extern "C" JNIEXPORT jfloat JNICALL
Java_android_renderscript_cts_CoreMathVerifier_log(JNIEnv *,jclass,jfloat x)247 Java_android_renderscript_cts_CoreMathVerifier_log(JNIEnv*, jclass, jfloat x) {
248 return logf(x);
249 }
250
251 extern "C" JNIEXPORT jfloat JNICALL
Java_android_renderscript_cts_CoreMathVerifier_logb(JNIEnv *,jclass,jfloat x)252 Java_android_renderscript_cts_CoreMathVerifier_logb(JNIEnv*, jclass, jfloat x) {
253 return logbf(x);
254 }
255
256 extern "C" JNIEXPORT jfloat JNICALL
Java_android_renderscript_cts_CoreMathVerifier_log10(JNIEnv *,jclass,jfloat x)257 Java_android_renderscript_cts_CoreMathVerifier_log10(JNIEnv*, jclass, jfloat x) {
258 return log10f(x);
259 }
260
261 extern "C" JNIEXPORT jfloat JNICALL
Java_android_renderscript_cts_CoreMathVerifier_log1p(JNIEnv *,jclass,jfloat x)262 Java_android_renderscript_cts_CoreMathVerifier_log1p(JNIEnv*, jclass, jfloat x) {
263 return log1pf(x);
264 }
265
266 extern "C" JNIEXPORT jfloat JNICALL
Java_android_renderscript_cts_CoreMathVerifier_log2(JNIEnv *,jclass,jfloat x)267 Java_android_renderscript_cts_CoreMathVerifier_log2(JNIEnv*, jclass, jfloat x) {
268 return log2f(x);
269 }
270
271 extern "C" JNIEXPORT jbyte JNICALL
Java_android_renderscript_cts_CoreMathVerifier_maxI8(JNIEnv *,jclass,jbyte x,jbyte y)272 Java_android_renderscript_cts_CoreMathVerifier_maxI8(JNIEnv*, jclass, jbyte x, jbyte y) {
273 return std::max(x, y);
274 }
275
276 extern "C" JNIEXPORT jbyte JNICALL
Java_android_renderscript_cts_CoreMathVerifier_maxU8(JNIEnv *,jclass,jbyte x,jbyte y)277 Java_android_renderscript_cts_CoreMathVerifier_maxU8(JNIEnv*, jclass, jbyte x, jbyte y) {
278 return std::max((uint8_t)x, (uint8_t)y);
279 }
280
281 extern "C" JNIEXPORT jshort JNICALL
Java_android_renderscript_cts_CoreMathVerifier_maxI16(JNIEnv *,jclass,jshort x,jshort y)282 Java_android_renderscript_cts_CoreMathVerifier_maxI16(JNIEnv*, jclass, jshort x, jshort y) {
283 return std::max(x, y);
284 }
285
286 extern "C" JNIEXPORT jshort JNICALL
Java_android_renderscript_cts_CoreMathVerifier_maxU16(JNIEnv *,jclass,jshort x,jshort y)287 Java_android_renderscript_cts_CoreMathVerifier_maxU16(JNIEnv*, jclass, jshort x, jshort y) {
288 return std::max((uint16_t)x, (uint16_t)y);
289 }
290
291 extern "C" JNIEXPORT jint JNICALL
Java_android_renderscript_cts_CoreMathVerifier_maxI32(JNIEnv *,jclass,jint x,jint y)292 Java_android_renderscript_cts_CoreMathVerifier_maxI32(JNIEnv*, jclass, jint x, jint y) {
293 return std::max(x, y);
294 }
295
296 extern "C" JNIEXPORT jint JNICALL
Java_android_renderscript_cts_CoreMathVerifier_maxU32(JNIEnv *,jclass,jint x,jint y)297 Java_android_renderscript_cts_CoreMathVerifier_maxU32(JNIEnv*, jclass, jint x, jint y) {
298 return std::max((uint32_t)x, (uint32_t)y);
299 }
300
301 extern "C" JNIEXPORT jlong JNICALL
Java_android_renderscript_cts_CoreMathVerifier_maxI64(JNIEnv *,jclass,jlong x,jlong y)302 Java_android_renderscript_cts_CoreMathVerifier_maxI64(JNIEnv*, jclass, jlong x, jlong y) {
303 return std::max(x, y);
304 }
305
306 extern "C" JNIEXPORT jlong JNICALL
Java_android_renderscript_cts_CoreMathVerifier_maxU64(JNIEnv *,jclass,jlong x,jlong y)307 Java_android_renderscript_cts_CoreMathVerifier_maxU64(JNIEnv*, jclass, jlong x, jlong y) {
308 return std::max((uint64_t)x, (uint64_t)y);
309 }
310
311 extern "C" JNIEXPORT jbyte JNICALL
Java_android_renderscript_cts_CoreMathVerifier_minI8(JNIEnv *,jclass,jbyte x,jbyte y)312 Java_android_renderscript_cts_CoreMathVerifier_minI8(JNIEnv*, jclass, jbyte x, jbyte y) {
313 return std::min(x, y);
314 }
315
316 extern "C" JNIEXPORT jbyte JNICALL
Java_android_renderscript_cts_CoreMathVerifier_minU8(JNIEnv *,jclass,jbyte x,jbyte y)317 Java_android_renderscript_cts_CoreMathVerifier_minU8(JNIEnv*, jclass, jbyte x, jbyte y) {
318 return std::min((uint8_t)x, (uint8_t)y);
319 }
320
321 extern "C" JNIEXPORT jshort JNICALL
Java_android_renderscript_cts_CoreMathVerifier_minI16(JNIEnv *,jclass,jshort x,jshort y)322 Java_android_renderscript_cts_CoreMathVerifier_minI16(JNIEnv*, jclass, jshort x, jshort y) {
323 return std::min(x, y);
324 }
325
326 extern "C" JNIEXPORT jshort JNICALL
Java_android_renderscript_cts_CoreMathVerifier_minU16(JNIEnv *,jclass,jshort x,jshort y)327 Java_android_renderscript_cts_CoreMathVerifier_minU16(JNIEnv*, jclass, jshort x, jshort y) {
328 return std::min((uint16_t)x, (uint16_t)y);
329 }
330
331 extern "C" JNIEXPORT jint JNICALL
Java_android_renderscript_cts_CoreMathVerifier_minI32(JNIEnv *,jclass,jint x,jint y)332 Java_android_renderscript_cts_CoreMathVerifier_minI32(JNIEnv*, jclass, jint x, jint y) {
333 return std::min(x, y);
334 }
335
336 extern "C" JNIEXPORT jint JNICALL
Java_android_renderscript_cts_CoreMathVerifier_minU32(JNIEnv *,jclass,jint x,jint y)337 Java_android_renderscript_cts_CoreMathVerifier_minU32(JNIEnv*, jclass, jint x, jint y) {
338 return std::min((uint32_t)x, (uint32_t)y);
339 }
340
341 extern "C" JNIEXPORT jlong JNICALL
Java_android_renderscript_cts_CoreMathVerifier_minI64(JNIEnv *,jclass,jlong x,jlong y)342 Java_android_renderscript_cts_CoreMathVerifier_minI64(JNIEnv*, jclass, jlong x, jlong y) {
343 return std::min(x, y);
344 }
345
346 extern "C" JNIEXPORT jlong JNICALL
Java_android_renderscript_cts_CoreMathVerifier_minU64(JNIEnv *,jclass,jlong x,jlong y)347 Java_android_renderscript_cts_CoreMathVerifier_minU64(JNIEnv*, jclass, jlong x, jlong y) {
348 return std::min((uint64_t)x, (uint64_t)y);
349 }
350
351 extern "C" JNIEXPORT jfloat JNICALL
Java_android_renderscript_cts_CoreMathVerifier_pow(JNIEnv *,jclass,jfloat x,jfloat y)352 Java_android_renderscript_cts_CoreMathVerifier_pow(JNIEnv*, jclass, jfloat x, jfloat y) {
353 return powf(x, y);
354 }
355
356 extern "C" JNIEXPORT jobject JNICALL
Java_android_renderscript_cts_CoreMathVerifier_remquo(JNIEnv * env,jclass,jfloat numerator,jfloat denominator)357 Java_android_renderscript_cts_CoreMathVerifier_remquo(JNIEnv* env, jclass, jfloat numerator,
358 jfloat denominator) {
359 JavaStruct result(env, "RemquoResult");
360 int quotient = 0;
361 result.SetFloat("remainder", remquof(numerator, denominator, "ient));
362 result.SetInt("quotient", quotient);
363 return result.getObject();
364 }
365
366 extern "C" JNIEXPORT jfloat JNICALL
Java_android_renderscript_cts_CoreMathVerifier_rint(JNIEnv *,jclass,jfloat x)367 Java_android_renderscript_cts_CoreMathVerifier_rint(JNIEnv*, jclass, jfloat x) {
368 return rintf(x);
369 }
370
371 extern "C" JNIEXPORT jfloat JNICALL
Java_android_renderscript_cts_CoreMathVerifier_round(JNIEnv *,jclass,jfloat x)372 Java_android_renderscript_cts_CoreMathVerifier_round(JNIEnv*, jclass, jfloat x) {
373 return roundf(x);
374 }
375
376 extern "C" JNIEXPORT jfloat JNICALL
Java_android_renderscript_cts_CoreMathVerifier_sin(JNIEnv *,jclass,jfloat x)377 Java_android_renderscript_cts_CoreMathVerifier_sin(JNIEnv*, jclass, jfloat x) {
378 return sinf(x);
379 }
380
381 extern "C" JNIEXPORT jfloat JNICALL
Java_android_renderscript_cts_CoreMathVerifier_sinh(JNIEnv *,jclass,jfloat x)382 Java_android_renderscript_cts_CoreMathVerifier_sinh(JNIEnv*, jclass, jfloat x) {
383 return sinhf(x);
384 }
385
386 extern "C" JNIEXPORT jfloat JNICALL
Java_android_renderscript_cts_CoreMathVerifier_sqrt(JNIEnv *,jclass,jfloat x)387 Java_android_renderscript_cts_CoreMathVerifier_sqrt(JNIEnv*, jclass, jfloat x) {
388 return sqrtf(x);
389 }
390
391 extern "C" JNIEXPORT jfloat JNICALL
Java_android_renderscript_cts_CoreMathVerifier_tan(JNIEnv *,jclass,jfloat x)392 Java_android_renderscript_cts_CoreMathVerifier_tan(JNIEnv*, jclass, jfloat x) {
393 return tanf(x);
394 }
395
396 extern "C" JNIEXPORT jfloat JNICALL
Java_android_renderscript_cts_CoreMathVerifier_tanh(JNIEnv *,jclass,jfloat x)397 Java_android_renderscript_cts_CoreMathVerifier_tanh(JNIEnv*, jclass, jfloat x) {
398 return tanhf(x);
399 }
400
401 extern "C" JNIEXPORT jfloat JNICALL
Java_android_renderscript_cts_CoreMathVerifier_tgamma(JNIEnv *,jclass,jfloat x)402 Java_android_renderscript_cts_CoreMathVerifier_tgamma(JNIEnv*, jclass, jfloat x) {
403 return tgammaf(x);
404 }
405
406 extern "C" JNIEXPORT jfloat JNICALL
Java_android_renderscript_cts_CoreMathVerifier_trunc(JNIEnv *,jclass,jfloat x)407 Java_android_renderscript_cts_CoreMathVerifier_trunc(JNIEnv*, jclass, jfloat x) {
408 return truncf(x);
409 }
410
411 extern "C" JNIEXPORT jbyte JNICALL
Java_android_renderscript_cts_CoreMathVerifier_convertCharToChar(JNIEnv *,jclass,jbyte x)412 Java_android_renderscript_cts_CoreMathVerifier_convertCharToChar(JNIEnv*, jclass, jbyte x) {
413 return (jbyte)(int8_t)(int8_t)x;
414 }
415 extern "C" JNIEXPORT jbyte JNICALL
Java_android_renderscript_cts_CoreMathVerifier_convertCharToUchar(JNIEnv *,jclass,jbyte x)416 Java_android_renderscript_cts_CoreMathVerifier_convertCharToUchar(JNIEnv*, jclass, jbyte x) {
417 return (jbyte)(uint8_t)(int8_t)x;
418 }
419 extern "C" JNIEXPORT jshort JNICALL
Java_android_renderscript_cts_CoreMathVerifier_convertCharToShort(JNIEnv *,jclass,jbyte x)420 Java_android_renderscript_cts_CoreMathVerifier_convertCharToShort(JNIEnv*, jclass, jbyte x) {
421 return (jshort)(int16_t)(int8_t)x;
422 }
423 extern "C" JNIEXPORT jshort JNICALL
Java_android_renderscript_cts_CoreMathVerifier_convertCharToUshort(JNIEnv *,jclass,jbyte x)424 Java_android_renderscript_cts_CoreMathVerifier_convertCharToUshort(JNIEnv*, jclass, jbyte x) {
425 return (jshort)(uint16_t)(int8_t)x;
426 }
427 extern "C" JNIEXPORT jint JNICALL
Java_android_renderscript_cts_CoreMathVerifier_convertCharToInt(JNIEnv *,jclass,jbyte x)428 Java_android_renderscript_cts_CoreMathVerifier_convertCharToInt(JNIEnv*, jclass, jbyte x) {
429 return (jint)(int32_t)(int8_t)x;
430 }
431 extern "C" JNIEXPORT jint JNICALL
Java_android_renderscript_cts_CoreMathVerifier_convertCharToUint(JNIEnv *,jclass,jbyte x)432 Java_android_renderscript_cts_CoreMathVerifier_convertCharToUint(JNIEnv*, jclass, jbyte x) {
433 return (jint)(uint32_t)(int8_t)x;
434 }
435 extern "C" JNIEXPORT jlong JNICALL
Java_android_renderscript_cts_CoreMathVerifier_convertCharToLong(JNIEnv *,jclass,jbyte x)436 Java_android_renderscript_cts_CoreMathVerifier_convertCharToLong(JNIEnv*, jclass, jbyte x) {
437 return (jlong)(int64_t)(int8_t)x;
438 }
439 extern "C" JNIEXPORT jlong JNICALL
Java_android_renderscript_cts_CoreMathVerifier_convertCharToUlong(JNIEnv *,jclass,jbyte x)440 Java_android_renderscript_cts_CoreMathVerifier_convertCharToUlong(JNIEnv*, jclass, jbyte x) {
441 return (jlong)(uint64_t)(int8_t)x;
442 }
443 extern "C" JNIEXPORT jfloat JNICALL
Java_android_renderscript_cts_CoreMathVerifier_convertCharToFloat(JNIEnv *,jclass,jbyte x)444 Java_android_renderscript_cts_CoreMathVerifier_convertCharToFloat(JNIEnv*, jclass, jbyte x) {
445 return (jfloat)(float)(int8_t)x;
446 }
447 extern "C" JNIEXPORT jdouble JNICALL
Java_android_renderscript_cts_CoreMathVerifier_convertCharToDouble(JNIEnv *,jclass,jbyte x)448 Java_android_renderscript_cts_CoreMathVerifier_convertCharToDouble(JNIEnv*, jclass, jbyte x) {
449 return (jdouble)(double)(int8_t)x;
450 }
451
452 extern "C" JNIEXPORT jbyte JNICALL
Java_android_renderscript_cts_CoreMathVerifier_convertUcharToChar(JNIEnv *,jclass,jbyte x)453 Java_android_renderscript_cts_CoreMathVerifier_convertUcharToChar(JNIEnv*, jclass, jbyte x) {
454 return (jbyte)(int8_t)(uint8_t)x;
455 }
456 extern "C" JNIEXPORT jbyte JNICALL
Java_android_renderscript_cts_CoreMathVerifier_convertUcharToUchar(JNIEnv *,jclass,jbyte x)457 Java_android_renderscript_cts_CoreMathVerifier_convertUcharToUchar(JNIEnv*, jclass, jbyte x) {
458 return (jbyte)(uint8_t)(uint8_t)x;
459 }
460 extern "C" JNIEXPORT jshort JNICALL
Java_android_renderscript_cts_CoreMathVerifier_convertUcharToShort(JNIEnv *,jclass,jbyte x)461 Java_android_renderscript_cts_CoreMathVerifier_convertUcharToShort(JNIEnv*, jclass, jbyte x) {
462 return (jshort)(int16_t)(uint8_t)x;
463 }
464 extern "C" JNIEXPORT jshort JNICALL
Java_android_renderscript_cts_CoreMathVerifier_convertUcharToUshort(JNIEnv *,jclass,jbyte x)465 Java_android_renderscript_cts_CoreMathVerifier_convertUcharToUshort(JNIEnv*, jclass, jbyte x) {
466 return (jshort)(uint16_t)(uint8_t)x;
467 }
468 extern "C" JNIEXPORT jint JNICALL
Java_android_renderscript_cts_CoreMathVerifier_convertUcharToInt(JNIEnv *,jclass,jbyte x)469 Java_android_renderscript_cts_CoreMathVerifier_convertUcharToInt(JNIEnv*, jclass, jbyte x) {
470 return (jint)(int32_t)(uint8_t)x;
471 }
472 extern "C" JNIEXPORT jint JNICALL
Java_android_renderscript_cts_CoreMathVerifier_convertUcharToUint(JNIEnv *,jclass,jbyte x)473 Java_android_renderscript_cts_CoreMathVerifier_convertUcharToUint(JNIEnv*, jclass, jbyte x) {
474 return (jint)(uint32_t)(uint8_t)x;
475 }
476 extern "C" JNIEXPORT jlong JNICALL
Java_android_renderscript_cts_CoreMathVerifier_convertUcharToLong(JNIEnv *,jclass,jbyte x)477 Java_android_renderscript_cts_CoreMathVerifier_convertUcharToLong(JNIEnv*, jclass, jbyte x) {
478 return (jlong)(int64_t)(uint8_t)x;
479 }
480 extern "C" JNIEXPORT jlong JNICALL
Java_android_renderscript_cts_CoreMathVerifier_convertUcharToUlong(JNIEnv *,jclass,jbyte x)481 Java_android_renderscript_cts_CoreMathVerifier_convertUcharToUlong(JNIEnv*, jclass, jbyte x) {
482 return (jlong)(uint64_t)(uint8_t)x;
483 }
484 extern "C" JNIEXPORT jfloat JNICALL
Java_android_renderscript_cts_CoreMathVerifier_convertUcharToFloat(JNIEnv *,jclass,jbyte x)485 Java_android_renderscript_cts_CoreMathVerifier_convertUcharToFloat(JNIEnv*, jclass, jbyte x) {
486 return (jfloat)(float)(uint8_t)x;
487 }
488 extern "C" JNIEXPORT jdouble JNICALL
Java_android_renderscript_cts_CoreMathVerifier_convertUcharToDouble(JNIEnv *,jclass,jbyte x)489 Java_android_renderscript_cts_CoreMathVerifier_convertUcharToDouble(JNIEnv*, jclass, jbyte x) {
490 return (jdouble)(double)(uint8_t)x;
491 }
492
493 extern "C" JNIEXPORT jbyte JNICALL
Java_android_renderscript_cts_CoreMathVerifier_convertShortToChar(JNIEnv *,jclass,jshort x)494 Java_android_renderscript_cts_CoreMathVerifier_convertShortToChar(JNIEnv*, jclass, jshort x) {
495 return (jbyte)(int8_t)(int16_t)x;
496 }
497 extern "C" JNIEXPORT jbyte JNICALL
Java_android_renderscript_cts_CoreMathVerifier_convertShortToUchar(JNIEnv *,jclass,jshort x)498 Java_android_renderscript_cts_CoreMathVerifier_convertShortToUchar(JNIEnv*, jclass, jshort x) {
499 return (jbyte)(uint8_t)(int16_t)x;
500 }
501 extern "C" JNIEXPORT jshort JNICALL
Java_android_renderscript_cts_CoreMathVerifier_convertShortToShort(JNIEnv *,jclass,jshort x)502 Java_android_renderscript_cts_CoreMathVerifier_convertShortToShort(JNIEnv*, jclass, jshort x) {
503 return (jshort)(int16_t)(int16_t)x;
504 }
505 extern "C" JNIEXPORT jshort JNICALL
Java_android_renderscript_cts_CoreMathVerifier_convertShortToUshort(JNIEnv *,jclass,jshort x)506 Java_android_renderscript_cts_CoreMathVerifier_convertShortToUshort(JNIEnv*, jclass, jshort x) {
507 return (jshort)(uint16_t)(int16_t)x;
508 }
509 extern "C" JNIEXPORT jint JNICALL
Java_android_renderscript_cts_CoreMathVerifier_convertShortToInt(JNIEnv *,jclass,jshort x)510 Java_android_renderscript_cts_CoreMathVerifier_convertShortToInt(JNIEnv*, jclass, jshort x) {
511 return (jint)(int32_t)(int16_t)x;
512 }
513 extern "C" JNIEXPORT jint JNICALL
Java_android_renderscript_cts_CoreMathVerifier_convertShortToUint(JNIEnv *,jclass,jshort x)514 Java_android_renderscript_cts_CoreMathVerifier_convertShortToUint(JNIEnv*, jclass, jshort x) {
515 return (jint)(uint32_t)(int16_t)x;
516 }
517 extern "C" JNIEXPORT jlong JNICALL
Java_android_renderscript_cts_CoreMathVerifier_convertShortToLong(JNIEnv *,jclass,jshort x)518 Java_android_renderscript_cts_CoreMathVerifier_convertShortToLong(JNIEnv*, jclass, jshort x) {
519 return (jlong)(int64_t)(int16_t)x;
520 }
521 extern "C" JNIEXPORT jlong JNICALL
Java_android_renderscript_cts_CoreMathVerifier_convertShortToUlong(JNIEnv *,jclass,jshort x)522 Java_android_renderscript_cts_CoreMathVerifier_convertShortToUlong(JNIEnv*, jclass, jshort x) {
523 return (jlong)(uint64_t)(int16_t)x;
524 }
525 extern "C" JNIEXPORT jfloat JNICALL
Java_android_renderscript_cts_CoreMathVerifier_convertShortToFloat(JNIEnv *,jclass,jshort x)526 Java_android_renderscript_cts_CoreMathVerifier_convertShortToFloat(JNIEnv*, jclass, jshort x) {
527 return (jfloat)(float)(int16_t)x;
528 }
529 extern "C" JNIEXPORT jdouble JNICALL
Java_android_renderscript_cts_CoreMathVerifier_convertShortToDouble(JNIEnv *,jclass,jshort x)530 Java_android_renderscript_cts_CoreMathVerifier_convertShortToDouble(JNIEnv*, jclass, jshort x) {
531 return (jdouble)(double)(int16_t)x;
532 }
533
534 extern "C" JNIEXPORT jbyte JNICALL
Java_android_renderscript_cts_CoreMathVerifier_convertUshortToChar(JNIEnv *,jclass,jshort x)535 Java_android_renderscript_cts_CoreMathVerifier_convertUshortToChar(JNIEnv*, jclass, jshort x) {
536 return (jbyte)(int8_t)(uint16_t)x;
537 }
538 extern "C" JNIEXPORT jbyte JNICALL
Java_android_renderscript_cts_CoreMathVerifier_convertUshortToUchar(JNIEnv *,jclass,jshort x)539 Java_android_renderscript_cts_CoreMathVerifier_convertUshortToUchar(JNIEnv*, jclass, jshort x) {
540 return (jbyte)(uint8_t)(uint16_t)x;
541 }
542 extern "C" JNIEXPORT jshort JNICALL
Java_android_renderscript_cts_CoreMathVerifier_convertUshortToShort(JNIEnv *,jclass,jshort x)543 Java_android_renderscript_cts_CoreMathVerifier_convertUshortToShort(JNIEnv*, jclass, jshort x) {
544 return (jshort)(int16_t)(uint16_t)x;
545 }
546 extern "C" JNIEXPORT jshort JNICALL
Java_android_renderscript_cts_CoreMathVerifier_convertUshortToUshort(JNIEnv *,jclass,jshort x)547 Java_android_renderscript_cts_CoreMathVerifier_convertUshortToUshort(JNIEnv*, jclass, jshort x) {
548 return (jshort)(uint16_t)(uint16_t)x;
549 }
550 extern "C" JNIEXPORT jint JNICALL
Java_android_renderscript_cts_CoreMathVerifier_convertUshortToInt(JNIEnv *,jclass,jshort x)551 Java_android_renderscript_cts_CoreMathVerifier_convertUshortToInt(JNIEnv*, jclass, jshort x) {
552 return (jint)(int32_t)(uint16_t)x;
553 }
554 extern "C" JNIEXPORT jint JNICALL
Java_android_renderscript_cts_CoreMathVerifier_convertUshortToUint(JNIEnv *,jclass,jshort x)555 Java_android_renderscript_cts_CoreMathVerifier_convertUshortToUint(JNIEnv*, jclass, jshort x) {
556 return (jint)(uint32_t)(uint16_t)x;
557 }
558 extern "C" JNIEXPORT jlong JNICALL
Java_android_renderscript_cts_CoreMathVerifier_convertUshortToLong(JNIEnv *,jclass,jshort x)559 Java_android_renderscript_cts_CoreMathVerifier_convertUshortToLong(JNIEnv*, jclass, jshort x) {
560 return (jlong)(int64_t)(uint16_t)x;
561 }
562 extern "C" JNIEXPORT jlong JNICALL
Java_android_renderscript_cts_CoreMathVerifier_convertUshortToUlong(JNIEnv *,jclass,jshort x)563 Java_android_renderscript_cts_CoreMathVerifier_convertUshortToUlong(JNIEnv*, jclass, jshort x) {
564 return (jlong)(uint64_t)(uint16_t)x;
565 }
566 extern "C" JNIEXPORT jfloat JNICALL
Java_android_renderscript_cts_CoreMathVerifier_convertUshortToFloat(JNIEnv *,jclass,jshort x)567 Java_android_renderscript_cts_CoreMathVerifier_convertUshortToFloat(JNIEnv*, jclass, jshort x) {
568 return (jfloat)(float)(uint16_t)x;
569 }
570 extern "C" JNIEXPORT jdouble JNICALL
Java_android_renderscript_cts_CoreMathVerifier_convertUshortToDouble(JNIEnv *,jclass,jshort x)571 Java_android_renderscript_cts_CoreMathVerifier_convertUshortToDouble(JNIEnv*, jclass, jshort x) {
572 return (jdouble)(double)(uint16_t)x;
573 }
574
575 extern "C" JNIEXPORT jbyte JNICALL
Java_android_renderscript_cts_CoreMathVerifier_convertIntToChar(JNIEnv *,jclass,jint x)576 Java_android_renderscript_cts_CoreMathVerifier_convertIntToChar(JNIEnv*, jclass, jint x) {
577 return (jbyte)(int8_t)(int32_t)x;
578 }
579 extern "C" JNIEXPORT jbyte JNICALL
Java_android_renderscript_cts_CoreMathVerifier_convertIntToUchar(JNIEnv *,jclass,jint x)580 Java_android_renderscript_cts_CoreMathVerifier_convertIntToUchar(JNIEnv*, jclass, jint x) {
581 return (jbyte)(uint8_t)(int32_t)x;
582 }
583 extern "C" JNIEXPORT jshort JNICALL
Java_android_renderscript_cts_CoreMathVerifier_convertIntToShort(JNIEnv *,jclass,jint x)584 Java_android_renderscript_cts_CoreMathVerifier_convertIntToShort(JNIEnv*, jclass, jint x) {
585 return (jshort)(int16_t)(int32_t)x;
586 }
587 extern "C" JNIEXPORT jshort JNICALL
Java_android_renderscript_cts_CoreMathVerifier_convertIntToUshort(JNIEnv *,jclass,jint x)588 Java_android_renderscript_cts_CoreMathVerifier_convertIntToUshort(JNIEnv*, jclass, jint x) {
589 return (jshort)(uint16_t)(int32_t)x;
590 }
591 extern "C" JNIEXPORT jint JNICALL
Java_android_renderscript_cts_CoreMathVerifier_convertIntToInt(JNIEnv *,jclass,jint x)592 Java_android_renderscript_cts_CoreMathVerifier_convertIntToInt(JNIEnv*, jclass, jint x) {
593 return (jint)(int32_t)(int32_t)x;
594 }
595 extern "C" JNIEXPORT jint JNICALL
Java_android_renderscript_cts_CoreMathVerifier_convertIntToUint(JNIEnv *,jclass,jint x)596 Java_android_renderscript_cts_CoreMathVerifier_convertIntToUint(JNIEnv*, jclass, jint x) {
597 return (jint)(uint32_t)(int32_t)x;
598 }
599 extern "C" JNIEXPORT jlong JNICALL
Java_android_renderscript_cts_CoreMathVerifier_convertIntToLong(JNIEnv *,jclass,jint x)600 Java_android_renderscript_cts_CoreMathVerifier_convertIntToLong(JNIEnv*, jclass, jint x) {
601 return (jlong)(int64_t)(int32_t)x;
602 }
603 extern "C" JNIEXPORT jlong JNICALL
Java_android_renderscript_cts_CoreMathVerifier_convertIntToUlong(JNIEnv *,jclass,jint x)604 Java_android_renderscript_cts_CoreMathVerifier_convertIntToUlong(JNIEnv*, jclass, jint x) {
605 return (jlong)(uint64_t)(int32_t)x;
606 }
607 extern "C" JNIEXPORT jfloat JNICALL
Java_android_renderscript_cts_CoreMathVerifier_convertIntToFloat(JNIEnv *,jclass,jint x)608 Java_android_renderscript_cts_CoreMathVerifier_convertIntToFloat(JNIEnv*, jclass, jint x) {
609 return (jfloat)(float)(int32_t)x;
610 }
611 extern "C" JNIEXPORT jdouble JNICALL
Java_android_renderscript_cts_CoreMathVerifier_convertIntToDouble(JNIEnv *,jclass,jint x)612 Java_android_renderscript_cts_CoreMathVerifier_convertIntToDouble(JNIEnv*, jclass, jint x) {
613 return (jdouble)(double)(int32_t)x;
614 }
615
616 extern "C" JNIEXPORT jbyte JNICALL
Java_android_renderscript_cts_CoreMathVerifier_convertUintToChar(JNIEnv *,jclass,jint x)617 Java_android_renderscript_cts_CoreMathVerifier_convertUintToChar(JNIEnv*, jclass, jint x) {
618 return (jbyte)(int8_t)(uint32_t)x;
619 }
620 extern "C" JNIEXPORT jbyte JNICALL
Java_android_renderscript_cts_CoreMathVerifier_convertUintToUchar(JNIEnv *,jclass,jint x)621 Java_android_renderscript_cts_CoreMathVerifier_convertUintToUchar(JNIEnv*, jclass, jint x) {
622 return (jbyte)(uint8_t)(uint32_t)x;
623 }
624 extern "C" JNIEXPORT jshort JNICALL
Java_android_renderscript_cts_CoreMathVerifier_convertUintToShort(JNIEnv *,jclass,jint x)625 Java_android_renderscript_cts_CoreMathVerifier_convertUintToShort(JNIEnv*, jclass, jint x) {
626 return (jshort)(int16_t)(uint32_t)x;
627 }
628 extern "C" JNIEXPORT jshort JNICALL
Java_android_renderscript_cts_CoreMathVerifier_convertUintToUshort(JNIEnv *,jclass,jint x)629 Java_android_renderscript_cts_CoreMathVerifier_convertUintToUshort(JNIEnv*, jclass, jint x) {
630 return (jshort)(uint16_t)(uint32_t)x;
631 }
632 extern "C" JNIEXPORT jint JNICALL
Java_android_renderscript_cts_CoreMathVerifier_convertUintToInt(JNIEnv *,jclass,jint x)633 Java_android_renderscript_cts_CoreMathVerifier_convertUintToInt(JNIEnv*, jclass, jint x) {
634 return (jint)(int32_t)(uint32_t)x;
635 }
636 extern "C" JNIEXPORT jint JNICALL
Java_android_renderscript_cts_CoreMathVerifier_convertUintToUint(JNIEnv *,jclass,jint x)637 Java_android_renderscript_cts_CoreMathVerifier_convertUintToUint(JNIEnv*, jclass, jint x) {
638 return (jint)(uint32_t)(uint32_t)x;
639 }
640 extern "C" JNIEXPORT jlong JNICALL
Java_android_renderscript_cts_CoreMathVerifier_convertUintToLong(JNIEnv *,jclass,jint x)641 Java_android_renderscript_cts_CoreMathVerifier_convertUintToLong(JNIEnv*, jclass, jint x) {
642 return (jlong)(int64_t)(uint32_t)x;
643 }
644 extern "C" JNIEXPORT jlong JNICALL
Java_android_renderscript_cts_CoreMathVerifier_convertUintToUlong(JNIEnv *,jclass,jint x)645 Java_android_renderscript_cts_CoreMathVerifier_convertUintToUlong(JNIEnv*, jclass, jint x) {
646 return (jlong)(uint64_t)(uint32_t)x;
647 }
648 extern "C" JNIEXPORT jfloat JNICALL
Java_android_renderscript_cts_CoreMathVerifier_convertUintToFloat(JNIEnv *,jclass,jint x)649 Java_android_renderscript_cts_CoreMathVerifier_convertUintToFloat(JNIEnv*, jclass, jint x) {
650 return (jfloat)(float)(uint32_t)x;
651 }
652 extern "C" JNIEXPORT jdouble JNICALL
Java_android_renderscript_cts_CoreMathVerifier_convertUintToDouble(JNIEnv *,jclass,jint x)653 Java_android_renderscript_cts_CoreMathVerifier_convertUintToDouble(JNIEnv*, jclass, jint x) {
654 return (jdouble)(double)(uint32_t)x;
655 }
656
657 extern "C" JNIEXPORT jbyte JNICALL
Java_android_renderscript_cts_CoreMathVerifier_convertLongToChar(JNIEnv *,jclass,jlong x)658 Java_android_renderscript_cts_CoreMathVerifier_convertLongToChar(JNIEnv*, jclass, jlong x) {
659 return (jbyte)(int8_t)(int64_t)x;
660 }
661 extern "C" JNIEXPORT jbyte JNICALL
Java_android_renderscript_cts_CoreMathVerifier_convertLongToUchar(JNIEnv *,jclass,jlong x)662 Java_android_renderscript_cts_CoreMathVerifier_convertLongToUchar(JNIEnv*, jclass, jlong x) {
663 return (jbyte)(uint8_t)(int64_t)x;
664 }
665 extern "C" JNIEXPORT jshort JNICALL
Java_android_renderscript_cts_CoreMathVerifier_convertLongToShort(JNIEnv *,jclass,jlong x)666 Java_android_renderscript_cts_CoreMathVerifier_convertLongToShort(JNIEnv*, jclass, jlong x) {
667 return (jshort)(int16_t)(int64_t)x;
668 }
669 extern "C" JNIEXPORT jshort JNICALL
Java_android_renderscript_cts_CoreMathVerifier_convertLongToUshort(JNIEnv *,jclass,jlong x)670 Java_android_renderscript_cts_CoreMathVerifier_convertLongToUshort(JNIEnv*, jclass, jlong x) {
671 return (jshort)(uint16_t)(int64_t)x;
672 }
673 extern "C" JNIEXPORT jint JNICALL
Java_android_renderscript_cts_CoreMathVerifier_convertLongToInt(JNIEnv *,jclass,jlong x)674 Java_android_renderscript_cts_CoreMathVerifier_convertLongToInt(JNIEnv*, jclass, jlong x) {
675 return (jint)(int32_t)(int64_t)x;
676 }
677 extern "C" JNIEXPORT jint JNICALL
Java_android_renderscript_cts_CoreMathVerifier_convertLongToUint(JNIEnv *,jclass,jlong x)678 Java_android_renderscript_cts_CoreMathVerifier_convertLongToUint(JNIEnv*, jclass, jlong x) {
679 return (jint)(uint32_t)(int64_t)x;
680 }
681 extern "C" JNIEXPORT jlong JNICALL
Java_android_renderscript_cts_CoreMathVerifier_convertLongToLong(JNIEnv *,jclass,jlong x)682 Java_android_renderscript_cts_CoreMathVerifier_convertLongToLong(JNIEnv*, jclass, jlong x) {
683 return (jlong)(int64_t)(int64_t)x;
684 }
685 extern "C" JNIEXPORT jlong JNICALL
Java_android_renderscript_cts_CoreMathVerifier_convertLongToUlong(JNIEnv *,jclass,jlong x)686 Java_android_renderscript_cts_CoreMathVerifier_convertLongToUlong(JNIEnv*, jclass, jlong x) {
687 return (jlong)(uint64_t)(int64_t)x;
688 }
689 extern "C" JNIEXPORT jfloat JNICALL
Java_android_renderscript_cts_CoreMathVerifier_convertLongToFloat(JNIEnv *,jclass,jlong x)690 Java_android_renderscript_cts_CoreMathVerifier_convertLongToFloat(JNIEnv*, jclass, jlong x) {
691 return (jfloat)(float)(int64_t)x;
692 }
693 extern "C" JNIEXPORT jdouble JNICALL
Java_android_renderscript_cts_CoreMathVerifier_convertLongToDouble(JNIEnv *,jclass,jlong x)694 Java_android_renderscript_cts_CoreMathVerifier_convertLongToDouble(JNIEnv*, jclass, jlong x) {
695 return (jdouble)(double)(int64_t)x;
696 }
697
698 extern "C" JNIEXPORT jbyte JNICALL
Java_android_renderscript_cts_CoreMathVerifier_convertUlongToChar(JNIEnv *,jclass,jlong x)699 Java_android_renderscript_cts_CoreMathVerifier_convertUlongToChar(JNIEnv*, jclass, jlong x) {
700 return (jbyte)(int8_t)(uint64_t)x;
701 }
702 extern "C" JNIEXPORT jbyte JNICALL
Java_android_renderscript_cts_CoreMathVerifier_convertUlongToUchar(JNIEnv *,jclass,jlong x)703 Java_android_renderscript_cts_CoreMathVerifier_convertUlongToUchar(JNIEnv*, jclass, jlong x) {
704 return (jbyte)(uint8_t)(uint64_t)x;
705 }
706 extern "C" JNIEXPORT jshort JNICALL
Java_android_renderscript_cts_CoreMathVerifier_convertUlongToShort(JNIEnv *,jclass,jlong x)707 Java_android_renderscript_cts_CoreMathVerifier_convertUlongToShort(JNIEnv*, jclass, jlong x) {
708 return (jshort)(int16_t)(uint64_t)x;
709 }
710 extern "C" JNIEXPORT jshort JNICALL
Java_android_renderscript_cts_CoreMathVerifier_convertUlongToUshort(JNIEnv *,jclass,jlong x)711 Java_android_renderscript_cts_CoreMathVerifier_convertUlongToUshort(JNIEnv*, jclass, jlong x) {
712 return (jshort)(uint16_t)(uint64_t)x;
713 }
714 extern "C" JNIEXPORT jint JNICALL
Java_android_renderscript_cts_CoreMathVerifier_convertUlongToInt(JNIEnv *,jclass,jlong x)715 Java_android_renderscript_cts_CoreMathVerifier_convertUlongToInt(JNIEnv*, jclass, jlong x) {
716 return (jint)(int32_t)(uint64_t)x;
717 }
718 extern "C" JNIEXPORT jint JNICALL
Java_android_renderscript_cts_CoreMathVerifier_convertUlongToUint(JNIEnv *,jclass,jlong x)719 Java_android_renderscript_cts_CoreMathVerifier_convertUlongToUint(JNIEnv*, jclass, jlong x) {
720 return (jint)(uint32_t)(uint64_t)x;
721 }
722 extern "C" JNIEXPORT jlong JNICALL
Java_android_renderscript_cts_CoreMathVerifier_convertUlongToLong(JNIEnv *,jclass,jlong x)723 Java_android_renderscript_cts_CoreMathVerifier_convertUlongToLong(JNIEnv*, jclass, jlong x) {
724 return (jlong)(int64_t)(uint64_t)x;
725 }
726 extern "C" JNIEXPORT jlong JNICALL
Java_android_renderscript_cts_CoreMathVerifier_convertUlongToUlong(JNIEnv *,jclass,jlong x)727 Java_android_renderscript_cts_CoreMathVerifier_convertUlongToUlong(JNIEnv*, jclass, jlong x) {
728 return (jlong)(uint64_t)(uint64_t)x;
729 }
730 extern "C" JNIEXPORT jfloat JNICALL
Java_android_renderscript_cts_CoreMathVerifier_convertUlongToFloat(JNIEnv *,jclass,jlong x)731 Java_android_renderscript_cts_CoreMathVerifier_convertUlongToFloat(JNIEnv*, jclass, jlong x) {
732 return (jfloat)(float)(uint64_t)x;
733 }
734 extern "C" JNIEXPORT jdouble JNICALL
Java_android_renderscript_cts_CoreMathVerifier_convertUlongToDouble(JNIEnv *,jclass,jlong x)735 Java_android_renderscript_cts_CoreMathVerifier_convertUlongToDouble(JNIEnv*, jclass, jlong x) {
736 return (jdouble)(double)(uint64_t)x;
737 }
738
739 extern "C" JNIEXPORT jbyte JNICALL
Java_android_renderscript_cts_CoreMathVerifier_convertFloatToChar(JNIEnv *,jclass,jfloat x)740 Java_android_renderscript_cts_CoreMathVerifier_convertFloatToChar(JNIEnv*, jclass, jfloat x) {
741 return (jbyte)(int8_t)(float)x;
742 }
743 extern "C" JNIEXPORT jbyte JNICALL
Java_android_renderscript_cts_CoreMathVerifier_convertFloatToUchar(JNIEnv *,jclass,jfloat x)744 Java_android_renderscript_cts_CoreMathVerifier_convertFloatToUchar(JNIEnv*, jclass, jfloat x) {
745 return (jbyte)(uint8_t)(float)x;
746 }
747 extern "C" JNIEXPORT jshort JNICALL
Java_android_renderscript_cts_CoreMathVerifier_convertFloatToShort(JNIEnv *,jclass,jfloat x)748 Java_android_renderscript_cts_CoreMathVerifier_convertFloatToShort(JNIEnv*, jclass, jfloat x) {
749 return (jshort)(int16_t)(float)x;
750 }
751 extern "C" JNIEXPORT jshort JNICALL
Java_android_renderscript_cts_CoreMathVerifier_convertFloatToUshort(JNIEnv *,jclass,jfloat x)752 Java_android_renderscript_cts_CoreMathVerifier_convertFloatToUshort(JNIEnv*, jclass, jfloat x) {
753 return (jshort)(uint16_t)(float)x;
754 }
755 extern "C" JNIEXPORT jint JNICALL
Java_android_renderscript_cts_CoreMathVerifier_convertFloatToInt(JNIEnv *,jclass,jfloat x)756 Java_android_renderscript_cts_CoreMathVerifier_convertFloatToInt(JNIEnv*, jclass, jfloat x) {
757 return (jint)(int32_t)(float)x;
758 }
759 extern "C" JNIEXPORT jint JNICALL
Java_android_renderscript_cts_CoreMathVerifier_convertFloatToUint(JNIEnv *,jclass,jfloat x)760 Java_android_renderscript_cts_CoreMathVerifier_convertFloatToUint(JNIEnv*, jclass, jfloat x) {
761 return (jint)(uint32_t)(float)x;
762 }
763 extern "C" JNIEXPORT jlong JNICALL
Java_android_renderscript_cts_CoreMathVerifier_convertFloatToLong(JNIEnv *,jclass,jfloat x)764 Java_android_renderscript_cts_CoreMathVerifier_convertFloatToLong(JNIEnv*, jclass, jfloat x) {
765 return (jlong)(int64_t)(float)x;
766 }
767 extern "C" JNIEXPORT jlong JNICALL
Java_android_renderscript_cts_CoreMathVerifier_convertFloatToUlong(JNIEnv *,jclass,jfloat x)768 Java_android_renderscript_cts_CoreMathVerifier_convertFloatToUlong(JNIEnv*, jclass, jfloat x) {
769 return (jlong)(uint64_t)(float)x;
770 }
771 extern "C" JNIEXPORT jfloat JNICALL
Java_android_renderscript_cts_CoreMathVerifier_convertFloatToFloat(JNIEnv *,jclass,jfloat x)772 Java_android_renderscript_cts_CoreMathVerifier_convertFloatToFloat(JNIEnv*, jclass, jfloat x) {
773 return (jfloat)(float)(float)x;
774 }
775 extern "C" JNIEXPORT jdouble JNICALL
Java_android_renderscript_cts_CoreMathVerifier_convertFloatToDouble(JNIEnv *,jclass,jfloat x)776 Java_android_renderscript_cts_CoreMathVerifier_convertFloatToDouble(JNIEnv*, jclass, jfloat x) {
777 return (jdouble)(double)(float)x;
778 }
779
780 extern "C" JNIEXPORT jbyte JNICALL
Java_android_renderscript_cts_CoreMathVerifier_convertDoubleToChar(JNIEnv *,jclass,jdouble x)781 Java_android_renderscript_cts_CoreMathVerifier_convertDoubleToChar(JNIEnv*, jclass, jdouble x) {
782 return (jbyte)(int8_t)(double)x;
783 }
784 extern "C" JNIEXPORT jbyte JNICALL
Java_android_renderscript_cts_CoreMathVerifier_convertDoubleToUchar(JNIEnv *,jclass,jdouble x)785 Java_android_renderscript_cts_CoreMathVerifier_convertDoubleToUchar(JNIEnv*, jclass, jdouble x) {
786 return (jbyte)(uint8_t)(double)x;
787 }
788 extern "C" JNIEXPORT jshort JNICALL
Java_android_renderscript_cts_CoreMathVerifier_convertDoubleToShort(JNIEnv *,jclass,jdouble x)789 Java_android_renderscript_cts_CoreMathVerifier_convertDoubleToShort(JNIEnv*, jclass, jdouble x) {
790 return (jshort)(int16_t)(double)x;
791 }
792 extern "C" JNIEXPORT jshort JNICALL
Java_android_renderscript_cts_CoreMathVerifier_convertDoubleToUshort(JNIEnv *,jclass,jdouble x)793 Java_android_renderscript_cts_CoreMathVerifier_convertDoubleToUshort(JNIEnv*, jclass, jdouble x) {
794 return (jshort)(uint16_t)(double)x;
795 }
796 extern "C" JNIEXPORT jint JNICALL
Java_android_renderscript_cts_CoreMathVerifier_convertDoubleToInt(JNIEnv *,jclass,jdouble x)797 Java_android_renderscript_cts_CoreMathVerifier_convertDoubleToInt(JNIEnv*, jclass, jdouble x) {
798 return (jint)(int32_t)(double)x;
799 }
800 extern "C" JNIEXPORT jint JNICALL
Java_android_renderscript_cts_CoreMathVerifier_convertDoubleToUint(JNIEnv *,jclass,jdouble x)801 Java_android_renderscript_cts_CoreMathVerifier_convertDoubleToUint(JNIEnv*, jclass, jdouble x) {
802 return (jint)(uint32_t)(double)x;
803 }
804 extern "C" JNIEXPORT jlong JNICALL
Java_android_renderscript_cts_CoreMathVerifier_convertDoubleToLong(JNIEnv *,jclass,jdouble x)805 Java_android_renderscript_cts_CoreMathVerifier_convertDoubleToLong(JNIEnv*, jclass, jdouble x) {
806 return (jlong)(int64_t)(double)x;
807 }
808 extern "C" JNIEXPORT jlong JNICALL
Java_android_renderscript_cts_CoreMathVerifier_convertDoubleToUlong(JNIEnv *,jclass,jdouble x)809 Java_android_renderscript_cts_CoreMathVerifier_convertDoubleToUlong(JNIEnv*, jclass, jdouble x) {
810 return (jlong)(uint64_t)(double)x;
811 }
812 extern "C" JNIEXPORT jfloat JNICALL
Java_android_renderscript_cts_CoreMathVerifier_convertDoubleToFloat(JNIEnv *,jclass,jdouble x)813 Java_android_renderscript_cts_CoreMathVerifier_convertDoubleToFloat(JNIEnv*, jclass, jdouble x) {
814 return (jfloat)(float)(double)x;
815 }
816 extern "C" JNIEXPORT jdouble JNICALL
Java_android_renderscript_cts_CoreMathVerifier_convertDoubleToDouble(JNIEnv *,jclass,jdouble x)817 Java_android_renderscript_cts_CoreMathVerifier_convertDoubleToDouble(JNIEnv*, jclass, jdouble x) {
818 return (jdouble)(double)(double)x;
819 }
820