Skip to content

Add foreign call test for arm64 #229

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 19 additions & 2 deletions contrib/eus64-check/Makefile
Original file line number Diff line number Diff line change
@@ -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

82 changes: 57 additions & 25 deletions contrib/eus64-check/eus64-test.l
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,39 @@
: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~%")
(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
Expand All @@ -47,30 +68,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))
Expand All @@ -88,7 +109,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))
Expand All @@ -105,28 +126,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
Expand All @@ -138,9 +161,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)
Expand All @@ -158,6 +182,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))
26 changes: 24 additions & 2 deletions contrib/eus64-check/test_foreign.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) ())
Expand All @@ -176,19 +177,40 @@ 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,
1040.0, 1050.0, 1060.0, 1070.0,
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));
}