ffi 0.5.4 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of ffi might be problematic. Click here for more details.

Files changed (203) hide show
  1. data/LICENSE +1 -27
  2. data/Rakefile +2 -11
  3. data/ext/ffi_c/AbstractMemory.c +6 -8
  4. data/ext/ffi_c/AbstractMemory.h +23 -21
  5. data/ext/ffi_c/AutoPointer.c +0 -1
  6. data/ext/ffi_c/Buffer.c +23 -8
  7. data/ext/ffi_c/Call.c +28 -0
  8. data/ext/ffi_c/Call.h +5 -1
  9. data/ext/ffi_c/DynamicLibrary.c +0 -1
  10. data/ext/ffi_c/Function.c +19 -2
  11. data/ext/ffi_c/MemoryPointer.c +2 -3
  12. data/ext/ffi_c/Pointer.c +23 -9
  13. data/ext/ffi_c/Struct.c +142 -69
  14. data/ext/ffi_c/Struct.h +16 -7
  15. data/ext/ffi_c/StructLayout.c +92 -55
  16. data/ext/ffi_c/Type.c +5 -22
  17. data/ext/ffi_c/Type.h +1 -1
  18. data/ext/ffi_c/Types.c +8 -2
  19. data/ext/ffi_c/Types.h +2 -0
  20. data/ext/ffi_c/extconf.rb +11 -7
  21. data/ext/ffi_c/libffi/ChangeLog +900 -84
  22. data/ext/ffi_c/libffi/ChangeLog.libffi +311 -0
  23. data/ext/ffi_c/libffi/LICENSE +1 -1
  24. data/ext/ffi_c/libffi/Makefile.am +14 -4
  25. data/ext/ffi_c/libffi/Makefile.in +362 -211
  26. data/ext/ffi_c/libffi/README +70 -92
  27. data/ext/ffi_c/libffi/aclocal.m4 +6068 -4586
  28. data/ext/ffi_c/libffi/config.guess +125 -143
  29. data/ext/ffi_c/libffi/config.sub +103 -27
  30. data/ext/ffi_c/libffi/configure +11364 -18497
  31. data/ext/ffi_c/libffi/configure.ac +43 -4
  32. data/ext/ffi_c/libffi/doc/libffi.info +15 -15
  33. data/ext/ffi_c/libffi/doc/libffi.texi +1 -1
  34. data/ext/ffi_c/libffi/doc/stamp-vti +4 -4
  35. data/ext/ffi_c/libffi/doc/version.texi +4 -4
  36. data/ext/ffi_c/libffi/fficonfig.h.in +24 -3
  37. data/ext/ffi_c/libffi/include/Makefile.am +1 -1
  38. data/ext/ffi_c/libffi/include/Makefile.in +97 -50
  39. data/ext/ffi_c/libffi/include/ffi.h.in +8 -2
  40. data/ext/ffi_c/libffi/include/ffi_common.h +24 -0
  41. data/ext/ffi_c/libffi/libtool-version +1 -1
  42. data/ext/ffi_c/libffi/ltmain.sh +7346 -5870
  43. data/ext/ffi_c/libffi/m4/libtool.m4 +7360 -0
  44. data/ext/ffi_c/libffi/m4/ltoptions.m4 +368 -0
  45. data/ext/ffi_c/libffi/m4/ltsugar.m4 +123 -0
  46. data/ext/ffi_c/libffi/m4/ltversion.m4 +23 -0
  47. data/ext/ffi_c/libffi/m4/lt~obsolete.m4 +92 -0
  48. data/ext/ffi_c/libffi/man/Makefile.in +115 -62
  49. data/ext/ffi_c/libffi/man/ffi_call.3 +3 -3
  50. data/ext/ffi_c/libffi/missing +15 -8
  51. data/ext/ffi_c/libffi/src/arm/sysv.S +15 -8
  52. data/ext/ffi_c/libffi/src/avr32/ffi.c +421 -0
  53. data/ext/ffi_c/libffi/src/avr32/ffitarget.h +50 -0
  54. data/ext/ffi_c/libffi/src/avr32/sysv.S +208 -0
  55. data/ext/ffi_c/libffi/src/closures.c +47 -10
  56. data/ext/ffi_c/libffi/src/frv/ffi.c +1 -1
  57. data/ext/ffi_c/libffi/src/java_raw_api.c +0 -3
  58. data/ext/ffi_c/libffi/src/mips/ffi.c +135 -32
  59. data/ext/ffi_c/libffi/src/mips/ffitarget.h +37 -4
  60. data/ext/ffi_c/libffi/src/mips/n32.S +67 -10
  61. data/ext/ffi_c/libffi/src/mips/o32.S +8 -8
  62. data/ext/ffi_c/libffi/src/pa/ffi.c +7 -0
  63. data/ext/ffi_c/libffi/src/powerpc/aix.S +163 -64
  64. data/ext/ffi_c/libffi/src/powerpc/aix_closure.S +308 -112
  65. data/ext/ffi_c/libffi/src/powerpc/ffi.c +20 -7
  66. data/ext/ffi_c/libffi/src/powerpc/ffi_darwin.c +208 -80
  67. data/ext/ffi_c/libffi/src/powerpc/ffitarget.h +11 -3
  68. data/ext/ffi_c/libffi/src/powerpc/sysv.S +12 -23
  69. data/ext/ffi_c/libffi/src/s390/sysv.S +1 -1
  70. data/ext/ffi_c/libffi/src/sh/sysv.S +9 -9
  71. data/ext/ffi_c/libffi/src/sh64/ffi.c +37 -22
  72. data/ext/ffi_c/libffi/src/sh64/sysv.S +23 -14
  73. data/ext/ffi_c/libffi/src/sparc/ffi.c +21 -6
  74. data/ext/ffi_c/libffi/src/sparc/v8.S +55 -14
  75. data/ext/ffi_c/libffi/src/x86/darwin.S +10 -9
  76. data/ext/ffi_c/libffi/src/x86/ffi.c +293 -86
  77. data/ext/ffi_c/libffi/src/x86/ffi64.c +73 -19
  78. data/ext/ffi_c/libffi/src/x86/ffitarget.h +30 -0
  79. data/ext/ffi_c/libffi/src/x86/sysv.S +21 -4
  80. data/ext/ffi_c/libffi/src/x86/unix64.S +8 -4
  81. data/ext/ffi_c/libffi/src/x86/win32.S +633 -147
  82. data/ext/ffi_c/libffi/src/x86/win64.S +460 -0
  83. data/ext/ffi_c/libffi/testsuite/Makefile.am +63 -54
  84. data/ext/ffi_c/libffi/testsuite/Makefile.in +112 -77
  85. data/ext/ffi_c/libffi/testsuite/lib/libffi-dg.exp +12 -1
  86. data/ext/ffi_c/libffi/testsuite/libffi.call/call.exp +4 -4
  87. data/ext/ffi_c/libffi/testsuite/libffi.call/closure_fn0.c +7 -15
  88. data/ext/ffi_c/libffi/testsuite/libffi.call/closure_fn1.c +7 -15
  89. data/ext/ffi_c/libffi/testsuite/libffi.call/closure_fn2.c +7 -15
  90. data/ext/ffi_c/libffi/testsuite/libffi.call/closure_fn3.c +7 -15
  91. data/ext/ffi_c/libffi/testsuite/libffi.call/closure_fn4.c +7 -15
  92. data/ext/ffi_c/libffi/testsuite/libffi.call/closure_fn5.c +7 -14
  93. data/ext/ffi_c/libffi/testsuite/libffi.call/closure_fn6.c +7 -15
  94. data/ext/ffi_c/libffi/testsuite/libffi.call/closure_loc_fn0.c +95 -0
  95. data/ext/ffi_c/libffi/testsuite/libffi.call/closure_stdcall.c +6 -14
  96. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_12byte.c +4 -12
  97. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_16byte.c +4 -12
  98. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_18byte.c +4 -12
  99. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_19byte.c +4 -12
  100. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_1_1byte.c +4 -12
  101. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_20byte.c +4 -12
  102. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_20byte1.c +4 -12
  103. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_24byte.c +4 -12
  104. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_2byte.c +4 -12
  105. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_3_1byte.c +4 -12
  106. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_3byte1.c +4 -12
  107. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_3byte2.c +4 -12
  108. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_4_1byte.c +4 -12
  109. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_4byte.c +4 -12
  110. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_5_1_byte.c +4 -12
  111. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_5byte.c +4 -12
  112. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_64byte.c +4 -12
  113. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_6_1_byte.c +4 -12
  114. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_6byte.c +4 -12
  115. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_7_1_byte.c +4 -12
  116. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_7byte.c +4 -12
  117. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_8byte.c +4 -12
  118. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_9byte1.c +4 -12
  119. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_9byte2.c +4 -12
  120. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_align_double.c +4 -12
  121. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_align_float.c +4 -12
  122. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_align_longdouble.c +4 -12
  123. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_align_longdouble_split.c +134 -0
  124. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_align_longdouble_split2.c +117 -0
  125. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_align_pointer.c +11 -17
  126. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_align_sint16.c +4 -12
  127. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_align_sint32.c +4 -12
  128. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_align_sint64.c +7 -15
  129. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_align_uint16.c +4 -12
  130. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_align_uint32.c +4 -12
  131. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_align_uint64.c +7 -15
  132. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_dbls_struct.c +66 -0
  133. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_double.c +4 -12
  134. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_double_va.c +57 -0
  135. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_float.c +4 -13
  136. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_longdouble.c +105 -0
  137. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_longdouble_va.c +57 -0
  138. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_multi_schar.c +4 -12
  139. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_multi_sshort.c +4 -12
  140. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_multi_sshortchar.c +4 -12
  141. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_multi_uchar.c +4 -12
  142. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_multi_ushort.c +4 -12
  143. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_multi_ushortchar.c +4 -12
  144. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_pointer.c +74 -0
  145. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_pointer_stack.c +140 -0
  146. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_schar.c +4 -12
  147. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_sint.c +4 -12
  148. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_sshort.c +4 -12
  149. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_uchar.c +4 -12
  150. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_uint.c +4 -12
  151. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_ulonglong.c +8 -16
  152. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_ushort.c +4 -12
  153. data/ext/ffi_c/libffi/testsuite/libffi.call/err_bad_abi.c +37 -0
  154. data/ext/ffi_c/libffi/testsuite/libffi.call/err_bad_typedef.c +25 -0
  155. data/ext/ffi_c/libffi/testsuite/libffi.call/ffitest.h +31 -0
  156. data/ext/ffi_c/libffi/testsuite/libffi.call/float2.c +2 -1
  157. data/ext/ffi_c/libffi/testsuite/libffi.call/huge_struct.c +342 -0
  158. data/ext/ffi_c/libffi/testsuite/libffi.call/nested_struct.c +4 -12
  159. data/ext/ffi_c/libffi/testsuite/libffi.call/nested_struct1.c +4 -12
  160. data/ext/ffi_c/libffi/testsuite/libffi.call/nested_struct10.c +4 -12
  161. data/ext/ffi_c/libffi/testsuite/libffi.call/nested_struct2.c +4 -12
  162. data/ext/ffi_c/libffi/testsuite/libffi.call/nested_struct3.c +4 -12
  163. data/ext/ffi_c/libffi/testsuite/libffi.call/nested_struct4.c +4 -12
  164. data/ext/ffi_c/libffi/testsuite/libffi.call/nested_struct5.c +4 -12
  165. data/ext/ffi_c/libffi/testsuite/libffi.call/nested_struct6.c +4 -12
  166. data/ext/ffi_c/libffi/testsuite/libffi.call/nested_struct7.c +4 -12
  167. data/ext/ffi_c/libffi/testsuite/libffi.call/nested_struct8.c +4 -12
  168. data/ext/ffi_c/libffi/testsuite/libffi.call/nested_struct9.c +4 -12
  169. data/ext/ffi_c/libffi/testsuite/libffi.call/problem1.c +4 -12
  170. data/ext/ffi_c/libffi/testsuite/libffi.call/return_ldl.c +1 -1
  171. data/ext/ffi_c/libffi/testsuite/libffi.call/return_ll1.c +1 -1
  172. data/ext/ffi_c/libffi/testsuite/libffi.call/stret_large.c +145 -0
  173. data/ext/ffi_c/libffi/testsuite/libffi.call/stret_large2.c +148 -0
  174. data/ext/ffi_c/libffi/testsuite/libffi.call/stret_medium.c +124 -0
  175. data/ext/ffi_c/libffi/testsuite/libffi.call/stret_medium2.c +124 -0
  176. data/ext/ffi_c/libffi/testsuite/libffi.call/testclosure.c +70 -0
  177. data/ext/ffi_c/libffi/testsuite/libffi.special/ffitestcxx.h +10 -0
  178. data/ext/ffi_c/libffi/testsuite/libffi.special/special.exp +4 -5
  179. data/ext/ffi_c/libffi/testsuite/libffi.special/unwindtest.cc +17 -16
  180. data/ext/ffi_c/libffi/texinfo.tex +155 -427
  181. data/lib/ffi/autopointer.rb +79 -20
  182. data/lib/ffi/callback.rb +4 -10
  183. data/lib/ffi/enum.rb +28 -0
  184. data/lib/ffi/io.rb +28 -0
  185. data/lib/ffi/library.rb +237 -182
  186. data/lib/ffi/memorypointer.rb +28 -62
  187. data/lib/ffi/platform.rb +27 -0
  188. data/lib/ffi/pointer.rb +28 -0
  189. data/lib/ffi/struct.rb +55 -1
  190. data/lib/ffi/types.rb +29 -0
  191. data/lib/ffi/variadic.rb +29 -0
  192. data/spec/ffi/library_spec.rb +31 -5
  193. data/spec/ffi/rbx/attach_function_spec.rb +2 -1
  194. data/spec/ffi/rbx/memory_pointer_spec.rb +2 -1
  195. data/spec/ffi/spec_helper.rb +5 -1
  196. data/spec/ffi/struct_spec.rb +64 -0
  197. metadata +28 -8
  198. data/ext/ffi_c/libffi/TODO +0 -1
  199. data/ext/ffi_c/libffi/ltcf-c.sh +0 -861
  200. data/ext/ffi_c/libffi/ltcf-cxx.sh +0 -1069
  201. data/ext/ffi_c/libffi/ltcf-gcj.sh +0 -700
  202. data/ext/ffi_c/libffi/ltconfig +0 -2862
  203. data/ext/ffi_c/libffi/mkinstalldirs +0 -158
