ffi 1.10.0 → 1.13.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (299) hide show
  1. checksums.yaml +4 -4
  2. data/{appveyor.yml → .appveyor.yml} +9 -1
  3. data/.github/workflows/ci.yml +64 -0
  4. data/.gitignore +3 -0
  5. data/.gitmodules +1 -0
  6. data/.travis.yml +35 -20
  7. data/CHANGELOG.md +124 -0
  8. data/Gemfile +6 -4
  9. data/README.md +29 -17
  10. data/Rakefile +29 -120
  11. data/ext/ffi_c/AbstractMemory.c +5 -9
  12. data/ext/ffi_c/Buffer.c +2 -2
  13. data/ext/ffi_c/Call.c +14 -41
  14. data/ext/ffi_c/Call.h +4 -7
  15. data/ext/ffi_c/ClosurePool.c +11 -14
  16. data/ext/ffi_c/DynamicLibrary.c +1 -1
  17. data/ext/ffi_c/Function.c +18 -117
  18. data/ext/ffi_c/FunctionInfo.c +1 -2
  19. data/ext/ffi_c/LongDouble.c +12 -10
  20. data/ext/ffi_c/LongDouble.h +0 -4
  21. data/ext/ffi_c/MemoryPointer.c +1 -1
  22. data/ext/ffi_c/MethodHandle.c +18 -24
  23. data/ext/ffi_c/MethodHandle.h +3 -2
  24. data/ext/ffi_c/Platform.c +1 -47
  25. data/ext/ffi_c/Pointer.c +1 -1
  26. data/ext/ffi_c/Struct.c +47 -51
  27. data/ext/ffi_c/Struct.h +12 -6
  28. data/ext/ffi_c/StructLayout.c +20 -14
  29. data/ext/ffi_c/Thread.c +4 -223
  30. data/ext/ffi_c/Thread.h +0 -14
  31. data/ext/ffi_c/Type.c +0 -18
  32. data/ext/ffi_c/Type.h +0 -1
  33. data/ext/ffi_c/Types.c +1 -1
  34. data/ext/ffi_c/Variadic.c +9 -15
  35. data/ext/ffi_c/compat.h +4 -0
  36. data/ext/ffi_c/extconf.rb +36 -26
  37. data/ext/ffi_c/ffi.c +3 -8
  38. data/ext/ffi_c/libffi.darwin.mk +1 -1
  39. data/ext/ffi_c/libffi/.appveyor.yml +29 -13
  40. data/ext/ffi_c/libffi/.gitattributes +4 -0
  41. data/ext/ffi_c/libffi/.travis.yml +51 -2
  42. data/ext/ffi_c/libffi/.travis/bfin-sim.exp +58 -0
  43. data/ext/ffi_c/libffi/.travis/build-cross-in-container.sh +14 -0
  44. data/ext/ffi_c/libffi/.travis/build-in-container.sh +12 -0
  45. data/ext/ffi_c/libffi/.travis/build.sh +116 -8
  46. data/ext/ffi_c/libffi/.travis/install.sh +65 -16
  47. data/ext/ffi_c/libffi/.travis/m32r-sim.exp +58 -0
  48. data/ext/ffi_c/libffi/.travis/or1k-sim.exp +58 -0
  49. data/ext/ffi_c/libffi/.travis/powerpc-eabisim.exp +58 -0
  50. data/ext/ffi_c/libffi/.travis/site.exp +10 -1
  51. data/ext/ffi_c/libffi/.travis/wine-sim.exp +55 -0
  52. data/ext/ffi_c/libffi/{ChangeLog.libffi-3.1 → ChangeLog.old} +1407 -0
  53. data/ext/ffi_c/libffi/LICENSE +1 -1
  54. data/ext/ffi_c/libffi/LICENSE-BUILDTOOLS +5 -4
  55. data/ext/ffi_c/libffi/Makefile.am +35 -41
  56. data/ext/ffi_c/libffi/README.md +29 -8
  57. data/ext/ffi_c/libffi/configure.ac +31 -11
  58. data/ext/ffi_c/libffi/configure.host +26 -9
  59. data/ext/ffi_c/libffi/generate-darwin-source-and-headers.py +1 -3
  60. data/ext/ffi_c/libffi/include/ffi.h.in +19 -7
  61. data/ext/ffi_c/libffi/include/ffi_common.h +5 -1
  62. data/ext/ffi_c/libffi/libffi.map.in +8 -12
  63. data/ext/ffi_c/libffi/libffi.xcodeproj/project.pbxproj +2 -48
  64. data/ext/ffi_c/libffi/libtool-version +1 -1
  65. data/ext/ffi_c/libffi/m4/asmcfi.m4 +1 -1
  66. data/ext/ffi_c/libffi/m4/ax_append_flag.m4 +5 -26
  67. data/ext/ffi_c/libffi/m4/ax_check_compile_flag.m4 +5 -26
  68. data/ext/ffi_c/libffi/m4/ax_compiler_vendor.m4 +2 -1
  69. data/ext/ffi_c/libffi/m4/ax_configure_args.m4 +5 -26
  70. data/ext/ffi_c/libffi/m4/ax_gcc_archflag.m4 +7 -3
  71. data/ext/ffi_c/libffi/make_sunver.pl +333 -0
  72. data/ext/ffi_c/libffi/msvc_build/aarch64/Ffi_staticLib.sln +33 -0
  73. data/ext/ffi_c/libffi/msvc_build/aarch64/Ffi_staticLib.vcxproj +130 -0
  74. data/ext/ffi_c/libffi/msvc_build/aarch64/Ffi_staticLib.vcxproj.filters +57 -0
  75. data/ext/ffi_c/libffi/msvc_build/aarch64/Ffi_staticLib.vcxproj.user +4 -0
  76. data/ext/ffi_c/libffi/msvc_build/aarch64/aarch64_include/ffi.h +511 -0
  77. data/ext/ffi_c/libffi/msvcc.sh +27 -2
  78. data/ext/ffi_c/libffi/src/aarch64/ffi.c +132 -58
  79. data/ext/ffi_c/libffi/src/aarch64/ffitarget.h +13 -2
  80. data/ext/ffi_c/libffi/src/aarch64/sysv.S +21 -8
  81. data/ext/ffi_c/libffi/src/aarch64/win64_armasm.S +506 -0
  82. data/ext/ffi_c/libffi/src/arm/ffi.c +40 -5
  83. data/ext/ffi_c/libffi/src/arm/ffitarget.h +8 -1
  84. data/ext/ffi_c/libffi/src/arm/sysv.S +2 -0
  85. data/ext/ffi_c/libffi/src/arm/sysv_msvc_arm32.S +311 -0
  86. data/ext/ffi_c/libffi/src/closures.c +51 -13
  87. data/ext/ffi_c/libffi/src/frv/ffi.c +1 -1
  88. data/ext/ffi_c/libffi/src/metag/ffi.c +1 -1
  89. data/ext/ffi_c/libffi/src/mips/o32.S +2 -0
  90. data/ext/ffi_c/libffi/src/moxie/ffi.c +1 -1
  91. data/ext/ffi_c/libffi/src/pa/ffi.c +46 -91
  92. data/ext/ffi_c/libffi/src/pa/ffitarget.h +1 -6
  93. data/ext/ffi_c/libffi/src/pa/hpux32.S +4 -2
  94. data/ext/ffi_c/libffi/src/pa/linux.S +27 -4
  95. data/ext/ffi_c/libffi/src/powerpc/ffi.c +6 -4
  96. data/ext/ffi_c/libffi/src/powerpc/ffi_linux64.c +211 -32
  97. data/ext/ffi_c/libffi/src/powerpc/ffi_powerpc.h +18 -7
  98. data/ext/ffi_c/libffi/src/powerpc/ffitarget.h +10 -4
  99. data/ext/ffi_c/libffi/src/powerpc/linux64.S +83 -28
  100. data/ext/ffi_c/libffi/src/powerpc/linux64_closure.S +68 -4
  101. data/ext/ffi_c/libffi/src/powerpc/sysv.S +5 -7
  102. data/ext/ffi_c/libffi/src/prep_cif.c +4 -2
  103. data/ext/ffi_c/libffi/src/riscv/ffi.c +42 -6
  104. data/ext/ffi_c/libffi/src/riscv/ffitarget.h +1 -0
  105. data/ext/ffi_c/libffi/src/riscv/sysv.S +86 -7
  106. data/ext/ffi_c/libffi/src/x86/ffi.c +21 -10
  107. data/ext/ffi_c/libffi/src/x86/ffi64.c +15 -11
  108. data/ext/ffi_c/libffi/src/x86/ffitarget.h +15 -2
  109. data/ext/ffi_c/libffi/src/x86/ffiw64.c +15 -10
  110. data/ext/ffi_c/libffi/src/x86/sysv.S +103 -8
  111. data/ext/ffi_c/libffi/src/x86/sysv_intel.S +995 -0
  112. data/ext/ffi_c/libffi/src/x86/unix64.S +99 -2
  113. data/ext/ffi_c/libffi/src/x86/win64.S +9 -1
  114. data/ext/ffi_c/libffi/testsuite/Makefile.am +114 -109
  115. data/ext/ffi_c/libffi/testsuite/lib/libffi.exp +26 -22
  116. data/ext/ffi_c/libffi/testsuite/libffi.bhaible/bhaible.exp +7 -2
  117. data/ext/ffi_c/libffi/testsuite/libffi.bhaible/test-call.c +1 -1
  118. data/ext/ffi_c/libffi/testsuite/libffi.bhaible/test-callback.c +1 -1
  119. data/ext/ffi_c/libffi/testsuite/libffi.call/call.exp +12 -1
  120. data/ext/ffi_c/libffi/testsuite/libffi.call/float2.c +9 -8
  121. data/ext/ffi_c/libffi/testsuite/libffi.call/va_1.c +1 -1
  122. data/ext/ffi_c/libffi/testsuite/libffi.closures/closure.exp +67 -0
  123. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/closure_fn0.c +0 -0
  124. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/closure_fn1.c +0 -0
  125. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/closure_fn2.c +0 -0
  126. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/closure_fn3.c +0 -0
  127. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/closure_fn4.c +0 -0
  128. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/closure_fn5.c +0 -0
  129. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/closure_fn6.c +0 -0
  130. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/closure_loc_fn0.c +0 -0
  131. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/closure_simple.c +0 -0
  132. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_12byte.c +0 -0
  133. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_16byte.c +0 -0
  134. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_18byte.c +0 -0
  135. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_19byte.c +0 -0
  136. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_1_1byte.c +0 -0
  137. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_20byte.c +0 -0
  138. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_20byte1.c +0 -0
  139. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_24byte.c +0 -0
  140. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_2byte.c +0 -0
  141. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_3_1byte.c +0 -0
  142. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_3byte1.c +0 -0
  143. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_3byte2.c +0 -0
  144. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_3float.c +0 -0
  145. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_4_1byte.c +0 -0
  146. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_4byte.c +0 -0
  147. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_5_1_byte.c +0 -0
  148. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_5byte.c +0 -0
  149. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_64byte.c +0 -0
  150. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_6_1_byte.c +0 -0
  151. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_6byte.c +0 -0
  152. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_7_1_byte.c +0 -0
  153. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_7byte.c +0 -0
  154. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_8byte.c +0 -0
  155. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_9byte1.c +0 -0
  156. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_9byte2.c +0 -0
  157. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_align_double.c +0 -0
  158. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_align_float.c +0 -0
  159. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_align_longdouble.c +0 -0
  160. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_align_longdouble_split.c +0 -0
  161. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_align_longdouble_split2.c +0 -0
  162. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_align_pointer.c +0 -0
  163. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_align_sint16.c +0 -0
  164. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_align_sint32.c +0 -0
  165. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_align_sint64.c +0 -0
  166. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_align_uint16.c +0 -0
  167. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_align_uint32.c +0 -0
  168. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_align_uint64.c +0 -0
  169. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_dbls_struct.c +0 -0
  170. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_double.c +0 -0
  171. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_double_va.c +0 -0
  172. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_float.c +0 -0
  173. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_longdouble.c +0 -0
  174. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_longdouble_va.c +0 -0
  175. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_many_mixed_args.c +0 -0
  176. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_many_mixed_float_double.c +0 -0
  177. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_multi_schar.c +0 -0
  178. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_multi_sshort.c +0 -0
  179. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_multi_sshortchar.c +0 -0
  180. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_multi_uchar.c +0 -0
  181. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_multi_ushort.c +0 -0
  182. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_multi_ushortchar.c +0 -0
  183. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_pointer.c +0 -0
  184. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_pointer_stack.c +0 -0
  185. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_schar.c +0 -0
  186. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_sint.c +0 -0
  187. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_sshort.c +0 -0
  188. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_struct_va1.c +0 -0
  189. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_uchar.c +0 -0
  190. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_uchar_va.c +0 -0
  191. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_uint.c +0 -0
  192. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_uint_va.c +0 -0
  193. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_ulong_va.c +0 -0
  194. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_ulonglong.c +0 -0
  195. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_ushort.c +0 -0
  196. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_ushort_va.c +0 -0
  197. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/err_bad_abi.c +0 -0
  198. data/ext/ffi_c/libffi/testsuite/libffi.closures/ffitest.h +138 -0
  199. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/huge_struct.c +1 -1
  200. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/nested_struct.c +0 -0
  201. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/nested_struct1.c +0 -0
  202. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/nested_struct10.c +0 -0
  203. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/nested_struct11.c +0 -0
  204. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/nested_struct2.c +0 -0
  205. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/nested_struct3.c +0 -0
  206. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/nested_struct4.c +0 -0
  207. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/nested_struct5.c +0 -0
  208. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/nested_struct6.c +0 -0
  209. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/nested_struct7.c +0 -0
  210. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/nested_struct8.c +0 -0
  211. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/nested_struct9.c +0 -0
  212. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/problem1.c +0 -0
  213. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/stret_large.c +0 -0
  214. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/stret_large2.c +0 -0
  215. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/stret_medium.c +0 -0
  216. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/stret_medium2.c +0 -0
  217. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/testclosure.c +0 -0
  218. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/unwindtest.cc +0 -0
  219. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/unwindtest_ffi_call.cc +0 -0
  220. data/ext/ffi_c/rbffi.h +0 -2
  221. data/ffi.gemspec +12 -5
  222. data/lib/ffi.rb +10 -2
  223. data/lib/ffi/data_converter.rb +67 -0
  224. data/lib/ffi/ffi.rb +2 -0
  225. data/lib/ffi/library.rb +10 -6
  226. data/lib/ffi/platform.rb +12 -3
  227. data/lib/ffi/platform/aarch64-freebsd/types.conf +89 -89
  228. data/lib/ffi/platform/aarch64-freebsd12/types.conf +89 -89
  229. data/lib/ffi/platform/aarch64-linux/types.conf +81 -81
  230. data/lib/ffi/platform/arm-freebsd/types.conf +87 -87
  231. data/lib/ffi/platform/arm-freebsd12/types.conf +87 -87
  232. data/lib/ffi/platform/arm-linux/types.conf +110 -82
  233. data/lib/ffi/platform/i386-cygwin/types.conf +1 -1
  234. data/lib/ffi/platform/i386-darwin/types.conf +63 -63
  235. data/lib/ffi/platform/i386-freebsd/types.conf +87 -87
  236. data/lib/ffi/platform/i386-freebsd12/types.conf +87 -87
  237. data/lib/ffi/platform/i386-gnu/types.conf +84 -84
  238. data/lib/ffi/platform/i386-linux/types.conf +77 -77
  239. data/lib/ffi/platform/i386-netbsd/types.conf +87 -87
  240. data/lib/ffi/platform/i386-openbsd/types.conf +89 -89
  241. data/lib/ffi/platform/i386-solaris/types.conf +96 -96
  242. data/lib/ffi/platform/i386-windows/types.conf +43 -96
  243. data/lib/ffi/platform/ia64-linux/types.conf +79 -79
  244. data/lib/ffi/platform/mips-linux/types.conf +79 -79
  245. data/lib/ffi/platform/mips64-linux/types.conf +81 -81
  246. data/lib/ffi/platform/mips64el-linux/types.conf +81 -81
  247. data/lib/ffi/platform/mipsel-linux/types.conf +79 -79
  248. data/lib/ffi/platform/mipsisa32r6-linux/types.conf +79 -79
  249. data/lib/ffi/platform/mipsisa32r6el-linux/types.conf +79 -79
  250. data/lib/ffi/platform/mipsisa64r6-linux/types.conf +81 -81
  251. data/lib/ffi/platform/mipsisa64r6el-linux/types.conf +81 -81
  252. data/lib/ffi/platform/powerpc-aix/types.conf +155 -155
  253. data/lib/ffi/platform/powerpc-darwin/types.conf +63 -63
  254. data/lib/ffi/platform/powerpc-linux/types.conf +108 -78
  255. data/lib/ffi/platform/powerpc-openbsd/types.conf +156 -0
  256. data/lib/ffi/platform/powerpc64-linux/types.conf +81 -81
  257. data/lib/ffi/platform/s390-linux/types.conf +79 -79
  258. data/lib/ffi/platform/s390x-linux/types.conf +79 -79
  259. data/lib/ffi/platform/sparc-linux/types.conf +79 -79
  260. data/lib/ffi/platform/sparc-solaris/types.conf +103 -103
  261. data/lib/ffi/platform/sparc64-linux/types.conf +79 -79
  262. data/lib/ffi/platform/sparcv9-openbsd/types.conf +156 -0
  263. data/lib/ffi/platform/sparcv9-solaris/types.conf +103 -103
  264. data/lib/ffi/platform/x86_64-cygwin/types.conf +1 -1
  265. data/lib/ffi/platform/x86_64-darwin/types.conf +88 -84
  266. data/lib/ffi/platform/x86_64-dragonflybsd/types.conf +130 -0
  267. data/lib/ffi/platform/x86_64-freebsd/types.conf +89 -89
  268. data/lib/ffi/platform/x86_64-freebsd12/types.conf +139 -109
  269. data/lib/ffi/platform/x86_64-linux/types.conf +107 -77
  270. data/lib/ffi/platform/x86_64-netbsd/types.conf +89 -89
  271. data/lib/ffi/platform/x86_64-openbsd/types.conf +86 -86
  272. data/lib/ffi/platform/x86_64-solaris/types.conf +96 -96
  273. data/lib/ffi/platform/x86_64-windows/types.conf +42 -110
  274. data/lib/ffi/pointer.rb +20 -13
  275. data/lib/ffi/struct.rb +13 -68
  276. data/lib/ffi/struct_by_reference.rb +72 -0
  277. data/lib/ffi/struct_layout.rb +96 -0
  278. data/lib/ffi/tools/const_generator.rb +5 -4
  279. data/lib/ffi/tools/generator.rb +47 -2
  280. data/lib/ffi/tools/generator_task.rb +13 -17
  281. data/lib/ffi/tools/struct_generator.rb +4 -4
  282. data/lib/ffi/tools/types_generator.rb +7 -4
  283. data/lib/ffi/types.rb +1 -1
  284. data/lib/ffi/version.rb +1 -1
  285. data/samples/getlogin.rb +1 -1
  286. data/samples/getpid.rb +1 -1
  287. data/samples/gettimeofday.rb +8 -8
  288. data/samples/hello.rb +2 -1
  289. data/samples/inotify.rb +1 -1
  290. data/samples/pty.rb +1 -2
  291. data/samples/qsort.rb +0 -1
  292. metadata +141 -116
  293. data/ext/ffi_c/DataConverter.c +0 -91
  294. data/ext/ffi_c/StructByReference.c +0 -190
  295. data/ext/ffi_c/StructByReference.h +0 -50
  296. data/ext/ffi_c/libffi/ChangeLog.libffi +0 -584
  297. data/ext/ffi_c/libffi/ChangeLog.libgcj +0 -40
  298. data/ext/ffi_c/libffi/ChangeLog.v1 +0 -764
  299. data/samples/sample_helper.rb +0 -6
