ffi 1.11.3 → 1.15.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (276) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +184 -0
  3. data/Gemfile +3 -4
  4. data/README.md +24 -3
  5. data/Rakefile +64 -69
  6. data/ext/ffi_c/AbstractMemory.c +24 -25
  7. data/ext/ffi_c/Buffer.c +4 -9
  8. data/ext/ffi_c/Call.c +4 -16
  9. data/ext/ffi_c/ClosurePool.c +75 -25
  10. data/ext/ffi_c/ClosurePool.h +3 -1
  11. data/ext/ffi_c/DynamicLibrary.c +1 -6
  12. data/ext/ffi_c/Function.c +38 -38
  13. data/ext/ffi_c/Function.h +0 -4
  14. data/ext/ffi_c/FunctionInfo.c +3 -8
  15. data/ext/ffi_c/LastError.c +2 -6
  16. data/ext/ffi_c/LongDouble.c +5 -3
  17. data/ext/ffi_c/LongDouble.h +0 -4
  18. data/ext/ffi_c/MemoryPointer.c +3 -8
  19. data/ext/ffi_c/MemoryPointer.h +0 -4
  20. data/ext/ffi_c/MethodHandle.c +21 -31
  21. data/ext/ffi_c/MethodHandle.h +3 -2
  22. data/ext/ffi_c/Platform.c +5 -9
  23. data/ext/ffi_c/Pointer.c +25 -26
  24. data/ext/ffi_c/Pointer.h +0 -4
  25. data/ext/ffi_c/Struct.c +49 -56
  26. data/ext/ffi_c/Struct.h +12 -6
  27. data/ext/ffi_c/StructByValue.c +2 -7
  28. data/ext/ffi_c/StructLayout.c +22 -20
  29. data/ext/ffi_c/Thread.c +0 -8
  30. data/ext/ffi_c/Thread.h +1 -9
  31. data/ext/ffi_c/Type.c +1 -1
  32. data/ext/ffi_c/Types.c +6 -7
  33. data/ext/ffi_c/Types.h +3 -4
  34. data/ext/ffi_c/Variadic.c +14 -9
  35. data/ext/ffi_c/compat.h +4 -0
  36. data/ext/ffi_c/extconf.rb +36 -24
  37. data/ext/ffi_c/libffi/.travis/bfin-sim.exp +58 -0
  38. data/ext/ffi_c/libffi/.travis/build-cross-in-container.sh +14 -0
  39. data/ext/ffi_c/libffi/.travis/build-in-container.sh +2 -12
  40. data/ext/ffi_c/libffi/.travis/build.sh +62 -30
  41. data/ext/ffi_c/libffi/.travis/install.sh +65 -37
  42. data/ext/ffi_c/libffi/.travis/m32r-sim.exp +58 -0
  43. data/ext/ffi_c/libffi/.travis/moxie-sim.exp +1 -1
  44. data/ext/ffi_c/libffi/.travis/or1k-sim.exp +58 -0
  45. data/ext/ffi_c/libffi/.travis/powerpc-eabisim.exp +58 -0
  46. data/ext/ffi_c/libffi/.travis/site.exp +10 -1
  47. data/ext/ffi_c/libffi/.travis/wine-sim.exp +55 -0
  48. data/ext/ffi_c/libffi/.travis.yml +32 -12
  49. data/ext/ffi_c/libffi/{ChangeLog.libffi-3.1 → ChangeLog.old} +1407 -0
  50. data/ext/ffi_c/libffi/LICENSE +1 -1
  51. data/ext/ffi_c/libffi/Makefile.am +53 -61
  52. data/ext/ffi_c/libffi/Makefile.in +458 -207
  53. data/ext/ffi_c/libffi/README.md +22 -6
  54. data/ext/ffi_c/libffi/config.guess +552 -331
  55. data/ext/ffi_c/libffi/config.sub +1321 -1306
  56. data/ext/ffi_c/libffi/configure +414 -342
  57. data/ext/ffi_c/libffi/configure.ac +32 -11
  58. data/ext/ffi_c/libffi/configure.host +37 -22
  59. data/ext/ffi_c/libffi/doc/Makefile.in +9 -5
  60. data/ext/ffi_c/libffi/doc/libffi.texi +26 -14
  61. data/ext/ffi_c/libffi/doc/version.texi +4 -4
  62. data/ext/ffi_c/libffi/fficonfig.h.in +13 -0
  63. data/ext/ffi_c/libffi/generate-darwin-source-and-headers.py +2 -4
  64. data/ext/ffi_c/libffi/include/Makefile.in +10 -6
  65. data/ext/ffi_c/libffi/include/ffi.h.in +15 -7
  66. data/ext/ffi_c/libffi/install-sh +23 -13
  67. data/ext/ffi_c/libffi/libffi.map.in +8 -12
  68. data/ext/ffi_c/libffi/libffi.xcodeproj/project.pbxproj +2 -48
  69. data/ext/ffi_c/libffi/libtool-version +1 -1
  70. data/ext/ffi_c/libffi/ltmain.sh +156 -61
  71. data/ext/ffi_c/libffi/m4/ax_append_flag.m4 +5 -26
  72. data/ext/ffi_c/libffi/m4/ax_check_compile_flag.m4 +5 -26
  73. data/ext/ffi_c/libffi/m4/ax_compiler_vendor.m4 +2 -1
  74. data/ext/ffi_c/libffi/m4/ax_configure_args.m4 +5 -26
  75. data/ext/ffi_c/libffi/m4/ax_gcc_archflag.m4 +7 -3
  76. data/ext/ffi_c/libffi/man/Makefile.in +9 -5
  77. data/ext/ffi_c/libffi/missing +8 -8
  78. data/ext/ffi_c/libffi/msvcc.sh +11 -11
  79. data/ext/ffi_c/libffi/src/aarch64/ffi.c +51 -35
  80. data/ext/ffi_c/libffi/src/aarch64/ffitarget.h +10 -5
  81. data/ext/ffi_c/libffi/src/aarch64/internal.h +1 -0
  82. data/ext/ffi_c/libffi/src/aarch64/sysv.S +14 -3
  83. data/ext/ffi_c/libffi/src/aarch64/win64_armasm.S +1 -1
  84. data/ext/ffi_c/libffi/src/arm/ffi.c +22 -0
  85. data/ext/ffi_c/libffi/src/arm/sysv.S +4 -4
  86. data/ext/ffi_c/libffi/src/closures.c +43 -12
  87. data/ext/ffi_c/libffi/src/csky/ffi.c +395 -0
  88. data/ext/ffi_c/libffi/src/csky/ffitarget.h +63 -0
  89. data/ext/ffi_c/libffi/src/csky/sysv.S +371 -0
  90. data/ext/ffi_c/libffi/src/dlmalloc.c +1 -1
  91. data/ext/ffi_c/libffi/src/kvx/asm.h +5 -0
  92. data/ext/ffi_c/libffi/src/kvx/ffi.c +273 -0
  93. data/ext/ffi_c/libffi/src/kvx/ffitarget.h +75 -0
  94. data/ext/ffi_c/libffi/src/kvx/sysv.S +127 -0
  95. data/ext/ffi_c/libffi/src/mips/ffi.c +5 -1
  96. data/ext/ffi_c/libffi/src/mips/ffitarget.h +1 -1
  97. data/ext/ffi_c/libffi/src/mips/o32.S +2 -0
  98. data/ext/ffi_c/libffi/src/pa/ffi.c +46 -91
  99. data/ext/ffi_c/libffi/src/pa/ffitarget.h +1 -6
  100. data/ext/ffi_c/libffi/src/pa/hpux32.S +4 -2
  101. data/ext/ffi_c/libffi/src/pa/linux.S +4 -2
  102. data/ext/ffi_c/libffi/src/powerpc/ffi.c +3 -2
  103. data/ext/ffi_c/libffi/src/powerpc/ffi_darwin.c +13 -1
  104. data/ext/ffi_c/libffi/src/powerpc/ffi_linux64.c +154 -8
  105. data/ext/ffi_c/libffi/src/powerpc/ffi_powerpc.h +18 -7
  106. data/ext/ffi_c/libffi/src/powerpc/ffitarget.h +10 -4
  107. data/ext/ffi_c/libffi/src/powerpc/linux64.S +91 -28
  108. data/ext/ffi_c/libffi/src/powerpc/linux64_closure.S +80 -4
  109. data/ext/ffi_c/libffi/src/powerpc/sysv.S +5 -7
  110. data/ext/ffi_c/libffi/src/prep_cif.c +1 -1
  111. data/ext/ffi_c/libffi/src/x86/ffi.c +15 -6
  112. data/ext/ffi_c/libffi/src/x86/ffi64.c +17 -8
  113. data/ext/ffi_c/libffi/src/x86/ffitarget.h +15 -2
  114. data/ext/ffi_c/libffi/src/x86/ffiw64.c +15 -8
  115. data/ext/ffi_c/libffi/src/x86/sysv.S +15 -6
  116. data/ext/ffi_c/libffi/src/x86/unix64.S +59 -4
  117. data/ext/ffi_c/libffi/src/x86/win64.S +7 -3
  118. data/ext/ffi_c/libffi/src/x86/win64_intel.S +3 -2
  119. data/ext/ffi_c/libffi/testsuite/Makefile.am +78 -75
  120. data/ext/ffi_c/libffi/testsuite/Makefile.in +124 -84
  121. data/ext/ffi_c/libffi/testsuite/lib/libffi.exp +7 -4
  122. data/ext/ffi_c/libffi/testsuite/libffi.bhaible/bhaible.exp +7 -2
  123. data/ext/ffi_c/libffi/testsuite/libffi.bhaible/test-call.c +4 -4
  124. data/ext/ffi_c/libffi/testsuite/libffi.bhaible/test-callback.c +2 -2
  125. data/ext/ffi_c/libffi/testsuite/libffi.call/call.exp +12 -1
  126. data/ext/ffi_c/libffi/testsuite/libffi.closures/closure.exp +67 -0
  127. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/closure_fn0.c +0 -0
  128. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/closure_fn1.c +0 -0
  129. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/closure_fn2.c +0 -0
  130. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/closure_fn3.c +0 -0
  131. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/closure_fn4.c +0 -0
  132. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/closure_fn5.c +0 -0
  133. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/closure_fn6.c +0 -0
  134. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/closure_loc_fn0.c +0 -0
  135. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/closure_simple.c +0 -0
  136. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_12byte.c +0 -0
  137. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_16byte.c +0 -0
  138. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_18byte.c +0 -0
  139. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_19byte.c +0 -0
  140. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_1_1byte.c +0 -0
  141. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_20byte.c +0 -0
  142. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_20byte1.c +0 -0
  143. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_24byte.c +0 -0
  144. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_2byte.c +0 -0
  145. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_3_1byte.c +0 -0
  146. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_3byte1.c +0 -0
  147. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_3byte2.c +0 -0
  148. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_3float.c +0 -0
  149. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_4_1byte.c +0 -0
  150. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_4byte.c +0 -0
  151. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_5_1_byte.c +0 -0
  152. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_5byte.c +0 -0
  153. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_64byte.c +0 -0
  154. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_6_1_byte.c +0 -0
  155. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_6byte.c +0 -0
  156. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_7_1_byte.c +0 -0
  157. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_7byte.c +0 -0
  158. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_8byte.c +0 -0
  159. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_9byte1.c +0 -0
  160. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_9byte2.c +0 -0
  161. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_align_double.c +0 -0
  162. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_align_float.c +0 -0
  163. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_align_longdouble.c +0 -0
  164. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_align_longdouble_split.c +0 -0
  165. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_align_longdouble_split2.c +0 -0
  166. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_align_pointer.c +0 -0
  167. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_align_sint16.c +0 -0
  168. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_align_sint32.c +0 -0
  169. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_align_sint64.c +0 -0
  170. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_align_uint16.c +0 -0
  171. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_align_uint32.c +0 -0
  172. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_align_uint64.c +0 -0
  173. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_dbls_struct.c +0 -0
  174. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_double.c +0 -0
  175. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_double_va.c +0 -0
  176. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_float.c +0 -0
  177. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_longdouble.c +0 -0
  178. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_longdouble_va.c +0 -0
  179. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_many_mixed_args.c +0 -0
  180. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_many_mixed_float_double.c +0 -0
  181. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_multi_schar.c +0 -0
  182. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_multi_sshort.c +0 -0
  183. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_multi_sshortchar.c +0 -0
  184. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_multi_uchar.c +0 -0
  185. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_multi_ushort.c +0 -0
  186. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_multi_ushortchar.c +0 -0
  187. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_pointer.c +0 -0
  188. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_pointer_stack.c +0 -0
  189. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_schar.c +0 -0
  190. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_sint.c +0 -0
  191. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_sshort.c +0 -0
  192. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_struct_va1.c +0 -0
  193. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_uchar.c +0 -0
  194. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_uchar_va.c +0 -0
  195. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_uint.c +0 -0
  196. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_uint_va.c +0 -0
  197. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_ulong_va.c +0 -0
  198. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_ulonglong.c +0 -0
  199. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_ushort.c +0 -0
  200. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_ushort_va.c +0 -0
  201. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/err_bad_abi.c +0 -0
  202. data/ext/ffi_c/libffi/testsuite/libffi.closures/ffitest.h +138 -0
  203. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/huge_struct.c +3 -1
  204. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/nested_struct.c +0 -0
  205. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/nested_struct1.c +0 -0
  206. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/nested_struct10.c +0 -0
  207. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/nested_struct11.c +0 -0
  208. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/nested_struct2.c +0 -0
  209. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/nested_struct3.c +0 -0
  210. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/nested_struct4.c +0 -0
  211. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/nested_struct5.c +0 -0
  212. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/nested_struct6.c +0 -0
  213. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/nested_struct7.c +0 -0
  214. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/nested_struct8.c +0 -0
  215. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/nested_struct9.c +0 -0
  216. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/problem1.c +0 -0
  217. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/stret_large.c +0 -0
  218. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/stret_large2.c +0 -0
  219. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/stret_medium.c +0 -0
  220. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/stret_medium2.c +0 -0
  221. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/testclosure.c +0 -0
  222. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/unwindtest.cc +0 -0
  223. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/unwindtest_ffi_call.cc +0 -0
  224. data/ffi.gemspec +4 -5
  225. data/lib/ffi/abstract_memory.rb +44 -0
  226. data/lib/ffi/autopointer.rb +1 -1
  227. data/lib/ffi/ffi.rb +2 -0
  228. data/lib/ffi/io.rb +3 -3
  229. data/lib/ffi/library.rb +8 -4
  230. data/lib/ffi/managedstruct.rb +2 -2
  231. data/lib/ffi/platform/aarch64-darwin/types.conf +130 -0
  232. data/lib/ffi/platform/aarch64-freebsd/types.conf +2 -2
  233. data/lib/ffi/platform/aarch64-freebsd12/types.conf +113 -60
  234. data/lib/ffi/platform/aarch64-openbsd/types.conf +134 -0
  235. data/lib/ffi/platform/arm-linux/types.conf +32 -4
  236. data/lib/ffi/platform/i386-windows/types.conf +26 -79
  237. data/lib/ffi/platform/powerpc-linux/types.conf +32 -2
  238. data/lib/ffi/platform/powerpc-openbsd/types.conf +156 -0
  239. data/lib/ffi/platform/powerpc64le-linux/types.conf +100 -0
  240. data/lib/ffi/platform/riscv64-linux/types.conf +104 -0
  241. data/lib/ffi/platform/sparcv9-openbsd/types.conf +156 -0
  242. data/lib/ffi/platform/x86_64-darwin/types.conf +4 -0
  243. data/lib/ffi/platform/x86_64-dragonflybsd/types.conf +4 -22
  244. data/lib/ffi/platform/x86_64-haiku/types.conf +117 -0
  245. data/lib/ffi/platform/x86_64-linux/types.conf +21 -0
  246. data/lib/ffi/platform/x86_64-msys/types.conf +119 -0
  247. data/lib/ffi/platform/x86_64-windows/types.conf +10 -78
  248. data/lib/ffi/platform.rb +18 -8
  249. data/lib/ffi/pointer.rb +21 -14
  250. data/lib/ffi/struct.rb +10 -5
  251. data/lib/ffi/tools/const_generator.rb +6 -4
  252. data/lib/ffi/tools/struct_generator.rb +2 -1
  253. data/lib/ffi/tools/types_generator.rb +2 -0
  254. data/lib/ffi/variadic.rb +1 -10
  255. data/lib/ffi/version.rb +1 -1
  256. data/lib/ffi.rb +10 -3
  257. data/rakelib/ffi_gem_helper.rb +65 -0
  258. data/samples/getlogin.rb +1 -1
  259. data/samples/getpid.rb +1 -1
  260. data/samples/gettimeofday.rb +8 -8
  261. data/samples/hello.rb +2 -1
  262. data/samples/inotify.rb +1 -1
  263. data/samples/pty.rb +1 -2
  264. data/samples/qsort.rb +0 -1
  265. metadata +133 -134
  266. data/.appveyor.yml +0 -27
  267. data/.gitignore +0 -25
  268. data/.gitmodules +0 -4
  269. data/.travis.yml +0 -42
  270. data/.yardopts +0 -5
  271. data/ext/ffi_c/libffi/ChangeLog.libffi +0 -584
  272. data/ext/ffi_c/libffi/ChangeLog.libgcj +0 -40
  273. data/ext/ffi_c/libffi/ChangeLog.v1 +0 -764
  274. data/ext/ffi_c/win32/stdbool.h +0 -8
  275. data/ext/ffi_c/win32/stdint.h +0 -201
  276. data/samples/sample_helper.rb +0 -6
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 644662e700692019ada112b10a164622c08978bbe2aecfeb38205a43df099e28
4
- data.tar.gz: 8699b821c2200c62c49c4265d5ce8b67862f53d71e1a2862b41ed5f44eedad87
3
+ metadata.gz: d6f15f4e38ad34949be88341216eed2ea132c4e5763d333c20c240491b033ff6
4
+ data.tar.gz: deefb7285ccae7d7248ee2697709e859d4c0017e3aab7e183ce7fc2a824bd395
5
5
  SHA512:
6
- metadata.gz: 6aee46baf520f91e112a1fdcd40218f51f100b50f56d126a94982d341f38919f3f550831db1c9da569d8457c2b50707654681b06ae6cae48ac4597d927b0569d
7
- data.tar.gz: c728916db8dad5ec04403ab9cead139b870f56d3e0a34f0b08ec467f9a153c1f29d2f9ad2e30bb3056476a4dd3d42edebfdfbd9f88477f9e08862601cb3277a0
6
+ metadata.gz: 7b2c32adb0af3689632c9b6113389245dba13d5f9e622efd2f322b0226933185ae0fbc128cb33c278dd2ef7fddda106fe8158904e95d1fa7d53b14ff72722ff6
7
+ data.tar.gz: 60ca6ad01c3d977b8b6efe0329683d4105cae8147848c9fcb0cabe643f5957e7a6ab6a06716e1f579ada6e0c3795f4fd4c0f16bda783342310a305423a5d7a60
data/CHANGELOG.md CHANGED
@@ -1,3 +1,187 @@
1
+ 1.15.5 / 2022-01-10
2
+ -------------------
3
+
4
+ Fixed:
5
+ * Fix long double argument or return values on 32bit i686. #849
6
+ * FFI::ConstGenerator: avoid usage of the same binary file simultaneously. #929
7
+
8
+ Added:
9
+ * Add Windows fat binary gem for Ruby-3.1
10
+
11
+ Removed:
12
+ * Remove Windows fat binary gem for Ruby < 2.4
13
+
14
+
15
+ 1.15.4 / 2021-09-01
16
+ -------------------
17
+
18
+ Fixed:
19
+ * Fix build for uClibc. #913
20
+ * Correct module lookup when including `ffi-module` gem. #912
21
+
22
+ Changed:
23
+ * Use ruby code of the ffi gem in JRuby-9.2.20+. #915
24
+
25
+
26
+ 1.15.3 / 2021-06-16
27
+ -------------------
28
+
29
+ Fixed:
30
+ * Fix temporary packaging issue with libffi. #904
31
+
32
+
33
+ 1.15.2 / 2021-06-16
34
+ -------------------
35
+
36
+ Added:
37
+ * Add support for Windows MINGW-UCRT build. #903
38
+ * Add `/opt/homebrew/lib/` to fallback search paths to improve homebrew support. #880 #882
39
+
40
+ Changed:
41
+ * Regenerate `types.conf` for FreeBSD12 aarch64. #902
42
+
43
+
44
+ 1.15.1 / 2021-05-22
45
+ -------------------
46
+
47
+ Fixed:
48
+ * Append -pthread to linker options. #893
49
+ * Use arm or aarch64 to identify Apple ARM CPU arch. #899
50
+ * Allow overriding `gcc` with the `CC` env var in `const_generator.rb` and `struct_generator.rb`. #897
51
+
52
+
53
+ 1.15.0 / 2021-03-05
54
+ -------------------
55
+
56
+ Fixed:
57
+ * Fix MSVC build
58
+ * Fix async callbacks in conjunction with fork(). #884
59
+
60
+ Added:
61
+ * Allow to pass callbacks in varargs. #885
62
+ * Name the threads for FFI callback dispatcher and async thread calls for easier debugging. #883
63
+ The name can be retrieved by Thread.name and is shown by Thread.list.inspect etc.
64
+ Even gdb shows the thread name on supported operating systems.
65
+ * Add types.conf for powerpc64le-linux
66
+ * Add types.conf for riscv64-linux
67
+ * More release automation of ffi gems
68
+
69
+ Changed:
70
+ * Switch from rubygems-tasks to bundler/gem_helper
71
+
72
+ Removed:
73
+ * Remove unused VariadicInvoker#init
74
+
75
+
76
+ 1.14.2 / 2020-12-21
77
+ -------------------
78
+
79
+ Fixed:
80
+ * Fix builtin libffi on newer Ubuntu caused by an outdated Makefile.in . #863
81
+
82
+
83
+ 1.14.1 / 2020-12-19
84
+ -------------------
85
+
86
+ Changed:
87
+ * Revert changes to FFI::Pointer#write_string made in ffi-1.14.0.
88
+ It breaks compatibilty in a way that can cause hard to find errors. #857
89
+
90
+
91
+ 1.14.0 / 2020-12-18
92
+ -------------------
93
+
94
+ Added:
95
+ * Add types.conf for x86_64-msys, x86_64-haiku, aarch64-openbsd and aarch64-darwin (alias arm64-darwin)
96
+ * Add method AbstractMemory#size_limit? . #829
97
+ * Add new extconf option --enable-libffi-alloc which is enabled per default on Apple M1 (arm64-darwin).
98
+
99
+ Changed:
100
+ * Do NULL pointer check only when array length > 0 . #305
101
+ * Raise an error on an unknown order argument. #830
102
+ * Change FFI::Pointer#write_string to terminate with a NUL byte like other string methods. #805
103
+ * Update bundled libffi to latest master.
104
+
105
+ Removed:
106
+ * Remove win32/stdint.h and stdbool.h because of copyright issue. #693
107
+
108
+ Fixed:
109
+ * Fix possible UTF-8 load error in loader script interpretation. #792
110
+ * Fix segfault on non-array argument to #write_array_of_*
111
+ * Fix memory leak in MethodHandle . #815
112
+ * Fix possible segfault in combination with fiddle or other libffi using gems . #835
113
+ * Fix possibility to use ffi ruby gem with JRuby-9.3 . #763
114
+ * Fix a GC issue, when a callback Proc is used on more than 2 callback signatures. #820
115
+
116
+
117
+ 1.13.1 / 2020-06-09
118
+ -------------------
119
+
120
+ Changed:
121
+ * Revert use of `ucrtbase.dll` as default C library on Windows-MINGW.
122
+ `ucrtbase.dll` is still used on MSWIN target. #790
123
+ * Test for `ffi_prep_closure_loc()` to make sure we can use this function.
124
+ This fixes incorrect use of system libffi on MacOS Mojave (10.14). #787
125
+ * Update types.conf on x86_64-dragonflybsd
126
+
127
+
128
+ 1.13.0 / 2020-06-01
129
+ -------------------
130
+
131
+ Added:
132
+ * Add TruffleRuby support. Almost all specs are running on TruffleRuby and succeed. #768
133
+ * Add ruby source files to the java gem. This allows to ship the Ruby library code per platform java gem and add it as a default gem to JRuby. #763
134
+ * Add FFI::Platform::LONG_DOUBLE_SIZE
135
+ * Add bounds checks for writing to an inline char[] . #756
136
+ * Add long double as callback return value. #771
137
+ * Update type definitions and add types from stdint.h and stddef.h on i386-windows, x86_64-windows, x86_64-darwin, x86_64-linux, arm-linux, powerpc-linux. #749
138
+ * Add new type definitions for powerpc-openbsd and sparcv9-openbsd. #775, #778
139
+
140
+ Changed:
141
+ * Raise required ruby version to >= 2.3.
142
+ * Lots of cleanups and improvements in library, specs and benchmarks.
143
+ * Fix a lot of compiler warnings at the C-extension
144
+ * Fix several install issues on MacOS:
145
+ * Look for libffi in SDK paths, since recent versions of macOS removed it from `/usr/include` . #757
146
+ * Fix error `ld: library not found for -lgcc_s.10.4`
147
+ * Don't built for i386 architecture as it is deprecated
148
+ * Several fixes for MSVC build on Windows. #779
149
+ * Use `ucrtbase.dll` as default C library on Windows instead of old `msvcrt.dll`. #779
150
+ * Update builtin libffi to fix a Powerpc issue with parameters of type long
151
+ * Allow unmodified sourcing of (the ruby code of) this gem in JRuby and TruffleRuby as a default gem. #747
152
+ * Improve check to detect if a module has a #find_type method suitable for FFI. This fixes compatibility with stdlib `mkmf` . #776
153
+
154
+ Removed:
155
+ * Reject callback with `:string` return type at definition, because it didn't work so far and is not save to use. #751, #782
156
+
157
+
158
+ 1.12.2 / 2020-02-01
159
+ -------------------
160
+
161
+ * Fix possible segfault at FFI::Struct#[] and []= after GC.compact . #742
162
+
163
+
164
+ 1.12.1 / 2020-01-14
165
+ -------------------
166
+
167
+ Added:
168
+ * Add binary gem support for ruby-2.7 on Windows
169
+
170
+
171
+ 1.12.0 / 2020-01-14
172
+ -------------------
173
+
174
+ Added:
175
+ * FFI::VERSION is defined as part of `require 'ffi'` now.
176
+ It is no longer necessary to `require 'ffi/version'` .
177
+
178
+ Changed:
179
+ * Update libffi to latest master.
180
+
181
+ Deprecated:
182
+ * Overwriting struct layouts is now warned and will be disallowed in ffi-2.0. #734, #735
183
+
184
+
1
185
  1.11.3 / 2019-11-25