@@ -21,19 +21,11 @@ typedef signed char (*cls_ret_schar)(signed char);
21
21
  int main (void)
22
22
  {
23
23
  ffi_cif cif;
24
- #ifndef USING_MMAP
25
- static ffi_closure cl;
26
- #endif
27
- ffi_closure *pcl;
24
+ void *code;
25
+ ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code);
28
26
  ffi_type * cl_arg_types[2];
29
27
  signed char res;
30
28
 
31
- #ifdef USING_MMAP
32
- pcl = allocate_mmap (sizeof(ffi_closure));
33
- #else
34
- pcl = &cl;
35
- #endif
36
-
37
29
  cl_arg_types[0] = &ffi_type_schar;
38
30
  cl_arg_types[1] = NULL;
39
31
 
@@ -41,9 +33,9 @@ int main (void)
41
33
  CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 1,
42
34
  &ffi_type_schar, cl_arg_types) == FFI_OK);
43
35
 
44
- CHECK(ffi_prep_closure(pcl, &cif, cls_ret_schar_fn, NULL) == FFI_OK);
36
+ CHECK(ffi_prep_closure_loc(pcl, &cif, cls_ret_schar_fn, NULL, code) == FFI_OK);
45
37
 
46
- res = (*((cls_ret_schar)pcl))(127);
38
+ res = (*((cls_ret_schar)code))(127);
47
39
  /* { dg-output "127: 127" } */