@@ -59,6 +59,7 @@ typedef enum ffi_abi {
59
59
  /* ---- Definitions for closures ----------------------------------------- */
60
60
 
61
61
  #define FFI_CLOSURES 1
62
+ #define FFI_GO_CLOSURES 1
62
63
  #define FFI_TRAMPOLINE_SIZE 24
63
64
  #define FFI_NATIVE_RAW_API 0
64
65
  #define FFI_EXTRA_CIF_FIELDS unsigned riscv_nfixedargs; unsigned riscv_unused;
@@ -67,8 +67,8 @@
67
67
  intreg pad[rv32 ? 2 : 0];
68
68
  intreg save_fp, save_ra;
69
69
  }
70
- void ffi_call_asm(size_t *stackargs, struct call_context *regargs,
71
- void (*fn)(void));
70
+ void ffi_call_asm (size_t *stackargs, struct call_context *regargs,
71
+ void (*fn) (void), void *closure);
72
72
  */
73
73
 
74
74
  #define FRAME_LEN (8 * FLTS + 8 * PTRS + 16)
@@ -98,6 +98,7 @@ ffi_call_asm:
98
98
 
99
99
  # Load arguments
100
100
  mv t1, a2
101
+ mv t2, a3
101
102
 
102
103
  #if FLTS
