ffi 1.9.25 → 1.15.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (339) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +212 -0
  3. data/Gemfile +3 -4
  4. data/README.md +38 -18
  5. data/Rakefile +55 -146
  6. data/ext/ffi_c/AbstractMemory.c +29 -34
  7. data/ext/ffi_c/Buffer.c +4 -9
  8. data/ext/ffi_c/Call.c +16 -49
  9. data/ext/ffi_c/Call.h +4 -7
  10. data/ext/ffi_c/ClosurePool.c +75 -25
  11. data/ext/ffi_c/ClosurePool.h +3 -1
  12. data/ext/ffi_c/DynamicLibrary.c +2 -7
  13. data/ext/ffi_c/Function.c +47 -131
  14. data/ext/ffi_c/Function.h +0 -4
  15. data/ext/ffi_c/FunctionInfo.c +3 -8
  16. data/ext/ffi_c/LastError.c +49 -8
  17. data/ext/ffi_c/LongDouble.c +12 -10
  18. data/ext/ffi_c/LongDouble.h +0 -4
  19. data/ext/ffi_c/MemoryPointer.c +3 -8
  20. data/ext/ffi_c/MemoryPointer.h +0 -4
  21. data/ext/ffi_c/MethodHandle.c +21 -31
  22. data/ext/ffi_c/MethodHandle.h +3 -2
  23. data/ext/ffi_c/Platform.c +3 -54
  24. data/ext/ffi_c/Pointer.c +25 -26
  25. data/ext/ffi_c/Pointer.h +0 -4
  26. data/ext/ffi_c/Struct.c +49 -56
  27. data/ext/ffi_c/Struct.h +12 -6
  28. data/ext/ffi_c/StructByValue.c +2 -7
  29. data/ext/ffi_c/StructLayout.c +22 -20
  30. data/ext/ffi_c/Thread.c +4 -228
  31. data/ext/ffi_c/Thread.h +1 -20
  32. data/ext/ffi_c/Type.c +1 -19
  33. data/ext/ffi_c/Type.h +0 -1
  34. data/ext/ffi_c/Types.c +7 -8
  35. data/ext/ffi_c/Types.h +3 -4
  36. data/ext/ffi_c/Variadic.c +23 -24
  37. data/ext/ffi_c/compat.h +4 -0
  38. data/ext/ffi_c/extconf.rb +53 -30
  39. data/ext/ffi_c/ffi.c +3 -8
  40. data/ext/ffi_c/libffi.darwin.mk +1 -1
  41. data/ext/ffi_c/libffi/.appveyor.yml +29 -13
  42. data/ext/ffi_c/libffi/.gitattributes +4 -0
  43. data/ext/ffi_c/libffi/.travis.yml +51 -2
  44. data/ext/ffi_c/libffi/.travis/bfin-sim.exp +58 -0
  45. data/ext/ffi_c/libffi/.travis/build-cross-in-container.sh +14 -0
  46. data/ext/ffi_c/libffi/.travis/build-in-container.sh +12 -0
  47. data/ext/ffi_c/libffi/.travis/build.sh +116 -8
  48. data/ext/ffi_c/libffi/.travis/install.sh +65 -16
  49. data/ext/ffi_c/libffi/.travis/m32r-sim.exp +58 -0
  50. data/ext/ffi_c/libffi/.travis/moxie-sim.exp +1 -1
  51. data/ext/ffi_c/libffi/.travis/or1k-sim.exp +58 -0
  52. data/ext/ffi_c/libffi/.travis/powerpc-eabisim.exp +58 -0
  53. data/ext/ffi_c/libffi/.travis/site.exp +10 -1
  54. data/ext/ffi_c/libffi/.travis/wine-sim.exp +55 -0
  55. data/ext/ffi_c/libffi/{ChangeLog.libffi-3.1 → ChangeLog.old} +1407 -0
  56. data/ext/ffi_c/libffi/LICENSE +1 -1
  57. data/ext/ffi_c/libffi/LICENSE-BUILDTOOLS +5 -4
  58. data/ext/ffi_c/libffi/Makefile.am +56 -72
  59. data/ext/ffi_c/libffi/README.md +33 -8
  60. data/ext/ffi_c/libffi/config.guess +552 -331
  61. data/ext/ffi_c/libffi/config.sub +1321 -1306
  62. data/ext/ffi_c/libffi/configure.ac +37 -12
  63. data/ext/ffi_c/libffi/configure.host +56 -27
  64. data/ext/ffi_c/libffi/doc/Makefile.am +3 -0
  65. data/ext/ffi_c/libffi/doc/libffi.texi +997 -0
  66. data/ext/ffi_c/libffi/doc/version.texi +4 -0
  67. data/ext/ffi_c/libffi/generate-darwin-source-and-headers.py +2 -4
  68. data/ext/ffi_c/libffi/include/ffi.h.in +19 -7
  69. data/ext/ffi_c/libffi/include/ffi_common.h +5 -1
  70. data/ext/ffi_c/libffi/libffi.map.in +8 -12
  71. data/ext/ffi_c/libffi/libffi.xcodeproj/project.pbxproj +2 -48
  72. data/ext/ffi_c/libffi/libtool-version +1 -1
  73. data/ext/ffi_c/libffi/m4/asmcfi.m4 +1 -1
  74. data/ext/ffi_c/libffi/m4/ax_append_flag.m4 +5 -26
  75. data/ext/ffi_c/libffi/m4/ax_check_compile_flag.m4 +5 -26
  76. data/ext/ffi_c/libffi/m4/ax_compiler_vendor.m4 +2 -1
  77. data/ext/ffi_c/libffi/m4/ax_configure_args.m4 +5 -26
  78. data/ext/ffi_c/libffi/m4/ax_gcc_archflag.m4 +7 -3
  79. data/ext/ffi_c/libffi/make_sunver.pl +333 -0
  80. data/ext/ffi_c/libffi/msvc_build/aarch64/Ffi_staticLib.sln +33 -0
  81. data/ext/ffi_c/libffi/msvc_build/aarch64/Ffi_staticLib.vcxproj +130 -0
  82. data/ext/ffi_c/libffi/msvc_build/aarch64/Ffi_staticLib.vcxproj.filters +57 -0
  83. data/ext/ffi_c/libffi/msvc_build/aarch64/Ffi_staticLib.vcxproj.user +4 -0
  84. data/ext/ffi_c/libffi/msvc_build/aarch64/aarch64_include/ffi.h +511 -0
  85. data/ext/ffi_c/libffi/msvcc.sh +38 -13
  86. data/ext/ffi_c/libffi/src/aarch64/ffi.c +153 -69
  87. data/ext/ffi_c/libffi/src/aarch64/ffitarget.h +19 -3
  88. data/ext/ffi_c/libffi/src/aarch64/internal.h +1 -0
  89. data/ext/ffi_c/libffi/src/aarch64/sysv.S +22 -9
  90. data/ext/ffi_c/libffi/src/aarch64/win64_armasm.S +506 -0
  91. data/ext/ffi_c/libffi/src/arm/ffi.c +62 -5
  92. data/ext/ffi_c/libffi/src/arm/ffitarget.h +8 -1
  93. data/ext/ffi_c/libffi/src/arm/sysv.S +6 -4
  94. data/ext/ffi_c/libffi/src/arm/sysv_msvc_arm32.S +311 -0
  95. data/ext/ffi_c/libffi/src/closures.c +69 -14
  96. data/ext/ffi_c/libffi/src/csky/ffi.c +395 -0
  97. data/ext/ffi_c/libffi/src/csky/ffitarget.h +63 -0
  98. data/ext/ffi_c/libffi/src/csky/sysv.S +371 -0
  99. data/ext/ffi_c/libffi/src/dlmalloc.c +1 -1
  100. data/ext/ffi_c/libffi/src/frv/ffi.c +1 -1
  101. data/ext/ffi_c/libffi/src/kvx/asm.h +5 -0
  102. data/ext/ffi_c/libffi/src/kvx/ffi.c +273 -0
  103. data/ext/ffi_c/libffi/src/kvx/ffitarget.h +75 -0
  104. data/ext/ffi_c/libffi/src/kvx/sysv.S +127 -0
  105. data/ext/ffi_c/libffi/src/metag/ffi.c +1 -1
  106. data/ext/ffi_c/libffi/src/mips/ffi.c +5 -1
  107. data/ext/ffi_c/libffi/src/mips/ffitarget.h +1 -1
  108. data/ext/ffi_c/libffi/src/mips/o32.S +2 -0
  109. data/ext/ffi_c/libffi/src/moxie/ffi.c +1 -1
  110. data/ext/ffi_c/libffi/src/pa/ffi.c +46 -91
  111. data/ext/ffi_c/libffi/src/pa/ffitarget.h +1 -6
  112. data/ext/ffi_c/libffi/src/pa/hpux32.S +4 -2
  113. data/ext/ffi_c/libffi/src/pa/linux.S +27 -4
  114. data/ext/ffi_c/libffi/src/powerpc/ffi.c +6 -4
  115. data/ext/ffi_c/libffi/src/powerpc/ffi_darwin.c +13 -1
  116. data/ext/ffi_c/libffi/src/powerpc/ffi_linux64.c +211 -32
  117. data/ext/ffi_c/libffi/src/powerpc/ffi_powerpc.h +18 -7
  118. data/ext/ffi_c/libffi/src/powerpc/ffitarget.h +10 -4
  119. data/ext/ffi_c/libffi/src/powerpc/linux64.S +91 -28
  120. data/ext/ffi_c/libffi/src/powerpc/linux64_closure.S +81 -5
  121. data/ext/ffi_c/libffi/src/powerpc/sysv.S +5 -7
  122. data/ext/ffi_c/libffi/src/prep_cif.c +4 -2
  123. data/ext/ffi_c/libffi/src/riscv/ffi.c +42 -6
  124. data/ext/ffi_c/libffi/src/riscv/ffitarget.h +1 -0
  125. data/ext/ffi_c/libffi/src/riscv/sysv.S +86 -7
  126. data/ext/ffi_c/libffi/src/x86/ffi.c +29 -12
  127. data/ext/ffi_c/libffi/src/x86/ffi64.c +22 -11
  128. data/ext/ffi_c/libffi/src/x86/ffitarget.h +15 -2
  129. data/ext/ffi_c/libffi/src/x86/ffiw64.c +20 -10
  130. data/ext/ffi_c/libffi/src/x86/sysv.S +105 -10
  131. data/ext/ffi_c/libffi/src/x86/sysv_intel.S +995 -0
  132. data/ext/ffi_c/libffi/src/x86/unix64.S +100 -4
  133. data/ext/ffi_c/libffi/src/x86/win64.S +12 -3
  134. data/ext/ffi_c/libffi/src/x86/win64_intel.S +3 -2
  135. data/ext/ffi_c/libffi/testsuite/Makefile.am +114 -109
  136. data/ext/ffi_c/libffi/testsuite/lib/libffi.exp +32 -8
  137. data/ext/ffi_c/libffi/testsuite/libffi.bhaible/bhaible.exp +7 -2
  138. data/ext/ffi_c/libffi/testsuite/libffi.bhaible/test-call.c +4 -4
  139. data/ext/ffi_c/libffi/testsuite/libffi.bhaible/test-callback.c +2 -2
  140. data/ext/ffi_c/libffi/testsuite/libffi.call/call.exp +12 -1
  141. data/ext/ffi_c/libffi/testsuite/libffi.call/float2.c +9 -8
  142. data/ext/ffi_c/libffi/testsuite/libffi.call/va_1.c +1 -1
  143. data/ext/ffi_c/libffi/testsuite/libffi.closures/closure.exp +67 -0
  144. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/closure_fn0.c +0 -0
  145. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/closure_fn1.c +0 -0
  146. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/closure_fn2.c +0 -0
  147. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/closure_fn3.c +0 -0
  148. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/closure_fn4.c +0 -0
  149. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/closure_fn5.c +0 -0
  150. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/closure_fn6.c +0 -0
  151. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/closure_loc_fn0.c +0 -0
  152. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/closure_simple.c +0 -0
  153. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_12byte.c +0 -0
  154. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_16byte.c +0 -0
  155. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_18byte.c +0 -0
  156. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_19byte.c +0 -0
  157. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_1_1byte.c +0 -0
  158. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_20byte.c +0 -0
  159. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_20byte1.c +0 -0
  160. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_24byte.c +0 -0
  161. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_2byte.c +0 -0
  162. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_3_1byte.c +0 -0
  163. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_3byte1.c +0 -0
  164. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_3byte2.c +0 -0
  165. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_3float.c +0 -0
  166. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_4_1byte.c +0 -0
  167. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_4byte.c +0 -0
  168. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_5_1_byte.c +0 -0
  169. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_5byte.c +0 -0
  170. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_64byte.c +0 -0
  171. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_6_1_byte.c +0 -0
  172. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_6byte.c +0 -0
  173. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_7_1_byte.c +0 -0
  174. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_7byte.c +0 -0
  175. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_8byte.c +0 -0
  176. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_9byte1.c +0 -0
  177. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_9byte2.c +0 -0
  178. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_align_double.c +0 -0
  179. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_align_float.c +0 -0
  180. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_align_longdouble.c +0 -0
  181. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_align_longdouble_split.c +0 -0
  182. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_align_longdouble_split2.c +0 -0
  183. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_align_pointer.c +0 -0
  184. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_align_sint16.c +0 -0
  185. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_align_sint32.c +0 -0
  186. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_align_sint64.c +0 -0
  187. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_align_uint16.c +0 -0
  188. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_align_uint32.c +0 -0
  189. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_align_uint64.c +0 -0
  190. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_dbls_struct.c +0 -0
  191. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_double.c +0 -0
  192. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_double_va.c +0 -0
  193. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_float.c +0 -0
  194. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_longdouble.c +0 -0
  195. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_longdouble_va.c +0 -0
  196. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_many_mixed_args.c +0 -0
  197. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_many_mixed_float_double.c +0 -0
  198. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_multi_schar.c +0 -0
  199. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_multi_sshort.c +0 -0
  200. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_multi_sshortchar.c +0 -0
  201. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_multi_uchar.c +0 -0
  202. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_multi_ushort.c +0 -0
  203. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_multi_ushortchar.c +0 -0
  204. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_pointer.c +0 -0
  205. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_pointer_stack.c +0 -0
  206. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_schar.c +0 -0
  207. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_sint.c +0 -0
  208. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_sshort.c +0 -0
  209. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_struct_va1.c +0 -0
  210. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_uchar.c +0 -0
  211. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_uchar_va.c +0 -0
  212. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_uint.c +0 -0
  213. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_uint_va.c +0 -0
  214. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_ulong_va.c +0 -0
  215. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_ulonglong.c +0 -0
  216. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_ushort.c +0 -0
  217. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_ushort_va.c +0 -0
  218. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/err_bad_abi.c +0 -0
  219. data/ext/ffi_c/libffi/testsuite/libffi.closures/ffitest.h +138 -0
  220. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/huge_struct.c +3 -1
  221. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/nested_struct.c +0 -0
  222. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/nested_struct1.c +0 -0
  223. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/nested_struct10.c +0 -0
  224. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/nested_struct11.c +0 -0
  225. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/nested_struct2.c +0 -0
  226. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/nested_struct3.c +0 -0
  227. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/nested_struct4.c +0 -0
  228. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/nested_struct5.c +0 -0
  229. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/nested_struct6.c +0 -0
  230. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/nested_struct7.c +0 -0
  231. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/nested_struct8.c +0 -0
  232. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/nested_struct9.c +0 -0
  233. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/problem1.c +0 -0
  234. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/stret_large.c +0 -0
  235. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/stret_large2.c +0 -0
  236. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/stret_medium.c +0 -0
  237. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/stret_medium2.c +0 -0
  238. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/testclosure.c +0 -0
  239. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/unwindtest.cc +0 -0
  240. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/unwindtest_ffi_call.cc +0 -0
  241. data/ext/ffi_c/rbffi.h +0 -2
  242. data/ffi.gemspec +13 -6
  243. data/lib/ffi.rb +10 -2
  244. data/lib/ffi/abstract_memory.rb +44 -0
  245. data/lib/ffi/autopointer.rb +1 -1
  246. data/lib/ffi/data_converter.rb +67 -0
  247. data/lib/ffi/ffi.rb +3 -0
  248. data/lib/ffi/io.rb +3 -3
  249. data/lib/ffi/library.rb +12 -8
  250. data/lib/ffi/managedstruct.rb +2 -2
  251. data/lib/ffi/platform.rb +34 -10
  252. data/lib/ffi/platform/aarch64-darwin/types.conf +130 -0
  253. data/lib/ffi/platform/aarch64-freebsd/types.conf +128 -0
  254. data/lib/ffi/platform/aarch64-freebsd12/types.conf +128 -0
  255. data/lib/ffi/platform/aarch64-linux/types.conf +81 -81
  256. data/lib/ffi/platform/aarch64-openbsd/types.conf +134 -0
  257. data/lib/ffi/platform/arm-freebsd/types.conf +152 -0
  258. data/lib/ffi/platform/arm-freebsd12/types.conf +152 -0
  259. data/lib/ffi/platform/arm-linux/types.conf +110 -82
  260. data/lib/ffi/platform/i386-cygwin/types.conf +1 -1
  261. data/lib/ffi/platform/i386-darwin/types.conf +63 -63
  262. data/lib/ffi/platform/i386-freebsd/types.conf +89 -89
  263. data/lib/ffi/platform/i386-freebsd12/types.conf +152 -0
  264. data/lib/ffi/platform/i386-gnu/types.conf +84 -84
  265. data/lib/ffi/platform/i386-linux/types.conf +77 -77
  266. data/lib/ffi/platform/i386-netbsd/types.conf +87 -87
  267. data/lib/ffi/platform/i386-openbsd/types.conf +89 -89
  268. data/lib/ffi/platform/i386-solaris/types.conf +96 -96
  269. data/lib/ffi/platform/i386-windows/types.conf +43 -96
  270. data/lib/ffi/platform/ia64-linux/types.conf +79 -79
  271. data/lib/ffi/platform/mips-linux/types.conf +79 -79
  272. data/lib/ffi/platform/mips64-linux/types.conf +81 -81
  273. data/lib/ffi/platform/mips64el-linux/types.conf +81 -81
  274. data/lib/ffi/platform/mipsel-linux/types.conf +79 -79
  275. data/lib/ffi/platform/mipsisa32r6-linux/types.conf +79 -79
  276. data/lib/ffi/platform/mipsisa32r6el-linux/types.conf +79 -79
  277. data/lib/ffi/platform/mipsisa64r6-linux/types.conf +81 -81
  278. data/lib/ffi/platform/mipsisa64r6el-linux/types.conf +81 -81
  279. data/lib/ffi/platform/powerpc-aix/types.conf +155 -155
  280. data/lib/ffi/platform/powerpc-darwin/types.conf +63 -63
  281. data/lib/ffi/platform/powerpc-linux/types.conf +108 -78
  282. data/lib/ffi/platform/powerpc-openbsd/types.conf +156 -0
  283. data/lib/ffi/platform/powerpc64-linux/types.conf +81 -81
  284. data/lib/ffi/platform/powerpc64le-linux/types.conf +100 -0
  285. data/lib/ffi/platform/riscv64-linux/types.conf +104 -0
  286. data/lib/ffi/platform/s390-linux/types.conf +79 -79
  287. data/lib/ffi/platform/s390x-linux/types.conf +79 -79
  288. data/lib/ffi/platform/sparc-linux/types.conf +79 -79
  289. data/lib/ffi/platform/sparc-solaris/types.conf +103 -103
  290. data/lib/ffi/platform/sparc64-linux/types.conf +79 -79
  291. data/lib/ffi/platform/sparcv9-openbsd/types.conf +156 -0
  292. data/lib/ffi/platform/sparcv9-solaris/types.conf +103 -103
  293. data/lib/ffi/platform/x86_64-cygwin/types.conf +1 -1
  294. data/lib/ffi/platform/x86_64-darwin/types.conf +88 -84
  295. data/lib/ffi/platform/x86_64-dragonflybsd/types.conf +130 -0
  296. data/lib/ffi/platform/x86_64-freebsd/types.conf +90 -90
  297. data/lib/ffi/platform/x86_64-freebsd12/types.conf +158 -0
  298. data/lib/ffi/platform/x86_64-haiku/types.conf +117 -0
  299. data/lib/ffi/platform/x86_64-linux/types.conf +107 -77
  300. data/lib/ffi/platform/x86_64-msys/types.conf +119 -0
  301. data/lib/ffi/platform/x86_64-netbsd/types.conf +89 -89
  302. data/lib/ffi/platform/x86_64-openbsd/types.conf +86 -86
  303. data/lib/ffi/platform/x86_64-solaris/types.conf +96 -96
  304. data/lib/ffi/platform/x86_64-windows/types.conf +42 -110
  305. data/lib/ffi/pointer.rb +26 -20
  306. data/lib/ffi/struct.rb +13 -68
  307. data/lib/ffi/struct_by_reference.rb +72 -0
  308. data/lib/ffi/struct_layout.rb +96 -0
  309. data/lib/ffi/tools/const_generator.rb +5 -4
  310. data/lib/ffi/tools/generator.rb +47 -2
  311. data/lib/ffi/tools/generator_task.rb +13 -17
  312. data/lib/ffi/tools/struct_generator.rb +4 -4
  313. data/lib/ffi/tools/types_generator.rb +7 -4
  314. data/lib/ffi/types.rb +1 -1
  315. data/lib/ffi/variadic.rb +1 -10
  316. data/lib/ffi/version.rb +1 -1
  317. data/rakelib/ffi_gem_helper.rb +65 -0
  318. data/samples/getlogin.rb +1 -1
  319. data/samples/getpid.rb +1 -1
  320. data/samples/gettimeofday.rb +8 -8
  321. data/samples/hello.rb +2 -1
  322. data/samples/inotify.rb +1 -1
  323. data/samples/pty.rb +1 -2
  324. data/samples/qsort.rb +0 -1
  325. metadata +160 -122
  326. data/.gitignore +0 -22
  327. data/.gitmodules +0 -3
  328. data/.travis.yml +0 -52
  329. data/.yardopts +0 -5
  330. data/appveyor.yml +0 -22
  331. data/ext/ffi_c/DataConverter.c +0 -91
  332. data/ext/ffi_c/StructByReference.c +0 -190
  333. data/ext/ffi_c/StructByReference.h +0 -50
  334. data/ext/ffi_c/libffi/ChangeLog.libffi +0 -584
  335. data/ext/ffi_c/libffi/ChangeLog.libgcj +0 -40
  336. data/ext/ffi_c/libffi/ChangeLog.v1 +0 -764
  337. data/ext/ffi_c/win32/stdbool.h +0 -8
  338. data/ext/ffi_c/win32/stdint.h +0 -201
  339. data/samples/sample_helper.rb +0 -6