2
186
  -------------------
3
187
 
data/Gemfile CHANGED
@@ -1,12 +1,11 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
3
  group :development do
4
- gem 'rake', '~> 12.1'
4
+ gem 'rake', '~> 13.0'
5
5
  gem 'rake-compiler', '~> 1.0.3'
6
- gem 'rake-compiler-dock', '~> 0.7.0'
6
+ gem 'rake-compiler-dock', '~> 1.0'
7
7
  gem 'rspec', '~> 3.0'
8
- gem 'rubygems-tasks', '~> 0.2.4', :require => 'rubygems/tasks'
9
- gem "rubysl", "~> 2.0", :platforms => 'rbx'
8
+ gem 'bundler', '>= 1.16', '< 3'
10
9
  end
11
10
 
12
11
  group :doc do
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # Ruby-FFI https://github.com/ffi/ffi/wiki [![Build Status](https://travis-ci.org/ffi/ffi.svg?branch=master)](https://travis-ci.org/ffi/ffi) [![Build status Windows](https://ci.appveyor.com/api/projects/status/r8wxn1sd4s794gg1/branch/master?svg=true)](https://ci.appveyor.com/project/larskanis/ffi-aofqa/branch/master)
1
+ # Ruby-FFI https://github.com/ffi/ffi/wiki [![Build Status](https://travis-ci.com/ffi/ffi.svg?branch=master)](https://travis-ci.com/ffi/ffi) [![Build status Windows](https://ci.appveyor.com/api/projects/status/r8wxn1sd4s794gg1/branch/master?svg=true)](https://ci.appveyor.com/project/larskanis/ffi-aofqa/branch/master)
2
2
 
