| Vladimir Marko | 7dac864 | 2019-11-06 17:09:30 +0000 | [diff] [blame^] | 1 | /* |
| 2 | * Copyright 2019 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 | |
| 19 | namespace art { |
| 20 | |
| 21 | static inline bool VerifyManyParameters( |
| 22 | jint i1, jlong l1, jfloat f1, jdouble d1, |
| 23 | jint i2, jlong l2, jfloat f2, jdouble d2, |
| 24 | jint i3, jlong l3, jfloat f3, jdouble d3, |
| 25 | jint i4, jlong l4, jfloat f4, jdouble d4, |
| 26 | jint i5, jlong l5, jfloat f5, jdouble d5, |
| 27 | jint i6, jlong l6, jfloat f6, jdouble d6, |
| 28 | jint i7, jlong l7, jfloat f7, jdouble d7, |
| 29 | jint i8, jlong l8, jfloat f8, jdouble d8) { |
| 30 | return |
| 31 | (i1 == 11) && (l1 == 12) && (f1 == 13.0) && (d1 == 14.0) && |
| 32 | (i2 == 21) && (l2 == 22) && (f2 == 23.0) && (d2 == 24.0) && |
| 33 | (i3 == 31) && (l3 == 32) && (f3 == 33.0) && (d3 == 34.0) && |
| 34 | (i4 == 41) && (l4 == 42) && (f4 == 43.0) && (d4 == 44.0) && |
| 35 | (i5 == 51) && (l5 == 52) && (f5 == 53.0) && (d5 == 54.0) && |
| 36 | (i6 == 61) && (l6 == 62) && (f6 == 63.0) && (d6 == 64.0) && |
| 37 | (i7 == 71) && (l7 == 72) && (f7 == 73.0) && (d7 == 74.0) && |
| 38 | (i8 == 81) && (l8 == 82) && (f8 == 83.0) && (d8 == 84.0); |
| 39 | } |
| 40 | |
| 41 | extern "C" JNIEXPORT jint JNICALL Java_Test_nativeMethod(JNIEnv*, jclass, jint i) { |
| 42 | return i; |
| 43 | } |
| 44 | |
| 45 | extern "C" JNIEXPORT jint JNICALL Java_Test_nativeMethodWithManyParameters( |
| 46 | JNIEnv*, jclass, |
| 47 | jint i1, jlong l1, jfloat f1, jdouble d1, |
| 48 | jint i2, jlong l2, jfloat f2, jdouble d2, |
| 49 | jint i3, jlong l3, jfloat f3, jdouble d3, |
| 50 | jint i4, jlong l4, jfloat f4, jdouble d4, |
| 51 | jint i5, jlong l5, jfloat f5, jdouble d5, |
| 52 | jint i6, jlong l6, jfloat f6, jdouble d6, |
| 53 | jint i7, jlong l7, jfloat f7, jdouble d7, |
| 54 | jint i8, jlong l8, jfloat f8, jdouble d8) { |
| 55 | bool ok = VerifyManyParameters( |
| 56 | i1, l1, f1, d1, |
| 57 | i2, l2, f2, d2, |
| 58 | i3, l3, f3, d3, |
| 59 | i4, l4, f4, d4, |
| 60 | i5, l5, f5, d5, |
| 61 | i6, l6, f6, d6, |
| 62 | i7, l7, f7, d7, |
| 63 | i8, l8, f8, d8); |
| 64 | return ok ? 42 : -1; |
| 65 | } |
| 66 | |
| 67 | extern "C" JNIEXPORT jint JNICALL Java_TestFast_nativeMethod(JNIEnv*, jclass, jint i) { |
| 68 | return i; |
| 69 | } |
| 70 | |
| 71 | extern "C" JNIEXPORT jint JNICALL Java_TestFast_nativeMethodWithManyParameters( |
| 72 | JNIEnv*, jclass, |
| 73 | jint i1, jlong l1, jfloat f1, jdouble d1, |
| 74 | jint i2, jlong l2, jfloat f2, jdouble d2, |
| 75 | jint i3, jlong l3, jfloat f3, jdouble d3, |
| 76 | jint i4, jlong l4, jfloat f4, jdouble d4, |
| 77 | jint i5, jlong l5, jfloat f5, jdouble d5, |
| 78 | jint i6, jlong l6, jfloat f6, jdouble d6, |
| 79 | jint i7, jlong l7, jfloat f7, jdouble d7, |
| 80 | jint i8, jlong l8, jfloat f8, jdouble d8) { |
| 81 | bool ok = VerifyManyParameters( |
| 82 | i1, l1, f1, d1, |
| 83 | i2, l2, f2, d2, |
| 84 | i3, l3, f3, d3, |
| 85 | i4, l4, f4, d4, |
| 86 | i5, l5, f5, d5, |
| 87 | i6, l6, f6, d6, |
| 88 | i7, l7, f7, d7, |
| 89 | i8, l8, f8, d8); |
| 90 | return ok ? 42 : -1; |
| 91 | } |
| 92 | |
| 93 | extern "C" JNIEXPORT jint JNICALL Java_TestCritical_nativeMethod(jint i) { |
| 94 | return i; |
| 95 | } |
| 96 | |
| 97 | extern "C" JNIEXPORT jint JNICALL Java_TestCritical_nativeMethodWithManyParameters( |
| 98 | jint i1, jlong l1, jfloat f1, jdouble d1, |
| 99 | jint i2, jlong l2, jfloat f2, jdouble d2, |
| 100 | jint i3, jlong l3, jfloat f3, jdouble d3, |
| 101 | jint i4, jlong l4, jfloat f4, jdouble d4, |
| 102 | jint i5, jlong l5, jfloat f5, jdouble d5, |
| 103 | jint i6, jlong l6, jfloat f6, jdouble d6, |
| 104 | jint i7, jlong l7, jfloat f7, jdouble d7, |
| 105 | jint i8, jlong l8, jfloat f8, jdouble d8) { |
| 106 | bool ok = VerifyManyParameters( |
| 107 | i1, l1, f1, d1, |
| 108 | i2, l2, f2, d2, |
| 109 | i3, l3, f3, d3, |
| 110 | i4, l4, f4, d4, |
| 111 | i5, l5, f5, d5, |
| 112 | i6, l6, f6, d6, |
| 113 | i7, l7, f7, d7, |
| 114 | i8, l8, f8, d8); |
| 115 | return ok ? 42 : -1; |
| 116 | } |
| 117 | |
| 118 | } // namespace art |