@@ -61,7 +61,7 @@ unsigned int ffi_prep_args(char *stack, extended_cif *ecif)
61
61
  argp -= z;
62
62
 
63
63
  /* Align if necessary */
64
- argp = (char *) ALIGN_DOWN(ALIGN_DOWN(argp, (*p_arg)->alignment), 4);
64
+ argp = (char *) FFI_ALIGN_DOWN(FFI_ALIGN_DOWN(argp, (*p_arg)->alignment), 4);
65
65
 
66
66
  if (z < sizeof(int)) {
67
67
  z = sizeof(int);
@@ -39,7 +39,9 @@
39
39
  #endif
40
40
 
41
41
  #ifndef USE__BUILTIN___CLEAR_CACHE
42
- # if defined(__OpenBSD__)
42
+ # if defined(__FreeBSD__)
43
+ # include <machine/sysarch.h>
44
+ # elif defined(__OpenBSD__)
43
45
  # include <mips64/sysarch.h>
44
46
  # else
45
47
  # include <sys/cachectl.h>
@@ -777,11 +779,13 @@ ffi_prep_closure_loc (ffi_closure *closure,
777
779
  closure->fun = fun;
778
780
  closure->user_data = user_data;
779
781
 
782
+ #if !defined(__FreeBSD__)
780
783
  #ifdef USE__BUILTIN___CLEAR_CACHE
781
784
  __builtin___clear_cache(clear_location, clear_location + FFI_TRAMPOLINE_SIZE);
782
785
  #else
783
786
  cacheflush (clear_location, FFI_TRAMPOLINE_SIZE, ICACHE);
784
787
  #endif
788
+ #endif /* ! __FreeBSD__ */
785
789
  return FFI_OK;
786
790
  }
787
791
 
@@ -41,7 +41,7 @@
41
41
  #define _MIPS_SIM_ABI32 1
42
42
  #define _MIPS_SIM_NABI32 2
43
43
  #define _MIPS_SIM_ABI64 3
44
- #elif !defined(__OpenBSD__)
44
+ #elif !defined(__OpenBSD__) && !defined(__FreeBSD__)
45
45
  # include <sgidefs.h>
46
46
  #endif
47
47
 
@@ -282,9 +282,11 @@ $LCFI12:
282
282
  li $13, 1 # FFI_O32
283
283
  bne $16, $13, 1f # Skip fp save if FFI_O32_SOFT_FLOAT
284
284
 
285
+ #ifndef __mips_soft_float
285
286
  # Store all possible float/double registers.
286
287
  s.d $f12, FA_0_0_OFF2($fp)
287
288
  s.d $f14, FA_1_0_OFF2($fp)
289
+ #endif
288
290
  1:
289
291
  # prepare arguments for ffi_closure_mips_inner_O32
290
292
  REG_L a0, 4($15) # cif
@@ -100,7 +100,7 @@ void *ffi_prep_args(char *stack, extended_cif *ecif)
100
100
  count += z;
101
101
  }
