ffi 1.10.0 → 1.14.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (332) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +165 -0
  3. data/Gemfile +6 -4
  4. data/README.md +38 -18
  5. data/Rakefile +36 -120
  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 -48
  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 +25 -129
  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 +12 -10
  17. data/ext/ffi_c/LongDouble.h +0 -4
  18. data/ext/ffi_c/MemoryPointer.c +3 -8
  19. data/ext/ffi_c/MethodHandle.c +21 -31
  20. data/ext/ffi_c/MethodHandle.h +3 -2
  21. data/ext/ffi_c/Platform.c +3 -54
  22. data/ext/ffi_c/Pointer.c +25 -26
  23. data/ext/ffi_c/Struct.c +49 -56
  24. data/ext/ffi_c/Struct.h +12 -6
  25. data/ext/ffi_c/StructByValue.c +2 -7
  26. data/ext/ffi_c/StructLayout.c +22 -19
  27. data/ext/ffi_c/Thread.c +4 -228
  28. data/ext/ffi_c/Thread.h +1 -20
  29. data/ext/ffi_c/Type.c +1 -19
  30. data/ext/ffi_c/Type.h +0 -1
  31. data/ext/ffi_c/Types.c +1 -1
  32. data/ext/ffi_c/Variadic.c +11 -22
  33. data/ext/ffi_c/compat.h +4 -0
  34. data/ext/ffi_c/extconf.rb +53 -30
  35. data/ext/ffi_c/ffi.c +3 -8
  36. data/ext/ffi_c/libffi.darwin.mk +1 -1
  37. data/ext/ffi_c/libffi/.appveyor.yml +29 -13
  38. data/ext/ffi_c/libffi/.gitattributes +4 -0
  39. data/ext/ffi_c/libffi/.travis.yml +51 -2
  40. data/ext/ffi_c/libffi/.travis/bfin-sim.exp +58 -0
  41. data/ext/ffi_c/libffi/.travis/build-cross-in-container.sh +14 -0
  42. data/ext/ffi_c/libffi/.travis/build-in-container.sh +12 -0
  43. data/ext/ffi_c/libffi/.travis/build.sh +116 -8
  44. data/ext/ffi_c/libffi/.travis/install.sh +65 -16
  45. data/ext/ffi_c/libffi/.travis/m32r-sim.exp +58 -0
  46. data/ext/ffi_c/libffi/.travis/moxie-sim.exp +1 -1
  47. data/ext/ffi_c/libffi/.travis/or1k-sim.exp +58 -0
  48. data/ext/ffi_c/libffi/.travis/powerpc-eabisim.exp +58 -0
  49. data/ext/ffi_c/libffi/.travis/site.exp +10 -1
  50. data/ext/ffi_c/libffi/.travis/wine-sim.exp +55 -0
  51. data/ext/ffi_c/libffi/{ChangeLog.libffi-3.1 → ChangeLog.old} +1407 -0
  52. data/ext/ffi_c/libffi/LICENSE +1 -1
  53. data/ext/ffi_c/libffi/LICENSE-BUILDTOOLS +5 -4
  54. data/ext/ffi_c/libffi/Makefile.am +56 -72
  55. data/ext/ffi_c/libffi/README.md +33 -8
  56. data/ext/ffi_c/libffi/config.guess +552 -331
  57. data/ext/ffi_c/libffi/config.sub +1321 -1306
  58. data/ext/ffi_c/libffi/configure.ac +37 -12
  59. data/ext/ffi_c/libffi/configure.host +56 -27
  60. data/ext/ffi_c/libffi/doc/Makefile.am +3 -0
  61. data/ext/ffi_c/libffi/doc/libffi.texi +997 -0
  62. data/ext/ffi_c/libffi/doc/version.texi +4 -0
  63. data/ext/ffi_c/libffi/generate-darwin-source-and-headers.py +2 -4
  64. data/ext/ffi_c/libffi/include/ffi.h.in +19 -7
  65. data/ext/ffi_c/libffi/include/ffi_common.h +5 -1
  66. data/ext/ffi_c/libffi/libffi.map.in +8 -12
  67. data/ext/ffi_c/libffi/libffi.xcodeproj/project.pbxproj +2 -48
  68. data/ext/ffi_c/libffi/libtool-version +1 -1
  69. data/ext/ffi_c/libffi/m4/asmcfi.m4 +1 -1
  70. data/ext/ffi_c/libffi/m4/ax_append_flag.m4 +5 -26
  71. data/ext/ffi_c/libffi/m4/ax_check_compile_flag.m4 +5 -26
  72. data/ext/ffi_c/libffi/m4/ax_compiler_vendor.m4 +2 -1
  73. data/ext/ffi_c/libffi/m4/ax_configure_args.m4 +5 -26
  74. data/ext/ffi_c/libffi/m4/ax_gcc_archflag.m4 +7 -3
  75. data/ext/ffi_c/libffi/make_sunver.pl +333 -0
  76. data/ext/ffi_c/libffi/msvc_build/aarch64/Ffi_staticLib.sln +33 -0
  77. data/ext/ffi_c/libffi/msvc_build/aarch64/Ffi_staticLib.vcxproj +130 -0
  78. data/ext/ffi_c/libffi/msvc_build/aarch64/Ffi_staticLib.vcxproj.filters +57 -0
  79. data/ext/ffi_c/libffi/msvc_build/aarch64/Ffi_staticLib.vcxproj.user +4 -0
  80. data/ext/ffi_c/libffi/msvc_build/aarch64/aarch64_include/ffi.h +511 -0
  81. data/ext/ffi_c/libffi/msvcc.sh +38 -13
  82. data/ext/ffi_c/libffi/src/aarch64/ffi.c +153 -69
  83. data/ext/ffi_c/libffi/src/aarch64/ffitarget.h +19 -3
  84. data/ext/ffi_c/libffi/src/aarch64/internal.h +1 -0
  85. data/ext/ffi_c/libffi/src/aarch64/sysv.S +22 -9
  86. data/ext/ffi_c/libffi/src/aarch64/win64_armasm.S +506 -0
  87. data/ext/ffi_c/libffi/src/arm/ffi.c +62 -5
  88. data/ext/ffi_c/libffi/src/arm/ffitarget.h +8 -1
  89. data/ext/ffi_c/libffi/src/arm/sysv.S +6 -4
  90. data/ext/ffi_c/libffi/src/arm/sysv_msvc_arm32.S +311 -0
  91. data/ext/ffi_c/libffi/src/closures.c +69 -14
  92. data/ext/ffi_c/libffi/src/csky/ffi.c +395 -0
  93. data/ext/ffi_c/libffi/src/csky/ffitarget.h +63 -0
  94. data/ext/ffi_c/libffi/src/csky/sysv.S +371 -0
  95. data/ext/ffi_c/libffi/src/dlmalloc.c +1 -1
  96. data/ext/ffi_c/libffi/src/frv/ffi.c +1 -1
  97. data/ext/ffi_c/libffi/src/kvx/asm.h +5 -0
  98. data/ext/ffi_c/libffi/src/kvx/ffi.c +273 -0
  99. data/ext/ffi_c/libffi/src/kvx/ffitarget.h +75 -0
  100. data/ext/ffi_c/libffi/src/kvx/sysv.S +127 -0
  101. data/ext/ffi_c/libffi/src/metag/ffi.c +1 -1
  102. data/ext/ffi_c/libffi/src/mips/ffi.c +5 -1
  103. data/ext/ffi_c/libffi/src/mips/ffitarget.h +1 -1
  104. data/ext/ffi_c/libffi/src/mips/o32.S +2 -0
  105. data/ext/ffi_c/libffi/src/moxie/ffi.c +1 -1
  106. data/ext/ffi_c/libffi/src/pa/ffi.c +46 -91
  107. data/ext/ffi_c/libffi/src/pa/ffitarget.h +1 -6
  108. data/ext/ffi_c/libffi/src/pa/hpux32.S +4 -2
  109. data/ext/ffi_c/libffi/src/pa/linux.S +27 -4
  110. data/ext/ffi_c/libffi/src/powerpc/ffi.c +6 -4
  111. data/ext/ffi_c/libffi/src/powerpc/ffi_darwin.c +13 -1
  112. data/ext/ffi_c/libffi/src/powerpc/ffi_linux64.c +211 -32
  113. data/ext/ffi_c/libffi/src/powerpc/ffi_powerpc.h +18 -7
  114. data/ext/ffi_c/libffi/src/powerpc/ffitarget.h +10 -4
  115. data/ext/ffi_c/libffi/src/powerpc/linux64.S +91 -28
  116. data/ext/ffi_c/libffi/src/powerpc/linux64_closure.S +81 -5
  117. data/ext/ffi_c/libffi/src/powerpc/sysv.S +5 -7
  118. data/ext/ffi_c/libffi/src/prep_cif.c +4 -2
  119. data/ext/ffi_c/libffi/src/riscv/ffi.c +42 -6
  120. data/ext/ffi_c/libffi/src/riscv/ffitarget.h +1 -0
  121. data/ext/ffi_c/libffi/src/riscv/sysv.S +86 -7
  122. data/ext/ffi_c/libffi/src/x86/ffi.c +29 -12
  123. data/ext/ffi_c/libffi/src/x86/ffi64.c +22 -11
  124. data/ext/ffi_c/libffi/src/x86/ffitarget.h +15 -2
  125. data/ext/ffi_c/libffi/src/x86/ffiw64.c +20 -10
  126. data/ext/ffi_c/libffi/src/x86/sysv.S +105 -10
  127. data/ext/ffi_c/libffi/src/x86/sysv_intel.S +995 -0
  128. data/ext/ffi_c/libffi/src/x86/unix64.S +100 -4
  129. data/ext/ffi_c/libffi/src/x86/win64.S +12 -3
  130. data/ext/ffi_c/libffi/src/x86/win64_intel.S +3 -2
  131. data/ext/ffi_c/libffi/testsuite/Makefile.am +114 -109
  132. data/ext/ffi_c/libffi/testsuite/lib/libffi.exp +32 -8
  133. data/ext/ffi_c/libffi/testsuite/libffi.bhaible/bhaible.exp +7 -2
  134. data/ext/ffi_c/libffi/testsuite/libffi.bhaible/test-call.c +4 -4
  135. data/ext/ffi_c/libffi/testsuite/libffi.bhaible/test-callback.c +2 -2
  136. data/ext/ffi_c/libffi/testsuite/libffi.call/call.exp +12 -1
  137. data/ext/ffi_c/libffi/testsuite/libffi.call/float2.c +9 -8
  138. data/ext/ffi_c/libffi/testsuite/libffi.call/va_1.c +1 -1
  139. data/ext/ffi_c/libffi/testsuite/libffi.closures/closure.exp +67 -0
  140. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/closure_fn0.c +0 -0
  141. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/closure_fn1.c +0 -0
  142. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/closure_fn2.c +0 -0
  143. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/closure_fn3.c +0 -0
  144. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/closure_fn4.c +0 -0
  145. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/closure_fn5.c +0 -0
  146. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/closure_fn6.c +0 -0
  147. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/closure_loc_fn0.c +0 -0
  148. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/closure_simple.c +0 -0
  149. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_12byte.c +0 -0
  150. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_16byte.c +0 -0
  151. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_18byte.c +0 -0
  152. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_19byte.c +0 -0
  153. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_1_1byte.c +0 -0
  154. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_20byte.c +0 -0
  155. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_20byte1.c +0 -0
  156. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_24byte.c +0 -0
  157. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_2byte.c +0 -0
  158. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_3_1byte.c +0 -0
  159. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_3byte1.c +0 -0
  160. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_3byte2.c +0 -0
  161. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_3float.c +0 -0
  162. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_4_1byte.c +0 -0
  163. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_4byte.c +0 -0
  164. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_5_1_byte.c +0 -0
  165. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_5byte.c +0 -0
  166. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_64byte.c +0 -0
  167. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_6_1_byte.c +0 -0
  168. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_6byte.c +0 -0
  169. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_7_1_byte.c +0 -0
  170. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_7byte.c +0 -0
  171. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_8byte.c +0 -0
  172. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_9byte1.c +0 -0
  173. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_9byte2.c +0 -0
  174. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_align_double.c +0 -0
  175. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_align_float.c +0 -0
  176. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_align_longdouble.c +0 -0
  177. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_align_longdouble_split.c +0 -0
  178. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_align_longdouble_split2.c +0 -0
  179. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_align_pointer.c +0 -0
  180. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_align_sint16.c +0 -0
  181. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_align_sint32.c +0 -0
  182. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_align_sint64.c +0 -0
  183. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_align_uint16.c +0 -0
  184. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_align_uint32.c +0 -0
  185. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_align_uint64.c +0 -0
  186. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_dbls_struct.c +0 -0
  187. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_double.c +0 -0
  188. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_double_va.c +0 -0
  189. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_float.c +0 -0
  190. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_longdouble.c +0 -0
  191. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_longdouble_va.c +0 -0
  192. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_many_mixed_args.c +0 -0
  193. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_many_mixed_float_double.c +0 -0
  194. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_multi_schar.c +0 -0
  195. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_multi_sshort.c +0 -0
  196. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_multi_sshortchar.c +0 -0
  197. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_multi_uchar.c +0 -0
  198. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_multi_ushort.c +0 -0
  199. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_multi_ushortchar.c +0 -0
  200. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_pointer.c +0 -0
  201. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_pointer_stack.c +0 -0
  202. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_schar.c +0 -0
  203. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_sint.c +0 -0
  204. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_sshort.c +0 -0
  205. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_struct_va1.c +0 -0
  206. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_uchar.c +0 -0
  207. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_uchar_va.c +0 -0
  208. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_uint.c +0 -0
  209. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_uint_va.c +0 -0
  210. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_ulong_va.c +0 -0
  211. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_ulonglong.c +0 -0
  212. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_ushort.c +0 -0
  213. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_ushort_va.c +0 -0
  214. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/err_bad_abi.c +0 -0
  215. data/ext/ffi_c/libffi/testsuite/libffi.closures/ffitest.h +138 -0
  216. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/huge_struct.c +3 -1
  217. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/nested_struct.c +0 -0
  218. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/nested_struct1.c +0 -0
  219. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/nested_struct10.c +0 -0
  220. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/nested_struct11.c +0 -0
  221. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/nested_struct2.c +0 -0
  222. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/nested_struct3.c +0 -0
  223. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/nested_struct4.c +0 -0
  224. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/nested_struct5.c +0 -0
  225. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/nested_struct6.c +0 -0
  226. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/nested_struct7.c +0 -0
  227. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/nested_struct8.c +0 -0
  228. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/nested_struct9.c +0 -0
  229. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/problem1.c +0 -0
  230. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/stret_large.c +0 -0
  231. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/stret_large2.c +0 -0
  232. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/stret_medium.c +0 -0
  233. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/stret_medium2.c +0 -0
  234. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/testclosure.c +0 -0
  235. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/unwindtest.cc +0 -0
  236. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/unwindtest_ffi_call.cc +0 -0
  237. data/ext/ffi_c/rbffi.h +0 -2
  238. data/ffi.gemspec +13 -6
  239. data/lib/ffi.rb +10 -2
  240. data/lib/ffi/abstract_memory.rb +44 -0
  241. data/lib/ffi/autopointer.rb +1 -1
  242. data/lib/ffi/data_converter.rb +67 -0
  243. data/lib/ffi/ffi.rb +3 -0
  244. data/lib/ffi/io.rb +3 -3
  245. data/lib/ffi/library.rb +11 -7
  246. data/lib/ffi/managedstruct.rb +2 -2
  247. data/lib/ffi/platform.rb +27 -9
  248. data/lib/ffi/platform/aarch64-darwin/types.conf +130 -0
  249. data/lib/ffi/platform/aarch64-freebsd/types.conf +89 -89
  250. data/lib/ffi/platform/aarch64-freebsd12/types.conf +89 -89
  251. data/lib/ffi/platform/aarch64-linux/types.conf +81 -81
  252. data/lib/ffi/platform/aarch64-openbsd/types.conf +134 -0
  253. data/lib/ffi/platform/arm-freebsd/types.conf +87 -87
  254. data/lib/ffi/platform/arm-freebsd12/types.conf +87 -87
  255. data/lib/ffi/platform/arm-linux/types.conf +110 -82
  256. data/lib/ffi/platform/i386-cygwin/types.conf +1 -1
  257. data/lib/ffi/platform/i386-darwin/types.conf +63 -63
  258. data/lib/ffi/platform/i386-freebsd/types.conf +87 -87
  259. data/lib/ffi/platform/i386-freebsd12/types.conf +87 -87
  260. data/lib/ffi/platform/i386-gnu/types.conf +84 -84
  261. data/lib/ffi/platform/i386-linux/types.conf +77 -77
  262. data/lib/ffi/platform/i386-netbsd/types.conf +87 -87
  263. data/lib/ffi/platform/i386-openbsd/types.conf +89 -89
  264. data/lib/ffi/platform/i386-solaris/types.conf +96 -96
  265. data/lib/ffi/platform/i386-windows/types.conf +43 -96
  266. data/lib/ffi/platform/ia64-linux/types.conf +79 -79
  267. data/lib/ffi/platform/mips-linux/types.conf +79 -79
  268. data/lib/ffi/platform/mips64-linux/types.conf +81 -81
  269. data/lib/ffi/platform/mips64el-linux/types.conf +81 -81
  270. data/lib/ffi/platform/mipsel-linux/types.conf +79 -79
  271. data/lib/ffi/platform/mipsisa32r6-linux/types.conf +79 -79
  272. data/lib/ffi/platform/mipsisa32r6el-linux/types.conf +79 -79
  273. data/lib/ffi/platform/mipsisa64r6-linux/types.conf +81 -81
  274. data/lib/ffi/platform/mipsisa64r6el-linux/types.conf +81 -81
  275. data/lib/ffi/platform/powerpc-aix/types.conf +155 -155
  276. data/lib/ffi/platform/powerpc-darwin/types.conf +63 -63
  277. data/lib/ffi/platform/powerpc-linux/types.conf +108 -78
  278. data/lib/ffi/platform/powerpc-openbsd/types.conf +156 -0
  279. data/lib/ffi/platform/powerpc64-linux/types.conf +81 -81
  280. data/lib/ffi/platform/s390-linux/types.conf +79 -79
  281. data/lib/ffi/platform/s390x-linux/types.conf +79 -79
  282. data/lib/ffi/platform/sparc-linux/types.conf +79 -79
  283. data/lib/ffi/platform/sparc-solaris/types.conf +103 -103
  284. data/lib/ffi/platform/sparc64-linux/types.conf +79 -79
  285. data/lib/ffi/platform/sparcv9-openbsd/types.conf +156 -0
  286. data/lib/ffi/platform/sparcv9-solaris/types.conf +103 -103
  287. data/lib/ffi/platform/x86_64-cygwin/types.conf +1 -1
  288. data/lib/ffi/platform/x86_64-darwin/types.conf +88 -84
  289. data/lib/ffi/platform/x86_64-dragonflybsd/types.conf +130 -0
  290. data/lib/ffi/platform/x86_64-freebsd/types.conf +89 -89
  291. data/lib/ffi/platform/x86_64-freebsd12/types.conf +139 -109
  292. data/lib/ffi/platform/x86_64-haiku/types.conf +117 -0
  293. data/lib/ffi/platform/x86_64-linux/types.conf +107 -77
  294. data/lib/ffi/platform/x86_64-msys/types.conf +119 -0
  295. data/lib/ffi/platform/x86_64-netbsd/types.conf +89 -89
  296. data/lib/ffi/platform/x86_64-openbsd/types.conf +86 -86
  297. data/lib/ffi/platform/x86_64-solaris/types.conf +96 -96
  298. data/lib/ffi/platform/x86_64-windows/types.conf +42 -110
  299. data/lib/ffi/pointer.rb +22 -15
  300. data/lib/ffi/struct.rb +13 -68
  301. data/lib/ffi/struct_by_reference.rb +72 -0
  302. data/lib/ffi/struct_layout.rb +96 -0
  303. data/lib/ffi/tools/const_generator.rb +5 -4
  304. data/lib/ffi/tools/generator.rb +47 -2
  305. data/lib/ffi/tools/generator_task.rb +13 -17
  306. data/lib/ffi/tools/struct_generator.rb +4 -4
  307. data/lib/ffi/tools/types_generator.rb +7 -4
  308. data/lib/ffi/types.rb +1 -1
  309. data/lib/ffi/variadic.rb +1 -1
  310. data/lib/ffi/version.rb +1 -1
  311. data/samples/getlogin.rb +1 -1
  312. data/samples/getpid.rb +1 -1
  313. data/samples/gettimeofday.rb +8 -8
  314. data/samples/hello.rb +2 -1
  315. data/samples/inotify.rb +1 -1
  316. data/samples/pty.rb +1 -2
  317. data/samples/qsort.rb +0 -1
  318. metadata +151 -122
  319. data/.gitignore +0 -22
  320. data/.gitmodules +0 -3
  321. data/.travis.yml +0 -43
  322. data/.yardopts +0 -5
  323. data/appveyor.yml +0 -22
  324. data/ext/ffi_c/DataConverter.c +0 -91
  325. data/ext/ffi_c/StructByReference.c +0 -190
  326. data/ext/ffi_c/StructByReference.h +0 -50
  327. data/ext/ffi_c/libffi/ChangeLog.libffi +0 -584
  328. data/ext/ffi_c/libffi/ChangeLog.libgcj +0 -40
  329. data/ext/ffi_c/libffi/ChangeLog.v1 +0 -764
  330. data/ext/ffi_c/win32/stdbool.h +0 -8
  331. data/ext/ffi_c/win32/stdint.h +0 -201
  332. data/samples/sample_helper.rb +0 -6