103
104
  FLARG fa0, -FRAME_LEN+0*FLTS(fp)
@@ -145,8 +146,10 @@ ffi_call_asm:
145
146
 
146
147
  /*
147
148
  ffi_closure_asm. Expects address of the passed-in ffi_closure in t1.
148
- void ffi_closure_inner(size_t *stackargs, struct call_context *regargs,
149
- ffi_closure *closure);
149
+ void ffi_closure_inner (ffi_cif *cif,
150
+ void (*fun) (ffi_cif *, void *, void **, void *),
151
+ void *user_data,
152
+ size_t *stackargs, struct call_context *regargs)
150
153
  */
151
154
 
152
155
  .globl ffi_closure_asm
@@ -187,9 +190,11 @@ ffi_closure_asm:
187
190
  SARG a7, 8*FLTS+7*PTRS(sp)
188
191
 
189
192
  /* enter C */
190
- addi a0, sp, FRAME_LEN
191
- mv a1, sp
192
- mv a2, t1
193
+ LARG a0, FFI_TRAMPOLINE_SIZE+0*PTRS(t1)
194
+ LARG a1, FFI_TRAMPOLINE_SIZE+1*PTRS(t1)
195
+ LARG a2, FFI_TRAMPOLINE_SIZE+2*PTRS(t1)
196
+ addi a3, sp, FRAME_LEN
197
+ mv a4, sp
193
198
 
