ffi 0.5.4-x86-mingw32 → 0.6.3-x86-mingw32

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 (222) hide show
  1. data/History.txt +102 -0
  2. data/LICENSE +1 -27
  3. data/Rakefile +4 -12
  4. data/ext/ffi_c/AbstractMemory.c +6 -8
  5. data/ext/ffi_c/AbstractMemory.h +23 -21
  6. data/ext/ffi_c/AutoPointer.c +0 -1
  7. data/ext/ffi_c/Buffer.c +23 -8
  8. data/ext/ffi_c/Call.c +31 -3
  9. data/ext/ffi_c/Call.h +5 -1
  10. data/ext/ffi_c/DynamicLibrary.c +0 -1
  11. data/ext/ffi_c/Function.c +22 -4
  12. data/ext/ffi_c/MemoryPointer.c +2 -3
  13. data/ext/ffi_c/Pointer.c +23 -9
  14. data/ext/ffi_c/Struct.c +227 -79
  15. data/ext/ffi_c/Struct.h +16 -7
  16. data/ext/ffi_c/StructLayout.c +92 -55
  17. data/ext/ffi_c/Type.c +5 -22
  18. data/ext/ffi_c/Type.h +1 -1
  19. data/ext/ffi_c/Types.c +9 -3
  20. data/ext/ffi_c/Types.h +2 -0
  21. data/ext/ffi_c/extconf.rb +11 -7
  22. data/ext/ffi_c/libffi.gnu.mk +1 -1
  23. data/ext/ffi_c/libffi.mk +1 -1
  24. data/ext/ffi_c/libffi/ChangeLog +900 -84
  25. data/ext/ffi_c/libffi/ChangeLog.libffi +311 -0
  26. data/ext/ffi_c/libffi/LICENSE +1 -1
  27. data/ext/ffi_c/libffi/Makefile.am +14 -4
  28. data/ext/ffi_c/libffi/Makefile.in +362 -211
  29. data/ext/ffi_c/libffi/README +70 -92
  30. data/ext/ffi_c/libffi/aclocal.m4 +6068 -4586
  31. data/ext/ffi_c/libffi/config.guess +125 -143
  32. data/ext/ffi_c/libffi/config.sub +103 -27
  33. data/ext/ffi_c/libffi/configure +11340 -18473
  34. data/ext/ffi_c/libffi/configure.ac +43 -4
  35. data/ext/ffi_c/libffi/doc/libffi.info +15 -15
  36. data/ext/ffi_c/libffi/doc/libffi.texi +1 -1
  37. data/ext/ffi_c/libffi/doc/stamp-vti +4 -4
  38. data/ext/ffi_c/libffi/doc/version.texi +4 -4
  39. data/ext/ffi_c/libffi/fficonfig.h.in +24 -3
  40. data/ext/ffi_c/libffi/include/Makefile.am +1 -1
  41. data/ext/ffi_c/libffi/include/Makefile.in +97 -50
  42. data/ext/ffi_c/libffi/include/ffi.h.in +8 -2
  43. data/ext/ffi_c/libffi/include/ffi_common.h +24 -0
  44. data/ext/ffi_c/libffi/libtool-version +1 -1
  45. data/ext/ffi_c/libffi/ltmain.sh +7346 -5870
  46. data/ext/ffi_c/libffi/m4/libtool.m4 +7360 -0
  47. data/ext/ffi_c/libffi/m4/ltoptions.m4 +368 -0
  48. data/ext/ffi_c/libffi/m4/ltsugar.m4 +123 -0
  49. data/ext/ffi_c/libffi/m4/ltversion.m4 +23 -0
  50. data/ext/ffi_c/libffi/m4/lt~obsolete.m4 +92 -0
  51. data/ext/ffi_c/libffi/man/Makefile.in +115 -62
  52. data/ext/ffi_c/libffi/man/ffi_call.3 +3 -3
  53. data/ext/ffi_c/libffi/missing +15 -8
  54. data/ext/ffi_c/libffi/src/arm/sysv.S +15 -8
  55. data/ext/ffi_c/libffi/src/avr32/ffi.c +421 -0
  56. data/ext/ffi_c/libffi/src/avr32/ffitarget.h +50 -0
  57. data/ext/ffi_c/libffi/src/avr32/sysv.S +208 -0
  58. data/ext/ffi_c/libffi/src/closures.c +47 -10
  59. data/ext/ffi_c/libffi/src/frv/ffi.c +1 -1
  60. data/ext/ffi_c/libffi/src/java_raw_api.c +0 -3
  61. data/ext/ffi_c/libffi/src/mips/ffi.c +135 -32
  62. data/ext/ffi_c/libffi/src/mips/ffitarget.h +37 -4
  63. data/ext/ffi_c/libffi/src/mips/n32.S +67 -10
  64. data/ext/ffi_c/libffi/src/mips/o32.S +8 -8
  65. data/ext/ffi_c/libffi/src/pa/ffi.c +7 -0
  66. data/ext/ffi_c/libffi/src/powerpc/aix.S +163 -64
  67. data/ext/ffi_c/libffi/src/powerpc/aix_closure.S +308 -112
  68. data/ext/ffi_c/libffi/src/powerpc/ffi.c +20 -7
  69. data/ext/ffi_c/libffi/src/powerpc/ffi_darwin.c +208 -80
  70. data/ext/ffi_c/libffi/src/powerpc/ffitarget.h +11 -3
  71. data/ext/ffi_c/libffi/src/powerpc/sysv.S +12 -23
  72. data/ext/ffi_c/libffi/src/s390/sysv.S +1 -1
  73. data/ext/ffi_c/libffi/src/sh/sysv.S +9 -9
  74. data/ext/ffi_c/libffi/src/sh64/ffi.c +37 -22
  75. data/ext/ffi_c/libffi/src/sh64/sysv.S +23 -14
  76. data/ext/ffi_c/libffi/src/sparc/ffi.c +21 -6
  77. data/ext/ffi_c/libffi/src/sparc/v8.S +55 -14
  78. data/ext/ffi_c/libffi/src/x86/darwin.S +10 -9
  79. data/ext/ffi_c/libffi/src/x86/ffi.c +293 -86
  80. data/ext/ffi_c/libffi/src/x86/ffi64.c +73 -19
  81. data/ext/ffi_c/libffi/src/x86/ffitarget.h +30 -0
  82. data/ext/ffi_c/libffi/src/x86/sysv.S +21 -4
  83. data/ext/ffi_c/libffi/src/x86/unix64.S +8 -4
  84. data/ext/ffi_c/libffi/src/x86/win32.S +633 -147
  85. data/ext/ffi_c/libffi/src/x86/win64.S +460 -0
  86. data/ext/ffi_c/libffi/testsuite/Makefile.am +63 -54
  87. data/ext/ffi_c/libffi/testsuite/Makefile.in +112 -77
  88. data/ext/ffi_c/libffi/testsuite/lib/libffi-dg.exp +12 -1
  89. data/ext/ffi_c/libffi/testsuite/libffi.call/call.exp +4 -4
  90. data/ext/ffi_c/libffi/testsuite/libffi.call/closure_fn0.c +7 -15
  91. data/ext/ffi_c/libffi/testsuite/libffi.call/closure_fn1.c +7 -15
  92. data/ext/ffi_c/libffi/testsuite/libffi.call/closure_fn2.c +7 -15
  93. data/ext/ffi_c/libffi/testsuite/libffi.call/closure_fn3.c +7 -15
  94. data/ext/ffi_c/libffi/testsuite/libffi.call/closure_fn4.c +7 -15
  95. data/ext/ffi_c/libffi/testsuite/libffi.call/closure_fn5.c +7 -14
  96. data/ext/ffi_c/libffi/testsuite/libffi.call/closure_fn6.c +7 -15
  97. data/ext/ffi_c/libffi/testsuite/libffi.call/closure_loc_fn0.c +95 -0
  98. data/ext/ffi_c/libffi/testsuite/libffi.call/closure_stdcall.c +6 -14
  99. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_12byte.c +4 -12
  100. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_16byte.c +4 -12
  101. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_18byte.c +4 -12
  102. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_19byte.c +4 -12
  103. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_1_1byte.c +4 -12
  104. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_20byte.c +4 -12
  105. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_20byte1.c +4 -12
  106. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_24byte.c +4 -12
  107. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_2byte.c +4 -12
  108. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_3_1byte.c +4 -12
  109. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_3byte1.c +4 -12
  110. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_3byte2.c +4 -12
  111. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_4_1byte.c +4 -12
  112. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_4byte.c +4 -12
  113. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_5_1_byte.c +4 -12
  114. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_5byte.c +4 -12
  115. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_64byte.c +4 -12
  116. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_6_1_byte.c +4 -12
  117. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_6byte.c +4 -12
  118. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_7_1_byte.c +4 -12
  119. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_7byte.c +4 -12
  120. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_8byte.c +4 -12
  121. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_9byte1.c +4 -12
  122. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_9byte2.c +4 -12
  123. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_align_double.c +4 -12
  124. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_align_float.c +4 -12
  125. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_align_longdouble.c +4 -12
  126. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_align_longdouble_split.c +134 -0
  127. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_align_longdouble_split2.c +117 -0
  128. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_align_pointer.c +11 -17
  129. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_align_sint16.c +4 -12
  130. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_align_sint32.c +4 -12
  131. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_align_sint64.c +7 -15
  132. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_align_uint16.c +4 -12
  133. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_align_uint32.c +4 -12
  134. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_align_uint64.c +7 -15
  135. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_dbls_struct.c +66 -0
  136. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_double.c +4 -12
  137. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_double_va.c +57 -0
  138. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_float.c +4 -13
  139. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_longdouble.c +105 -0
  140. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_longdouble_va.c +57 -0
  141. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_multi_schar.c +4 -12
  142. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_multi_sshort.c +4 -12
  143. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_multi_sshortchar.c +4 -12
  144. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_multi_uchar.c +4 -12
  145. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_multi_ushort.c +4 -12
  146. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_multi_ushortchar.c +4 -12
  147. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_pointer.c +74 -0
  148. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_pointer_stack.c +140 -0
  149. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_schar.c +4 -12
  150. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_sint.c +4 -12
  151. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_sshort.c +4 -12
  152. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_uchar.c +4 -12
  153. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_uint.c +4 -12
  154. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_ulonglong.c +8 -16
  155. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_ushort.c +4 -12
  156. data/ext/ffi_c/libffi/testsuite/libffi.call/err_bad_abi.c +37 -0
  157. data/ext/ffi_c/libffi/testsuite/libffi.call/err_bad_typedef.c +25 -0
  158. data/ext/ffi_c/libffi/testsuite/libffi.call/ffitest.h +31 -0
  159. data/ext/ffi_c/libffi/testsuite/libffi.call/float2.c +2 -1
  160. data/ext/ffi_c/libffi/testsuite/libffi.call/huge_struct.c +342 -0
  161. data/ext/ffi_c/libffi/testsuite/libffi.call/nested_struct.c +4 -12
  162. data/ext/ffi_c/libffi/testsuite/libffi.call/nested_struct1.c +4 -12
  163. data/ext/ffi_c/libffi/testsuite/libffi.call/nested_struct10.c +4 -12
  164. data/ext/ffi_c/libffi/testsuite/libffi.call/nested_struct2.c +4 -12
  165. data/ext/ffi_c/libffi/testsuite/libffi.call/nested_struct3.c +4 -12
  166. data/ext/ffi_c/libffi/testsuite/libffi.call/nested_struct4.c +4 -12
  167. data/ext/ffi_c/libffi/testsuite/libffi.call/nested_struct5.c +4 -12
  168. data/ext/ffi_c/libffi/testsuite/libffi.call/nested_struct6.c +4 -12
  169. data/ext/ffi_c/libffi/testsuite/libffi.call/nested_struct7.c +4 -12
  170. data/ext/ffi_c/libffi/testsuite/libffi.call/nested_struct8.c +4 -12
  171. data/ext/ffi_c/libffi/testsuite/libffi.call/nested_struct9.c +4 -12
  172. data/ext/ffi_c/libffi/testsuite/libffi.call/problem1.c +4 -12
  173. data/ext/ffi_c/libffi/testsuite/libffi.call/return_ldl.c +1 -1
  174. data/ext/ffi_c/libffi/testsuite/libffi.call/return_ll1.c +1 -1
  175. data/ext/ffi_c/libffi/testsuite/libffi.call/stret_large.c +145 -0
  176. data/ext/ffi_c/libffi/testsuite/libffi.call/stret_large2.c +148 -0
  177. data/ext/ffi_c/libffi/testsuite/libffi.call/stret_medium.c +124 -0
  178. data/ext/ffi_c/libffi/testsuite/libffi.call/stret_medium2.c +124 -0
  179. data/ext/ffi_c/libffi/testsuite/libffi.call/testclosure.c +70 -0
  180. data/ext/ffi_c/libffi/testsuite/libffi.special/ffitestcxx.h +10 -0
  181. data/ext/ffi_c/libffi/testsuite/libffi.special/special.exp +4 -5
  182. data/ext/ffi_c/libffi/testsuite/libffi.special/unwindtest.cc +17 -16
  183. data/ext/ffi_c/libffi/texinfo.tex +155 -427
  184. data/gen/Rakefile +4 -2
  185. data/lib/1.8/ffi_c.so +0 -0
  186. data/lib/1.9/ffi_c.so +0 -0
  187. data/lib/ffi/autopointer.rb +79 -20
  188. data/lib/ffi/callback.rb +4 -10
  189. data/lib/ffi/enum.rb +28 -0
  190. data/lib/ffi/ffi.rb +1 -0
  191. data/lib/ffi/io.rb +28 -0
  192. data/lib/ffi/library.rb +237 -182
  193. data/lib/ffi/memorypointer.rb +28 -62
  194. data/lib/ffi/platform.rb +27 -0
  195. data/lib/ffi/pointer.rb +28 -0
  196. data/lib/ffi/struct.rb +55 -1
  197. data/lib/ffi/types.rb +29 -0
  198. data/lib/ffi/variadic.rb +29 -0
  199. data/spec/ffi/library_spec.rb +31 -5
  200. data/spec/ffi/rbx/attach_function_spec.rb +2 -1
  201. data/spec/ffi/rbx/memory_pointer_spec.rb +2 -1
  202. data/spec/ffi/spec_helper.rb +5 -1
  203. data/spec/ffi/struct_spec.rb +82 -0
  204. data/tasks/ann.rake +80 -0
  205. data/tasks/extension.rake +25 -0
  206. data/tasks/gem.rake +200 -0
  207. data/tasks/git.rake +41 -0
  208. data/tasks/notes.rake +27 -0
  209. data/tasks/post_load.rake +34 -0
  210. data/tasks/rdoc.rake +50 -0
  211. data/tasks/rubyforge.rake +55 -0
  212. data/tasks/setup.rb +300 -0
  213. data/tasks/spec.rake +54 -0
  214. data/tasks/svn.rake +47 -0
  215. data/tasks/test.rake +40 -0
  216. metadata +312 -279
  217. data/ext/ffi_c/libffi/TODO +0 -1
  218. data/ext/ffi_c/libffi/ltcf-c.sh +0 -861
  219. data/ext/ffi_c/libffi/ltcf-cxx.sh +0 -1069
  220. data/ext/ffi_c/libffi/ltcf-gcj.sh +0 -700
  221. data/ext/ffi_c/libffi/ltconfig +0 -2862
  222. data/ext/ffi_c/libffi/mkinstalldirs +0 -158