@@ -29,33 +29,12 @@
29
29
  # Copyright (c) 2008 Guido U. Draheim <guidod@gmx.de>
30
30
  # Copyright (c) 2011 Maarten Bosmans <mkbosmans@gmail.com>
31
31
  #
32
- # This program is free software: you can redistribute it and/or modify it
33
- # under the terms of the GNU General Public License as published by the
34
- # Free Software Foundation, either version 3 of the License, or (at your
35
- # option) any later version.
36
- #
37
- # This program is distributed in the hope that it will be useful, but
38
- # WITHOUT ANY WARRANTY; without even the implied warranty of
39
- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
40
- # Public License for more details.
41
- #
42
- # You should have received a copy of the GNU General Public License along
43
- # with this program. If not, see <https://www.gnu.org/licenses/>.
44
- #
45
- # As a special exception, the respective Autoconf Macro's copyright owner
46
- # gives unlimited permission to copy, distribute and modify the configure
47
- # scripts that are the output of Autoconf when processing the Macro. You
48
- # need not follow the terms of the GNU General Public License when using
49
- # or distributing such scripts, even though portions of the text of the
50
- # Macro appear in them. The GNU General Public License (GPL) does govern
51
- # all other use of the material that constitutes the Autoconf Macro.
52
- #
53
- # This special exception to the GPL applies to versions of the Autoconf
54
- # Macro released by the Autoconf Archive. When you make and distribute a
55
- # modified version of the Autoconf Macro, you may extend this special
56
- # exception to the GPL to apply to your modified version as well.
32
+ # Copying and distribution of this file, with or without modification, are
33
+ # permitted in any medium without royalty provided the copyright notice
34
+ # and this notice are preserved. This file is offered as-is, without any
35
+ # warranty.
57
36
 