102
102
 
103
- return (stack + ((count > 24) ? 24 : ALIGN_DOWN(count, 8)));
103
+ return (stack + ((count > 24) ? 24 : FFI_ALIGN_DOWN(count, 8)));
104
104
  }
105
105
 
106
106
  /* Perform machine dependent cif processing */
@@ -421,12 +421,15 @@ ffi_status ffi_closure_inner_pa32(ffi_closure *closure, UINT32 *stack)
421
421
  ffi_cif *cif;
422
422
  void **avalue;
423
423
  void *rvalue;
424
- UINT32 ret[2]; /* function can return up to 64-bits in registers */
424
+ /* Functions can return up to 64-bits in registers. Return address
425
+ must be double word aligned. */
426
+ union { double rd; UINT32 ret[2]; } u;
425
427
  ffi_type **p_arg;
426
428
  char *tmp;
427
429
  int i, avn;
428
430
  unsigned int slot = FIRST_ARG_SLOT;
429
431
  register UINT32 r28 asm("r28");
432
+ ffi_closure *c = (ffi_closure *)FFI_RESTORE_PTR (closure);
430
433
 
431
434
  cif = closure->cif;
432
435
 
@@ -434,7 +437,7 @@ ffi_status ffi_closure_inner_pa32(ffi_closure *closure, UINT32 *stack)
434
437
  if (cif->flags == FFI_TYPE_STRUCT)