48
40
  printf("res: %d\n", res);
49
41
  /* { dg-output "\nres: 127" } */
@@ -19,19 +19,11 @@ typedef signed int (*cls_ret_sint)(signed int);
19
19
  int main (void)
20
20
  {
21
21
  ffi_cif cif;
22
- #ifndef USING_MMAP
23
- static ffi_closure cl;
24
- #endif
25
- ffi_closure *pcl;
22
+ void *code;
23
+ ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code);
26
24
  ffi_type * cl_arg_types[2];
27
25
  signed int res;
28
26
 
29
- #ifdef USING_MMAP
30
- pcl = allocate_mmap (sizeof(ffi_closure));
31
- #else
32
- pcl = &cl;
33
- #endif
34
-
35
27
  cl_arg_types[0] = &ffi_type_sint;
36
28
  cl_arg_types[1] = NULL;
37
29
 
@@ -39,9 +31,9 @@ int main (void)
39
31
  CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 1,
40
32
  &ffi_type_sint, cl_arg_types) == FFI_OK);
41
33
 
42
- CHECK(ffi_prep_closure(pcl, &cif, cls_ret_sint_fn, NULL) == FFI_OK);
34
+ CHECK(ffi_prep_closure_loc(pcl, &cif, cls_ret_sint_fn, NULL, code) == FFI_OK);
43
35
 
44
- res = (*((cls_ret_sint)pcl))(65534);
36
+ res = (*((cls_ret_sint)code))(65534);
45
37
  /* { dg-output "65534: 65534" } */
46
38
  printf("res: %d\n",res);
47
39
  /* { dg-output "\nres: 65534" } */
@@ -19,19 +19,11 @@ typedef signed short (*cls_ret_sshort)(signed short);
19
19
  int main (void)
20
20
  {
21
21
  ffi_cif cif;
22
- #ifndef USING_MMAP
23
- static ffi_closure cl;
24
- #endif
25
- ffi_closure *pcl;
22
+ void *code;
23
+ ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code);
26
24
  ffi_type * cl_arg_types[2];
27
25
  signed short res;
28
26
 
29
- #ifdef USING_MMAP
30
- pcl = allocate_mmap (sizeof(ffi_closure));
31
- #else
32
- pcl = &cl;
33
- #endif
34
-
35
27
  cl_arg_types[0] = &ffi_type_sshort;
36
28
  cl_arg_types[1] = NULL;
37
29
 
@@ -39,9 +31,9 @@ int main (void)
39
31
  CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 1,
40
32
  &ffi_type_sshort, cl_arg_types) == FFI_OK);
41
33
 
42
- CHECK(ffi_prep_closure(pcl, &cif, cls_ret_sshort_fn, NULL) == FFI_OK);
34
+ CHECK(ffi_prep_closure_loc(pcl, &cif, cls_ret_sshort_fn, NULL, code) == FFI_OK);
43
35
 
44
- res = (*((cls_ret_sshort)pcl))(255);
36
+ res = (*((cls_ret_sshort)code))(255);
45
37
  /* { dg-output "255: 255" } */
46
38
  printf("res: %d\n",res);
47
39
  /* { dg-output "\nres: 255" } */
@@ -19,19 +19,11 @@ typedef unsigned char (*cls_ret_uchar)(unsigned char);
19
19
  int main (void)
20
20
  {
21
21
  ffi_cif cif;
22
- #ifndef USING_MMAP
23
- static ffi_closure cl;
24
- #endif
25
- ffi_closure *pcl;
22
+ void *code;
23
+ ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code);
26
24
  ffi_type * cl_arg_types[2];
27
25
  unsigned char res;
28
26
 
29
- #ifdef USING_MMAP
30
- pcl = allocate_mmap (sizeof(ffi_closure));
31
- #else
32
- pcl = &cl;
33
- #endif
34
-
35
27
  cl_arg_types[0] = &ffi_type_uchar;
36
28
  cl_arg_types[1] = NULL;
37
29
 
@@ -39,9 +31,9 @@ int main (void)
39
31
  CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 1,
40
32
  &ffi_type_uchar, cl_arg_types) == FFI_OK);
41
33
 
42
- CHECK(ffi_prep_closure(pcl, &cif, cls_ret_uchar_fn, NULL) == FFI_OK);
34
+ CHECK(ffi_prep_closure_loc(pcl, &cif, cls_ret_uchar_fn, NULL, code) == FFI_OK);
43
35
 
44
- res = (*((cls_ret_uchar)pcl))(127);
36
+ res = (*((cls_ret_uchar)code))(127);
45
37
  /* { dg-output "127: 127" } */
46
38
  printf("res: %d\n",res);
47
39
  /* { dg-output "\nres: 127" } */
