From c08794c7c07e1c6e322457220f1ca58d309b4bc7 Mon Sep 17 00:00:00 2001 From: YoheiKakiuchi Date: Thu, 5 Jan 2017 18:07:30 +0900 Subject: [PATCH 1/2] [aarch64] add foreign function call check for ARM 64bit --- contrib/eus64-check/Makefile | 21 +++++++++- contrib/eus64-check/eus64-test.l | 63 ++++++++++++++++++------------ contrib/eus64-check/test_foreign.c | 6 ++- 3 files changed, 61 insertions(+), 29 deletions(-) diff --git a/contrib/eus64-check/Makefile b/contrib/eus64-check/Makefile index f22b41acb..5e715e355 100644 --- a/contrib/eus64-check/Makefile +++ b/contrib/eus64-check/Makefile @@ -1,14 +1,31 @@ all : test_foreign.so +MARCH=$(shell uname -m) + test_foreign.so : test_foreign.c ifeq ($(ARCHDIR), Linux64) - gcc -m64 -O2 -g -falign-functions=8 -Dx86_64 -DLinux -fPIC -c $< - gcc -m64 -shared -fPIC -falign-functions=8 -o $@ test_foreign.o +## + gcc -O2 -g -falign-functions=8 -Dx86_64 -DLinux -fPIC -c $< + gcc -shared -fPIC -falign-functions=8 -o $@ test_foreign.o +else +ifeq ($(ARCHDIR), LinuxARM) +ifeq ($(MARCH), aarch64) +## arm 64bit + gcc -O2 -g -Wimplicit -falign-functions=8 -Daarch64 -Darmv8 -DARM -DLinux -fPIC -c $< + gcc -shared -fPIC -falign-functions=8 -o $@ test_foreign.o +else +## arm 32bit + gcc -O2 -g -falign-functions=4 -DARM -DLinux -fpic -c $< + gcc -shared -fpic -falign-functions=4 -o $@ test_foreign.o +endif else +## Linux32 bit gcc -m32 -O2 -g -falign-functions=4 -Di386 -Di486 -DLinux -fpic -c $< gcc -m32 -shared -fpic -falign-functions=4 -o $@ test_foreign.o endif +endif clean : \rm -f *.o *.so + diff --git a/contrib/eus64-check/eus64-test.l b/contrib/eus64-check/eus64-test.l index 6c20ea6be..0775cd840 100644 --- a/contrib/eus64-check/eus64-test.l +++ b/contrib/eus64-check/eus64-test.l @@ -31,14 +31,16 @@ (format t "~%multiple arguments passing~%") -(format t "expected result~%") +(format t "expected result~%") (format t "100 101 102 103 104 105 1000.000000 1010.000000 1020.000000 1030.000000 1040.000000 1050.000000 1060.000000 1070.000000 2080.000000 2090.000000 -206 207~%") -(format t "exec in eus64~%") +206 207 +test-testd = 1.23456 +~%") +(format t "exec in eus~%") (format t "test-testd = ~A~%" (test-testd 100 101 102 103 104 105 @@ -47,30 +49,30 @@ 2080.0 2090.0 206 207)) -(format t "~%float-test~%") +(format t "~%~%float-test~%") (format t "expected result~%") (format t "0: 1.000000e-01 ..~%") (format t "0: 2.000000e-01 ..~%") (format t "0: 3.000000e-01 ..~%") (format t "0: 4.000000e-01 ..~%") -(format t "exec in eus64~%") +(format t "~%float-test(success, exec in eus)~%") (float-test 0 0.1 0.2 0.3 0.4) -(format t "~%float2-test~%") +(format t "~%float2-test(fail, exec in eus)~%") (float2-test 0 0.1 0.2 0.3 0.4) -(format t "~%float3-test~%") +(format t "~%float3-test(depend on architecture, exec in eus)~%") (float3-test 0 0.1 0.2 0.3 0.4) -(format t "~%double-test~%") +(format t "~%~%double-test~%") (format t "expected result~%") (format t "1: 1.000000e-01 ..~%") (format t "1: 2.000000e-01 ..~%") (format t "1: 3.000000e-01 ..~%") (format t "1: 4.000000e-01 ..~%") -(format t "exec in eus64~%") +(format t "~%double-test(success, exec in eus)~%") (double-test 1 0.1 0.2 0.3 0.4) -(format t "~%double2-test~%") +(format t "~%double2-test(fail, exec in eus)~%") (double2-test 1 0.1 0.2 0.3 0.4) -(format t "~%double3-test~%") +(format t "~%double3-test(depend on architecture, exec in eus)~%") (double3-test 1 0.1 0.2 0.3 0.4) (setq iv (integer-vector 0 100 10000 1000000 100000000 10000000000)) @@ -88,7 +90,7 @@ 3: 1000000 F4240 4: 100000000 5F5E100 5: 10000000000 2540BE400~%") -(format t "exec in eus64~%") +(format t "~%lv-test(exec in eus)~%") (lv-test (length iv) iv) (setq fv (float-vector 0.1 0.2 0.3 0.5 0.7)) @@ -105,28 +107,30 @@ 2: 3.000000e-01 3FD3333333333330 3: 5.000000e-01 3FE0000000000000 4: 7.000000e-01 3FE6666666666664~%") -(format t "exec in eus64~%") +(format t "~%dv-test(exec in eus)~%") (dv-test (length fv) fv) + (setq str "input : test64 string") (format t "~%str-test~%") -(format t "expected result~%") -(format t "print : ~S~%" str) -(format t "exec in eus64~%") +;;(format t "expected result~%") +(format t "input string : ~S~%" str) +(format t "~%str-test(exec in eus)~%") (str-test (length str) str) (format t "~%return double test~%") (format t "expected result~%") -(format t "ret-double ~8,8e~%" (+ 0.55555 133.0)) -(format t "exec in eus64~%") -(format t "ret-double ~8,8e~%" (ret-double 0.55555 133.0)) +(format t " ret-double ~8,8e~%" (+ 0.55555 133.0)) +(format t "~%ret-double(exec in eus)~%") +(format t " ret-double ~8,8e~%" (ret-double 0.55555 133.0)) + (format t "~%return long test~%") (format t "expected result~%") -(format t "ret-long ~D~%" (+ 123 645000)) -(format t "exec in eus64~%") -(format t "ret-long ~D~%" (ret-long 123 645000)) +(format t " ret-long ~D~%" (+ 123 645000)) +(format t "~%ret-long(exec in eus)~%") +(format t " ret-long ~D~%" (ret-long 123 645000)) ;; ret-int ;; ret-short @@ -138,9 +142,10 @@ 1234) ;; (format t "~%callback function test(integer)~%") -(format t "callback function is set~%") +(format t " callback function is set~%") (set-ifunc (pod-address 'LISP-IFUNC)) -(format t "call-ifunc = ~A~%" (call-ifunc)) +(format t " expected result: LISP-INTFUNC is called, return 1234~%") +(format t " call-ifunc = ~A~%" (call-ifunc)) (defun-c-callable LISP-FFUNC ((i0 :integer) (i1 :integer) (i2 :integer) (i3 :integer) (i4 :integer) (i5 :integer) @@ -158,6 +163,14 @@ (format t "return ~A~%" 0.12345) 0.12345) (format t "~%callback function test(float)~%") -(format t "callback function is set~%") +(format t " callback function is set~%") (set-ffunc (pod-address 'LISP-FFUNC)) +(format t " expected result: LISP-FFUNC is called + 100 101 102 + 103 104 105 + 1000.0 1010.0 1020.0 1030.0 + 1040.0 1050.0 1060.0 1070.0 + 2080.0 2090.0 + 206 207 + return 0.12345~%") (format t "call-ffunc = ~A~%" (call-ffunc)) diff --git a/contrib/eus64-check/test_foreign.c b/contrib/eus64-check/test_foreign.c index b31627c32..ec00e4b5d 100644 --- a/contrib/eus64-check/test_foreign.c +++ b/contrib/eus64-check/test_foreign.c @@ -166,6 +166,7 @@ static double (*gf) (long i0, long i1, long i2, long set_ifunc(long (*f) ()) { g = f; + printf("set_ifunc, g = %lX\n", g); } long set_ffunc(double (*f) ()) @@ -176,15 +177,16 @@ long set_ffunc(double (*f) ()) double d4, double d5, double d6, double d7, double d8, double d9, long i6, long i7))f; + printf("set_ffunc, gf = %lX\n", gf); } long call_ifunc() { - printf("g = %lX\n", g); + printf("call_ifunc, g = %lX\n", g); return g(); } double call_ffunc() { - printf("gf = %lX\n", gf); + printf("call_ffunc, gf = %lX\n", gf); return gf(100,101,102, 103,104,105, 1000.0, 1010.0, 1020.0, 1030.0, From 47a5be3f87ae37d9182ce43356ea8195699f304c Mon Sep 17 00:00:00 2001 From: YoheiKakiuchi Date: Fri, 6 Jan 2017 05:25:53 +0000 Subject: [PATCH 2/2] [aarch64] add size check for pointer/double/integer --- contrib/eus64-check/eus64-test.l | 19 +++++++++++++++++++ contrib/eus64-check/test_foreign.c | 20 ++++++++++++++++++++ 2 files changed, 39 insertions(+) diff --git a/contrib/eus64-check/eus64-test.l b/contrib/eus64-check/eus64-test.l index 0775cd840..e9afc0317 100644 --- a/contrib/eus64-check/eus64-test.l +++ b/contrib/eus64-check/eus64-test.l @@ -27,8 +27,27 @@ :integer :integer) :float) (defforeign call-ifunc *testmod* "call_ifunc" () :integer) (defforeign call-ffunc *testmod* "call_ffunc" () :float) + + (defforeign get-size-pointer *testmod* "get_size_of_pointer" () :integer) + (defforeign get-size-float32 *testmod* "get_size_of_float32" () :integer) + (defforeign get-size-double *testmod* "get_size_of_double" () :integer) + (defforeign get-size-long *testmod* "get_size_of_long" () :integer) + (defforeign get-size-int *testmod* "get_size_of_int" () :integer) ) +(format t "~%;;;; pointer size check ;;;;~%") + +(format t "pointer size ~D ~D~%" + lisp::sizeof-* (get-size-pointer)) +(format t "double size ~D ~D~%" + lisp::sizeof-double (get-size-double)) +(format t "long integer size ~D ~D~%" + (cadr (assoc :long lisp::sizeof-types)) + (get-size-long)) +(format t "integer size ~D ~D~%" + lisp::sizeof-int (get-size-int)) +(format t "float size ~D ~D~%" + lisp::sizeof-float (get-size-float32)) (format t "~%multiple arguments passing~%") (format t "expected result~%") diff --git a/contrib/eus64-check/test_foreign.c b/contrib/eus64-check/test_foreign.c index ec00e4b5d..d4089d701 100644 --- a/contrib/eus64-check/test_foreign.c +++ b/contrib/eus64-check/test_foreign.c @@ -194,3 +194,23 @@ double call_ffunc() { 2080.0, 2090.0, 206, 207); } + +long get_size_of_pointer() { + return (sizeof(void *)); +} + +long get_size_of_float32() { + return (sizeof(float)); +} + +long get_size_of_double() { + return (sizeof(double)); +} + +long get_size_of_long() { + return (sizeof(long)); +} + +long get_size_of_int() { + return (sizeof(int)); +}