435
438
  rvalue = (void *)r28;
436
439
  else
437
- rvalue = &ret[0];
440
+ rvalue = &u;
438
441
 
439
442
  avalue = (void **)alloca(cif->nargs * FFI_SIZEOF_ARG);
440
443
  avn = cif->nargs;
@@ -529,35 +532,35 @@ ffi_status ffi_closure_inner_pa32(ffi_closure *closure, UINT32 *stack)
529
532
  }
530
533
 
531
534
  /* Invoke the closure. */
532
- (closure->fun) (cif, rvalue, avalue, closure->user_data);
535
+ (c->fun) (cif, rvalue, avalue, c->user_data);
533
536
 
534
- debug(3, "after calling function, ret[0] = %08x, ret[1] = %08x\n", ret[0],
535
- ret[1]);
537
+ debug(3, "after calling function, ret[0] = %08x, ret[1] = %08x\n", u.ret[0],
538
+ u.ret[1]);
536
539
 
537
540
  /* Store the result using the lower 2 bytes of the flags. */
538
541
  switch (cif->flags)
539
542
  {
540
543
  case FFI_TYPE_UINT8:
541
- *(stack - FIRST_ARG_SLOT) = (UINT8)(ret[0] >> 24);
544
+ *(stack - FIRST_ARG_SLOT) = (UINT8)(u.ret[0] >> 24);
542
545
  break;
543
546
  case FFI_TYPE_SINT8:
544
- *(stack - FIRST_ARG_SLOT) = (SINT8)(ret[0] >> 24);
547
+ *(stack - FIRST_ARG_SLOT) = (SINT8)(u.ret[0] >> 24);
545
548
  break;
546
549
  case FFI_TYPE_UINT16:
547
- *(stack - FIRST_ARG_SLOT) = (UINT16)(ret[0] >> 16);
550
+ *(stack - FIRST_ARG_SLOT) = (UINT16)(u.ret[0] >> 16);
548
551
  break;
549
552
  case FFI_TYPE_SINT16:
550
- *(stack - FIRST_ARG_SLOT) = (SINT16)(ret[0] >> 16);
553
+ *(stack - FIRST_ARG_SLOT) = (SINT16)(u.ret[0] >> 16);
551
554
  break;
552
555
  case FFI_TYPE_INT:
553
556
  case FFI_TYPE_SINT32:
554
557
  case FFI_TYPE_UINT32:
555
- *(stack - FIRST_ARG_SLOT) = ret[0];
558
+ *(stack - FIRST_ARG_SLOT) = u.ret[0];
556
559
  break;
557
560
  case FFI_TYPE_SINT64:
558
561
  case FFI_TYPE_UINT64:
559
- *(stack - FIRST_ARG_SLOT) = ret[0];
560
- *(stack - FIRST_ARG_SLOT - 1) = ret[1];
562
+ *(stack - FIRST_ARG_SLOT) = u.ret[0];
563
+ *(stack - FIRST_ARG_SLOT - 1) = u.ret[1];
561
564
  break;
562
565
 
563
566
  case FFI_TYPE_DOUBLE:
@@ -577,7 +580,7 @@ ffi_status ffi_closure_inner_pa32(ffi_closure *closure, UINT32 *stack)
577
580
  case FFI_TYPE_SMALL_STRUCT4:
578
581
  tmp = (void*)(stack - FIRST_ARG_SLOT);
579
582
  tmp += 4 - cif->rtype->size;
580
- memcpy((void*)tmp, &ret[0], cif->rtype->size);
583
+ memcpy((void*)tmp, &u, cif->rtype->size);
581
584
  break;
582
585
 
583
586
  case FFI_TYPE_SMALL_STRUCT5:
@@ -598,7 +601,7 @@ ffi_status ffi_closure_inner_pa32(ffi_closure *closure, UINT32 *stack)
598
601
  }