@@ -20,19 +20,11 @@ typedef unsigned int (*cls_ret_uint)(unsigned int);
20
20
  int main (void)
21
21
  {
22
22
  ffi_cif cif;
23
- #ifndef USING_MMAP
24
- static ffi_closure cl;
25
- #endif
26
- ffi_closure *pcl;
23
+ void *code;
24
+ ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code);
27
25
  ffi_type * cl_arg_types[2];
28
26
  unsigned int res;
29
27
 
30
- #ifdef USING_MMAP
31
- pcl = allocate_mmap (sizeof(ffi_closure));
32
- #else
33
- pcl = &cl;
34
- #endif
35
-
36
28
  cl_arg_types[0] = &ffi_type_uint;
37
29
  cl_arg_types[1] = NULL;
38
30
 
@@ -40,9 +32,9 @@ int main (void)
40
32
  CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 1,
41
33
  &ffi_type_uint, cl_arg_types) == FFI_OK);
42
34
 
43
- CHECK(ffi_prep_closure(pcl, &cif, cls_ret_uint_fn, NULL) == FFI_OK);
35
+ CHECK(ffi_prep_closure_loc(pcl, &cif, cls_ret_uint_fn, NULL, code) == FFI_OK);
44
36
 
45
- res = (*((cls_ret_uint)pcl))(2147483647);
37
+ res = (*((cls_ret_uint)code))(2147483647);
46
38
  /* { dg-output "2147483647: 2147483647" } */
47
39
  printf("res: %d\n",res);
48
40
  /* { dg-output "\nres: 2147483647" } */
@@ -12,7 +12,7 @@ static void cls_ret_ulonglong_fn(ffi_cif* cif __UNUSED__, void* resp,
12
12
  {
13
13
  *(unsigned long long *)resp= *(unsigned long long *)args[0];
14
14
 
15
- printf("%llu: %llu\n",*(unsigned long long *)args[0],
15
+ printf("%" PRIuLL ": %" PRIuLL "\n",*(unsigned long long *)args[0],
16
16
  *(unsigned long long *)(resp));
17
17
  }
18
18
  typedef unsigned long long (*cls_ret_ulonglong)(unsigned long long);
@@ -20,34 +20,26 @@ typedef unsigned long long (*cls_ret_ulonglong)(unsigned long long);
20
20
  int main (void)
21
21
  {
22
22
  ffi_cif cif;
23
- #ifndef USING_MMAP
24
- static ffi_closure cl;
25
- #endif
26
- ffi_closure *pcl;
23
+ void *code;
24
+ ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code);
27
25
  ffi_type * cl_arg_types[2];
28
26
  unsigned long long res;
29
27
 
30
- #ifdef USING_MMAP
31
- pcl = allocate_mmap (sizeof(ffi_closure));
32
- #else
33
- pcl = &cl;
34
- #endif
35
-
36
28
  cl_arg_types[0] = &ffi_type_uint64;
37
29
  cl_arg_types[1] = NULL;
38
30
 
39
31
  /* Initialize the cif */
40
32
  CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 1,
41
33
  &ffi_type_uint64, cl_arg_types) == FFI_OK);
42
- CHECK(ffi_prep_closure(pcl, &cif, cls_ret_ulonglong_fn, NULL) == FFI_OK);
43
- res = (*((cls_ret_ulonglong)pcl))(214LL);
34
+ CHECK(ffi_prep_closure_loc(pcl, &cif, cls_ret_ulonglong_fn, NULL, code) == FFI_OK);
35
+ res = (*((cls_ret_ulonglong)code))(214LL);
44
36
  /* { dg-output "214: 214" } */
45
- printf("res: %lld\n", res);
37
+ printf("res: %" PRIdLL "\n", res);
46
38
  /* { dg-output "\nres: 214" } */
47
39
 
48
- res = (*((cls_ret_ulonglong)pcl))(9223372035854775808LL);
40
+ res = (*((cls_ret_ulonglong)code))(9223372035854775808LL);
49
41
  /* { dg-output "\n9223372035854775808: 9223372035854775808" } */
50
- printf("res: %lld\n", res);
42
+ printf("res: %" PRIdLL "\n", res);
51
43
  /* { dg-output "\nres: 9223372035854775808" } */
52
44
 
53
45
  exit(0);
@@ -20,19 +20,11 @@ typedef unsigned short (*cls_ret_ushort)(unsigned short);
20
20
  int main (void)
21
21
  {
22
22
  ffi_cif cif;
23
- #ifndef USING_MMAP
24
- static ffi_closure cl;
25
- #endif
26
- ffi_closure *pcl;
23
+ void *code;
24
+ ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code);
27
25
  ffi_type * cl_arg_types[2];
28
26
  unsigned short res;
29
27
 
30
- #ifdef USING_MMAP
31
- pcl = allocate_mmap (sizeof(ffi_closure));
32
- #else
33
- pcl = &cl;
34
- #endif
35
-
36
28
  cl_arg_types[0] = &ffi_type_ushort;
37
29
  cl_arg_types[1] = NULL;
38
30
 
@@ -40,9 +32,9 @@ int main (void)
40
32
  CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 1,
41
33
  &ffi_type_ushort, cl_arg_types) == FFI_OK);
42
34
 
43
- CHECK(ffi_prep_closure(pcl, &cif, cls_ret_ushort_fn, NULL) == FFI_OK);
35
+ CHECK(ffi_prep_closure_loc(pcl, &cif, cls_ret_ushort_fn, NULL, code) == FFI_OK);
44
36
 
45
- res = (*((cls_ret_ushort)pcl))(65535);
37
+ res = (*((cls_ret_ushort)code))(65535);
46
38
  /* { dg-output "65535: 65535" } */
47
39
  printf("res: %d\n",res);
48
40
  /* { dg-output "\nres: 65535" } */
@@ -0,0 +1,37 @@
1
+ /* Area: ffi_prep_cif, ffi_prep_closure
2
+ Purpose: Test error return for bad ABIs.
3
+ Limitations: none.
4
+ PR: none.
5
+ Originator: Blake Chaffin 6/6/2007 */
6
+
7
+ /* { dg-do run { xfail *-*-* } } */
8
+ #include "ffitest.h"
9
+
10
+ static void
11
+ dummy_fn(ffi_cif* cif __UNUSED__, void* resp __UNUSED__,
12
+ void** args __UNUSED__, void* userdata __UNUSED__)
13
+ {}
14
+
15
+ int main (void)
16
+ {
17
+ ffi_cif cif;
18
+ void *code;
19
+ ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code);
20
+ void* args[1];
21
+ ffi_type* arg_types[1];
22
+
23
+ arg_types[0] = NULL;
24
+ args[0] = NULL;
25
+
26
+ CHECK(ffi_prep_cif(&cif, 255, 0, &ffi_type_void,
27
+ arg_types) == FFI_BAD_ABI);
28
+
29
+ CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 0, &ffi_type_void,
30
+ arg_types) == FFI_OK);
31
+
32
+ cif.abi= 255;
33
+
34
+ CHECK(ffi_prep_closure_loc(pcl, &cif, dummy_fn, NULL, code) == FFI_BAD_ABI);
35
+
36
+ exit(0);
37
+ }
@@ -0,0 +1,25 @@
1
+ /* Area: ffi_prep_cif
2
+ Purpose: Test error return for bad typedefs.
3
+ Limitations: none.
4
+ PR: none.
5
+ Originator: Blake Chaffin 6/6/2007 */
6
+
7
+ /* { dg-do run { xfail *-*-* } } */
8
+ #include "ffitest.h"
9
+
10
+ int main (void)
11
+ {
12
+ ffi_cif cif;
13
+ ffi_type* arg_types[1];
14
+
15
+ arg_types[0] = NULL;
16
+
17
+ ffi_type badType = ffi_type_void;
18
+
19
+ badType.size = 0;
20
+
21
+ CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 0, &badType,
22
+ arg_types) == FFI_BAD_TYPEDEF);
23
+
24
+ exit(0);
25
+ }
@@ -5,6 +5,14 @@
5
5
  #include <ffi.h>