@@ -0,0 +1,57 @@
1
+ /* Area: ffi_call, closure_call
2
+ Purpose: Test long doubles passed in variable argument lists.
3
+ Limitations: none.
4
+ PR: none.
5
+ Originator: Blake Chaffin 6/6/2007 */
6
+
7
+ /* { dg-do run { xfail strongarm*-*-* xscale*-*-* } } */
8
+ /* { dg-output "" { xfail avr32*-*-* x86_64-*-mingw* } } */
9
+ #include "ffitest.h"
10
+
11
+ static void
12
+ cls_longdouble_va_fn(ffi_cif* cif __UNUSED__, void* resp,
13
+ void** args, void* userdata __UNUSED__)
14
+ {
15
+ char* format = *(char**)args[0];
16
+ long double ldValue = *(long double*)args[1];
17
+
18
+ *(ffi_arg*)resp = printf(format, ldValue);
19
+ }
20
+
21
+ int main (void)
22
+ {
23
+ ffi_cif cif;
24
+ void *code;
25
+ ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code);
26
+ void* args[3];
27
+ ffi_type* arg_types[3];
28
+
29
+ char* format = "%.1Lf\n";
30
+ long double ldArg = 7;
31
+ ffi_arg res = 0;
32
+
33
+ arg_types[0] = &ffi_type_pointer;
34
+ arg_types[1] = &ffi_type_longdouble;
35
+ arg_types[2] = NULL;
36
+
37
+ CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 2, &ffi_type_sint,
38
+ arg_types) == FFI_OK);
39
+
40
+ args[0] = &format;
41
+ args[1] = &ldArg;
42
+ args[2] = NULL;
43
+
44
+ ffi_call(&cif, FFI_FN(printf), &res, args);
45
+ // { dg-output "7.0" }
46
+ printf("res: %d\n", (int) res);
47
+ // { dg-output "\nres: 4" }
48
+
49
+ CHECK(ffi_prep_closure_loc(pcl, &cif, cls_longdouble_va_fn, NULL, code) == FFI_OK);
50
+
51
+ res = ((int(*)(char*, long double))(code))(format, ldArg);
52
+ // { dg-output "\n7.0" }
53
+ printf("res: %d\n", (int) res);
54
+ // { dg-output "\nres: 4" }
55
+
56
+ exit(0);
57
+ }
@@ -36,21 +36,13 @@ typedef signed char (*test_type)(signed char, signed char);
36
36
  int main (void)