599
602
 
600
603
  memset (ret2, 0, sizeof (ret2));
601
- memcpy ((char *)ret2 + off, ret, 8 - off);
604
+ memcpy ((char *)ret2 + off, &u, 8 - off);
602
605
 
603
606
  *(stack - FIRST_ARG_SLOT) = ret2[0];
604
607
  *(stack - FIRST_ARG_SLOT - 1) = ret2[1];
@@ -630,89 +633,41 @@ ffi_prep_closure_loc (ffi_closure* closure,
630
633
  void *user_data,
631
634
  void *codeloc)
632
635
  {
633
- UINT32 *tramp = (UINT32 *)(closure->tramp);
634
- #ifdef PA_HPUX
635
- UINT32 *tmp;
636
- #endif
636
+ ffi_closure *c = (ffi_closure *)FFI_RESTORE_PTR (closure);
637
+
638
+ /* The layout of a function descriptor. A function pointer with the PLABEL
639
+ bit set points to a function descriptor. */
640
+ struct pa32_fd
641
+ {
642
+ UINT32 code_pointer;
643
+ UINT32 gp;
644
+ };
645
+
646
+ struct ffi_pa32_trampoline_struct
647
+ {
648
+ UINT32 code_pointer; /* Pointer to ffi_closure_unix. */
649
+ UINT32 fake_gp; /* Pointer to closure, installed as gp. */
650
+ UINT32 real_gp; /* Real gp value. */
651
+ };
652
+
653
+ struct ffi_pa32_trampoline_struct *tramp;
654
+ struct pa32_fd *fd;
637
655
 
638
656
  if (cif->abi != FFI_PA32)
639
657
  return FFI_BAD_ABI;
640
658
 
641
- /* Make a small trampoline that will branch to our
642
- handler function. Use PC-relative addressing. */
643
-
644
- #ifdef PA_LINUX
645
- tramp[0] = 0xeaa00000; /* b,l .+8,%r21 ; %r21 <- pc+8 */
646
- tramp[1] = 0xd6a01c1e; /* depi 0,31,2,%r21 ; mask priv bits */
647
- tramp[2] = 0x4aa10028; /* ldw 20(%r21),%r1 ; load plabel */
648
- tramp[3] = 0x36b53ff1; /* ldo -8(%r21),%r21 ; get closure addr */
649
- tramp[4] = 0x0c201096; /* ldw 0(%r1),%r22 ; address of handler */
650
- tramp[5] = 0xeac0c000; /* bv%r0(%r22) ; branch to handler */
651
- tramp[6] = 0x0c281093; /* ldw 4(%r1),%r19 ; GP of handler */
652
- tramp[7] = ((UINT32)(ffi_closure_pa32) & ~2);
653
-
654
- /* Flush d/icache -- have to flush up 2 two lines because of
655
- alignment. */
656
- __asm__ volatile(
657
- "fdc 0(%0)\n\t"
658
- "fdc %1(%0)\n\t"
659
- "fic 0(%%sr4, %0)\n\t"
660
- "fic %1(%%sr4, %0)\n\t"
661
- "sync\n\t"
662
- "nop\n\t"
663
- "nop\n\t"
664
- "nop\n\t"
665
- "nop\n\t"
666
- "nop\n\t"
667
- "nop\n\t"
668
- "nop\n"
669
- :
670
- : "r"((unsigned long)tramp & ~31),
671
- "r"(32 /* stride */)
672
- : "memory");
673
- #endif
659
+ /* Get function descriptor address for ffi_closure_pa32. */
660
+ fd = (struct pa32_fd *)((UINT32)ffi_closure_pa32 & ~3);
674
661
 
675
- #ifdef PA_HPUX
676
- tramp[0] = 0xeaa00000; /* b,l .+8,%r21 ; %r21 <- pc+8 */
677
- tramp[1] = 0xd6a01c1e; /* depi 0,31,2,%r21 ; mask priv bits */
678
- tramp[2] = 0x4aa10038; /* ldw 28(%r21),%r1 ; load plabel */
679
- tramp[3] = 0x36b53ff1; /* ldo -8(%r21),%r21 ; get closure addr */
680
- tramp[4] = 0x0c201096; /* ldw 0(%r1),%r22 ; address of handler */
681
- tramp[5] = 0x02c010b4; /* ldsid (%r22),%r20 ; load space id */
682
- tramp[6] = 0x00141820; /* mtsp %r20,%sr0 ; into %sr0 */
683
- tramp[7] = 0xe2c00000; /* be 0(%sr0,%r22) ; branch to handler */
684
- tramp[8] = 0x0c281093; /* ldw 4(%r1),%r19 ; GP of handler */
685
- tramp[9] = ((UINT32)(ffi_closure_pa32) & ~2);
686
-
687
- /* Flush d/icache -- have to flush three lines because of alignment. */
688
- __asm__ volatile(
689
- "copy %1,%0\n\t"
690
- "fdc,m %2(%0)\n\t"
691
- "fdc,m %2(%0)\n\t"
692
- "fdc,m %2(%0)\n\t"
693
- "ldsid (%1),%0\n\t"
694
- "mtsp %0,%%sr0\n\t"
695
- "copy %1,%0\n\t"
696
- "fic,m %2(%%sr0,%0)\n\t"
697
- "fic,m %2(%%sr0,%0)\n\t"
698
- "fic,m %2(%%sr0,%0)\n\t"
699
- "sync\n\t"
700
- "nop\n\t"
701
- "nop\n\t"
702
- "nop\n\t"
703
- "nop\n\t"
704
- "nop\n\t"
705
- "nop\n\t"
706
- "nop\n"
707
- : "=&r" ((unsigned long)tmp)
708
- : "r" ((unsigned long)tramp & ~31),
709
- "r" (32/* stride */)
710
- : "memory");
711
- #endif
662
+ /* Setup trampoline. */
663
+ tramp = (struct ffi_pa32_trampoline_struct *)c->tramp;
664
+ tramp->code_pointer = fd->code_pointer;
665
+ tramp->fake_gp = (UINT32)codeloc & ~3;
666
+ tramp->real_gp = fd->gp;
712
667
 
713
- closure->cif = cif;
714
- closure->user_data = user_data;
715
- closure->fun = fun;
668
+ c->cif = cif;
669
+ c->user_data = user_data;
670
+ c->fun = fun;
716
671
 
717
672
  return FFI_OK;
718
673
  }