6
6
  #include "fficonfig.h"
7
7
 
8
+ #if defined HAVE_STDINT_H
9
+ #include <stdint.h>
10
+ #endif
11
+
12
+ #if defined HAVE_INTTYPES_H
13
+ #include <inttypes.h>
14
+ #endif
15
+
8
16
  #define MAX_ARGS 256
9
17
 
10
18
  #define CHECK(x) !(x) ? abort() : 0
@@ -43,6 +51,29 @@
43
51
 
44
52
  #endif
45
53
 
54
+ /* MinGW kludge. */
55
+ #ifdef _WIN64
56
+ #define PRIdLL "I64d"
57
+ #define PRIuLL "I64u"
58
+ #else
59
+ #define PRIdLL "lld"
60
+ #define PRIuLL "llu"
61
+ #endif
62
+
63
+ /* PA HP-UX kludge. */
64
+ #if defined(__hppa__) && defined(__hpux__) && !defined(PRIuPTR)
65
+ #define PRIuPTR "lu"
66
+ #endif
67
+
68
+ /* Solaris < 10 kludge. */
69
+ #if defined(__sun__) && defined(__svr4__) && !defined(PRIuPTR)
70
+ #if defined(__arch64__) || defined (__x86_64__)
71
+ #define PRIuPTR "lu"
72
+ #else
73
+ #define PRIuPTR "u"
74
+ #endif
75
+ #endif
76
+
46
77
  #ifdef USING_MMAP
47
78
  static inline void *
48
79
  allocate_mmap (size_t size)
@@ -4,7 +4,8 @@
4
4
  PR: none.
5
5
  Originator: From the original ffitest.c */
6
6
 
7
- /* { dg-do run } */
7
+ /* { dg-excess-errors "fails" { target x86_64-*-mingw* x86_64-*-cygwin* } } */
8
+ /* { dg-do run { xfail x86_64-*-mingw* x86_64-*-cygwin* } } */
8
9
 
9
10
  #include "ffitest.h"
10
11
  #include "float.h"