194
199
  call ffi_closure_inner
195
200
 
@@ -212,3 +217,77 @@ ffi_closure_asm:
212
217
  ret
213
218
  .cfi_endproc
214
219
  .size ffi_closure_asm, .-ffi_closure_asm
220
+
221
+ /*
222
+ ffi_go_closure_asm. Expects address of the passed-in ffi_go_closure in t2.
223
+ void ffi_closure_inner (ffi_cif *cif,
224
+ void (*fun) (ffi_cif *, void *, void **, void *),
225
+ void *user_data,
226
+ size_t *stackargs, struct call_context *regargs)
227
+ */
228
+
229
+ .globl ffi_go_closure_asm
230
+ .hidden ffi_go_closure_asm
231
+ .type ffi_go_closure_asm, @function
232
+ ffi_go_closure_asm:
233
+ .cfi_startproc
234
+
235
+ addi sp, sp, -FRAME_LEN
236
+ .cfi_def_cfa_offset FRAME_LEN
237
+
238
+ /* make a frame */
239
+ SARG fp, FRAME_LEN - 2*PTRS(sp)
240
+ .cfi_offset 8, -2*PTRS
241
+ SARG ra, FRAME_LEN - 1*PTRS(sp)
242
+ .cfi_offset 1, -1*PTRS
243
+ addi fp, sp, FRAME_LEN
244
+
245
+ /* save arguments */
246
+ #if FLTS
247
+ FSARG fa0, 0*FLTS(sp)
248
+ FSARG fa1, 1*FLTS(sp)
249
+ FSARG fa2, 2*FLTS(sp)
250
+ FSARG fa3, 3*FLTS(sp)
251
+ FSARG fa4, 4*FLTS(sp)
252
+ FSARG fa5, 5*FLTS(sp)
253
+ FSARG fa6, 6*FLTS(sp)
254
+ FSARG fa7, 7*FLTS(sp)
255
+ #endif
256
+
257
+ SARG a0, 8*FLTS+0*PTRS(sp)
258
+ SARG a1, 8*FLTS+1*PTRS(sp)
259
+ SARG a2, 8*FLTS+2*PTRS(sp)
260
+ SARG a3, 8*FLTS+3*PTRS(sp)
261
+ SARG a4, 8*FLTS+4*PTRS(sp)
262
+ SARG a5, 8*FLTS+5*PTRS(sp)
263
+ SARG a6, 8*FLTS+6*PTRS(sp)
264
+ SARG a7, 8*FLTS+7*PTRS(sp)
265
+
266
+ /* enter C */
267
+ LARG a0, 1*PTRS(t2)
268
+ LARG a1, 2*PTRS(t2)
269
+ mv a2, t2
270
+ addi a3, sp, FRAME_LEN
271
+ mv a4, sp
272
+
273
+ call ffi_closure_inner
274
+
275
+ /* return values */
276
+ #if FLTS
277
+ FLARG fa0, 0*FLTS(sp)
278
+ FLARG fa1, 1*FLTS(sp)
279
+ #endif
280
+
281
+ LARG a0, 8*FLTS+0*PTRS(sp)
282
+ LARG a1, 8*FLTS+1*PTRS(sp)
283
+
284
+ /* restore and return */
285
+ LARG ra, FRAME_LEN-1*PTRS(sp)
286
+ .cfi_restore 1
287
+ LARG fp, FRAME_LEN-2*PTRS(sp)
288
+ .cfi_restore 8
289
+ addi sp, sp, FRAME_LEN
290
+ .cfi_def_cfa_offset 0
291
+ ret
292
+ .cfi_endproc
293
+ .size ffi_go_closure_asm, .-ffi_go_closure_asm
@@ -29,7 +29,7 @@
29
29
  DEALINGS IN THE SOFTWARE.