37
37
  {
38
38
  ffi_cif cif;
39
- #ifndef USING_MMAP
40
- static ffi_closure cl;
41
- #endif
42
- ffi_closure *pcl;
39
+ void *code;
40
+ ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code);
43
41
  void * args_dbl[3];
44
42
  ffi_type * cl_arg_types[3];
45
43
  ffi_arg res_call;
46
44
  signed char a, b, res_closure;
47
45
 
48
- #ifdef USING_MMAP
49
- pcl = allocate_mmap (sizeof(ffi_closure));
50
- #else
51
- pcl = &cl;
52
- #endif
53
-
54
46
  a = 2;
55
47
  b = 125;
56
48
 
@@ -71,9 +63,9 @@ int main (void)
71
63
  printf("res: %d\n", (signed char)res_call);
72
64
  /* { dg-output "\nres: 127" } */
73
65
 
74
- CHECK(ffi_prep_closure(pcl, &cif, test_func_gn, NULL) == FFI_OK);
66
+ CHECK(ffi_prep_closure_loc(pcl, &cif, test_func_gn, NULL, code) == FFI_OK);
75
67
 
76
- res_closure = (*((test_type)pcl))(2, 125);
68
+ res_closure = (*((test_type)code))(2, 125);
77
69
  /* { dg-output "\n2 125: 127" } */
