Debian Codegraph @

build-system/integration-test/test-projects/ndkJniLib/lib/src/main/jni/hello-jni.c

raw
1 /*
2 * Copyright (C) 2009 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 <string.h>
18 #include <jni.h>
19
20 /* This is a trivial JNI example where we use a native method
21 * to return a new VM String. See the corresponding Java source
22 * file located at:
23 *
24 * apps/samples/hello-jni/project/src/com/example/hellojni/HelloJni.java
25 */
26 jstring
27 Java_com_example_hellojni_lib_HelloJni_stringFromJNI(JNIEnv* env, jobject thiz)
28 {
29 #if defined(__arm__)
30 #if defined(__ARM_ARCH_7A__)
31 #if defined(__ARM_NEON__)
32 #define ABI "armeabi-v7a with NEON"
33 #else
34 #define ABI "armeabi-v7a"
35 #endif
36 #else
37 #define ABI "armeabi"
38 #endif
39 #elif defined(__i386__)
40 #define ABI "x86"
41 #elif defined(__mips__)
42 #define ABI "mips"
43 #else
44 #define ABI "unknown"
45 #endif
46
47 return (*env)->NewStringUTF(env, "Hello from JNI ! My ABI is " ABI ".");
48 }
49
50 jstring
51 Java_com_example_hellojni_lib_HelloJni_jniNameFromJNI(JNIEnv* env, jobject thiz)
52 {
53 #if defined(__arm__)
54 #if defined(__ARM_ARCH_7A__)
55 #if defined(__ARM_NEON__)
56 #define ABI "armeabi-v7a with NEON"
57 #else
58 #define ABI "armeabi-v7a"
59 #endif
60 #else
61 #define ABI "armeabi"
62 #endif
63 #elif defined(__i386__)
64 #define ABI "x86"
65 #elif defined(__mips__)
66 #define ABI "mips"
67 #else
68 #define ABI "unknown"
69 #endif
70
71 return (*env)->NewStringUTF(env, ABI);
72 }