30
30
  ----------------------------------------------------------------------- */
31
31
 
32
- #ifndef __x86_64__
32
+ #if defined(__i386__) || defined(_M_IX86)
33
33
  #include <ffi.h>
34
34
  #include <ffi_common.h>
35
35
  #include <stdint.h>
@@ -51,6 +51,13 @@
51
51
  # define __declspec(x) __attribute__((x))
52
52
  #endif
53
53
 
54
+ #if defined(_MSC_VER) && defined(_M_IX86)
55
+ /* Stack is not 16-byte aligned on Windows. */
56
+ #define STACK_ALIGN(bytes) (bytes)
57
+ #else
58
+ #define STACK_ALIGN(bytes) FFI_ALIGN (bytes, 16)
59
+ #endif
60
+
54
61
  /* Perform machine dependent cif processing. */
55
62
  ffi_status FFI_HIDDEN
56
63
  ffi_prep_cif_machdep(ffi_cif *cif)
@@ -177,7 +184,7 @@ ffi_prep_cif_machdep(ffi_cif *cif)
177
184
  bytes = FFI_ALIGN (bytes, t->alignment);
178
185
  bytes += FFI_ALIGN (t->size, FFI_SIZEOF_ARG);
179
186
  }
180
- cif->bytes = FFI_ALIGN (bytes, 16);
187
+ cif->bytes = bytes;
181
188
 
182
189
  return FFI_OK;
183
190
  }
@@ -285,7 +292,7 @@ ffi_call_int (ffi_cif *cif, void (*fn)(void), void *rvalue,
285
292
  }
286
293
  }
287
294
 
288
- bytes = cif->bytes;
295
+ bytes = STACK_ALIGN (cif->bytes);
289
296
  stack = alloca(bytes + sizeof(*frame) + rsize);
290
297
  argp = (dir < 0 ? stack + bytes : stack);
291
298
  frame = (struct call_frame *)(stack + bytes);
@@ -429,7 +436,7 @@ ffi_closure_inner (struct closure_frame *frame, char *stack)
429
436
  rvalue = frame->rettemp;
430
437
  pabi = &abi_params[cabi];
431
438
  dir = pabi->dir;
432
- argp = (dir < 0 ? stack + cif->bytes : stack);
439
+ argp = (dir < 0 ? stack + STACK_ALIGN (cif->bytes) : stack);
433
440
 
434
441
  switch (flags)
435
442
  {
@@ -545,17 +552,21 @@ ffi_prep_closure_loc (ffi_closure* closure,
545
552
  case FFI_REGISTER:
546
553
  dest = ffi_closure_REGISTER;
547
554
  op = 0x68; /* pushl imm */
555
+ break;
548
556
  default:
549
557
  return FFI_BAD_ABI;
550
558
  }
551
559
 
560
+ /* endbr32. */
561
+ *(UINT32 *) tramp = 0xfb1e0ff3;
562
+
552
563
  /* movl or pushl immediate. */
553
- tramp[0] = op;
554
- *(void **)(tramp + 1) = codeloc;
564
+ tramp[4] = op;
565
+ *(void **)(tramp + 5) = codeloc;
555
566
 
556
567
  /* jmp dest */
557
- tramp[5] = 0xe9;
558
- *(unsigned *)(tramp + 6) = (unsigned)dest - ((unsigned)codeloc + 10);
568
+ tramp[9] = 0xe9;
569
+ *(unsigned *)(tramp + 10) = (unsigned)dest - ((unsigned)codeloc + 14);
559
570
 
560
571
  closure->cif = cif;
561
572
  closure->fun = fun;
@@ -692,7 +703,7 @@ ffi_raw_call(ffi_cif *cif, void (*fn)(void), void *rvalue, ffi_raw *avalue)
692
703
  }
693
704
  }
694
705
 
695
- bytes = cif->bytes;
706
+ bytes = STACK_ALIGN (cif->bytes);
696
707
  argp = stack =
697
708
  (void *)((uintptr_t)alloca(bytes + sizeof(*frame) + rsize + 15) & ~16);
698
709
  frame = (struct call_frame *)(stack + bytes);
@@ -750,4 +761,4 @@ ffi_raw_call(ffi_cif *cif, void (*fn)(void), void *rvalue, ffi_raw *avalue)
750
761
  ffi_call_i386 (frame, stack);
751
762
  }
752
763
  #endif /* !FFI_NO_RAW_API */