78
70
  printf("res: %d\n", res_closure);
79
71
  /* { dg-output "\nres: 127" } */
@@ -36,21 +36,13 @@ typedef signed short (*test_type)(signed short, signed short);
36
36
  int main (void)
37
37
  {
38
38
  ffi_cif cif;
39
- #ifndef USING_MMAP
40
- static ffi_closure cl;
41
- #endif
42
- ffi_closure *pcl;
39
+ void *code;
40
+ ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code);
43
41
  void * args_dbl[3];
44
42
  ffi_type * cl_arg_types[3];
45
43
  ffi_arg res_call;
46
44
  unsigned short a, b, res_closure;
47
45
 
48
- #ifdef USING_MMAP
49
- pcl = allocate_mmap (sizeof(ffi_closure));
50
- #else
51
- pcl = &cl;
52
- #endif
53
-
54
46
  a = 2;
55
47
  b = 32765;
56
48
 
@@ -71,9 +63,9 @@ int main (void)
71
63
  printf("res: %d\n", (unsigned short)res_call);
72
64
  /* { dg-output "\nres: 32767" } */
73
65
 
74
- CHECK(ffi_prep_closure(pcl, &cif, test_func_gn, NULL) == FFI_OK);
66
+ CHECK(ffi_prep_closure_loc(pcl, &cif, test_func_gn, NULL, code) == FFI_OK);
75
67
 
