Merge tag 'v3.14.25' into backport/v3.14.24-ltsi-rc1+v3.14.25/snapshot-merge.wip
[platform/adaptation/renesas_rcar/renesas_kernel.git] / drivers / staging / ktap / test / ffi / ffi_test.kp
1 function failed(msg) {
2         printf("failed: " .. msg);
3         printf("\n")
4         exit(-1);
5 }
6
7
8 cdef[[
9         void ffi_test_void();
10         int ffi_test_int1(unsigned char a, char b, unsigned short c, short d);
11         long long ffi_test_int2(unsigned int a, int b, unsigned long c, long d,
12                                 unsigned long long e, long long f, long long g);
13         void *ffi_test_pointer1(char *a);
14         long long ffi_test_var_arg(int n, ...);
15         unsigned long long ffi_test_sched_clock(void);
16 ]]
17
18
19 ret = C.ffi_test_void()
20 if (ret != nil) {
21         failed("ffi_test_void should return nil")
22 }
23
24 ret = C.ffi_test_int1(1111, 1111, 1111, 1111)
25 if (ret != 2396) {
26         failed("ffi_test_int1(1111, 1111, 1111, 1111) should return 2396")
27 }
28
29 ret = C.ffi_test_int2(90, 7800, 560000, 34000000, 1200000000, 900000000000, 78000000000000)
30 if (ret != 78901234567890) {
31         failed("ffi_test_int2 should return 78901234567890")
32 }
33
34 ret = C.ffi_test_pointer1("")
35 if (ret == nil) {
36         failed("ffi_test_pointer1 shoudl return address around 0xffff8800--------")
37 }
38
39 ret = C.ffi_test_var_arg(7, 90, 7800, 560000, 34000000, 1200000000, 900000000000, 78000000000000)
40 if (ret != 78901234567890) {
41         failed("ffi_test_var_arg should return 78901234567890")
42 }
43
44 ret = C.ffi_test_sched_clock()
45 if (ret == nil) {
46         failed("ffi_test_clock should not return nil")
47 }