@@ -0,0 +1,342 @@
1
+ /* Area: ffi_call, closure_call
2
+ Purpose: Check large structure returns.
3
+ Limitations: none.
4
+ PR: none.
5
+ Originator: Blake Chaffin 6/18/2007
6
+ */
7
+
8
+ /* { dg-excess-errors "" { target x86_64-*-mingw* x86_64-*-cygwin* } } */
9
+ /* { dg-do run { xfail strongarm*-*-* xscale*-*-* } } */
10
+ /* { dg-options -mlong-double-128 { target powerpc64*-*-* } } */
11
+ /* { dg-output "" { xfail x86_64-*-mingw* x86_64-*-cygwin* } } */
12
+
13
+ #include "ffitest.h"
14
+
15
+ typedef struct BigStruct{
16
+ uint8_t a;
17
+ int8_t b;
18
+ uint16_t c;
19
+ int16_t d;
20
+ uint32_t e;
21
+ int32_t f;
22
+ uint64_t g;
23
+ int64_t h;
24
+ float i;
25
+ double j;
26
+ long double k;
27
+ char* l;
28
+ uint8_t m;
29
+ int8_t n;
30
+ uint16_t o;
31
+ int16_t p;
32
+ uint32_t q;
33
+ int32_t r;
34
+ uint64_t s;
35
+ int64_t t;
36
+ float u;
37
+ double v;
38
+ long double w;
39
+ char* x;
40
+ uint8_t y;
41
+ int8_t z;
42
+ uint16_t aa;
43
+ int16_t bb;
44
+ uint32_t cc;
45
+ int32_t dd;
46
+ uint64_t ee;
47
+ int64_t ff;
48
+ float gg;
49
+ double hh;
50
+ long double ii;
51
+ char* jj;
52
+ uint8_t kk;
53
+ int8_t ll;
54
+ uint16_t mm;
55
+ int16_t nn;
56
+ uint32_t oo;
57
+ int32_t pp;
58
+ uint64_t qq;
59
+ int64_t rr;
60
+ float ss;
61
+ double tt;
62
+ long double uu;
63
+ char* vv;
64
+ uint8_t ww;
65
+ int8_t xx;
66
+ } BigStruct;
67
+
68
+ BigStruct
69
+ test_large_fn(
70
+ uint8_t ui8_1,
71
+ int8_t si8_1,
72
+ uint16_t ui16_1,
73
+ int16_t si16_1,
74
+ uint32_t ui32_1,
75
+ int32_t si32_1,
76
+ uint64_t ui64_1,
77
+ int64_t si64_1,
78
+ float f_1,
79
+ double d_1,
80
+ long double ld_1,
81
+ char* p_1,
82
+ uint8_t ui8_2,
83
+ int8_t si8_2,
84
+ uint16_t ui16_2,
85
+ int16_t si16_2,
86
+ uint32_t ui32_2,
87
+ int32_t si32_2,
88
+ uint64_t ui64_2,
89
+ int64_t si64_2,
90
+ float f_2,
91
+ double d_2,
92
+ long double ld_2,
93
+ char* p_2,
94
+ uint8_t ui8_3,
95
+ int8_t si8_3,
96
+ uint16_t ui16_3,
97
+ int16_t si16_3,
98
+ uint32_t ui32_3,
99
+ int32_t si32_3,
100
+ uint64_t ui64_3,
101
+ int64_t si64_3,
102
+ float f_3,
103
+ double d_3,
104
+ long double ld_3,
105
+ char* p_3,
106
+ uint8_t ui8_4,
107
+ int8_t si8_4,
108
+ uint16_t ui16_4,
109
+ int16_t si16_4,
110
+ uint32_t ui32_4,
111
+ int32_t si32_4,
112
+ uint64_t ui64_4,
113
+ int64_t si64_4,
114
+ float f_4,
115
+ double d_4,
116
+ long double ld_4,
117
+ char* p_4,
118
+ uint8_t ui8_5,
119
+ int8_t si8_5)
120
+ {
121
+ BigStruct retVal = {
122
+ ui8_1 + 1, si8_1 + 1, ui16_1 + 1, si16_1 + 1, ui32_1 + 1, si32_1 + 1,
123
+ ui64_1 + 1, si64_1 + 1, f_1 + 1, d_1 + 1, ld_1 + 1, (char*)((intptr_t)p_1 + 1),
124
+ ui8_2 + 2, si8_2 + 2, ui16_2 + 2, si16_2 + 2, ui32_2 + 2, si32_2 + 2,
125
+ ui64_2 + 2, si64_2 + 2, f_2 + 2, d_2 + 2, ld_2 + 2, (char*)((intptr_t)p_2 + 2),
126
+ ui8_3 + 3, si8_3 + 3, ui16_3 + 3, si16_3 + 3, ui32_3 + 3, si32_3 + 3,
127
+ ui64_3 + 3, si64_3 + 3, f_3 + 3, d_3 + 3, ld_3 + 3, (char*)((intptr_t)p_3 + 3),
128
+ ui8_4 + 4, si8_4 + 4, ui16_4 + 4, si16_4 + 4, ui32_4 + 4, si32_4 + 4,
129
+ ui64_4 + 4, si64_4 + 4, f_4 + 4, d_4 + 4, ld_4 + 4, (char*)((intptr_t)p_4 + 4),
130
+ ui8_5 + 5, si8_5 + 5};
131
+
132
+ printf("%hhu %hhd %hu %hd %u %d %" PRIu64 " %" PRId64 " %.0f %.0f %.0Lf %#lx "
133
+ "%hhu %hhd %hu %hd %u %d %" PRIu64 " %" PRId64 " %.0f %.0f %.0Lf %#lx "
134
+ "%hhu %hhd %hu %hd %u %d %" PRIu64 " %" PRId64 " %.0f %.0f %.0Lf %#lx "
135
+ "%hhu %hhd %hu %hd %u %d %" PRIu64 " %" PRId64 " %.0f %.0f %.0Lf %#lx %hhu %hhd: "
136
+ "%hhu %hhd %hu %hd %u %d %" PRIu64 " %" PRId64 " %.0f %.0f %.0Lf %#lx "
137
+ "%hhu %hhd %hu %hd %u %d %" PRIu64 " %" PRId64 " %.0f %.0f %.0Lf %#lx "
138
+ "%hhu %hhd %hu %hd %u %d %" PRIu64 " %" PRId64 " %.0f %.0f %.0Lf %#lx "
139
+ "%hhu %hhd %hu %hd %u %d %" PRIu64 " %" PRId64 " %.0f %.0f %.0Lf %#lx %hhu %hhd\n",
140
+ ui8_1, si8_1, ui16_1, si16_1, ui32_1, si32_1, ui64_1, si64_1, f_1, d_1, ld_1, (unsigned long)p_1,
141
+ ui8_2, si8_2, ui16_2, si16_2, ui32_2, si32_2, ui64_2, si64_2, f_2, d_2, ld_2, (unsigned long)p_2,
142
+ ui8_3, si8_3, ui16_3, si16_3, ui32_3, si32_3, ui64_3, si64_3, f_3, d_3, ld_3, (unsigned long)p_3,
143
+ ui8_4, si8_4, ui16_4, si16_4, ui32_4, si32_4, ui64_4, si64_4, f_4, d_4, ld_4, (unsigned long)p_4, ui8_5, si8_5,
144
+ retVal.a, retVal.b, retVal.c, retVal.d, retVal.e, retVal.f,
145
+ retVal.g, retVal.h, retVal.i, retVal.j, retVal.k, (unsigned long)retVal.l,
146
+ retVal.m, retVal.n, retVal.o, retVal.p, retVal.q, retVal.r,
147
+ retVal.s, retVal.t, retVal.u, retVal.v, retVal.w, (unsigned long)retVal.x,
148
+ retVal.y, retVal.z, retVal.aa, retVal.bb, retVal.cc, retVal.dd,
149
+ retVal.ee, retVal.ff, retVal.gg, retVal.hh, retVal.ii, (unsigned long)retVal.jj,
150
+ retVal.kk, retVal.ll, retVal.mm, retVal.nn, retVal.oo, retVal.pp,
151
+ retVal.qq, retVal.rr, retVal.ss, retVal.tt, retVal.uu, (unsigned long)retVal.vv, retVal.ww, retVal.xx);
152
+
153
+ return retVal;
154
+ }
155
+
156
+ static void
157
+ cls_large_fn(ffi_cif* cif __UNUSED__, void* resp, void** args, void* userdata __UNUSED__)
158
+ {
159
+ uint8_t ui8_1 = *(uint8_t*)args[0];
160
+ int8_t si8_1 = *(int8_t*)args[1];
161
+ uint16_t ui16_1 = *(uint16_t*)args[2];
162
+ int16_t si16_1 = *(int16_t*)args[3];
163
+ uint32_t ui32_1 = *(uint32_t*)args[4];
164
+ int32_t si32_1 = *(int32_t*)args[5];
165
+ uint64_t ui64_1 = *(uint64_t*)args[6];
166
+ int64_t si64_1 = *(int64_t*)args[7];
167
+ float f_1 = *(float*)args[8];
168
+ double d_1 = *(double*)args[9];
169
+ long double ld_1 = *(long double*)args[10];
170
+ char* p_1 = *(char**)args[11];
171
+ uint8_t ui8_2 = *(uint8_t*)args[12];
172
+ int8_t si8_2 = *(int8_t*)args[13];
173
+ uint16_t ui16_2 = *(uint16_t*)args[14];
174
+ int16_t si16_2 = *(int16_t*)args[15];
175
+ uint32_t ui32_2 = *(uint32_t*)args[16];
176
+ int32_t si32_2 = *(int32_t*)args[17];
177
+ uint64_t ui64_2 = *(uint64_t*)args[18];
178
+ int64_t si64_2 = *(int64_t*)args[19];
179
+ float f_2 = *(float*)args[20];
180
+ double d_2 = *(double*)args[21];
181
+ long double ld_2 = *(long double*)args[22];
182
+ char* p_2 = *(char**)args[23];
183
+ uint8_t ui8_3 = *(uint8_t*)args[24];
184
+ int8_t si8_3 = *(int8_t*)args[25];
185
+ uint16_t ui16_3 = *(uint16_t*)args[26];
186
+ int16_t si16_3 = *(int16_t*)args[27];
187
+ uint32_t ui32_3 = *(uint32_t*)args[28];
188
+ int32_t si32_3 = *(int32_t*)args[29];
189
+ uint64_t ui64_3 = *(uint64_t*)args[30];
190
+ int64_t si64_3 = *(int64_t*)args[31];
191
+ float f_3 = *(float*)args[32];
192
+ double d_3 = *(double*)args[33];
193
+ long double ld_3 = *(long double*)args[34];
194
+ char* p_3 = *(char**)args[35];
195
+ uint8_t ui8_4 = *(uint8_t*)args[36];
196
+ int8_t si8_4 = *(int8_t*)args[37];
197
+ uint16_t ui16_4 = *(uint16_t*)args[38];
198
+ int16_t si16_4 = *(int16_t*)args[39];
199
+ uint32_t ui32_4 = *(uint32_t*)args[40];
200
+ int32_t si32_4 = *(int32_t*)args[41];
201
+ uint64_t ui64_4 = *(uint64_t*)args[42];
202
+ int64_t si64_4 = *(int64_t*)args[43];
203
+ float f_4 = *(float*)args[44];
204
+ double d_4 = *(double*)args[45];
205
+ long double ld_4 = *(long double*)args[46];
206
+ char* p_4 = *(char**)args[47];
207
+ uint8_t ui8_5 = *(uint8_t*)args[48];
208
+ int8_t si8_5 = *(int8_t*)args[49];
209
+
210
+ *(BigStruct*)resp = test_large_fn(
211
+ ui8_1, si8_1, ui16_1, si16_1, ui32_1, si32_1, ui64_1, si64_1, f_1, d_1, ld_1, p_1,
212
+ ui8_2, si8_2, ui16_2, si16_2, ui32_2, si32_2, ui64_2, si64_2, f_2, d_2, ld_2, p_2,
213
+ ui8_3, si8_3, ui16_3, si16_3, ui32_3, si32_3, ui64_3, si64_3, f_3, d_3, ld_3, p_3,
214
+ ui8_4, si8_4, ui16_4, si16_4, ui32_4, si32_4, ui64_4, si64_4, f_4, d_4, ld_4, p_4,
215
+ ui8_5, si8_5);
216
+ }
217
+
218
+ int
219
+ main(int argc __UNUSED__, const char** argv __UNUSED__)
220
+ {
221
+ void *code;
222
+ ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code);
223
+
224
+ ffi_cif cif;
225
+ ffi_type* argTypes[51];
226
+ void* argValues[51];
227
+
228
+ ffi_type ret_struct_type;
229
+ ffi_type* st_fields[51];
230
+ BigStruct retVal;
231
+
232
+ memset (&retVal, 0, sizeof(retVal));
233
+
234
+ ret_struct_type.size = 0;
235
+ ret_struct_type.alignment = 0;
236
+ ret_struct_type.type = FFI_TYPE_STRUCT;
237
+ ret_struct_type.elements = st_fields;
238
+
239
+ st_fields[0] = st_fields[12] = st_fields[24] = st_fields[36] = st_fields[48] = &ffi_type_uint8;
240
+ st_fields[1] = st_fields[13] = st_fields[25] = st_fields[37] = st_fields[49] = &ffi_type_sint8;
241
+ st_fields[2] = st_fields[14] = st_fields[26] = st_fields[38] = &ffi_type_uint16;
242
+ st_fields[3] = st_fields[15] = st_fields[27] = st_fields[39] = &ffi_type_sint16;
243
+ st_fields[4] = st_fields[16] = st_fields[28] = st_fields[40] = &ffi_type_uint32;
244
+ st_fields[5] = st_fields[17] = st_fields[29] = st_fields[41] = &ffi_type_sint32;
245
+ st_fields[6] = st_fields[18] = st_fields[30] = st_fields[42] = &ffi_type_uint64;
246
+ st_fields[7] = st_fields[19] = st_fields[31] = st_fields[43] = &ffi_type_sint64;
247
+ st_fields[8] = st_fields[20] = st_fields[32] = st_fields[44] = &ffi_type_float;
248
+ st_fields[9] = st_fields[21] = st_fields[33] = st_fields[45] = &ffi_type_double;
249
+ st_fields[10] = st_fields[22] = st_fields[34] = st_fields[46] = &ffi_type_longdouble;
250
+ st_fields[11] = st_fields[23] = st_fields[35] = st_fields[47] = &ffi_type_pointer;
251
+
252
+ st_fields[50] = NULL;
253
+
254
+ uint8_t ui8 = 1;
255
+ int8_t si8 = 2;
256
+ uint16_t ui16 = 3;
257
+ int16_t si16 = 4;
258
+ uint32_t ui32 = 5;
259
+ int32_t si32 = 6;
260
+ uint64_t ui64 = 7;
261
+ int64_t si64 = 8;
262
+ float f = 9;
263
+ double d = 10;
264
+ long double ld = 11;
265
+ char* p = (char*)0x12345678;
266
+
267
+ argTypes[0] = argTypes[12] = argTypes[24] = argTypes[36] = argTypes[48] = &ffi_type_uint8;
268
+ argValues[0] = argValues[12] = argValues[24] = argValues[36] = argValues[48] = &ui8;
269
+ argTypes[1] = argTypes[13] = argTypes[25] = argTypes[37] = argTypes[49] = &ffi_type_sint8;
270
+ argValues[1] = argValues[13] = argValues[25] = argValues[37] = argValues[49] = &si8;
271
+ argTypes[2] = argTypes[14] = argTypes[26] = argTypes[38] = &ffi_type_uint16;
272
+ argValues[2] = argValues[14] = argValues[26] = argValues[38] = &ui16;
273
+ argTypes[3] = argTypes[15] = argTypes[27] = argTypes[39] = &ffi_type_sint16;
274
+ argValues[3] = argValues[15] = argValues[27] = argValues[39] = &si16;
275
+ argTypes[4] = argTypes[16] = argTypes[28] = argTypes[40] = &ffi_type_uint32;
276
+ argValues[4] = argValues[16] = argValues[28] = argValues[40] = &ui32;
277
+ argTypes[5] = argTypes[17] = argTypes[29] = argTypes[41] = &ffi_type_sint32;
278
+ argValues[5] = argValues[17] = argValues[29] = argValues[41] = &si32;
279
+ argTypes[6] = argTypes[18] = argTypes[30] = argTypes[42] = &ffi_type_uint64;
280
+ argValues[6] = argValues[18] = argValues[30] = argValues[42] = &ui64;
281
+ argTypes[7] = argTypes[19] = argTypes[31] = argTypes[43] = &ffi_type_sint64;
282
+ argValues[7] = argValues[19] = argValues[31] = argValues[43] = &si64;
283
+ argTypes[8] = argTypes[20] = argTypes[32] = argTypes[44] = &ffi_type_float;
284
+ argValues[8] = argValues[20] = argValues[32] = argValues[44] = &f;
285
+ argTypes[9] = argTypes[21] = argTypes[33] = argTypes[45] = &ffi_type_double;
286
+ argValues[9] = argValues[21] = argValues[33] = argValues[45] = &d;
287
+ argTypes[10] = argTypes[22] = argTypes[34] = argTypes[46] = &ffi_type_longdouble;
288
+ argValues[10] = argValues[22] = argValues[34] = argValues[46] = &ld;
289
+ argTypes[11] = argTypes[23] = argTypes[35] = argTypes[47] = &ffi_type_pointer;
290
+ argValues[11] = argValues[23] = argValues[35] = argValues[47] = &p;
291
+
292
+ argTypes[50] = NULL;
293
+ argValues[50] = NULL;
294
+
295
+ CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 50, &ret_struct_type, argTypes) == FFI_OK);
296
+
297
+ ffi_call(&cif, FFI_FN(test_large_fn), &retVal, argValues);
298
+ // { dg-output "1 2 3 4 5 6 7 8 9 10 11 0x12345678 1 2 3 4 5 6 7 8 9 10 11 0x12345678 1 2 3 4 5 6 7 8 9 10 11 0x12345678 1 2 3 4 5 6 7 8 9 10 11 0x12345678 1 2: 2 3 4 5 6 7 8 9 10 11 12 0x12345679 3 4 5 6 7 8 9 10 11 12 13 0x1234567a 4 5 6 7 8 9 10 11 12 13 14 0x1234567b 5 6 7 8 9 10 11 12 13 14 15 0x1234567c 6 7" }
299
+ printf("res: %hhu %hhd %hu %hd %u %d %" PRIu64 " %" PRId64 " %.0f %.0f %.0Lf %#lx "
300
+ "%hhu %hhd %hu %hd %u %d %" PRIu64 " %" PRId64 " %.0f %.0f %.0Lf %#lx "
301
+ "%hhu %hhd %hu %hd %u %d %" PRIu64 " %" PRId64 " %.0f %.0f %.0Lf %#lx "
302
+ "%hhu %hhd %hu %hd %u %d %" PRIu64 " %" PRId64 " %.0f %.0f %.0Lf %#lx %hhu %hhd\n",
303
+ retVal.a, retVal.b, retVal.c, retVal.d, retVal.e, retVal.f,
304
+ retVal.g, retVal.h, retVal.i, retVal.j, retVal.k, (unsigned long)retVal.l,
305
+ retVal.m, retVal.n, retVal.o, retVal.p, retVal.q, retVal.r,
306
+ retVal.s, retVal.t, retVal.u, retVal.v, retVal.w, (unsigned long)retVal.x,
307
+ retVal.y, retVal.z, retVal.aa, retVal.bb, retVal.cc, retVal.dd,
308
+ retVal.ee, retVal.ff, retVal.gg, retVal.hh, retVal.ii, (unsigned long)retVal.jj,
309
+ retVal.kk, retVal.ll, retVal.mm, retVal.nn, retVal.oo, retVal.pp,
310
+ retVal.qq, retVal.rr, retVal.ss, retVal.tt, retVal.uu, (unsigned long)retVal.vv, retVal.ww, retVal.xx);
311
+ // { dg-output "\nres: 2 3 4 5 6 7 8 9 10 11 12 0x12345679 3 4 5 6 7 8 9 10 11 12 13 0x1234567a 4 5 6 7 8 9 10 11 12 13 14 0x1234567b 5 6 7 8 9 10 11 12 13 14 15 0x1234567c 6 7" }
312
+
313
+ CHECK(ffi_prep_closure_loc(pcl, &cif, cls_large_fn, NULL, code) == FFI_OK);
314
+
315
+ retVal = ((BigStruct(*)(
316
+ uint8_t, int8_t, uint16_t, int16_t, uint32_t, int32_t, uint64_t, int64_t, float, double, long double, char*,
317
+ uint8_t, int8_t, uint16_t, int16_t, uint32_t, int32_t, uint64_t, int64_t, float, double, long double, char*,
318
+ uint8_t, int8_t, uint16_t, int16_t, uint32_t, int32_t, uint64_t, int64_t, float, double, long double, char*,
319
+ uint8_t, int8_t, uint16_t, int16_t, uint32_t, int32_t, uint64_t, int64_t, float, double, long double, char*,
320
+ uint8_t, int8_t))(code))(
321
+ ui8, si8, ui16, si16, ui32, si32, ui64, si64, f, d, ld, p,
322
+ ui8, si8, ui16, si16, ui32, si32, ui64, si64, f, d, ld, p,
323
+ ui8, si8, ui16, si16, ui32, si32, ui64, si64, f, d, ld, p,
324
+ ui8, si8, ui16, si16, ui32, si32, ui64, si64, f, d, ld, p,
325
+ ui8, si8);
326
+ // { dg-output "\n1 2 3 4 5 6 7 8 9 10 11 0x12345678 1 2 3 4 5 6 7 8 9 10 11 0x12345678 1 2 3 4 5 6 7 8 9 10 11 0x12345678 1 2 3 4 5 6 7 8 9 10 11 0x12345678 1 2: 2 3 4 5 6 7 8 9 10 11 12 0x12345679 3 4 5 6 7 8 9 10 11 12 13 0x1234567a 4 5 6 7 8 9 10 11 12 13 14 0x1234567b 5 6 7 8 9 10 11 12 13 14 15 0x1234567c 6 7" }
327
+ printf("res: %hhu %hhd %hu %hd %u %d %" PRIu64 " %" PRId64 " %.0f %.0f %.0Lf %#lx "
328
+ "%hhu %hhd %hu %hd %u %d %" PRIu64 " %" PRId64 " %.0f %.0f %.0Lf %#lx "
329
+ "%hhu %hhd %hu %hd %u %d %" PRIu64 " %" PRId64 " %.0f %.0f %.0Lf %#lx "
330
+ "%hhu %hhd %hu %hd %u %d %" PRIu64 " %" PRId64 " %.0f %.0f %.0Lf %#lx %hhu %hhd\n",
331
+ retVal.a, retVal.b, retVal.c, retVal.d, retVal.e, retVal.f,
332
+ retVal.g, retVal.h, retVal.i, retVal.j, retVal.k, (unsigned long)retVal.l,
333
+ retVal.m, retVal.n, retVal.o, retVal.p, retVal.q, retVal.r,
334
+ retVal.s, retVal.t, retVal.u, retVal.v, retVal.w, (unsigned long)retVal.x,
335
+ retVal.y, retVal.z, retVal.aa, retVal.bb, retVal.cc, retVal.dd,
336
+ retVal.ee, retVal.ff, retVal.gg, retVal.hh, retVal.ii, (unsigned long)retVal.jj,
337
+ retVal.kk, retVal.ll, retVal.mm, retVal.nn, retVal.oo, retVal.pp,
338
+ retVal.qq, retVal.rr, retVal.ss, retVal.tt, retVal.uu, (unsigned long)retVal.vv, retVal.ww, retVal.xx);
339
+ // { dg-output "\nres: 2 3 4 5 6 7 8 9 10 11 12 0x12345679 3 4 5 6 7 8 9 10 11 12 13 0x1234567a 4 5 6 7 8 9 10 11 12 13 14 0x1234567b 5 6 7 8 9 10 11 12 13 14 15 0x1234567c 6 7" }
340
+
341
+ return 0;
342
+ }