3
3
  ## Description
4
4
 
@@ -38,10 +38,19 @@ For less minimalistic and more examples you may look at:
38
38
 
39
39
  ## Requirements
40
40
 
41
- When installing the gem on CRuby (MRI) or Rubinius, you will need:
41
+ When installing the gem on CRuby (MRI), you will need:
42
42
  * A C compiler (e.g., Xcode on macOS, `gcc` or `clang` on everything else)
43
+ Optionally (speeds up installation):
43
44
  * The `libffi` library and development headers - this is commonly in the `libffi-dev` or `libffi-devel` packages
44
45
 
46
+ The ffi gem comes with a builtin libffi version, which is used, when the system libffi library is not available or too old.
47
+ Use of the system libffi can be enforced by:
48
+ ```
49
+ gem install ffi -- --enable-system-libffi # to install the gem manually
50
+ bundle config build.ffi --enable-system-libffi # for bundle install
51
+ ```
52
+ or prevented by `--disable-system-libffi`.
53
+
45
54
  On Linux systems running with [PaX](https://en.wikipedia.org/wiki/PaX) (Gentoo, Alpine, etc.), FFI may trigger `mprotect` errors. You may need to disable [mprotect](https://en.wikibooks.org/wiki/Grsecurity/Appendix/Grsecurity_and_PaX_Configuration_Options#Restrict_mprotect.28.29) for ruby (`paxctl -m [/path/to/ruby]`) for the time being until a solution is found.
46
55
 
47
56
  On FreeBSD systems pkgconf must be installed for the gem to be able to compile using clang. Install either via packages `pkg install pkgconf` or from ports via `devel/pkgconf`.
@@ -53,14 +62,26 @@ On JRuby and TruffleRuby, there are no requirements to install the FFI gem, and
53
62
  From rubygems:
54
63
 
55
64
  [sudo] gem install ffi
65
+
66
+ From a Gemfile using git or GitHub
67
+
68
+ gem 'ffi', github: 'ffi/ffi', submodules: true
56
69
 
57
70
  or from the git repository on github:
58
71
 
59
72
  git clone git://github.com/ffi/ffi.git
60
- git submodule update --init --recursive
61
73
  cd ffi
74
+ git submodule update --init --recursive
75
+ bundle install
62
76
  rake install
63
77
 
78
+ ### Install options:
79
+
80
+ * `--enable-system-libffi` : Force usage of system libffi
81
+ * `--disable-system-libffi` : Force usage of builtin libffi
82
+ * `--enable-libffi-alloc` : Force closure allocation by libffi
83
+ * `--disable-libffi-alloc` : Force closure allocation by builtin method
84
+
64
85
  ## License
65
86
 
66
87
  The ffi library is covered by the BSD license, also see the LICENSE file.
data/Rakefile CHANGED
@@ -1,40 +1,24 @@
1
- require 'rubygems/tasks'
2
1
  require 'rbconfig'
3
- require 'rake/clean'
4
- require File.expand_path("./lib/ffi/version")
5
-
6
2
  require 'date'
7
3
  require 'fileutils'
8
4
  require 'rbconfig'
9
5
  require 'rspec/core/rake_task'
10
6
  require 'rubygems/package_task'
11
-
12
- def java?
13
- /java/ === RUBY_PLATFORM
14
- end
7
+ require 'rake/extensiontask'
8
+ require_relative "lib/ffi/version"
9
+ require_relative "rakelib/ffi_gem_helper"
15
10
 
16
11
  BUILD_DIR = "build"
17
12
  BUILD_EXT_DIR = File.join(BUILD_DIR, "#{RbConfig::CONFIG['arch']}", 'ffi_c', RUBY_VERSION)
18
13
 
19
- def gem_spec
20
- @gem_spec ||= Gem::Specification.load('ffi.gemspec')
21
- end
22
-
23
- TEST_DEPS = []
24
- if RUBY_PLATFORM == "java"
25
- RSpec::Core::RakeTask.new(:spec) do |config|
26
- config.rspec_opts = YAML.load_file 'spec/spec.opts'
27
- end
28
- else
29
- RSpec::Core::RakeTask.new(:spec => :compile) do |config|
30
- config.rspec_opts = YAML.load_file 'spec/spec.opts'
31
- end
14
+ gem_spec = Bundler.load_gemspec('ffi.gemspec')
32
15
 
33
- TEST_DEPS.unshift :compile
16
+ RSpec::Core::RakeTask.new(:spec => :compile) do |config|
17
+ config.rspec_opts = YAML.load_file 'spec/spec.opts'
34
18
  end
35
19
 
36
20
  desc "Build all packages"
37
- task :package => %w[ gem:java gem:windows ]
21
+ task :package => %w[ gem:java gem:native ]
38
22
 
39
23
  CLOBBER.include 'lib/ffi/types.conf'
40
24
  CLOBBER.include 'pkg'
@@ -50,6 +34,13 @@ CLEAN.include "pkg/ffi-*-{mingw32,java}"
50
34
  CLEAN.include 'lib/1.*'
51
35
  CLEAN.include 'lib/2.*'
52
36
 
37
+ # clean all shipped files, that are not in git
38
+ CLEAN.include(
39
+ gem_spec.files -
40
+ `git --git-dir ext/ffi_c/libffi/.git ls-files -z`.split("\x0").map { |f| File.join("ext/ffi_c/libffi", f) } -
41
+ `git ls-files -z`.split("\x0")
42
+ )
43
+
53
44
  task :distclean => :clobber
54
45
 
55
46
  desc "Test the extension"
@@ -58,37 +49,29 @@ task :test => [ :spec ]
58
49
 
59
50
  namespace :bench do
60
51
  ITER = ENV['ITER'] ? ENV['ITER'].to_i : 100000
61
- bench_libs = "-Ilib" unless RUBY_PLATFORM == "java"
62
- bench_files = Dir["bench/bench_*.rb"].reject { |f| f == "bench/bench_helper.rb" }
52
+ bench_files = Dir["bench/bench_*.rb"].sort.reject { |f| f == "bench/bench_helper.rb" }
63
53
  bench_files.each do |bench|
64
- task File.basename(bench, ".rb")[6..-1] => TEST_DEPS do
65
- sh %{#{Gem.ruby} #{bench_libs} #{bench} #{ITER}}
54
+ task File.basename(bench, ".rb")[6..-1] => :compile do
55
+ sh %{#{Gem.ruby} #{bench} #{ITER}}
66
56
  end
67
57
  end
68
- task :all => TEST_DEPS do
58
+ task :all => :compile do
69
59
  bench_files.each do |bench|
70
- sh %{#{Gem.ruby} #{bench_libs} #{bench}}
60
+ sh %{#{Gem.ruby} #{bench}}
71
61
  end
72
62
  end
73
63
  end
74
64
 
75
- task 'spec:run' => TEST_DEPS
76
- task 'spec:specdoc' => TEST_DEPS
65
+ task 'spec:run' => :compile
66
+ task 'spec:specdoc' => :compile
77
67
 
78
68
  task :default => :spec
79
69
 
80
70
  namespace 'java' do
81
71
 
82
- java_gem_spec = Gem::Specification.new do |s|
83
- s.name = gem_spec.name
84
- s.version = gem_spec.version
85
- s.author = gem_spec.author
86
- s.email = gem_spec.email
87
- s.homepage = gem_spec.homepage
88
- s.summary = gem_spec.summary
89
- s.description = gem_spec.description
90
- s.files = %w(LICENSE COPYING README.md CHANGELOG.md Rakefile)
91
- s.license = gem_spec.license
72
+ java_gem_spec = gem_spec.dup.tap do |s|
73
+ s.files.reject! { |f| File.fnmatch?("ext/*", f) }
74
+ s.extensions = []
92
75
  s.platform = 'java'
93
76
  end
94
77
 
@@ -101,36 +84,49 @@ end
101
84
 
102
85
  task 'gem:java' => 'java:gem'
103
86
 
104
- unless java?
87
+ FfiGemHelper.install_tasks
88
+ # Register windows gems to be pushed to rubygems.org
89
+ Bundler::GemHelper.instance.cross_platforms = %w[x86-mingw32 x64-mingw-ucrt x64-mingw32]
90
+
91
+ if RUBY_ENGINE == 'ruby' || RUBY_ENGINE == 'rbx'
105
92
  require 'rake/extensiontask'
106
93
  Rake::ExtensionTask.new('ffi_c', gem_spec) do |ext|
107
94
  ext.name = 'ffi_c' # indicate the name of the extension.
108
95
  # ext.lib_dir = BUILD_DIR # put binaries into this folder.
109
96
  ext.tmp_dir = BUILD_DIR # temporary folder used during compilation.
110
97
  ext.cross_compile = true # enable cross compilation (requires cross compile toolchain)
111
- ext.cross_platform = %w[i386-mingw32 x64-mingw32] # forces the Windows platform instead of the default one
98
+ ext.cross_platform = Bundler::GemHelper.instance.cross_platforms
112
99
  ext.cross_compiling do |spec|
113
100
  spec.files.reject! { |path| File.fnmatch?('ext/*', path) }
114
101
  end
102
+
103
+ end
104
+ else
105
+ task :compile do
106
+ STDERR.puts "Nothing to compile on #{RUBY_ENGINE}"
115
107
  end
108
+ end
116
109
 
117
- # To reduce the gem file size strip mingw32 dlls before packaging
118
- ENV['RUBY_CC_VERSION'].to_s.split(':').each do |ruby_version|
119
- task "build/i386-mingw32/stage/lib/#{ruby_version[/^\d+\.\d+/]}/ffi_c.so" do |t|
120
- sh "i686-w64-mingw32-strip -S build/i386-mingw32/stage/lib/#{ruby_version[/^\d+\.\d+/]}/ffi_c.so"
121
- end
122
110
 
123
- task "build/x64-mingw32/stage/lib/#{ruby_version[/^\d+\.\d+/]}/ffi_c.so" do |t|
124
- sh "x86_64-w64-mingw32-strip -S build/x64-mingw32/stage/lib/#{ruby_version[/^\d+\.\d+/]}/ffi_c.so"
125
- end
111
+ namespace "gem" do
112
+ task 'prepare' do
113
+ require 'rake_compiler_dock'
114
+ sh "bundle package --all"
126
115
  end
127
- end
128
116
 
129
- desc "build a windows gem without all the ceremony"
130
- task "gem:windows" do
131
- require "rake_compiler_dock"
132
- sh "bundle package"
133
- RakeCompilerDock.sh "sudo apt-get update && sudo apt-get install -y libltdl-dev && bundle --local && rake cross native gem MAKE='nice make -j`nproc`'"
117
+ Bundler::GemHelper.instance.cross_platforms.each do |plat|
118
+ desc "Build all native binary gems in parallel"
119
+ multitask 'native' => plat
120
+
121
+ desc "Build the native gem for #{plat}"
122
+ task plat => ['prepare', 'build'] do
123
+ RakeCompilerDock.sh <<-EOT, platform: plat
124
+ sudo apt-get update &&
125
+ sudo apt-get install -y libltdl-dev && bundle --local &&
126
+ rake cross native gem MAKE='nice make -j`nproc`' RUBY_CC_VERSION=${RUBY_CC_VERSION/:2.2.2/}
127
+ EOT
128
+ end
129
+ end
134
130
  end
135
131
 
136
132
  directory "ext/ffi_c/libffi"
@@ -142,7 +138,7 @@ task :libffi => "ext/ffi_c/libffi/autogen.sh"
142
138
 
143
139
  LIBFFI_GIT_FILES = `git --git-dir ext/ffi_c/libffi/.git ls-files -z`.split("\x0")
144
140
 
145
- # Generate files in gemspec but not in libffi's git repo by running autogen.sh
141
+ # Generate files which are in the gemspec but not in libffi's git repo by running autogen.sh
146
142
  gem_spec.files.select do |f|
147
143
  f =~ /ext\/ffi_c\/libffi\/(.*)/ && !LIBFFI_GIT_FILES.include?($1)
148
144
  end.each do |f|
@@ -158,16 +154,20 @@ end.each do |f|
158
154
  end
159
155
  end
160
156
 
161
- $LOAD_PATH.unshift File.join(File.dirname(__FILE__), 'lib')
162
- require 'ffi/platform'
157
+ # Make sure we have all gemspec files before packaging
158
+ task :build => gem_spec.files
159
+ task :gem => :build
160
+
161
+
162
+ require_relative "lib/ffi/platform"
163
163
  types_conf = File.expand_path(File.join(FFI::Platform::CONF_DIR, 'types.conf'))
164
164
  logfile = File.join(File.dirname(__FILE__), 'types_log')
165
165
 
166
- file types_conf => File.join("lib", "ffi", "version.rb") do |task|
166
+ task types_conf do |task|
167
167
  require 'fileutils'
168
- require 'ffi/tools/types_generator'
168
+ require_relative "lib/ffi/tools/types_generator"
169
169
  options = {}
170
- FileUtils.mkdir_p(File.dirname(task.name), { :mode => 0755 })
170
+ FileUtils.mkdir_p(File.dirname(task.name), mode: 0755 )
171
171
  File.open(task.name, File::CREAT|File::TRUNC|File::RDWR, 0644) do |f|
172
172
  f.puts FFI::TypesGenerator.generate(options)
173
173
  end
@@ -177,12 +177,7 @@ file types_conf => File.join("lib", "ffi", "version.rb") do |task|
177
177
  end
178
178
 
179
179
  desc "Create or update type information for platform #{FFI::Platform::NAME}"
180
- task :types_conf => types_conf do
181
- end
182
-
183
- Gem::Tasks.new do |t|
184
- t.scm.tag.format = '%s'
185
- end
180
+ task :types_conf => types_conf
186
181
 
187
182
  begin
188
183
  require 'yard'
@@ -32,12 +32,9 @@
32
32
  #include <sys/types.h>
33
33
  #ifndef _MSC_VER
34
34
  # include <sys/param.h>
35
- # include <stdint.h>
36
- # include <stdbool.h>
37
- #else
38
- # include "win32/stdbool.h"
39
- # include "win32/stdint.h"
40
35
  #endif
36
+ #include <stdint.h>
37
+ #include <stdbool.h>
41
38
 
42
39
  #include <limits.h>
43
40
  #include <ruby.h>
@@ -135,11 +132,13 @@ static VALUE memory_put_array_of_##name(VALUE self, VALUE offset, VALUE ary); \
135
132
  static VALUE \
136
133
  memory_put_array_of_##name(VALUE self, VALUE offset, VALUE ary) \
137
134
  { \
138
- long count = RARRAY_LEN(ary); \
135
+ long count; \
139
136
  long off = NUM2LONG(offset); \
140
137
  AbstractMemory* memory = MEMORY(self); \
141
138
  long i; \
142
- checkWrite(memory); \
139
+ Check_Type(ary, T_ARRAY); \
140
+ count = RARRAY_LEN(ary); \
141
+ if (likely(count > 0)) checkWrite(memory); \
143
142
  checkBounds(memory, off, count * sizeof(type)); \
144
143
  for (i = 0; i < count; i++) { \
145
144
  type tmp = (type) VAL(toNative(RARRAY_PTR(ary)[i]), swap); \
@@ -162,7 +161,7 @@ memory_get_array_of_##name(VALUE self, VALUE offset, VALUE length) \
162
161
  AbstractMemory* memory = MEMORY(self); \
163
162
  VALUE retVal = rb_ary_new2(count); \
164
163
  long i; \
165
- checkRead(memory); \
164
+ if (likely(count > 0)) checkRead(memory); \
166
165
  checkBounds(memory, off, count * sizeof(type)); \
167
166
  for (i = 0; i < count; ++i) { \
168
167
  type tmp; \
@@ -209,13 +208,13 @@ SWAPU16(uint16_t x)
209
208
  ((x >> 40) & 0x000000000000ff00ULL) | \
210
209
  ((x >> 56) & 0x00000000000000ffULL))
211
210
 
212
- static inline int32_t
211
+ static inline int32_t
213
212
  SWAPS32(int32_t x)
214
213
  {
215
214
  return bswap32(x);
216
215
  }
217
216
 
218
- static inline uint32_t
217
+ static inline uint32_t
219
218
  SWAPU32(uint32_t x)
220
219
  {
221
220
  return bswap32(x);
@@ -450,7 +449,7 @@ memory_get_array_of_string(int argc, VALUE* argv, VALUE self)
450
449
  int i;
451
450
 
452
451
  checkBounds(ptr, off, count * sizeof (char*));
453
-
452
+
454
453
  for (i = 0; i < count; ++i) {
455
454
  const char* strptr = *((const char**) (ptr->address + off) + i);
456
455
  rb_ary_push(retVal, (strptr == NULL ? Qnil : rb_str_new2(strptr)));
@@ -477,7 +476,7 @@ memory_get_array_of_string(int argc, VALUE* argv, VALUE self)
477
476
  * @param [Numeric] count number of strings to get. If nil, return all strings
478
477
  * @return [Array<String>]
479
478
  */
480
- static VALUE
479
+ static VALUE
481
480
  memory_read_array_of_string(int argc, VALUE* argv, VALUE self)
482
481
  {
483
482
  VALUE* rargv = ALLOCA_N(VALUE, argc + 1);
@@ -535,13 +534,13 @@ memory_get_bytes(VALUE self, VALUE offset, VALUE length)
535
534
  {
536
535
  AbstractMemory* ptr = MEMORY(self);
537
536
  long off, len;
538
-
537
+
539
538
  off = NUM2LONG(offset);
540
539
  len = NUM2LONG(length);
541
540
 
542
541
  checkRead(ptr);
543
542
  checkBounds(ptr, off, len);
544
-
543
+
545
544
  return rb_str_new((char *) ptr->address + off, len);
546
545
  }
547
546
 
@@ -595,7 +594,7 @@ memory_put_bytes(int argc, VALUE* argv, VALUE self)
595
594
  * equivalent to :
596
595
  * memory.get_bytes(0, length)
597
596
  */
598
- static VALUE
597
+ static VALUE
599
598
  memory_read_bytes(VALUE self, VALUE length)
600
599
  {
601
600
  return memory_get_bytes(self, INT2FIX(0), length);
@@ -610,7 +609,7 @@ memory_read_bytes(VALUE self, VALUE length)
610
609
  * equivalent to :
611
610
  * memory.put_bytes(0, str, index, length)
612
611
  */
613
- static VALUE
612
+ static VALUE
614
613
  memory_write_bytes(int argc, VALUE* argv, VALUE self)
615
614
  {
616
615
  VALUE* wargv = ALLOCA_N(VALUE, argc + 1);
@@ -643,7 +642,7 @@ memory_type_size(VALUE self)
643
642
  * Document-method: []
644
643
  * call-seq: memory[idx]
645
644
  * @param [Numeric] idx index to access in memory
646
- * @return
645
+ * @return
647
646
  * Memory read accessor.
648
647
  */
649
648
  static VALUE
@@ -748,9 +747,9 @@ MemoryOps rbffi_AbstractMemoryOps = {
748
747
  void
749
748
  rbffi_AbstractMemory_Init(VALUE moduleFFI)
750
749
  {
751
- /*
750
+ /*
752
751
  * Document-class: FFI::AbstractMemory
753
- *
752
+ *
754
753
  * {AbstractMemory} is the base class for many memory management classes such as {Buffer}.
755
754
  *
756
755
  * This class has a lot of methods to work with integers :
@@ -778,8 +777,8 @@ rbffi_AbstractMemory_Init(VALUE moduleFFI)
778
777
  */
779
778
  VALUE classMemory = rb_define_class_under(moduleFFI, "AbstractMemory", rb_cObject);
780
779
  rbffi_AbstractMemoryClass = classMemory;
781
- /*
782
- * Document-variable: FFI::AbstractMemory
780
+ /*
781
+ * Document-variable: FFI::AbstractMemory
783
782
  */
784
783
  rb_global_variable(&rbffi_AbstractMemoryClass);
785
784
  rb_define_alloc_func(classMemory, memory_allocate);
@@ -807,13 +806,13 @@ rbffi_AbstractMemory_Init(VALUE moduleFFI)
807
806
  rb_define_method(classMemory, "read_array_of_" #type, memory_read_array_of_##type, 1); \
808
807
  rb_define_method(classMemory, "write_array_of_u" #type, memory_write_array_of_u##type, 1); \
809
808
  rb_define_method(classMemory, "read_array_of_u" #type, memory_read_array_of_u##type, 1);
810
-
809
+
811
810
  INT(int8);
812
811
  INT(int16);
813
812
  INT(int32);
814
813
  INT(int64);
815
814
  INT(long);
816
-
815
+
817
816
  #define ALIAS(name, old) \
818
817
  rb_define_alias(classMemory, "put_" #name, "put_" #old); \
819
818
  rb_define_alias(classMemory, "get_" #name, "get_" #old); \
@@ -831,12 +830,12 @@ rbffi_AbstractMemory_Init(VALUE moduleFFI)
831
830
  rb_define_alias(classMemory, "read_array_of_" #name, "read_array_of_" #old); \
832
831
  rb_define_alias(classMemory, "write_array_of_u" #name, "write_array_of_u" #old); \
833
832
  rb_define_alias(classMemory, "read_array_of_u" #name, "read_array_of_u" #old);
834
-
833
+
835
834
  ALIAS(char, int8);
836
835
  ALIAS(short, int16);
837
836
  ALIAS(int, int32);
838
837
  ALIAS(long_long, int64);
839
-
838
+
840
839
  /*
841
840
  * Document-method: put_float32
842
841
  * call-seq: memory.put_float32offset, value)