76
- res_closure = (*((test_type)pcl))(2, 32765);
68
+ res_closure = (*((test_type)code))(2, 32765);
77
69
  /* { dg-output "\n2 32765: 32767" } */
78
70
  printf("res: %d\n", res_closure);
79
71
  /* { dg-output "\nres: 32767" } */
@@ -41,22 +41,14 @@ typedef signed short (*test_type)(signed char, signed short,
41
41
  int main (void)
42
42
  {
43
43
  ffi_cif cif;
44
- #ifndef USING_MMAP
45
- static ffi_closure cl;
46
- #endif
47
- ffi_closure *pcl;
44
+ void *code;
45
+ ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code);
48
46
  void * args_dbl[5];
49
47
  ffi_type * cl_arg_types[5];
50
48
  ffi_arg res_call;
51
49
  signed char a, c;
52
50
  signed short b, d, res_closure;
53
51
 
54
- #ifdef USING_MMAP
55
- pcl = allocate_mmap (sizeof(ffi_closure));
56
- #else
57
- pcl = &cl;
58
- #endif
59
-
60
52
  a = 1;
61
53
  b = 32765;
62
54
  c = 127;
@@ -83,9 +75,9 @@ int main (void)
83
75
  printf("res: %d\n", (signed short)res_call);
84
76
  /* { dg-output "\nres: 32765" } */
85
77
 
86
- CHECK(ffi_prep_closure(pcl, &cif, test_func_gn, NULL) == FFI_OK);
78
+ CHECK(ffi_prep_closure_loc(pcl, &cif, test_func_gn, NULL, code) == FFI_OK);
87
79
 
88
- res_closure = (*((test_type)pcl))(1, 32765, 127, -128);
80
+ res_closure = (*((test_type)code))(1, 32765, 127, -128);
89
81
  /* { dg-output "\n1 32765 127 -128: 32765" } */
90
82
  printf("res: %d\n", res_closure);
91
83
  /* { dg-output "\nres: 32765" } */
@@ -47,21 +47,13 @@ void test_func(ffi_cif *cif __UNUSED__, void *rval __UNUSED__, void **avals,
47
47
  int main (void)
48
48
  {
49
49
  ffi_cif cif;
50
- #ifndef USING_MMAP
51
- static ffi_closure cl;
52
- #endif
53
- ffi_closure *pcl;
50
+ void *code;
51
+ ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code);
54
52
  void * args_dbl[5];
55
53
  ffi_type * cl_arg_types[5];
56
54
  ffi_arg res_call;
57
55
  unsigned char a, b, c, d, res_closure;
58
56
 
59
- #ifdef USING_MMAP
60
- pcl = allocate_mmap (sizeof(ffi_closure));
61
- #else
62
- pcl = &cl;
63
- #endif
64
-
65
57
  a = 1;
66
58
  b = 2;
67
59
  c = 127;
@@ -88,9 +80,9 @@ int main (void)
88
80
  printf("res: %d\n", (unsigned char)res_call);
89
81
  /* { dg-output "\nres: 255" } */
90
82
 
91
- CHECK(ffi_prep_closure(pcl, &cif, test_func_gn, NULL) == FFI_OK);
83
+ CHECK(ffi_prep_closure_loc(pcl, &cif, test_func_gn, NULL, code) == FFI_OK);
92
84
 
93
- res_closure = (*((test_type)pcl))(1, 2, 127, 125);
85
+ res_closure = (*((test_type)code))(1, 2, 127, 125);
94
86
  /* { dg-output "\n1 2 127 125: 255" } */
95
87
  printf("res: %d\n", res_closure);
96
88
  /* { dg-output "\nres: 255" } */
@@ -36,21 +36,13 @@ typedef unsigned short (*test_type)(unsigned short, unsigned short);
36
36
  int main (void)
37
37
  {
38
38
  ffi_cif cif;
39
- #ifndef USING_MMAP
40
- static ffi_closure cl;
41
- #endif
42
- ffi_closure *pcl;
39
+ void *code;
40
+ ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code);
43
41
  void * args_dbl[3];
44
42
  ffi_type * cl_arg_types[3];
45
43
  ffi_arg res_call;
46
44
  unsigned short a, b, res_closure;
47
45
 
48
- #ifdef USING_MMAP
49
- pcl = allocate_mmap (sizeof(ffi_closure));
50
- #else
51
- pcl = &cl;
52
- #endif
53
-
54
46
  a = 2;
55
47
  b = 32765;
56
48
 
@@ -71,9 +63,9 @@ int main (void)
71
63
  printf("res: %d\n", (unsigned short)res_call);
72
64
  /* { dg-output "\nres: 32767" } */
73
65
 
74
- CHECK(ffi_prep_closure(pcl, &cif, test_func_gn, NULL) == FFI_OK);
66
+ CHECK(ffi_prep_closure_loc(pcl, &cif, test_func_gn, NULL, code) == FFI_OK);
75
67
 
76
- res_closure = (*((test_type)pcl))(2, 32765);
68
+ res_closure = (*((test_type)code))(2, 32765);
77
69
  /* { dg-output "\n2 32765: 32767" } */
78
70
  printf("res: %d\n", res_closure);
79
71
  /* { dg-output "\nres: 32767" } */
@@ -41,22 +41,14 @@ typedef unsigned short (*test_type)(unsigned char, unsigned short,
41
41
  int main (void)
42
42
  {
43
43
  ffi_cif cif;
44
- #ifndef USING_MMAP
45
- static ffi_closure cl;
46
- #endif
47
- ffi_closure *pcl;
44
+ void *code;
45
+ ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code);
48
46
  void * args_dbl[5];
49
47
  ffi_type * cl_arg_types[5];
50
48
  ffi_arg res_call;
51
49
  unsigned char a, c;
52
50
  unsigned short b, d, res_closure;
53
51
 
54
- #ifdef USING_MMAP
55
- pcl = allocate_mmap (sizeof(ffi_closure));
56
- #else
57
- pcl = &cl;
58
- #endif
59
-
60
52
  a = 1;
61
53
  b = 2;
62
54
  c = 127;
@@ -83,9 +75,9 @@ int main (void)
83
75
  printf("res: %d\n", (unsigned short)res_call);
84
76
  /* { dg-output "\nres: 258" } */
85
77
 
86
- CHECK(ffi_prep_closure(pcl, &cif, test_func_gn, NULL) == FFI_OK);
78
+ CHECK(ffi_prep_closure_loc(pcl, &cif, test_func_gn, NULL, code) == FFI_OK);
87
79
 
88
- res_closure = (*((test_type)pcl))(1, 2, 127, 128);
80
+ res_closure = (*((test_type)code))(1, 2, 127, 128);
89
81
  /* { dg-output "\n1 2 127 128: 258" } */
90
82
  printf("res: %d\n", res_closure);
91
83
  /* { dg-output "\nres: 258" } */
@@ -0,0 +1,74 @@
1
+ /* Area: ffi_call, closure_call
2
+ Purpose: Check pointer arguments.
3
+ Limitations: none.
4
+ PR: none.
5
+ Originator: Blake Chaffin 6/6/2007 */
6
+
7
+ /* { dg-do run { xfail strongarm*-*-* xscale*-*-* } } */
8
+ #include "ffitest.h"
9
+
10
+ void* cls_pointer_fn(void* a1, void* a2)
11
+ {
12
+ void* result = (void*)((intptr_t)a1 + (intptr_t)a2);
13
+
14
+ printf("0x%08x 0x%08x: 0x%08x\n",
15
+ (unsigned int)(uintptr_t) a1,
16
+ (unsigned int)(uintptr_t) a2,
17
+ (unsigned int)(uintptr_t) result);
18
+
19
+ return result;
20
+ }
21
+
22
+ static void
23
+ cls_pointer_gn(ffi_cif* cif __UNUSED__, void* resp,
24
+ void** args, void* userdata __UNUSED__)
25
+ {
26
+ void* a1 = *(void**)(args[0]);
27
+ void* a2 = *(void**)(args[1]);
28
+
29
+ *(void**)resp = cls_pointer_fn(a1, a2);
30
+ }
31
+
32
+ int main (void)
33
+ {
34
+ ffi_cif cif;
35
+ void *code;
36
+ ffi_closure* pcl = ffi_closure_alloc(sizeof(ffi_closure), &code);
37
+ void* args[3];
38
+ // ffi_type cls_pointer_type;
39
+ ffi_type* arg_types[3];
40
+
41
+ /* cls_pointer_type.size = sizeof(void*);
42
+ cls_pointer_type.alignment = 0;
43
+ cls_pointer_type.type = FFI_TYPE_POINTER;
44
+ cls_pointer_type.elements = NULL;*/
45
+
46
+ void* arg1 = (void*)0x12345678;
47
+ void* arg2 = (void*)0x89abcdef;
48
+ ffi_arg res = 0;
49
+
50
+ arg_types[0] = &ffi_type_pointer;
51
+ arg_types[1] = &ffi_type_pointer;
52
+ arg_types[2] = NULL;
53
+
54
+ CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 2, &ffi_type_pointer,
55
+ arg_types) == FFI_OK);
56
+
57
+ args[0] = &arg1;
58
+ args[1] = &arg2;
59
+ args[2] = NULL;
60
+
61
+ ffi_call(&cif, FFI_FN(cls_pointer_fn), &res, args);
62
+ /* { dg-output "0x12345678 0x89abcdef: 0x9be02467" } */
63
+ printf("res: 0x%08x\n", (unsigned int) res);
64
+ /* { dg-output "\nres: 0x9be02467" } */
65
+
66
+ CHECK(ffi_prep_closure_loc(pcl, &cif, cls_pointer_gn, NULL, code) == FFI_OK);
67
+
68
+ res = (ffi_arg)((void*(*)(void*, void*))(code))(arg1, arg2);
69
+ /* { dg-output "\n0x12345678 0x89abcdef: 0x9be02467" } */
70
+ printf("res: 0x%08x\n", (unsigned int) res);
71
+ /* { dg-output "\nres: 0x9be02467" } */
72
+
73
+ exit(0);
74
+ }
@@ -0,0 +1,140 @@
1
+ /* Area: ffi_call, closure_call
2
+ Purpose: Check pointer arguments across multiple hideous stack frames.
3
+ Limitations: none.
4
+ PR: none.
5
+ Originator: Blake Chaffin 6/7/2007 */
6
+
7
+ /* { dg-do run { xfail strongarm*-*-* xscale*-*-* } } */
8
+ #include "ffitest.h"
9
+
10
+ static long dummyVar;
11
+
12
+ long dummy_func(
13
+ long double a1, char b1,
14
+ long double a2, char b2,
15
+ long double a3, char b3,
16
+ long double a4, char b4)
17
+ {
18
+ return a1 + b1 + a2 + b2 + a3 + b3 + a4 + b4;
19
+ }
20
+
21
+ void* cls_pointer_fn2(void* a1, void* a2)
22
+ {
23
+ long double trample1 = (intptr_t)a1 + (intptr_t)a2;
24
+ char trample2 = ((char*)&a1)[0] + ((char*)&a2)[0];
25
+ long double trample3 = (intptr_t)trample1 + (intptr_t)a1;
26
+ char trample4 = trample2 + ((char*)&a1)[1];
27
+ long double trample5 = (intptr_t)trample3 + (intptr_t)a2;
28
+ char trample6 = trample4 + ((char*)&a2)[1];
29
+ long double trample7 = (intptr_t)trample5 + (intptr_t)trample1;
30
+ char trample8 = trample6 + trample2;
31
+
32
+ dummyVar = dummy_func(trample1, trample2, trample3, trample4,
33
+ trample5, trample6, trample7, trample8);
34
+
35
+ void* result = (void*)((intptr_t)a1 + (intptr_t)a2);
36
+
37
+ printf("0x%08x 0x%08x: 0x%08x\n",
38
+ (unsigned int)(uintptr_t) a1,
39
+ (unsigned int)(uintptr_t) a2,
40
+ (unsigned int)(uintptr_t) result);
41
+
42
+ return result;
43
+ }
44
+
45
+ void* cls_pointer_fn1(void* a1, void* a2)
46
+ {
47
+ long double trample1 = (intptr_t)a1 + (intptr_t)a2;
48
+ char trample2 = ((char*)&a1)[0] + ((char*)&a2)[0];
49
+ long double trample3 = (intptr_t)trample1 + (intptr_t)a1;
50
+ char trample4 = trample2 + ((char*)&a1)[1];
51
+ long double trample5 = (intptr_t)trample3 + (intptr_t)a2;
52
+ char trample6 = trample4 + ((char*)&a2)[1];
53
+ long double trample7 = (intptr_t)trample5 + (intptr_t)trample1;
54
+ char trample8 = trample6 + trample2;
55
+
56
+ dummyVar = dummy_func(trample1, trample2, trample3, trample4,
57
+ trample5, trample6, trample7, trample8);
58
+
59
+ void* result = (void*)((intptr_t)a1 + (intptr_t)a2);
60
+
61
+ printf("0x%08x 0x%08x: 0x%08x\n",
62
+ (unsigned int)(intptr_t) a1,
63
+ (unsigned int)(intptr_t) a2,
64
+ (unsigned int)(intptr_t) result);
65
+
66
+ result = cls_pointer_fn2(result, a1);
67
+
68
+ return result;
69
+ }
70
+
71
+ static void
72
+ cls_pointer_gn(ffi_cif* cif __UNUSED__, void* resp,
73
+ void** args, void* userdata __UNUSED__)
74
+ {
75
+ void* a1 = *(void**)(args[0]);
76
+ void* a2 = *(void**)(args[1]);
77
+
78
+ long double trample1 = (intptr_t)a1 + (intptr_t)a2;
79
+ char trample2 = ((char*)&a1)[0] + ((char*)&a2)[0];
80
+ long double trample3 = (intptr_t)trample1 + (intptr_t)a1;
81
+ char trample4 = trample2 + ((char*)&a1)[1];
82
+ long double trample5 = (intptr_t)trample3 + (intptr_t)a2;
83
+ char trample6 = trample4 + ((char*)&a2)[1];
84
+ long double trample7 = (intptr_t)trample5 + (intptr_t)trample1;
85
+ char trample8 = trample6 + trample2;
86
+
87
+ dummyVar = dummy_func(trample1, trample2, trample3, trample4,
88
+ trample5, trample6, trample7, trample8);
89
+
90
+ *(void**)resp = cls_pointer_fn1(a1, a2);
91
+ }
92
+
93
+ int main (void)
94
+ {
95
+ ffi_cif cif;
96
+ void *code;
97
+ ffi_closure* pcl = ffi_closure_alloc(sizeof(ffi_closure), &code);
98
+ void* args[3];
99
+ // ffi_type cls_pointer_type;
100
+ ffi_type* arg_types[3];
101
+
102
+ /* cls_pointer_type.size = sizeof(void*);
103
+ cls_pointer_type.alignment = 0;
104
+ cls_pointer_type.type = FFI_TYPE_POINTER;
105
+ cls_pointer_type.elements = NULL;*/
106
+
107
+ void* arg1 = (void*)0x01234567;
108
+ void* arg2 = (void*)0x89abcdef;
109
+ ffi_arg res = 0;
110
+
111
+ arg_types[0] = &ffi_type_pointer;
112
+ arg_types[1] = &ffi_type_pointer;
113
+ arg_types[2] = NULL;
114
+
115
+ CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 2, &ffi_type_pointer,
116
+ arg_types) == FFI_OK);
117
+
118
+ args[0] = &arg1;
119
+ args[1] = &arg2;
120
+ args[2] = NULL;
121
+
122
+ printf("\n");
123
+ ffi_call(&cif, FFI_FN(cls_pointer_fn1), &res, args);
124
+
125
+ printf("res: 0x%08x\n", (unsigned int) res);
126
+ // { dg-output "\n0x01234567 0x89abcdef: 0x8acf1356" }
127
+ // { dg-output "\n0x8acf1356 0x01234567: 0x8bf258bd" }
128
+ // { dg-output "\nres: 0x8bf258bd" }
129
+
130
+ CHECK(ffi_prep_closure_loc(pcl, &cif, cls_pointer_gn, NULL, code) == FFI_OK);
131
+
132
+ res = (ffi_arg)((void*(*)(void*, void*))(code))(arg1, arg2);
133
+
134
+ printf("res: 0x%08x\n", (unsigned int) res);
135
+ // { dg-output "\n0x01234567 0x89abcdef: 0x8acf1356" }
136
+ // { dg-output "\n0x8acf1356 0x01234567: 0x8bf258bd" }
137
+ // { dg-output "\nres: 0x8bf258bd" }
138
+
139
+ exit(0);
140
+ }