@@ -68,12 +68,7 @@ typedef enum ffi_abi {
68
68
 
69
69
  #define FFI_CLOSURES 1
70
70
  #define FFI_NATIVE_RAW_API 0
71
-
72
- #ifdef PA_LINUX
73
- #define FFI_TRAMPOLINE_SIZE 32
74
- #else
75
- #define FFI_TRAMPOLINE_SIZE 40
76
- #endif
71
+ #define FFI_TRAMPOLINE_SIZE 12
77
72
 
78
73
  #define FFI_TYPE_SMALL_STRUCT2 -1
79
74
  #define FFI_TYPE_SMALL_STRUCT3 -2
@@ -259,7 +259,7 @@ L$done
259
259
  L$FE1
260
260
 
261
261
  /* void ffi_closure_pa32(void);
262
- Called with closure argument in %r21 */
262
+ Called with closure argument in %r19 */
263
263
 
264
264
  .SPACE $TEXT$
265
265
  .SUBSPA $CODE$
@@ -285,7 +285,9 @@ L$CFI22
285
285
  stw %arg2, -44(%r3)
286
286
  stw %arg3, -48(%r3)
287
287
 
288
- copy %r21, %arg0
288
+ /* Retrieve closure pointer and real gp. */
289
+ copy %r19, %arg0
290
+ ldw 8(%r19), %r19
289
291
  bl ffi_closure_inner_pa32, %r2
290
292
  copy %r3, %arg1
291
293
  ldwm -64(%sp), %r3
@@ -252,7 +252,7 @@ ffi_call_pa32:
252
252
  .LFE1:
253
253
 
254
254
  /* void ffi_closure_pa32(void);
255
- Called with closure argument in %r21 */
255
+ Called with closure argument in %r19 */
256
256
  .export ffi_closure_pa32,code
257
257
  .import ffi_closure_inner_pa32,code
258
258
 
@@ -277,7 +277,9 @@ ffi_closure_pa32:
277
277
  stw %arg2, -44(%r3)
278
278
  stw %arg3, -48(%r3)
279
279
 
280
- copy %r21, %arg0
280
+ /* Retrieve closure pointer and real gp. */
281
+ copy %r19, %arg0
282
+ ldw 8(%r19), %r19
281
283
  bl ffi_closure_inner_pa32, %r2
282
284
  copy %r3, %arg1
283
285
 
@@ -297,10 +299,18 @@ ffi_closure_pa32:
297
299
  .LSCIE1:
298
300
  .word 0x0 ;# CIE Identifier Tag
299
301
  .byte 0x1 ;# CIE Version
302
+ #ifdef __PIC__
303
+ .ascii "zR\0" ;# CIE Augmentation: 'z' - data, 'R' - DW_EH_PE_... data
304
+ #else
300
305
  .ascii "\0" ;# CIE Augmentation
306
+ #endif
301
307
  .uleb128 0x1 ;# CIE Code Alignment Factor
302
308
  .sleb128 4 ;# CIE Data Alignment Factor
303
309
  .byte 0x2 ;# CIE RA Column
310
+ #ifdef __PIC__
311
+ .uleb128 0x1 ;# Augmentation size
312
+ .byte 0x1b ;# FDE Encoding (DW_EH_PE_pcrel|DW_EH_PE_sdata4)
313
+ #endif
304
314
  .byte 0xc ;# DW_CFA_def_cfa
305
315
  .uleb128 0x1e
306
316
  .uleb128 0x0
@@ -310,9 +320,15 @@ ffi_closure_pa32:
310
320
  .word .LEFDE1-.LASFDE1 ;# FDE Length
311
321
  .LASFDE1:
312
322
  .word .LASFDE1-.Lframe1 ;# FDE CIE offset
313
- .word .LFB1 ;# FDE initial location
323
+ #ifdef __PIC__
324
+ .word .LFB1-. ;# FDE initial location
325
+ #else
326
+ .word .LFB1 ;# FDE initial location
327
+ #endif
314
328
  .word .LFE1-.LFB1 ;# FDE address range
315
-
329
+ #ifdef __PIC__
330
+ .uleb128 0x0 ;# Augmentation size: no data
331
+ #endif
316
332
  .byte 0x4 ;# DW_CFA_advance_loc4
317
333
  .word .LCFI11-.LFB1
318
334
  .byte 0x83 ;# DW_CFA_offset, column 0x3
@@ -338,8 +354,15 @@ ffi_closure_pa32:
338
354
  .word .LEFDE2-.LASFDE2 ;# FDE Length
339
355
  .LASFDE2:
340
356
  .word .LASFDE2-.Lframe1 ;# FDE CIE offset
357
+ #ifdef __PIC__
358
+ .word .LFB2-. ;# FDE initial location
359
+ #else
341
360
  .word .LFB2 ;# FDE initial location
361
+ #endif
342
362
  .word .LFE2-.LFB2 ;# FDE address range
363
+ #ifdef __PIC__
364
+ .uleb128 0x0 ;# Augmentation size: no data
365
+ #endif
343
366
  .byte 0x4 ;# DW_CFA_advance_loc4
344
367
  .word .LCFI21-.LFB2
345
368
  .byte 0x83 ;# DW_CFA_offset, column 0x3
@@ -85,8 +85,9 @@ ffi_call_int (ffi_cif *cif,
85
85
  can write r3 and r4 to memory without worrying about struct size.
86
86
 
87
87
  For ELFv2 ABI, use a bounce buffer for homogeneous structs too,
88
- for similar reasons. */
89
- unsigned long smst_buffer[8];
88
+ for similar reasons. This bounce buffer must be aligned to 16
89
+ bytes for use with homogeneous structs of vectors (float128). */
90
+ float128 smst_buffer[8];
90
91
  extended_cif ecif;
91
92
 
92
93
  ecif.cif = cif;
@@ -121,8 +122,9 @@ ffi_call_int (ffi_cif *cif,
121
122
  # endif
122
123
  /* The SYSV ABI returns a structure of up to 8 bytes in size
123
124
  left-padded in r3/r4, and the ELFv2 ABI similarly returns a
124
- structure of up to 8 bytes in size left-padded in r3. */
125
- if (rsize <= 8)
125
+ structure of up to 8 bytes in size left-padded in r3. But
126
+ note that a structure of a single float is not paddded. */
127
+ if (rsize <= 8 && (cif->flags & FLAG_RETURNS_FP) == 0)
126
128
  memcpy (rvalue, (char *) smst_buffer + 8 - rsize, rsize);
127
129
  else
128
130
  #endif
@@ -33,7 +33,10 @@
33
33
  #include <stdlib.h>
34
34
 
35
35
  extern void ffi_closure_ASM (void);
36
+
37
+ #if defined (FFI_GO_CLOSURES)
36
38
  extern void ffi_go_closure_ASM (void);
39
+ #endif
37
40
 
38
41
  enum {
39
42
  /* The assembly depends on these exact flags.
@@ -909,8 +912,10 @@ ffi_prep_cif_machdep (ffi_cif *cif)
909
912
  extern void ffi_call_AIX(extended_cif *, long, unsigned, unsigned *,
910
913
  void (*fn)(void), void (*fn2)(void));
911
914
 
915
+ #if defined (FFI_GO_CLOSURES)
912
916
  extern void ffi_call_go_AIX(extended_cif *, long, unsigned, unsigned *,
913
917
  void (*fn)(void), void (*fn2)(void), void *closure);
918
+ #endif
914
919
 
915
920
  extern void ffi_call_DARWIN(extended_cif *, long, unsigned, unsigned *,
916
921
  void (*fn)(void), void (*fn2)(void), ffi_type*);
@@ -950,6 +955,7 @@ ffi_call (ffi_cif *cif, void (*fn)(void), void *rvalue, void **avalue)
950
955
  }
951
956
  }
952
957
 
958
+ #if defined (FFI_GO_CLOSURES)
953
959
  void
954
960
  ffi_call_go (ffi_cif *cif, void (*fn) (void), void *rvalue, void **avalue,
955
961
  void *closure)
@@ -981,6 +987,7 @@ ffi_call_go (ffi_cif *cif, void (*fn) (void), void *rvalue, void **avalue,
981
987
  break;
982
988
  }
983
989
  }
990
+ #endif
984
991
 
985
992
  static void flush_icache(char *);
986
993
  static void flush_range(char *, int);
@@ -1110,6 +1117,7 @@ ffi_prep_closure_loc (ffi_closure* closure,
1110
1117
  return FFI_OK;
1111
1118
  }
1112
1119
 
1120
+ #if defined (FFI_GO_CLOSURES)
1113
1121
  ffi_status
1114
1122
  ffi_prep_go_closure (ffi_go_closure* closure,
1115
1123
  ffi_cif* cif,
@@ -1133,6 +1141,7 @@ ffi_prep_go_closure (ffi_go_closure* closure,
1133
1141
  }
1134
1142
  return FFI_OK;
1135
1143
  }
1144
+ #endif
1136
1145
 
1137
1146
  static void
1138
1147
  flush_icache(char *addr)
@@ -1168,9 +1177,11 @@ ffi_type *
1168
1177
  ffi_closure_helper_DARWIN (ffi_closure *, void *,
1169
1178
  unsigned long *, ffi_dblfl *);
1170
1179
 
1180
+ #if defined (FFI_GO_CLOSURES)
1171
1181
  ffi_type *
1172
1182
  ffi_go_closure_helper_DARWIN (ffi_go_closure*, void *,
1173
1183
  unsigned long *, ffi_dblfl *);
1184
+ #endif
1174
1185
 
1175
1186
  /* Basically the trampoline invokes ffi_closure_ASM, and on
1176
1187
  entry, r11 holds the address of the closure.
@@ -1430,6 +1441,7 @@ ffi_closure_helper_DARWIN (ffi_closure *closure, void *rvalue,
1430
1441
  closure->user_data, rvalue, pgr, pfr);
1431
1442
  }
1432
1443
 
1444
+ #if defined (FFI_GO_CLOSURES)
1433
1445
  ffi_type *
1434
1446
  ffi_go_closure_helper_DARWIN (ffi_go_closure *closure, void *rvalue,
1435
1447
  unsigned long *pgr, ffi_dblfl *pfr)
@@ -1437,4 +1449,4 @@ ffi_go_closure_helper_DARWIN (ffi_go_closure *closure, void *rvalue,
1437
1449
  return ffi_closure_helper_common (closure->cif, closure->fun,
1438
1450
  closure, rvalue, pgr, pfr);
1439
1451
  }
1440
-
1452
+ #endif