58
- #serial 5
37
+ #serial 6
59
38
 
60
39
  AC_DEFUN([AX_CHECK_COMPILE_FLAG],
61
40
  [AC_PREREQ(2.64)dnl for _AC_LANG_PREFIX and AS_VAR_IF
@@ -44,7 +44,7 @@
44
44
  # modified version of the Autoconf Macro, you may extend this special
45
45
  # exception to the GPL to apply to your modified version as well.
46
46
 
47
- #serial 16
47
+ #serial 17
48
48
 
49
49
  AC_DEFUN([AX_COMPILER_VENDOR],
50
50
  [AC_CACHE_CHECK([for _AC_LANG compiler vendor], ax_cv_[]_AC_LANG_ABBREV[]_compiler_vendor,
@@ -56,6 +56,7 @@ AC_DEFUN([AX_COMPILER_VENDOR],
56
56
  clang: __clang__
57
57
  cray: _CRAYC
58
58
  fujitsu: __FUJITSU
59
+ sdcc: SDCC, __SDCC
59
60
  gnu: __GNUC__
60
61
  sun: __SUNPRO_C,__SUNPRO_CC
61
62
  hp: __HP_cc,__HP_aCC
@@ -31,33 +31,12 @@
31
31
  #
32
32
  # Copyright (c) 2008 Guido U. Draheim <guidod@gmx.de>
33
33
  #
34
- # This program is free software; you can redistribute it and/or modify it
35
- # under the terms of the GNU General Public License as published by the
36
- # Free Software Foundation; either version 3 of the License, or (at your
37
- # option) any later version.
38
- #
39
- # This program is distributed in the hope that it will be useful, but
40
- # WITHOUT ANY WARRANTY; without even the implied warranty of
41
- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
42
- # Public License for more details.
43
- #
44
- # You should have received a copy of the GNU General Public License along
45
- # with this program. If not, see <https://www.gnu.org/licenses/>.
46
- #
47
- # As a special exception, the respective Autoconf Macro's copyright owner
48
- # gives unlimited permission to copy, distribute and modify the configure
49
- # scripts that are the output of Autoconf when processing the Macro. You
50
- # need not follow the terms of the GNU General Public License when using
51
- # or distributing such scripts, even though portions of the text of the
52
- # Macro appear in them. The GNU General Public License (GPL) does govern
53
- # all other use of the material that constitutes the Autoconf Macro.
54
- #
55
- # This special exception to the GPL applies to versions of the Autoconf
56
- # Macro released by the Autoconf Archive. When you make and distribute a
57
- # modified version of the Autoconf Macro, you may extend this special
58
- # exception to the GPL to apply to your modified version as well.
34
+ # Copying and distribution of this file, with or without modification, are
35
+ # permitted in any medium without royalty provided the copyright notice
36
+ # and this notice are preserved. This file is offered as-is, without any
37
+ # warranty.
59
38
 
60
- #serial 13
39
+ #serial 14
61
40
 
62
41
  AC_DEFUN([AX_CONFIGURE_ARGS],[
63
42
  # [$]@ is unusable in 2.60+ but earlier autoconf had no ac_configure_args
@@ -37,7 +37,7 @@
37
37
  # Copyright (c) 2008 Steven G. Johnson <stevenj@alum.mit.edu>
38
38
  # Copyright (c) 2008 Matteo Frigo
39
39
  # Copyright (c) 2014 Tsukasa Oi
40
- # Copyright (c) 2017 Alexey Kopytov
40
+ # Copyright (c) 2017-2018 Alexey Kopytov
41
41
  #
42
42
  # This program is free software: you can redistribute it and/or modify it
43
43
  # under the terms of the GNU General Public License as published by the
@@ -65,7 +65,7 @@
65
65
  # modified version of the Autoconf Macro, you may extend this special
66
66
  # exception to the GPL to apply to your modified version as well.
67
67
 
68
- #serial 20
68
+ #serial 22
69
69
 
70
70
  AC_DEFUN([AX_GCC_ARCHFLAG],
71
71
  [AC_REQUIRE([AC_PROG_CC])
@@ -108,7 +108,7 @@ case $host_cpu in
108
108
  *2?6[[ad]]?:*:*:*) ax_gcc_arch="sandybridge corei7-avx corei7 core2 pentium-m pentium3 pentiumpro" ;;
109
109
  *3?6[[ae]]?:*:*:*) ax_gcc_arch="ivybridge core-avx-i corei7-avx corei7 core2 pentium-m pentium3 pentiumpro" ;;
110
110
  *3?6[[cf]]?:*:*:*|*4?6[[56]]?:*:*:*) ax_gcc_arch="haswell core-avx2 core-avx-i corei7-avx corei7 core2 pentium-m pentium3 pentiumpro" ;;
111
- *3?6d?:*:*:*) ax_gcc_arch="broadwell core-avx2 core-avx-i corei7-avx corei7 core2 pentium-m pentium3 pentiumpro" ;;
111
+ *3?6d?:*:*:*|*4?6[[7f]]?:*:*:*|*5?66?:*:*:*) ax_gcc_arch="broadwell core-avx2 core-avx-i corei7-avx corei7 core2 pentium-m pentium3 pentiumpro" ;;
112
112
  *1?6c?:*:*:*|*2?6[[67]]?:*:*:*|*3?6[[56]]?:*:*:*) ax_gcc_arch="bonnell atom core2 pentium-m pentium3 pentiumpro" ;;
113
113
  *3?67?:*:*:*|*[[45]]?6[[ad]]?:*:*:*) ax_gcc_arch="silvermont atom core2 pentium-m pentium3 pentiumpro" ;;
114
114
  *000?f[[012]]?:*:*:*|?f[[012]]?:*:*:*|f[[012]]?:*:*:*) ax_gcc_arch="pentium4 pentiumpro" ;;
@@ -198,6 +198,10 @@ case $host_cpu in
198
198
  *POWER4*|*power4*|*gq*) ax_gcc_arch="power4 970";;
199
199
  *POWER5*|*power5*|*gr*|*gs*) ax_gcc_arch="power5 power4 970";;