753
- #endif /* !__x86_64__ */
764
+ #endif /* __i386__ */
@@ -282,7 +282,7 @@ classify_argument (ffi_type *type, enum x86_64_reg_class classes[],
282
282
 
283
283
  /* The X86_64_SSEUP_CLASS should be always preceded by
284
284
  X86_64_SSE_CLASS or X86_64_SSEUP_CLASS. */
285
- if (classes[i] == X86_64_SSEUP_CLASS
285
+ if (i > 1 && classes[i] == X86_64_SSEUP_CLASS
286
286
  && classes[i - 1] != X86_64_SSE_CLASS
287
287
  && classes[i - 1] != X86_64_SSEUP_CLASS)
288
288
  {
@@ -293,7 +293,7 @@ classify_argument (ffi_type *type, enum x86_64_reg_class classes[],
293
293
 
294
294
  /* If X86_64_X87UP_CLASS isn't preceded by X86_64_X87_CLASS,
295
295
  everything should be passed in memory. */
296
- if (classes[i] == X86_64_X87UP_CLASS
296
+ if (i > 1 && classes[i] == X86_64_X87UP_CLASS
297
297
  && (classes[i - 1] != X86_64_X87_CLASS))
298
298
  {
299
299
  /* The first one should never be X86_64_X87UP_CLASS. */
@@ -394,7 +394,7 @@ extern ffi_status
394
394
  ffi_prep_cif_machdep_efi64(ffi_cif *cif);
395
395
  #endif
396
396
 
397
- ffi_status
397
+ ffi_status FFI_HIDDEN
398
398
  ffi_prep_cif_machdep (ffi_cif *cif)
399
399
  {
400
400
  int gprcount, ssecount, i, avn, ngpr, nsse;
@@ -451,9 +451,11 @@ ffi_prep_cif_machdep (ffi_cif *cif)
451
451
  case FFI_TYPE_DOUBLE:
452
452
  flags = UNIX64_RET_XMM64;
453
453
  break;
454
+ #if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE
454
455
  case FFI_TYPE_LONGDOUBLE:
455
456
  flags = UNIX64_RET_X87;
456
457
  break;
458
+ #endif
457
459
  case FFI_TYPE_STRUCT:
458
460
  n = examine_argument (cif->rtype, classes, 1, &ngpr, &nsse);
459
461
  if (n == 0)
@@ -726,13 +728,15 @@ ffi_prep_closure_loc (ffi_closure* closure,
726
728
  void *user_data,
727
729
  void *codeloc)
728
730
  {
729
- static const unsigned char trampoline[16] = {
730
- /* leaq -0x7(%rip),%r10 # 0x0 */
731
- 0x4c, 0x8d, 0x15, 0xf9, 0xff, 0xff, 0xff,
732
- /* jmpq *0x3(%rip) # 0x10 */
733
- 0xff, 0x25, 0x03, 0x00, 0x00, 0x00,
734
- /* nopl (%rax) */
735
- 0x0f, 0x1f, 0x00
731
+ static const unsigned char trampoline[24] = {
732
+ /* endbr64 */
733
+ 0xf3, 0x0f, 0x1e, 0xfa,
734
+ /* leaq -0xb(%rip),%r10 # 0x0 */
735
+ 0x4c, 0x8d, 0x15, 0xf5, 0xff, 0xff, 0xff,
736
+ /* jmpq *0x7(%rip) # 0x18 */
737
+ 0xff, 0x25, 0x07, 0x00, 0x00, 0x00,
738
+ /* nopl 0(%rax) */
739
+ 0x0f, 0x1f, 0x80, 0x00, 0x00, 0x00, 0x00
736
740
  };
737
741
  void (*dest)(void);
738
742
  char *tramp = closure->tramp;
@@ -750,7 +754,7 @@ ffi_prep_closure_loc (ffi_closure* closure,
750
754
  dest = ffi_closure_unix64;
751
755
 
752
756
  memcpy (tramp, trampoline, sizeof(trampoline));
753
- *(UINT64 *)(tramp + 16) = (uintptr_t)dest;
757
+ *(UINT64 *)(tramp + sizeof (trampoline)) = (uintptr_t)dest;
754
758
 
755
759
  closure->cif = cif;
756
760
  closure->fun = fun;
@@ -136,12 +136,25 @@ typedef enum ffi_abi {
136
136
 
137
137
  #if defined (X86_64) || defined(X86_WIN64) \
138
138
  || (defined (__x86_64__) && defined (X86_DARWIN))
139
- # define FFI_TRAMPOLINE_SIZE 24
139
+ /* 4 bytes of ENDBR64 + 7 bytes of LEA + 6 bytes of JMP + 7 bytes of NOP
140
+ + 8 bytes of pointer. */
141
+ # define FFI_TRAMPOLINE_SIZE 32
140
142
  # define FFI_NATIVE_RAW_API 0
141
143
  #else
142
- # define FFI_TRAMPOLINE_SIZE 12
144
+ /* 4 bytes of ENDBR32 + 5 bytes of MOV + 5 bytes of JMP + 2 unused
145
+ bytes. */
146
+ # define FFI_TRAMPOLINE_SIZE 16
143
147
  # define FFI_NATIVE_RAW_API 1 /* x86 has native raw api support */
144
148
  #endif
145
149
 
150
+ #if !defined(GENERATE_LIBFFI_MAP) && defined(__ASSEMBLER__) \
151
+ && defined(__CET__)
152
+ # include <cet.h>
153
+ # define _CET_NOTRACK notrack
154
+ #else
155
+ # define _CET_ENDBR
156
+ # define _CET_NOTRACK
157
+ #endif
158
+
146
159
  #endif
147
160
 
@@ -25,6 +25,7 @@
25
25
  DEALINGS IN THE SOFTWARE.
26
26
  ----------------------------------------------------------------------- */
27
27
 
28
+ #if defined(__x86_64__) || defined(_M_AMD64)
28
29
  #include <ffi.h>
29
30
  #include <ffi_common.h>
30
31
  #include <stdlib.h>
@@ -33,7 +34,7 @@
33
34
  #ifdef X86_WIN64
34
35
  #define EFI64(name) name
35
36
  #else
36
- #define EFI64(name) name##_efi64
37
+ #define EFI64(name) FFI_HIDDEN name##_efi64
37
38
  #endif
38
39
 
39
40
  struct win64_call_frame
@@ -48,7 +49,7 @@ struct win64_call_frame
48
49
  extern void ffi_call_win64 (void *stack, struct win64_call_frame *,
49
50
  void *closure) FFI_HIDDEN;
50
51
 
51
- ffi_status
52
+ ffi_status FFI_HIDDEN
52
53
  EFI64(ffi_prep_cif_machdep)(ffi_cif *cif)
53
54
  {
54
55
  int flags, n;
@@ -195,13 +196,15 @@ EFI64(ffi_prep_closure_loc)(ffi_closure* closure,
195
196
  void *user_data,
196
197
  void *codeloc)
197
198
  {
198
- static const unsigned char trampoline[16] = {
199
- /* leaq -0x7(%rip),%r10 # 0x0 */
200
- 0x4c, 0x8d, 0x15, 0xf9, 0xff, 0xff, 0xff,
201
- /* jmpq *0x3(%rip) # 0x10 */
202
- 0xff, 0x25, 0x03, 0x00, 0x00, 0x00,
203
- /* nopl (%rax) */
204
- 0x0f, 0x1f, 0x00
199
+ static const unsigned char trampoline[FFI_TRAMPOLINE_SIZE - 8] = {
200
+ /* endbr64 */
201
+ 0xf3, 0x0f, 0x1e, 0xfa,
202
+ /* leaq -0xb(%rip),%r10 # 0x0 */
203
+ 0x4c, 0x8d, 0x15, 0xf5, 0xff, 0xff, 0xff,
204
+ /* jmpq *0x7(%rip) # 0x18 */
205
+ 0xff, 0x25, 0x07, 0x00, 0x00, 0x00,
206
+ /* nopl 0(%rax) */
207
+ 0x0f, 0x1f, 0x80, 0x00, 0x00, 0x00, 0x00
205
208
  };
206
209
  char *tramp = closure->tramp;
207
210
 
@@ -215,7 +218,7 @@ EFI64(ffi_prep_closure_loc)(ffi_closure* closure,
215
218
  }
216
219
 
217
220
  memcpy (tramp, trampoline, sizeof(trampoline));
218
- *(UINT64 *)(tramp + 16) = (uintptr_t)ffi_closure_win64;
221
+ *(UINT64 *)(tramp + sizeof (trampoline)) = (uintptr_t)ffi_closure_win64;
219
222
 
220
223
  closure->cif = cif;
221
224
  closure->fun = fun;
@@ -306,3 +309,5 @@ ffi_closure_win64_inner(ffi_cif *cif,
306
309
  fun (cif, rvalue, avalue, user_data);
307
310
  return flags;
308
311
  }
312
+
313
+ #endif /* __x86_64__ */
@@ -26,7 +26,7 @@
26
26
  DEALINGS IN THE SOFTWARE.
27
27
  ----------------------------------------------------------------------- */
28
28
 
29
- #ifndef __x86_64__
29
+ #ifdef __i386__
30
30
  #ifndef _MSC_VER
31
31
 
32
32
  #define LIBFFI_ASM
@@ -92,6 +92,7 @@
92
92
  ffi_call_i386:
93
93
  L(UW0):
94
94
  # cfi_startproc
95
+ _CET_ENDBR
95
96
  #if !HAVE_FASTCALL
96
97
  movl 4(%esp), %ecx
97
98
  movl 8(%esp), %edx
@@ -133,7 +134,7 @@ L(pc1):
133
134
  leal L(store_table)(,%ecx, 8), %ebx
134
135
  #endif
135
136
  movl 16(%ebp), %ecx /* load result address */
136
- jmp *%ebx
137
+ _CET_NOTRACK jmp *%ebx
137
138
 
138
139
  .balign 8
139
140
  L(store_table):
@@ -256,7 +257,7 @@ ENDF(ffi_call_i386)
256
257
  andl $X86_RET_TYPE_MASK, %eax; \
257
258
  leal L(C1(load_table,N))(, %eax, 8), %edx; \
258
259
  movl closure_CF(%esp), %eax; /* optimiztic load */ \
259
- jmp *%edx
260
+ _CET_NOTRACK jmp *%edx
260
261
 
261
262
  #ifdef __PIC__
262
263
  # if defined X86_DARWIN || defined HAVE_HIDDEN_VISIBILITY_ATTRIBUTE
@@ -267,7 +268,7 @@ ENDF(ffi_call_i386)
267
268
  L(C1(pc,N)): \
268
269
  leal L(C1(load_table,N))-L(C1(pc,N))(%edx, %eax, 8), %edx; \
269
270
  movl closure_CF(%esp), %eax; /* optimiztic load */ \
270
- jmp *%edx
271
+ _CET_NOTRACK jmp *%edx
271
272
  # else
272
273
  # define FFI_CLOSURE_CALL_INNER_SAVE_EBX
273
274
  # undef FFI_CLOSURE_CALL_INNER
@@ -286,7 +287,7 @@ L(C1(UW,UWN)): \
286
287
  L(C1(UW,UWN)): \
287
288
  /* cfi_restore(%ebx); */ \
288
289
  movl closure_CF(%esp), %eax; /* optimiztic load */ \
289
- jmp *%edx
290
+ _CET_NOTRACK jmp *%edx
290
291
  # endif /* DARWIN || HIDDEN */
291
292
  #endif /* __PIC__ */
292
293
 
@@ -296,6 +297,7 @@ L(C1(UW,UWN)): \
296
297
  C(ffi_go_closure_EAX):
297
298
  L(UW6):
298
299
  # cfi_startproc
300
+ _CET_ENDBR
299
301
  subl $closure_FS, %esp
300
302
  L(UW7):
301
303
  # cfi_def_cfa_offset(closure_FS + 4)
@@ -316,6 +318,7 @@ ENDF(C(ffi_go_closure_EAX))
316
318
  C(ffi_go_closure_ECX):
317
319
  L(UW9):
318
320
  # cfi_startproc
321
+ _CET_ENDBR
319
322
  subl $closure_FS, %esp
320
323
  L(UW10):
321
324
  # cfi_def_cfa_offset(closure_FS + 4)
@@ -340,6 +343,7 @@ ENDF(C(ffi_go_closure_ECX))
340
343
  C(ffi_closure_i386):
341
344
  L(UW12):
342
345
  # cfi_startproc
346
+ _CET_ENDBR
343
347
  subl $closure_FS, %esp
344
348
  L(UW13):
345
349
  # cfi_def_cfa_offset(closure_FS + 4)
@@ -423,6 +427,7 @@ ENDF(C(ffi_closure_i386))
423
427
  C(ffi_go_closure_STDCALL):
424
428
  L(UW21):
425
429
  # cfi_startproc
430
+ _CET_ENDBR
426
431
  subl $closure_FS, %esp
427
432
  L(UW22):
428
433
  # cfi_def_cfa_offset(closure_FS + 4)
@@ -448,6 +453,7 @@ L(UW24):
448
453
  # cfi_startproc
449
454
  # cfi_def_cfa(%esp, 8)
450
455
  # cfi_offset(%eip, -8)
456
+ _CET_ENDBR
451
457
  subl $closure_FS-4, %esp
452
458
  L(UW25):
453
459
  # cfi_def_cfa_offset(closure_FS + 4)
@@ -470,6 +476,7 @@ ENDF(C(ffi_closure_REGISTER))
470
476
  C(ffi_closure_STDCALL):
471
477
  L(UW27):
472
478
  # cfi_startproc
479
+ _CET_ENDBR
473
480
  subl $closure_FS, %esp
474
481
  L(UW28):
475
482
  # cfi_def_cfa_offset(closure_FS + 4)
@@ -576,6 +583,7 @@ ENDF(C(ffi_closure_STDCALL))
576
583
  C(ffi_closure_raw_SYSV):
577
584
  L(UW32):
578
585
  # cfi_startproc
586
+ _CET_ENDBR
579
587
  subl $raw_closure_S_FS, %esp
580
588
  L(UW33):
581
589
  # cfi_def_cfa_offset(raw_closure_S_FS + 4)
@@ -679,6 +687,7 @@ ENDF(C(ffi_closure_raw_SYSV))
679
687
  C(ffi_closure_raw_THISCALL):
680
688
  L(UW41):
681
689
  # cfi_startproc
690
+ _CET_ENDBR
682
691
  /* Rearrange the stack such that %ecx is the first argument.
683
692
  This means moving the return address. */
684
693
  popl %edx
@@ -792,9 +801,9 @@ ENDF(C(ffi_closure_raw_THISCALL))
792
801
 
793
802
  #ifdef X86_DARWIN
794
803
  # define COMDAT(X) \
795
- .section __TEXT,__textcoal_nt,coalesced,pure_instructions; \
804
+ .section __TEXT,__text,coalesced,pure_instructions; \
796
805
  .weak_definition X; \
797
- .private_extern X
806
+ FFI_HIDDEN(X)
798
807
  #elif defined __ELF__ && !(defined(__sun__) && defined(__svr4__))
799
808
  # define COMDAT(X) \
800
809
  .section .text.X,"axG",@progbits,X,comdat; \
@@ -1035,8 +1044,94 @@ L(SFDE9):
1035
1044
  L(EFDE9):
1036
1045
  #endif /* !FFI_NO_RAW_API */
1037
1046
 
1047
+ #ifdef _WIN32
1048
+ .def @feat.00;
1049
+ .scl 3;
1050
+ .type 0;
1051
+ .endef
1052
+ .globl @feat.00
1053
+ @feat.00 = 1
1054
+ #endif
1055
+
1056
+ #ifdef __APPLE__
1057
+ .subsections_via_symbols
1058
+ .section __LD,__compact_unwind,regular,debug
1059
+
1060
+ /* compact unwind for ffi_call_i386 */
1061
+ .long C(ffi_call_i386)
1062
+ .set L1,L(UW5)-L(UW0)
1063
+ .long L1
1064
+ .long 0x04000000 /* use dwarf unwind info */
1065
+ .long 0
1066
+ .long 0
1067
+
1068
+ /* compact unwind for ffi_go_closure_EAX */
1069
+ .long C(ffi_go_closure_EAX)
1070
+ .set L2,L(UW8)-L(UW6)
1071
+ .long L2
1072
+ .long 0x04000000 /* use dwarf unwind info */
1073
+ .long 0
1074
+ .long 0
1075
+
1076
+ /* compact unwind for ffi_go_closure_ECX */
1077
+ .long C(ffi_go_closure_ECX)
1078
+ .set L3,L(UW11)-L(UW9)
1079
+ .long L3
1080
+ .long 0x04000000 /* use dwarf unwind info */
1081
+ .long 0
1082
+ .long 0
1083
+
1084
+ /* compact unwind for ffi_closure_i386 */
1085
+ .long C(ffi_closure_i386)
1086
+ .set L4,L(UW20)-L(UW12)
1087
+ .long L4
1088
+ .long 0x04000000 /* use dwarf unwind info */
1089
+ .long 0
1090
+ .long 0
1091
+
1092
+ /* compact unwind for ffi_go_closure_STDCALL */
1093
+ .long C(ffi_go_closure_STDCALL)
1094
+ .set L5,L(UW23)-L(UW21)
1095
+ .long L5
1096
+ .long 0x04000000 /* use dwarf unwind info */
1097
+ .long 0
1098
+ .long 0
1099
+
1100
+ /* compact unwind for ffi_closure_REGISTER */
1101
+ .long C(ffi_closure_REGISTER)
1102
+ .set L6,L(UW26)-L(UW24)
1103
+ .long L6
1104
+ .long 0x04000000 /* use dwarf unwind info */
1105
+ .long 0
1106
+ .long 0
1107
+
1108
+ /* compact unwind for ffi_closure_STDCALL */
1109
+ .long C(ffi_closure_STDCALL)
1110
+ .set L7,L(UW31)-L(UW27)
1111
+ .long L7
1112
+ .long 0x04000000 /* use dwarf unwind info */
1113
+ .long 0
1114
+ .long 0
1115
+
1116
+ /* compact unwind for ffi_closure_raw_SYSV */
1117
+ .long C(ffi_closure_raw_SYSV)
1118
+ .set L8,L(UW40)-L(UW32)
1119
+ .long L8
1120
+ .long 0x04000000 /* use dwarf unwind info */
1121
+ .long 0
1122
+ .long 0
1123
+
1124
+ /* compact unwind for ffi_closure_raw_THISCALL */
1125
+ .long C(ffi_closure_raw_THISCALL)
1126
+ .set L9,L(UW52)-L(UW41)
1127
+ .long L9
1128
+ .long 0x04000000 /* use dwarf unwind info */
1129
+ .long 0
1130
+ .long 0
1131
+ #endif /* __APPLE__ */
1132
+
1038
1133
  #endif /* ifndef _MSC_VER */
1039
- #endif /* ifndef __x86_64__ */
1134
+ #endif /* ifdef __i386__ */
1040
1135
 
1041
1136
  #if defined __ELF__ && defined __linux__
1042
1137
  .section .note.GNU-stack,"",@progbits