summaryrefslogtreecommitdiffstats
path: root/test/native
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2011-07-23 01:50:21 +0200
committerSven Gothel <[email protected]>2011-07-23 01:50:21 +0200
commit967782f7bdbd0dd73c2e3ea448a0c9d44552a7d9 (patch)
treee05edc4bed58c9ff8503728b0a6db07b67032144 /test/native
parent2d57b3cbb4a8189ecb5523f6d8de3aa37db78a13 (diff)
Adding native crosscompile test to ubuntu/armv7 and android/armv7
Diffstat (limited to 'test/native')
-rw-r--r--test/native/alignment_test.sh4
-rw-r--r--test/native/cross-android-armv7-tst1/HelloJava.java16
-rw-r--r--test/native/cross-android-armv7-tst1/android.ndk.env-4.4.3-androideabi.armv7-a.sh85
-rw-r--r--test/native/cross-android-armv7-tst1/arm-gcc-test.c123
-rw-r--r--test/native/cross-android-armv7-tst1/arm-gcc-test.sh15
-rw-r--r--test/native/cross-android-armv7-tst1/hello-fp.c16
-rw-r--r--test/native/cross-android-armv7-tst1/hello-fp.sh15
-rw-r--r--test/native/cross-android-armv7-tst1/hello-java.c119
-rw-r--r--test/native/cross-android-armv7-tst1/hello-java.sh23
-rw-r--r--test/native/cross-ubuntu-armv7-tst1/arm-gcc-test.c123
-rw-r--r--test/native/cross-ubuntu-armv7-tst1/arm-gcc-test.sh13
11 files changed, 552 insertions, 0 deletions
diff --git a/test/native/alignment_test.sh b/test/native/alignment_test.sh
new file mode 100644
index 0000000..9cd8354
--- /dev/null
+++ b/test/native/alignment_test.sh
@@ -0,0 +1,4 @@
+#! /bin/bash
+
+gcc -o alignment_test alignment_test.c
+./alignment_test
diff --git a/test/native/cross-android-armv7-tst1/HelloJava.java b/test/native/cross-android-armv7-tst1/HelloJava.java
new file mode 100644
index 0000000..3c6a841
--- /dev/null
+++ b/test/native/cross-android-armv7-tst1/HelloJava.java
@@ -0,0 +1,16 @@
+
+public class HelloJava {
+ public static void main(String args[]) {
+ System.out.print("HelloJava main(");
+ for(int i=0; i<args.length; i++) {
+ if(0<i) {
+ System.out.print(", ");
+ }
+ System.out.print(args[i]);
+ }
+ System.out.println(")");
+ }
+ public static void test(int i) {
+ System.out.println("HelloJava test("+i+")");
+ }
+}
diff --git a/test/native/cross-android-armv7-tst1/android.ndk.env-4.4.3-androideabi.armv7-a.sh b/test/native/cross-android-armv7-tst1/android.ndk.env-4.4.3-androideabi.armv7-a.sh
new file mode 100644
index 0000000..1db8b70
--- /dev/null
+++ b/test/native/cross-android-armv7-tst1/android.ndk.env-4.4.3-androideabi.armv7-a.sh
@@ -0,0 +1,85 @@
+#! /bin/sh
+
+# http://forum.xda-developers.com/showthread.php?t=625277
+#
+
+#
+# Android NDK tool chain setup
+# run cd ~/android/ndk; make APP-xxx -V1 to obtain toolchain values
+#
+# Old NDK <= 4
+# ./build/prebuilt/linux-x86/arm-eabi-4.2.1/bin/
+# ./build/prebuilt/linux-x86/arm-eabi-4.4.0/bin/
+#
+# New NDK >= 5
+# ./toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin/arm-linux-androideabi-gcc
+# ./toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/arm-linux-androideabi/bin/gcc
+#
+# ./toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/lib/gcc/arm-linux-androideabi/4.4.3/thumb/libgcc.a
+# ./toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/lib/gcc/arm-linux-androideabi/4.4.3/libgcc.a
+# ./toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/lib/gcc/arm-linux-androideabi/4.4.3/armv7-a/thumb/libgcc.a
+# ./toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/lib/gcc/arm-linux-androideabi/4.4.3/armv7-a/libgcc.a
+# ./toolchains/x86-4.4.3/prebuilt/linux-x86/lib/gcc/i686-android-linux/4.4.3/libgcc.a
+
+
+
+
+export NDK_ROOT=/opt-linux-x86/android-ndk
+
+ANDROID_VERSION=9
+GCC_VERSION=4.4.3
+HOST_ARCH=linux-x86
+TARGET_ARCH=arm-linux-androideabi
+# mcpu: cortex-a8', `cortex-a9', `cortex-r4', `cortex-r4f', `cortex-m3', `cortex-m1', `xscale', `iwmmxt', `iwmmxt2', `ep9312'.
+TARGET_CPU_ARCH=
+TARGET_CPU_NAME=armv7-a
+TARGET_CPU_TUNE=armv7-a
+# mfpu: `vfp', `vfpv3', `vfpv3-d16' and `neon'
+TARGET_FPU_NAME=vfpv3
+TARGET_FPU_ABI=softfp
+
+TARGET_TOOL_PATH=${NDK_ROOT}/toolchains/${TARGET_ARCH}-${GCC_VERSION}/prebuilt/${HOST_ARCH}
+
+#TARGET_OS_PATH=/usr/local/projects/android/gt-i9000xxjf3/system
+TARGET_OS_PATH=${NDK_ROOT}/platforms/android-${ANDROID_VERSION}/arch-arm/usr
+
+export NDK_XBIN_PATH=${TARGET_TOOL_PATH}/bin
+export NDK_BIN_PATH=${TARGET_TOOL_PATH}/${TARGET_ARCH}/bin
+
+export NDK_GCC=${NDK_XBIN_PATH}/${TARGET_ARCH}-gcc
+export NDK_AR=${NDK_XBIN_PATH}/${TARGET_ARCH}-ar
+export NDK_STRIP=${NDK_XBIN_PATH}/${TARGET_ARCH}-strip
+export NDK_READELF=${NDK_XBIN_PATH}/${TARGET_ARCH}-readelf
+
+export PATH=${NDK_XBIN_PATH}:$PATH
+
+export NDK_INCLUDE="-I${TARGET_OS_PATH}/include"
+
+# -mfloat-abi=${TARGET_FPU_ABI} -mfpu=${TARGET_FPU_NAME} \
+# -D__ARM_ARCH_7__ -D__ARM_ARCH_7A__ \
+# -ffunction-sections -funwind-tables -fstack-protector -fno-short-enums \
+# -O3 -fomit-frame-pointer -fno-strict-aliasing -finline-limit=64 \
+# -mcpu=${TARGET_CPU_NAME} -mtune=${TARGET_CPU_TUNE} \
+
+export NDK_CFLAGS="\
+-march=${TARGET_CPU_NAME} \
+-fpic \
+-DANDROID \
+"
+
+#
+# THIS WORKS
+#
+
+export NDK_LDFLAGS="\
+-Wl,--demangle \
+-nostdlib -Bdynamic -Wl,-dynamic-linker,/system/bin/linker -Wl,--gc-sections -Wl,-z,nocopyreloc \
+${TARGET_OS_PATH}/lib/libc.so \
+${TARGET_OS_PATH}/lib/libstdc++.so \
+${TARGET_OS_PATH}/lib/libm.so \
+${TARGET_OS_PATH}/lib/crtbegin_dynamic.o \
+-Wl,--no-undefined -Wl,-rpath-link=${TARGET_OS_PATH}/lib \
+${TARGET_TOOL_PATH}/lib/gcc/${TARGET_ARCH}/${GCC_VERSION}/${TARGET_CPU_NAME}/libgcc.a \
+${TARGET_OS_PATH}/lib/crtend_android.o \
+"
+
diff --git a/test/native/cross-android-armv7-tst1/arm-gcc-test.c b/test/native/cross-android-armv7-tst1/arm-gcc-test.c
new file mode 100644
index 0000000..b67dc1f
--- /dev/null
+++ b/test/native/cross-android-armv7-tst1/arm-gcc-test.c
@@ -0,0 +1,123 @@
+
+#include <stdio.h>
+#include <stdint.h>
+
+typedef struct {
+ char c; // 1
+ int32_t i; // 4
+ int64_t l; // 8
+} struct_m1;
+
+typedef struct {
+ char c1;
+ struct_m1 s1;
+ char c2;
+ struct_m1 s2[2];
+} struct_m2;
+
+#define ADDR(a) ((long)((void *)&(a)))
+#define ADDRD(a,b) ((long)(ADDR(a)-ADDR(b)))
+
+void dumpStructMetrics01() {
+ struct_m1 sm1;
+ struct_m2 sm2;
+
+ printf("sz m1 %ld\n", (long) sizeof(struct_m1));
+ printf("sz m2 %ld\n", (long) sizeof(struct_m2));
+
+ printf("m1: i-0: %ld\n", ADDRD((sm1.i),(sm1)));
+ printf("m1: l-0: %ld\n", ADDRD((sm1.l),(sm1)));
+
+ printf("m2: s1-0: %ld\n", ADDRD((sm2.s1),(sm2)));
+ printf("m2: s1.c-0: %ld\n", ADDRD((sm2.s1.c),(sm2)));
+ printf("m2: c2-s1[: %ld\n", ADDRD((sm2.c2),(sm2.s1.l))-8);
+ printf("m2: s2-0: %ld\n", ADDRD((sm2.s2),(sm2)));
+ printf("m2: sz(s2[2]): %ld\n", (long) sizeof(sm2.s2));
+}
+
+typedef struct {
+ int8_t c1;
+ int8_t v;
+} struct_alignment_int8;
+
+typedef struct {
+ int8_t c1;
+ int16_t v;
+} struct_alignment_int16;
+
+typedef struct {
+ int8_t c1;
+ int32_t v;
+} struct_alignment_int32;
+
+typedef struct {
+ int8_t c1;
+ int64_t v;
+} struct_alignment_int64;
+
+typedef struct {
+ int8_t c1;
+ void * v;
+} struct_alignment_pointer;
+
+typedef struct {
+ int8_t c1;
+ float v;
+} struct_alignment_float;
+
+typedef struct {
+ int8_t c1;
+ double v;
+} struct_alignment_double;
+
+typedef struct {
+ char c1;
+ long double v;
+} struct_alignment_longdouble;
+
+size_t padding(size_t totalsize, size_t typesize) { return totalsize - typesize - sizeof(char); }
+size_t alignment(size_t totalsize, size_t typesize) { return totalsize - typesize; }
+
+int main(int argc, char * argv[] ) {
+ printf("Hello World\n");
+ #ifdef __arm__
+ #warning __arm__
+ printf("__arm__\n");
+ #endif
+ #ifdef __thumb__
+ #warning __thumb__
+ printf("__thumb__\n");
+ #endif
+ #ifdef __ARM_EABI__
+ #warning __ARM_EABI__
+ printf("__ARM_EABI__\n");
+ #endif
+ #ifdef __ARMEL__
+ #warning __ARMEL__
+ printf("__ARMEL__\n");
+ #endif
+ #ifdef __VFP_FP__
+ #warning __VFP_FP__
+ printf("__VFP_FP__\n");
+ #endif
+ #ifdef __MAVERICK__
+ #warning __MAVERICK__
+ printf("__MAVERICK__\n");
+ #endif
+ #ifdef __SOFTFP__
+ #warning __SOFTFP__
+ printf("__SOFTFP__\n");
+ #endif
+
+ printf("sizeof/alignment int8_t: %d / %d / %d\n", sizeof(int8_t), sizeof( struct_alignment_int8 ), alignment(sizeof( struct_alignment_int8 ), sizeof(int8_t)));
+ printf("sizeof/alignment int16_t: %d / %d / %d\n", sizeof(int16_t), sizeof( struct_alignment_int16 ), alignment(sizeof( struct_alignment_int16 ), sizeof(int16_t)));
+ printf("sizeof/alignment int32_t: %d / %d / %d\n", sizeof(int32_t), sizeof( struct_alignment_int32 ), alignment(sizeof( struct_alignment_int32 ), sizeof(int32_t)));
+ printf("sizeof/alignment int64_t: %d / %d / %d\n", sizeof(int64_t), sizeof( struct_alignment_int64 ), alignment(sizeof( struct_alignment_int64 ), sizeof(int64_t)));
+ printf("sizeof/alignment pointer: %d / %d / %d\n", sizeof(void *), sizeof( struct_alignment_pointer ), alignment(sizeof( struct_alignment_pointer ), sizeof(void *)));
+ printf("sizeof/alignment float: %d / %d / %d\n", sizeof(float), sizeof( struct_alignment_float ), alignment(sizeof( struct_alignment_float ), sizeof(float)));
+ printf("sizeof/alignment double: %d / %d / %d\n", sizeof(double), sizeof( struct_alignment_double ), alignment(sizeof( struct_alignment_double ), sizeof(double)));
+ printf("sizeof/alignment long double: %d / %d / %d\n", sizeof(long double), sizeof( struct_alignment_longdouble ), alignment(sizeof( struct_alignment_longdouble ), sizeof(long double)));
+
+ dumpStructMetrics01();
+ return 0;
+}
diff --git a/test/native/cross-android-armv7-tst1/arm-gcc-test.sh b/test/native/cross-android-armv7-tst1/arm-gcc-test.sh
new file mode 100644
index 0000000..ecdf88a
--- /dev/null
+++ b/test/native/cross-android-armv7-tst1/arm-gcc-test.sh
@@ -0,0 +1,15 @@
+
+TEST_APP=arm-gcc-test
+
+SPEC=androideabi.armv7-a
+
+. /opt-linux-x86/etc/profile.android
+. ./android.ndk.env-4.4.3-${SPEC}.sh
+
+mkdir -p build/native
+
+$NDK_GCC $NDK_INCLUDE $NDK_CFLAGS $NDK_LDFLAGS -o build/native/${TEST_APP}-${SPEC} ${TEST_APP}.c
+$NDK_READELF -a build/native/${TEST_APP}-${SPEC} > build/native/${TEST_APP}-${SPEC}.txt
+adb push build/native/${TEST_APP}-${SPEC} /projects/native-tst
+adb shell /projects/native-tst/${TEST_APP}-${SPEC}
+
diff --git a/test/native/cross-android-armv7-tst1/hello-fp.c b/test/native/cross-android-armv7-tst1/hello-fp.c
new file mode 100644
index 0000000..d94f660
--- /dev/null
+++ b/test/native/cross-android-armv7-tst1/hello-fp.c
@@ -0,0 +1,16 @@
+#include <stdio.h>
+#include <math.h>
+
+int main(int argc, char ** argv) {
+ double d1 = 3.14;
+ double d2 = 2.0;
+ double dr;
+
+ dr = d1 * d2;
+ printf("hello %lf * %lf = %lf\n", d1, d2, dr);
+
+ dr = sin(d1);
+ printf("hello sin(%lf) = %lf\n", d1, dr);
+
+ return 0;
+}
diff --git a/test/native/cross-android-armv7-tst1/hello-fp.sh b/test/native/cross-android-armv7-tst1/hello-fp.sh
new file mode 100644
index 0000000..c4a627e
--- /dev/null
+++ b/test/native/cross-android-armv7-tst1/hello-fp.sh
@@ -0,0 +1,15 @@
+
+TEST_APP=hello-fp
+
+SPEC=androideabi.armv7-a
+
+. /opt-linux-x86/etc/profile.android
+. ./android.ndk.env-4.4.3-${SPEC}.sh
+
+mkdir -p build/native
+
+$NDK_GCC $NDK_INCLUDE $NDK_CFLAGS $NDK_LDFLAGS -o build/native/${TEST_APP}-${SPEC} ${TEST_APP}.c
+$NDK_READELF -a build/native/${TEST_APP}-${SPEC} > build/native/${TEST_APP}-${SPEC}.txt
+adb push build/native/${TEST_APP}-${SPEC} /projects/native-tst
+adb shell /projects/native-tst/${TEST_APP}-${SPEC}
+
diff --git a/test/native/cross-android-armv7-tst1/hello-java.c b/test/native/cross-android-armv7-tst1/hello-java.c
new file mode 100644
index 0000000..51826e4
--- /dev/null
+++ b/test/native/cross-android-armv7-tst1/hello-java.c
@@ -0,0 +1,119 @@
+#include <stdio.h>
+#include <math.h>
+
+#include <jni.h>
+#include <dlfcn.h>
+
+typedef jint (*FPTR_JNI_GetDefaultJavaVMInitArgs)(void*);
+typedef jint (*FPTR_JNI_CreateJavaVM)(JavaVM**, JNIEnv**, void*);
+typedef jint (*FPTR_JNI_GetCreatedJavaVMs)(JavaVM**, jsize, jsize*);
+
+static const char * FN_JVM_LIB_NAME = "libdvm.so";
+static const char * FN_JNI_GetDefaultJavaVMInitArgs = "JNI_GetDefaultJavaVMInitArgs";
+static const char * FN_JNI_CreateJavaVM = "JNI_CreateJavaVM";
+static const char * FN_JNI_GetCreatedJavaVMs = "JNI_GetCreatedJavaVMs";
+
+int main(int argc, char ** argv) {
+ void * jvmLibHandle;
+ FPTR_JNI_GetDefaultJavaVMInitArgs fptr_JNI_GetDefaultJavaVMInitArgs;
+ FPTR_JNI_CreateJavaVM fptr_JNI_CreateJavaVM;
+ FPTR_JNI_GetCreatedJavaVMs fptr_JNI_GetCreatedJavaVMs;
+ jint jres;
+
+ JavaVM *jvm; /* denotes a Java VM */
+ JNIEnv *env; /* pointer to native method interface */
+
+#if 0
+ const int vm_options_count = 4;
+ JavaVMOption vm_options[vm_options_count];
+ {
+ int i=0;
+ vm_options[i++].optionString = "-Djava.compiler=NONE"; /* disable JIT */
+ vm_options[i++].optionString = "-Djava.class.path=c:\myclasses"; /* user classes */
+ vm_options[i++].optionString = "-Djava.library.path=c:\mylibs"; /* set native library path */
+ vm_options[i++].optionString = "-verbose:jni"; /* print JNI-related messages */
+ }
+#else
+ const int vm_options_count = 1;
+ JavaVMOption vm_options[vm_options_count];
+ {
+ int i=0;
+ vm_options[i++].optionString = "-Djava.class.path=HelloJava.jar"; /* user classes (OK) */
+ // vm_options[i++].optionString = "-cp HelloJava.jar"; /* user classes (NOT OK) */
+ // vm_options[i++].optionString = "-cp"; /* user classes (OK) */
+ // vm_options[i++].optionString = "HelloJava.jar"; /* user classes (OK) */
+ }
+#endif
+ JavaVMInitArgs vm_args; /* VM initialization arguments */
+
+ jvmLibHandle = dlopen(FN_JVM_LIB_NAME, RTLD_LAZY | RTLD_GLOBAL);
+ if(NULL == jvmLibHandle) {
+ fprintf(stderr, "Error: Could not open %s, abort\n", FN_JVM_LIB_NAME);
+ return -1;
+ }
+ fptr_JNI_GetDefaultJavaVMInitArgs = (FPTR_JNI_GetDefaultJavaVMInitArgs) dlsym(jvmLibHandle, FN_JNI_GetDefaultJavaVMInitArgs);
+ if(NULL == fptr_JNI_GetDefaultJavaVMInitArgs) {
+ fprintf(stderr, "Error: Could not resolve %s, abort\n", FN_JNI_GetDefaultJavaVMInitArgs);
+ return -1;
+ }
+ fptr_JNI_CreateJavaVM = (FPTR_JNI_CreateJavaVM) dlsym(jvmLibHandle, FN_JNI_CreateJavaVM);
+ if(NULL == fptr_JNI_CreateJavaVM) {
+ fprintf(stderr, "Error: Could not resolve %s, abort\n", FN_JNI_CreateJavaVM);
+ return -1;
+ }
+ fptr_JNI_GetCreatedJavaVMs = (FPTR_JNI_GetCreatedJavaVMs) dlsym(jvmLibHandle, FN_JNI_GetCreatedJavaVMs);
+ if(NULL == fptr_JNI_GetCreatedJavaVMs) {
+ fprintf(stderr, "Error: Could not resolve %s, abort\n", FN_JNI_GetCreatedJavaVMs);
+ return -1;
+ }
+
+ /* Get the default initialization arguments and set the class
+ * path */
+ /**
+ jres = fptr_JNI_GetDefaultJavaVMInitArgs(&vm_args);
+ if(JNI_OK != jres) {
+ fprintf(stderr, "Error: JNI_GetDefaultJavaVMInitArgs failed: %d, abort\n", jres);
+ return -1;
+ } */
+ // vm_args.classpath = ...;
+
+ vm_args.version = JNI_VERSION_1_2;
+ vm_args.options = vm_options;
+ vm_args.nOptions = vm_options_count;
+ vm_args.ignoreUnrecognized = JNI_TRUE;
+
+ /* load and initialize a Java VM, return a JNI interface
+ * pointer in env */
+ jres = fptr_JNI_CreateJavaVM(&jvm, &env, &vm_args);
+ if(JNI_OK != jres) {
+ fprintf(stderr, "Error: JNI_CreateJavaVM failed: %d, abort\n", jres);
+ return -1;
+ }
+ fprintf(stderr, "Info: VM created\n");
+
+ /* invoke the HelloJava.test method using the JNI */
+ jclass cls = (*env)->FindClass(env, "HelloJava");
+ if(NULL == cls) {
+ fprintf(stderr, "Error: Could not resolve Class HelloJava, abort\n");
+ (*jvm)->DestroyJavaVM(jvm);
+ return -1;
+ }
+ fprintf(stderr, "Info: Found Class HelloJava\n");
+
+ jmethodID mid = (*env)->GetStaticMethodID(env, cls, "test", "(I)V");
+ if(NULL == cls) {
+ fprintf(stderr, "Error: Could not resolve Method \"void HelloJava.test(int)\", abort\n");
+ (*jvm)->DestroyJavaVM(jvm);
+ return -1;
+ }
+ fprintf(stderr, "Info: Found Method HelloJava.test(int)\n");
+
+ (*env)->CallStaticVoidMethod(env, cls, mid, 100);
+ fprintf(stderr, "Info: post invocation\n");
+
+ /* We are done. */
+ (*jvm)->DestroyJavaVM(jvm);
+ fprintf(stderr, "Info: post VM\n");
+
+ return 0;
+}
diff --git a/test/native/cross-android-armv7-tst1/hello-java.sh b/test/native/cross-android-armv7-tst1/hello-java.sh
new file mode 100644
index 0000000..b373f2e
--- /dev/null
+++ b/test/native/cross-android-armv7-tst1/hello-java.sh
@@ -0,0 +1,23 @@
+
+TEST_APP=hello-java
+
+SPEC=androideabi.armv7-a
+
+. /opt-linux-x86/etc/profile.android
+. ./android.ndk.env-4.4.3-${SPEC}.sh
+
+JAVA_INCLUDE="-I/opt-linux-x86/j2se6/include"
+
+mkdir -p build/native
+mkdir -p build/classes
+mkdir -p build/jar
+
+javac -d build/classes HelloJava.java
+dx --dex --output=build/jar/HelloJava.jar ./build/classes
+adb push build/jar/HelloJava.jar /projects/native-tst
+adb shell 'cd /projects/native-tst ; dalvikvm -cp HelloJava.jar HelloJava'
+
+$NDK_GCC $NDK_INCLUDE $JAVA_INCLUDE $NDK_CFLAGS $NDK_LDFLAGS -o build/native/${TEST_APP}-${SPEC} ${TEST_APP}.c
+$NDK_READELF -a build/native/${TEST_APP}-${SPEC} > build/native/${TEST_APP}-${SPEC}.txt
+adb push build/native/${TEST_APP}-${SPEC} /projects/native-tst
+adb shell "cd /projects/native-tst ; ./${TEST_APP}-${SPEC}"
diff --git a/test/native/cross-ubuntu-armv7-tst1/arm-gcc-test.c b/test/native/cross-ubuntu-armv7-tst1/arm-gcc-test.c
new file mode 100644
index 0000000..b67dc1f
--- /dev/null
+++ b/test/native/cross-ubuntu-armv7-tst1/arm-gcc-test.c
@@ -0,0 +1,123 @@
+
+#include <stdio.h>
+#include <stdint.h>
+
+typedef struct {
+ char c; // 1
+ int32_t i; // 4
+ int64_t l; // 8
+} struct_m1;
+
+typedef struct {
+ char c1;
+ struct_m1 s1;
+ char c2;
+ struct_m1 s2[2];
+} struct_m2;
+
+#define ADDR(a) ((long)((void *)&(a)))
+#define ADDRD(a,b) ((long)(ADDR(a)-ADDR(b)))
+
+void dumpStructMetrics01() {
+ struct_m1 sm1;
+ struct_m2 sm2;
+
+ printf("sz m1 %ld\n", (long) sizeof(struct_m1));
+ printf("sz m2 %ld\n", (long) sizeof(struct_m2));
+
+ printf("m1: i-0: %ld\n", ADDRD((sm1.i),(sm1)));
+ printf("m1: l-0: %ld\n", ADDRD((sm1.l),(sm1)));
+
+ printf("m2: s1-0: %ld\n", ADDRD((sm2.s1),(sm2)));
+ printf("m2: s1.c-0: %ld\n", ADDRD((sm2.s1.c),(sm2)));
+ printf("m2: c2-s1[: %ld\n", ADDRD((sm2.c2),(sm2.s1.l))-8);
+ printf("m2: s2-0: %ld\n", ADDRD((sm2.s2),(sm2)));
+ printf("m2: sz(s2[2]): %ld\n", (long) sizeof(sm2.s2));
+}
+
+typedef struct {
+ int8_t c1;
+ int8_t v;
+} struct_alignment_int8;
+
+typedef struct {
+ int8_t c1;
+ int16_t v;
+} struct_alignment_int16;
+
+typedef struct {
+ int8_t c1;
+ int32_t v;
+} struct_alignment_int32;
+
+typedef struct {
+ int8_t c1;
+ int64_t v;
+} struct_alignment_int64;
+
+typedef struct {
+ int8_t c1;
+ void * v;
+} struct_alignment_pointer;
+
+typedef struct {
+ int8_t c1;
+ float v;
+} struct_alignment_float;
+
+typedef struct {
+ int8_t c1;
+ double v;
+} struct_alignment_double;
+
+typedef struct {
+ char c1;
+ long double v;
+} struct_alignment_longdouble;
+
+size_t padding(size_t totalsize, size_t typesize) { return totalsize - typesize - sizeof(char); }
+size_t alignment(size_t totalsize, size_t typesize) { return totalsize - typesize; }
+
+int main(int argc, char * argv[] ) {
+ printf("Hello World\n");
+ #ifdef __arm__
+ #warning __arm__
+ printf("__arm__\n");
+ #endif
+ #ifdef __thumb__
+ #warning __thumb__
+ printf("__thumb__\n");
+ #endif
+ #ifdef __ARM_EABI__
+ #warning __ARM_EABI__
+ printf("__ARM_EABI__\n");
+ #endif
+ #ifdef __ARMEL__
+ #warning __ARMEL__
+ printf("__ARMEL__\n");
+ #endif
+ #ifdef __VFP_FP__
+ #warning __VFP_FP__
+ printf("__VFP_FP__\n");
+ #endif
+ #ifdef __MAVERICK__
+ #warning __MAVERICK__
+ printf("__MAVERICK__\n");
+ #endif
+ #ifdef __SOFTFP__
+ #warning __SOFTFP__
+ printf("__SOFTFP__\n");
+ #endif
+
+ printf("sizeof/alignment int8_t: %d / %d / %d\n", sizeof(int8_t), sizeof( struct_alignment_int8 ), alignment(sizeof( struct_alignment_int8 ), sizeof(int8_t)));
+ printf("sizeof/alignment int16_t: %d / %d / %d\n", sizeof(int16_t), sizeof( struct_alignment_int16 ), alignment(sizeof( struct_alignment_int16 ), sizeof(int16_t)));
+ printf("sizeof/alignment int32_t: %d / %d / %d\n", sizeof(int32_t), sizeof( struct_alignment_int32 ), alignment(sizeof( struct_alignment_int32 ), sizeof(int32_t)));
+ printf("sizeof/alignment int64_t: %d / %d / %d\n", sizeof(int64_t), sizeof( struct_alignment_int64 ), alignment(sizeof( struct_alignment_int64 ), sizeof(int64_t)));
+ printf("sizeof/alignment pointer: %d / %d / %d\n", sizeof(void *), sizeof( struct_alignment_pointer ), alignment(sizeof( struct_alignment_pointer ), sizeof(void *)));
+ printf("sizeof/alignment float: %d / %d / %d\n", sizeof(float), sizeof( struct_alignment_float ), alignment(sizeof( struct_alignment_float ), sizeof(float)));
+ printf("sizeof/alignment double: %d / %d / %d\n", sizeof(double), sizeof( struct_alignment_double ), alignment(sizeof( struct_alignment_double ), sizeof(double)));
+ printf("sizeof/alignment long double: %d / %d / %d\n", sizeof(long double), sizeof( struct_alignment_longdouble ), alignment(sizeof( struct_alignment_longdouble ), sizeof(long double)));
+
+ dumpStructMetrics01();
+ return 0;
+}
diff --git a/test/native/cross-ubuntu-armv7-tst1/arm-gcc-test.sh b/test/native/cross-ubuntu-armv7-tst1/arm-gcc-test.sh
new file mode 100644
index 0000000..5243652
--- /dev/null
+++ b/test/native/cross-ubuntu-armv7-tst1/arm-gcc-test.sh
@@ -0,0 +1,13 @@
+
+PATH=`pwd`/../../../make/lib/linux-x86_64/arm-linux-gnueabi/bin:$PATH
+export PATH
+
+TEST_APP=arm-gcc-test
+
+mkdir -p build/native
+ssh jogamp@beagle01 mkdir -p projects/native-tst
+
+gcc -o build/native/${TEST_APP} ${TEST_APP}.c
+scp build/native/${TEST_APP} jogamp@beagle01:projects/native-tst/
+ssh jogamp@beagle01 "cd projects/native-tst ; ./${TEST_APP}"
+