200
200
  603ev|8240) ax_gcc_arch="$cputype 603e 603";;
201
+ *POWER7*) ax_gcc_arch="power7";;
202
+ *POWER8*) ax_gcc_arch="power8";;
203
+ *POWER9*) ax_gcc_arch="power9";;
204
+ *POWER10*) ax_gcc_arch="power10";;
201
205
  *) ax_gcc_arch=$cputype ;;
202
206
  esac
203
207
  ax_gcc_arch="$ax_gcc_arch powerpc"
@@ -0,0 +1,333 @@
1
+ #!/usr/bin/perl -w
2
+
3
+ # make_sunver.pl
4
+ #
5
+ # This script takes at least two arguments, a GNU style version script and
6
+ # a list of object and archive files, and generates a corresponding Sun
7
+ # style version script as follows:
8
+ #
9
+ # Each glob pattern, C++ mangled pattern or literal in the input script is
10
+ # matched against all global symbols in the input objects, emitting those
11
+ # that matched (or nothing if no match was found).
12
+ # A comment with the original pattern and its type is left in the output
13
+ # file to make it easy to understand the matches.
14
+ #
15
+ # It uses elfdump when present (native), GNU readelf otherwise.
16
+ # It depends on the GNU version of c++filt, since it must understand the
17
+ # GNU mangling style.
18
+
19
+ use FileHandle;
20
+ use IPC::Open2;
21
+
22
+ # Enforce C locale.
23
+ $ENV{'LC_ALL'} = "C";
24
+ $ENV{'LANG'} = "C";
25
+
26
+ # Input version script, GNU style.
27
+ my $symvers = shift;
28
+
29
+ ##########
30
+ # Get all the symbols from the library, match them, and add them to a hash.
31
+
32
+ my %sym_hash = ();
33
+
34
+ # List of objects and archives to process.
35
+ my @OBJECTS = ();
36
+
37
+ # List of shared objects to omit from processing.
38
+ my @SHAREDOBJS = ();
39
+
40
+ # Filter out those input archives that have corresponding shared objects to
41
+ # avoid adding all symbols matched in the archive to the output map.
42
+ foreach $file (@ARGV) {
43
+ if (($so = $file) =~ s/\.a$/.so/ && -e $so) {
44
+ printf STDERR "omitted $file -> $so\n";
45
+ push (@SHAREDOBJS, $so);
46
+ } else {
47
+ push (@OBJECTS, $file);
48
+ }
49
+ }
50
+
51
+ # We need to detect and ignore hidden symbols. Solaris nm can only detect
52
+ # this in the harder to parse default output format, and GNU nm not at all,
53
+ # so use elfdump -s in the native case and GNU readelf -s otherwise.
54
+ # GNU objdump -t cannot be used since it produces a variable number of
55
+ # columns.
56
+
57
+ # The path to elfdump.
58
+ my $elfdump = "/usr/ccs/bin/elfdump";
59
+
60
+ if (-f $elfdump) {
61
+ open ELFDUMP,$elfdump.' -s '.(join ' ',@OBJECTS).'|' or die $!;
62
+ my $skip_arsym = 0;
63
+
64
+ while (<ELFDUMP>) {
65
+ chomp;
66
+
67
+ # Ignore empty lines.
68
+ if (/^$/) {
69
+ # End of archive symbol table, stop skipping.
70
+ $skip_arsym = 0 if $skip_arsym;
71
+ next;
72
+ }
73
+
74
+ # Keep skipping until end of archive symbol table.
75
+ next if ($skip_arsym);
76
+
77
+ # Ignore object name header for individual objects and archives.
78
+ next if (/:$/);
79
+
80
+ # Ignore table header lines.
81
+ next if (/^Symbol Table Section:/);
82
+ next if (/index.*value.*size/);
83
+
84
+ # Start of archive symbol table: start skipping.
85
+ if (/^Symbol Table: \(archive/) {
86
+ $skip_arsym = 1;
87
+ next;
88
+ }
89
+
90
+ # Split table.
91
+ (undef, undef, undef, undef, $bind, $oth, undef, $shndx, $name) = split;
92
+
93
+ # Error out for unknown input.
94
+ die "unknown input line:\n$_" unless defined($bind);
95
+
96
+ # Ignore local symbols.
97
+ next if ($bind eq "LOCL");
98
+ # Ignore hidden symbols.
99
+ next if ($oth eq "H");
100
+ # Ignore undefined symbols.
101
+ next if ($shndx eq "UNDEF");
102
+ # Error out for unhandled cases.
103
+ if ($bind !~ /^(GLOB|WEAK)/ or $oth ne "D") {
104
+ die "unhandled symbol:\n$_";
105
+ }
106
+
107
+ # Remember symbol.
108
+ $sym_hash{$name}++;
109
+ }
110
+ close ELFDUMP or die "$elfdump error";
111
+ } else {
112
+ open READELF, 'readelf -s -W '.(join ' ',@OBJECTS).'|' or die $!;
113
+ # Process each symbol.
114
+ while (<READELF>) {
115
+ chomp;
116
+
117
+ # Ignore empty lines.
118
+ next if (/^$/);
119
+
120
+ # Ignore object name header.
121
+ next if (/^File: .*$/);
122
+
123
+ # Ignore table header lines.
124
+ next if (/^Symbol table.*contains.*:/);
125
+ next if (/Num:.*Value.*Size/);
126
+
127
+ # Split table.
128
+ (undef, undef, undef, undef, $bind, $vis, $ndx, $name) = split;
129
+
130
+ # Error out for unknown input.
131
+ die "unknown input line:\n$_" unless defined($bind);
132
+
133
+ # Ignore local symbols.
134
+ next if ($bind eq "LOCAL");
135
+ # Ignore hidden symbols.
136
+ next if ($vis eq "HIDDEN");
137
+ # Ignore undefined symbols.
138
+ next if ($ndx eq "UND");
139
+ # Error out for unhandled cases.
140
+ if ($bind !~ /^(GLOBAL|WEAK)/ or $vis ne "DEFAULT") {
141
+ die "unhandled symbol:\n$_";
142
+ }
143
+
144
+ # Remember symbol.
145
+ $sym_hash{$name}++;
146
+ }
147
+ close READELF or die "readelf error";
148
+ }
149
+
150
+ ##########
151
+ # The various types of glob patterns.
152
+ #
153
+ # A glob pattern that is to be applied to the demangled name: 'cxx'.
154
+ # A glob patterns that applies directly to the name in the .o files: 'glob'.
155
+ # This pattern is ignored; used for local variables (usually just '*'): 'ign'.
156
+
157
+ # The type of the current pattern.
158
+ my $glob = 'glob';
159
+
160
+ # We're currently inside `extern "C++"', which Sun ld doesn't understand.
161
+ my $in_extern = 0;
162
+
163
+ # The c++filt command to use. This *must* be GNU c++filt; the Sun Studio
164
+ # c++filt doesn't handle the GNU mangling style.
165
+ my $cxxfilt = $ENV{'CXXFILT'} || "c++filt";
166
+
167
+ # The current version name.
168
+ my $current_version = "";
169
+
170
+ # Was there any attempt to match a symbol to this version?
171
+ my $matches_attempted;
172
+
173
+ # The number of versions which matched this symbol.
174
+ my $matched_symbols;
175
+
176
+ open F,$symvers or die $!;
177
+
178
+ # Print information about generating this file
179
+ print "# This file was generated by make_sunver.pl. DO NOT EDIT!\n";
180
+ print "# It was generated by:\n";
181
+ printf "# %s %s %s\n", $0, $symvers, (join ' ',@ARGV);
182
+ printf "# Omitted archives with corresponding shared libraries: %s\n",
183
+ (join ' ', @SHAREDOBJS) if $#SHAREDOBJS >= 0;
184
+ print "#\n\n";
185
+
186
+ while (<F>) {
187
+ # Lines of the form '};'
188
+ if (/^([ \t]*)(\}[ \t]*;[ \t]*)$/) {
189
+ $glob = 'glob';
190
+ if ($in_extern) {
191
+ $in_extern--;
192
+ print "$1##$2\n";
193
+ } else {
194
+ print;
195
+ }
196
+ next;
197
+ }
198
+
199
+ # Lines of the form '} SOME_VERSION_NAME_1.0;'
200
+ if (/^[ \t]*\}[ \tA-Z0-9_.a-z]+;[ \t]*$/) {
201
+ $glob = 'glob';
202
+ # We tried to match symbols agains this version, but none matched.
203
+ # Emit dummy hidden symbol to avoid marking this version WEAK.
204
+ if ($matches_attempted && $matched_symbols == 0) {
205
+ print " hidden:\n";
206
+ print " .force_WEAK_off_$current_version = DATA S0x0 V0x0;\n";
207
+ }
208
+ print; next;
209
+ }
210
+
211
+ # Comment and blank lines
212
+ if (/^[ \t]*\#/) { print; next; }
213
+ if (/^[ \t]*$/) { print; next; }
214
+
215
+ # Lines of the form '{'
216
+ if (/^([ \t]*){$/) {
217
+ if ($in_extern) {
218
+ print "$1##{\n";
219
+ } else {
220
+ print;
221
+ }
222
+ next;
223
+ }
224
+
225
+ # Lines of the form 'SOME_VERSION_NAME_1.1 {'
226
+ if (/^([A-Z0-9_.]+)[ \t]+{$/) {
227
+ # Record version name.
228
+ $current_version = $1;
229
+ # Reset match attempts, #matched symbols for this version.
230
+ $matches_attempted = 0;
231
+ $matched_symbols = 0;
232
+ print;
233
+ next;
234
+ }
235
+
236
+ # Ignore 'global:'
237
+ if (/^[ \t]*global:$/) { print; next; }
238
+
239
+ # After 'local:', globs should be ignored, they won't be exported.
240
+ if (/^[ \t]*local:$/) {
241
+ $glob = 'ign';
242
+ print;
243
+ next;
244
+ }
245
+
246
+ # After 'extern "C++"', globs are C++ patterns
247
+ if (/^([ \t]*)(extern \"C\+\+\"[ \t]*)$/) {
248
+ $in_extern++;
249
+ $glob = 'cxx';
250
+ # Need to comment, Sun ld cannot handle this.
251
+ print "$1##$2\n"; next;
252
+ }
253
+
254
+ # Chomp newline now we're done with passing through the input file.
255
+ chomp;
256
+
257
+ # Catch globs. Note that '{}' is not allowed in globs by this script,
258
+ # so only '*' and '[]' are available.
259
+ if (/^([ \t]*)([^ \t;{}#]+);?[ \t]*$/) {
260
+ my $ws = $1;
261
+ my $ptn = $2;
262
+ # Turn the glob into a regex by replacing '*' with '.*', '?' with '.'.
263
+ # Keep $ptn so we can still print the original form.
264
+ ($pattern = $ptn) =~ s/\*/\.\*/g;
265
+ $pattern =~ s/\?/\./g;
266
+
267
+ if ($glob eq 'ign') {
268
+ # We're in a local: * section; just continue.
269
+ print "$_\n";
270
+ next;
271
+ }
272
+
273
+ # Print the glob commented for human readers.
274
+ print "$ws##$ptn ($glob)\n";
275
+ # We tried to match a symbol to this version.
276
+ $matches_attempted++;
277
+
278
+ if ($glob eq 'glob') {
279
+ my %ptn_syms = ();
280
+
281
+ # Match ptn against symbols in %sym_hash.
282
+ foreach my $sym (keys %sym_hash) {
283
+ # Maybe it matches one of the patterns based on the symbol in
284
+ # the .o file.
285
+ $ptn_syms{$sym}++ if ($sym =~ /^$pattern$/);
286
+ }
287
+
288
+ foreach my $sym (sort keys(%ptn_syms)) {
289
+ $matched_symbols++;
290
+ print "$ws$sym;\n";
291
+ }
292
+ } elsif ($glob eq 'cxx') {
293
+ my %dem_syms = ();
294
+
295
+ # Verify that we're actually using GNU c++filt. Other versions
296
+ # most likely cannot handle GNU style symbol mangling.
297
+ my $cxxout = `$cxxfilt --version 2>&1`;
298
+ $cxxout =~ m/GNU/ or die "$0 requires GNU c++filt to function";
299
+
300
+ # Talk to c++filt through a pair of file descriptors.
301
+ # Need to start a fresh instance per pattern, otherwise the
302
+ # process grows to 500+ MB.
303
+ my $pid = open2(*FILTIN, *FILTOUT, $cxxfilt) or die $!;
304
+
305
+ # Match ptn against symbols in %sym_hash.
306
+ foreach my $sym (keys %sym_hash) {
307
+ # No? Well, maybe its demangled form matches one of those
308
+ # patterns.
309
+ printf FILTOUT "%s\n",$sym;
310
+ my $dem = <FILTIN>;
311
+ chomp $dem;
312
+ $dem_syms{$sym}++ if ($dem =~ /^$pattern$/);
313
+ }
314
+
315
+ close FILTOUT or die "c++filt error";
316
+ close FILTIN or die "c++filt error";
317
+ # Need to wait for the c++filt process to avoid lots of zombies.
318
+ waitpid $pid, 0;
319
+
320
+ foreach my $sym (sort keys(%dem_syms)) {
321
+ $matched_symbols++;
322
+ print "$ws$sym;\n";
323
+ }
324
+ } else {
325
+ # No? Well, then ignore it.
326
+ }
327
+ next;
328
+ }
329
+ # Important sanity check. This script can't handle lots of formats
330
+ # that GNU ld can, so be sure to error out if one is seen!
331
+ die "strange line `$_'";
332
+ }
333
+ close F;