ffi 1.17.1 → 1.17.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (136) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +0 -0
  3. data/CHANGELOG.md +33 -0
  4. data/Gemfile +8 -3
  5. data/README.md +1 -0
  6. data/Rakefile +7 -4
  7. data/Steepfile +8 -0
  8. data/ext/ffi_c/DynamicLibrary.c +1 -1
  9. data/ext/ffi_c/Function.c +2 -0
  10. data/ext/ffi_c/MethodHandle.c +4 -2
  11. data/ext/ffi_c/libffi/.ci/Containerfile.ppc64le +12 -0
  12. data/ext/ffi_c/libffi/.ci/build.sh +38 -33
  13. data/ext/ffi_c/libffi/.ci/install.sh +46 -50
  14. data/ext/ffi_c/libffi/.ci/site.exp +6 -0
  15. data/ext/ffi_c/libffi/.gail-labels +44 -0
  16. data/ext/ffi_c/libffi/.github/workflows/build.yml +212 -333
  17. data/ext/ffi_c/libffi/.github/workflows/emscripten.yml +101 -58
  18. data/ext/ffi_c/libffi/.github/workflows/label-new-issue.yaml +15 -0
  19. data/ext/ffi_c/libffi/.github/workflows/tarball.yml +55 -0
  20. data/ext/ffi_c/libffi/LICENSE +1 -1
  21. data/ext/ffi_c/libffi/Makefile.am +20 -15
  22. data/ext/ffi_c/libffi/Makefile.in +41 -54
  23. data/ext/ffi_c/libffi/README.md +40 -4
  24. data/ext/ffi_c/libffi/acinclude.m4 +6 -0
  25. data/ext/ffi_c/libffi/config.guess +80 -22
  26. data/ext/ffi_c/libffi/config.sub +161 -80
  27. data/ext/ffi_c/libffi/configure +1058 -1372
  28. data/ext/ffi_c/libffi/configure.ac +28 -14
  29. data/ext/ffi_c/libffi/configure.host +6 -6
  30. data/ext/ffi_c/libffi/doc/Makefile.in +4 -0
  31. data/ext/ffi_c/libffi/doc/libffi.texi +27 -4
  32. data/ext/ffi_c/libffi/doc/version.texi +4 -4
  33. data/ext/ffi_c/libffi/fficonfig.h.in +9 -9
  34. data/ext/ffi_c/libffi/generate-darwin-source-and-headers.py +1 -28
  35. data/ext/ffi_c/libffi/include/Makefile.in +4 -0
  36. data/ext/ffi_c/libffi/include/ffi.h.in +19 -1
  37. data/ext/ffi_c/libffi/include/ffi_cfi.h +2 -0
  38. data/ext/ffi_c/libffi/include/ffi_common.h +17 -0
  39. data/ext/ffi_c/libffi/libffi.map.in +13 -1
  40. data/ext/ffi_c/libffi/libtool-version +1 -1
  41. data/ext/ffi_c/libffi/m4/asmcfi.m4 +28 -11
  42. data/ext/ffi_c/libffi/m4/ax_check_compile_flag.m4 +13 -3
  43. data/ext/ffi_c/libffi/man/Makefile.in +4 -0
  44. data/ext/ffi_c/libffi/src/aarch64/ffi.c +7 -4
  45. data/ext/ffi_c/libffi/src/aarch64/ffitarget.h +2 -2
  46. data/ext/ffi_c/libffi/src/aarch64/internal.h +63 -17
  47. data/ext/ffi_c/libffi/src/aarch64/sysv.S +22 -12
  48. data/ext/ffi_c/libffi/src/arc/arcompact.S +2 -2
  49. data/ext/ffi_c/libffi/src/arc/ffi.c +6 -2
  50. data/ext/ffi_c/libffi/src/arm/sysv.S +1 -1
  51. data/ext/ffi_c/libffi/src/closures.c +3 -3
  52. data/ext/ffi_c/libffi/src/dlmalloc.c +1 -0
  53. data/ext/ffi_c/libffi/src/mips/ffitarget.h +2 -4
  54. data/ext/ffi_c/libffi/src/mips/n32.S +4 -0
  55. data/ext/ffi_c/libffi/src/mips/o32.S +4 -0
  56. data/ext/ffi_c/libffi/src/or1k/ffi.c +2 -2
  57. data/ext/ffi_c/libffi/src/pa/linux.S +4 -0
  58. data/ext/ffi_c/libffi/src/powerpc/ffi.c +19 -0
  59. data/ext/ffi_c/libffi/src/powerpc/ffi_linux64.c +26 -19
  60. data/ext/ffi_c/libffi/src/powerpc/ffi_sysv.c +26 -16
  61. data/ext/ffi_c/libffi/src/powerpc/internal.h +10 -0
  62. data/ext/ffi_c/libffi/src/powerpc/linux64_closure.S +47 -0
  63. data/ext/ffi_c/libffi/src/powerpc/ppc_closure.S +24 -0
  64. data/ext/ffi_c/libffi/src/prep_cif.c +1 -4
  65. data/ext/ffi_c/libffi/src/riscv/ffi.c +39 -16
  66. data/ext/ffi_c/libffi/src/riscv/internal.h +7 -0
  67. data/ext/ffi_c/libffi/src/riscv/sysv.S +24 -0
  68. data/ext/ffi_c/libffi/src/s390/ffi.c +28 -1
  69. data/ext/ffi_c/libffi/src/s390/internal.h +11 -0
  70. data/ext/ffi_c/libffi/src/s390/sysv.S +38 -0
  71. data/ext/ffi_c/libffi/src/sparc/ffi.c +16 -0
  72. data/ext/ffi_c/libffi/src/tramp.c +6 -1
  73. data/ext/ffi_c/libffi/src/types.c +23 -1
  74. data/ext/ffi_c/libffi/src/{wasm32 → wasm}/ffi.c +166 -315
  75. data/ext/ffi_c/libffi/src/{wasm32 → wasm}/ffitarget.h +17 -0
  76. data/ext/ffi_c/libffi/src/x86/ffi.c +4 -1
  77. data/ext/ffi_c/libffi/src/x86/ffi64.c +4 -1
  78. data/ext/ffi_c/libffi/src/x86/ffitarget.h +0 -3
  79. data/ext/ffi_c/libffi/src/x86/sysv.S +1 -3
  80. data/ext/ffi_c/libffi/src/x86/sysv_intel.S +1 -3
  81. data/ext/ffi_c/libffi/testsuite/Makefile.am +6 -4
  82. data/ext/ffi_c/libffi/testsuite/Makefile.in +10 -4
  83. data/ext/ffi_c/libffi/testsuite/emscripten/build-tests.sh +4 -24
  84. data/ext/ffi_c/libffi/testsuite/emscripten/build.sh +10 -27
  85. data/ext/ffi_c/libffi/testsuite/emscripten/node-tests.sh +6 -31
  86. data/ext/ffi_c/libffi/testsuite/lib/libffi.exp +269 -256
  87. data/ext/ffi_c/libffi/testsuite/libffi.bhaible/testcases.c +1 -1
  88. data/ext/ffi_c/libffi/testsuite/libffi.call/callback.c +2 -2
  89. data/ext/ffi_c/libffi/testsuite/libffi.call/callback2.c +2 -2
  90. data/ext/ffi_c/libffi/testsuite/libffi.call/callback3.c +2 -2
  91. data/ext/ffi_c/libffi/testsuite/libffi.call/callback4.c +2 -2
  92. data/ext/ffi_c/libffi/testsuite/libffi.call/ffitest.h +3 -0
  93. data/ext/ffi_c/libffi/testsuite/libffi.call/longjmp.c +60 -0
  94. data/ext/ffi_c/libffi/testsuite/libffi.call/overread.c +54 -0
  95. data/ext/ffi_c/libffi/testsuite/libffi.call/struct_int_float.c +88 -0
  96. data/ext/ffi_c/libffi/testsuite/libffi.call/va_struct2.c +1 -0
  97. data/ext/ffi_c/libffi/testsuite/libffi.call/va_struct3.c +1 -0
  98. data/ext/ffi_c/libffi/testsuite/libffi.call/x32.c +31 -0
  99. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_dbls_struct.c +1 -1
  100. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_multi_sshortchar.c +1 -1
  101. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_multi_ushortchar.c +1 -1
  102. data/ext/ffi_c/libffi/testsuite/libffi.closures/huge_struct.c +1 -2
  103. data/ext/ffi_c/libffi/testsuite/libffi.closures/unwindtest.cc +2 -0
  104. data/ext/ffi_c/libffi/testsuite/libffi.closures/unwindtest_ffi_call.cc +2 -0
  105. data/ext/ffi_c/libffi/testsuite/libffi.complex/complex_int.c +1 -1
  106. data/ext/ffi_c/libffi/testsuite/libffi.threads/ffitest.h +1 -0
  107. data/ext/ffi_c/libffi/testsuite/libffi.threads/threads.exp +50 -0
  108. data/ext/ffi_c/libffi/testsuite/libffi.threads/tsan.c +74 -0
  109. data/ext/ffi_c/libffi.mk +5 -0
  110. data/ffi.gemspec +4 -5
  111. data/lib/ffi/autopointer.rb +6 -0
  112. data/lib/ffi/compat.rb +11 -0
  113. data/lib/ffi/function.rb +23 -0
  114. data/lib/ffi/library.rb +19 -3
  115. data/lib/ffi/struct_by_reference.rb +1 -1
  116. data/lib/ffi/version.rb +1 -1
  117. data/samples/hello_ractor.rb +9 -1
  118. data/samples/qsort_ractor.rb +9 -1
  119. data/sig/ffi/auto_pointer.rbs +1 -1
  120. data/sig/ffi/errno.rbs +8 -0
  121. data/sig/ffi/platform.rbs +49 -0
  122. data/sig/ffi/struct.rbs +2 -2
  123. data/sig/ffi/struct_by_reference.rbs +1 -1
  124. data/sig/ffi.rbs +4 -1
  125. data.tar.gz.sig +0 -0
  126. metadata +37 -83
  127. metadata.gz.sig +0 -0
  128. data/ext/ffi_c/libffi/.appveyor/site.exp +0 -16
  129. data/ext/ffi_c/libffi/.appveyor.yml +0 -84
  130. data/ext/ffi_c/libffi/.circleci/config.yml +0 -156
  131. data/ext/ffi_c/libffi/src/nios2/ffi.c +0 -304
  132. data/ext/ffi_c/libffi/src/nios2/ffitarget.h +0 -52
  133. data/ext/ffi_c/libffi/src/nios2/sysv.S +0 -136
  134. data/lib/ffi/tools/types_generator.rb +0 -137
  135. data/rakelib/ffi_gem_helper.rb +0 -65
  136. /data/ext/ffi_c/libffi/{.appveyor → .ci}/unix-noexec.exp +0 -0
@@ -1,10 +1,15 @@
1
1
  dnl Process this with autoconf to create configure
2
2
 
3
- AC_PREREQ([2.71])
3
+ AC_PREREQ([2.68])
4
4
 
5
- AC_INIT([libffi],[3.4.6],[http://github.com/libffi/libffi/issues])
5
+ AC_INIT([libffi],[3.5.2],[http://github.com/libffi/libffi/issues])
6
6
  AC_CONFIG_HEADERS([fficonfig.h])
7
7
 
8
+ FFI_VERSION_STRING="3.5.2"
9
+ FFI_VERSION_NUMBER=30502
10
+ AC_SUBST(FFI_VERSION_STRING)
11
+ AC_SUBST(FFI_VERSION_NUMBER)
12
+
8
13
  AC_CANONICAL_TARGET
9
14
  target_alias=${target_alias-$host_alias}
10
15
 
@@ -42,7 +47,7 @@ AC_PROG_EGREP
42
47
  LT_INIT
43
48
  AC_CONFIG_MACRO_DIR([m4])
44
49
 
45
- AC_CHECK_TOOL(READELF, readelf)
50
+ AC_CHECK_TOOLS([READELF], [readelf greadelf])
46
51
 
47
52
  # Test for 64-bit build.
48
53
  AC_CHECK_SIZEOF([size_t])
@@ -89,10 +94,6 @@ m4_warn([obsolete],
89
94
  [The preprocessor macro `STDC_HEADERS' is obsolete.
90
95
  Except in unusual embedded environments, you can safely include all
91
96
  ISO C90 headers unconditionally.])dnl
92
- # Autoupdate added the next two lines to ensure that your configure
93
- # script's behavior did not change. They are probably safe to remove.
94
- AC_CHECK_INCLUDES_DEFAULT
95
- AC_PROG_EGREP
96
97
 
97
98
  AC_CHECK_FUNCS(memcpy)
98
99
  AC_CHECK_HEADERS(alloca.h)
@@ -122,6 +123,8 @@ AC_C_BIGENDIAN
122
123
 
123
124
  GCC_AS_CFI_PSEUDO_OP
124
125
 
126
+ AC_ARG_VAR([WASM64_MEMORY64], [Used only for the wasm64 target. Set to 1 (default) or 2 for Emscripten's -sMEMORY64 mode])
127
+
125
128
  case "$TARGET" in
126
129
  SPARC)
127
130
  AC_CACHE_CHECK([assembler and linker support unaligned pc related relocs],
@@ -171,7 +174,7 @@ case "$TARGET" in
171
174
  libffi_cv_as_s390_zarch=no
172
175
  echo 'void foo(void) { bar(); bar(); }' > conftest.c
173
176
  if $CC $CFLAGS -S conftest.c > /dev/null 2>&1; then
174
- if grep -q brasl conftest.s; then
177
+ if $GREP -q brasl conftest.s; then
175
178
  libffi_cv_as_s390_zarch=yes
176
179
  fi
177
180
  fi
@@ -181,6 +184,15 @@ case "$TARGET" in
181
184
  [Define if the compiler uses zarch features.])
182
185
  fi
183
186
  ;;
187
+ wasm64)
188
+ if test -z "$WASM64_MEMORY64"; then
189
+ WASM64_MEMORY64=1
190
+ fi
191
+ CFLAGS="$CFLAGS -sMEMORY64=$WASM64_MEMORY64"
192
+ ;;
193
+ LOONGARCH64)
194
+ CFLAGS="$CFLAGS -mcmodel=medium"
195
+ ;;
184
196
  esac
185
197
 
186
198
  AC_CACHE_CHECK([whether compiler supports pointer authentication],
@@ -189,17 +201,17 @@ AC_CACHE_CHECK([whether compiler supports pointer authentication],
189
201
  AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
190
202
  #ifdef __clang__
191
203
  # if __has_feature(ptrauth_calls)
192
- # define HAVE_PTRAUTH 1
204
+ # define HAVE_ARM64E_PTRAUTH 1
193
205
  # endif
194
206
  #endif
195
207
 
196
- #ifndef HAVE_PTRAUTH
208
+ #ifndef HAVE_ARM64E_PTRAUTH
197
209
  # error Pointer authentication not supported
198
210
  #endif
199
211
  ]])],[libffi_cv_as_ptrauth=yes],[libffi_cv_as_ptrauth=no])
200
212
  ])
201
213
  if test "x$libffi_cv_as_ptrauth" = xyes; then
202
- AC_DEFINE(HAVE_PTRAUTH, 1,
214
+ AC_DEFINE(HAVE_ARM64E_PTRAUTH, 1,
203
215
  [Define if your compiler supports pointer authentication.])
204
216
  fi
205
217
 
@@ -229,7 +241,7 @@ case "$target" in
229
241
  [Cannot use PROT_EXEC on this target, so, we revert to
230
242
  alternative means])
231
243
  ;;
232
- *-apple-* | *-*-freebsd* | *-*-kfreebsd* | *-*-openbsd* | *-pc-solaris* | *-linux-android*)
244
+ *-apple-* | *-*-dragonfly* | *-*-freebsd* | *-*-kfreebsd* | *-*-openbsd* | *-pc-solaris* | *-linux-android*)
233
245
  AC_DEFINE(FFI_MMAP_EXEC_WRIT, 1,
234
246
  [Cannot use malloc on this target, so, we revert to
235
247
  alternative means])
@@ -277,7 +289,7 @@ if test "x$GCC" = "xyes"; then
277
289
  libffi_cv_ro_eh_frame=yes
278
290
  echo 'extern void foo (void); void bar (void) { foo (); foo (); }' > conftest.c
279
291
  if $CC $CFLAGS -c -fpic -fexceptions $libffi_cv_no_lto -o conftest.o conftest.c > /dev/null 2>&1; then
280
- if $READELF -WS conftest.o 2>/dev/null | grep -q -n 'eh_frame .* WA'; then
292
+ if $READELF -WS conftest.o 2>/dev/null | $GREP -q -n 'eh_frame .* WA'; then
281
293
  libffi_cv_ro_eh_frame=no
282
294
  fi
283
295
  fi
@@ -382,7 +394,9 @@ case "$target" in
382
394
  [Define this if you want statically defined trampolines])
383
395
  fi
384
396
  ;;
385
- *arm*-*-linux-* | aarch64*-*-linux-* | i*86-*-linux-* | x86_64-*-linux-* | loongarch*-*-linux-*)
397
+ *arm*-*-linux-* | aarch64*-*-linux-* | i*86-*-linux-* | x86_64-*-linux-* \
398
+ | loongarch*-*-linux-* | s390x*-linux-* | powerpc*-linux-* \
399
+ | riscv*-linux-*)
386
400
  AC_DEFINE(FFI_EXEC_STATIC_TRAMP, 1,
387
401
  [Define this if you want statically defined trampolines])
388
402
  ;;
@@ -185,11 +185,6 @@ case "${host}" in
185
185
  TARGET=MIPS; TARGETDIR=mips
186
186
  ;;
187
187
 
188
- nios2*-linux*)
189
- TARGET=NIOS2; TARGETDIR=nios2
190
- SOURCES="ffi.c sysv.S"
191
- ;;
192
-
193
188
  or1k*-*-*)
194
189
  TARGET=OR1K; TARGETDIR=or1k
195
190
  SOURCES="ffi.c sysv.S"
@@ -266,7 +261,12 @@ case "${host}" in
266
261
  ;;
267
262
 
268
263
  wasm32-*-*)
269
- TARGET=wasm32; TARGETDIR=wasm32
264
+ TARGET=wasm32; TARGETDIR=wasm
265
+ SOURCES="ffi.c"
266
+ ;;
267
+
268
+ wasm64-*-*)
269
+ TARGET=wasm64; TARGETDIR=wasm
270
270
  SOURCES="ffi.c"
271
271
  ;;
272
272
 
@@ -239,6 +239,8 @@ EGREP = @EGREP@
239
239
  ETAGS = @ETAGS@
240
240
  EXEEXT = @EXEEXT@
241
241
  FFI_EXEC_TRAMPOLINE_TABLE = @FFI_EXEC_TRAMPOLINE_TABLE@
242
+ FFI_VERSION_NUMBER = @FFI_VERSION_NUMBER@
243
+ FFI_VERSION_STRING = @FFI_VERSION_STRING@
242
244
  FGREP = @FGREP@
243
245
  FILECMD = @FILECMD@
244
246
  GREP = @GREP@
@@ -289,6 +291,7 @@ TARGET = @TARGET@
289
291
  TARGETDIR = @TARGETDIR@
290
292
  TARGET_OBJ = @TARGET_OBJ@
291
293
  VERSION = @VERSION@
294
+ WASM64_MEMORY64 = @WASM64_MEMORY64@
292
295
  abs_builddir = @abs_builddir@
293
296
  abs_srcdir = @abs_srcdir@
294
297
  abs_top_builddir = @abs_top_builddir@
@@ -297,6 +300,7 @@ ac_ct_AR = @ac_ct_AR@
297
300
  ac_ct_CC = @ac_ct_CC@
298
301
  ac_ct_CXX = @ac_ct_CXX@
299
302
  ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
303
+ ac_ct_READELF = @ac_ct_READELF@
300
304
  am__include = @am__include@
301
305
  am__leading_dot = @am__leading_dot@
302
306
  am__quote = @am__quote@
@@ -18,7 +18,7 @@
18
18
  This manual is for libffi, a portable foreign function interface
19
19
  library.
20
20
 
21
- Copyright @copyright{} 2008--2024 Anthony Green and Red Hat, Inc.
21
+ Copyright @copyright{} 2008--2025 Anthony Green and Red Hat, Inc.
22
22
 
23
23
  Permission is hereby granted, free of charge, to any person obtaining
24
24
  a copy of this software and associated documentation files (the
@@ -236,6 +236,29 @@ object declared as @code{short}; but if the return type is
236
236
  a larger type -- usually @code{ffi_arg}.
237
237
  @end defun
238
238
 
239
+ @findex ffi_get_version
240
+ @defun {const char *} ffi_get_version (void)
241
+ Returns the library version as a string. This string is also
242
+ available at build time as the macro @code{FFI_VERSION_STRING}.
243
+ @end defun
244
+
245
+ @findex ffi_get_version_number
246
+ @defun {unsigned long} ffi_get_version_number (void)
247
+ Returns the library version as an unsigned long value where
248
+ version ``x.y.z'' is represented as the number x*10000+y*100+z.
249
+ This number is also available at build time as the macro
250
+ @code{FFI_VERSION_NUMBER}.
251
+ @end defun
252
+
253
+ @findex ffi_get_default_abi
254
+ @defun {unsigned int} ffi_get_default_abi (void)
255
+ Return the value of @code{FFI_DEFAULT_ABI}.
256
+ @end defun
257
+
258
+ @findex ffi_get_closure_size
259
+ @defun {size_t} ffi_get_closure_size (void)
260
+ Return @code{sizeof(ffi_closure)}.
261
+ @end defun
239
262
 
240
263
  @node Simple Example
241
264
  @section Simple Example
@@ -263,14 +286,14 @@ int main()
263
286
  &ffi_type_sint, args) == FFI_OK)
264
287
  @{
265
288
  s = "Hello World!";
266
- ffi_call(&cif, puts, &rc, values);
289
+ ffi_call(&cif, (void(*)())puts, &rc, values);
267
290
  /* rc now holds the result of the call to puts */
268
291
 
269
292
  /* values holds a pointer to the function's arg, so to
270
293
  call puts() again all we need to do is change the
271
294
  value of s */
272
295
  s = "This is cool!";
273
- ffi_call(&cif, puts, &rc, values);
296
+ ffi_call(&cif, (void(*)())puts, &rc, values);
274
297
  @}
275
298
 
276
299
  return 0;
@@ -627,7 +650,7 @@ Here is the corresponding code to describe this struct to
627
650
 
628
651
  tm_type.size = tm_type.alignment = 0;
629
652
  tm_type.type = FFI_TYPE_STRUCT;
630
- tm_type.elements = &tm_type_elements;
653
+ tm_type.elements = tm_type_elements;
631
654
 
632
655
  for (i = 0; i < 9; i++)
633
656
  tm_type_elements[i] = &ffi_type_sint;
@@ -1,4 +1,4 @@
1
- @set UPDATED 15 February 2024
2
- @set UPDATED-MONTH February 2024
3
- @set EDITION 3.4.6
4
- @set VERSION 3.4.6
1
+ @set UPDATED 2 August 2025
2
+ @set UPDATED-MONTH August 2025
3
+ @set EDITION 3.5.2
4
+ @set VERSION 3.5.2
@@ -31,6 +31,9 @@
31
31
  /* Define to 1 if you have the <alloca.h> header file. */
32
32
  #undef HAVE_ALLOCA_H
33
33
 
34
+ /* Define if your compiler supports pointer authentication. */
35
+ #undef HAVE_ARM64E_PTRAUTH
36
+
34
37
  /* Define if your assembler supports .cfi_* directives. */
35
38
  #undef HAVE_AS_CFI_PSEUDO_OP
36
39
 
@@ -65,15 +68,12 @@
65
68
  /* Define if you support more than one size of the long double type */
66
69
  #undef HAVE_LONG_DOUBLE_VARIANT
67
70
 
68
- /* Define to 1 if you have the 'memcpy' function. */
71
+ /* Define to 1 if you have the `memcpy' function. */
69
72
  #undef HAVE_MEMCPY
70
73
 
71
- /* Define to 1 if you have the 'memfd_create' function. */
74
+ /* Define to 1 if you have the `memfd_create' function. */
72
75
  #undef HAVE_MEMFD_CREATE
73
76
 
74
- /* Define if your compiler supports pointer authentication. */
75
- #undef HAVE_PTRAUTH
76
-
77
77
  /* Define if .eh_frame sections should be read-only. */
78
78
  #undef HAVE_RO_EH_FRAME
79
79
 
@@ -131,16 +131,16 @@
131
131
  /* Define to the version of this package. */
132
132
  #undef PACKAGE_VERSION
133
133
 
134
- /* The size of 'double', as computed by sizeof. */
134
+ /* The size of `double', as computed by sizeof. */
135
135
  #undef SIZEOF_DOUBLE
136
136
 
137
- /* The size of 'long double', as computed by sizeof. */
137
+ /* The size of `long double', as computed by sizeof. */
138
138
  #undef SIZEOF_LONG_DOUBLE
139
139
 
140
- /* The size of 'size_t', as computed by sizeof. */
140
+ /* The size of `size_t', as computed by sizeof. */
141
141
  #undef SIZEOF_SIZE_T
142
142
 
143
- /* Define to 1 if all of the C89 standard headers exist (not just the ones
143
+ /* Define to 1 if all of the C90 standard headers exist (not just the ones
144
144
  required in a freestanding environment). This macro is provided for
145
145
  backward compatibility; new code need not use it. */
146
146
  #undef STDC_HEADERS
@@ -11,15 +11,6 @@ class Platform(object):
11
11
  pass
12
12
 
13
13
 
14
- class i386_platform(Platform):
15
- arch = 'i386'
16
-
17
- prefix = "#ifdef __i386__\n\n"
18
- suffix = "\n\n#endif"
19
- src_dir = 'x86'
20
- src_files = ['sysv.S', 'ffi.c', 'internal.h']
21
-
22
-
23
14
  class x86_64_platform(Platform):
24
15
  arch = 'x86_64'
25
16
 
@@ -47,13 +38,6 @@ class armv7_platform(Platform):
47
38
  src_files = ['sysv.S', 'ffi.c', 'internal.h']
48
39
 
49
40
 
50
- class ios_simulator_i386_platform(i386_platform):
51
- target = 'i386-apple-ios-simulator'
52
- directory = 'darwin_ios'
53
- sdk = 'iphonesimulator'
54
- version_min = '-miphoneos-version-min=7.0'
55
-
56
-
57
41
  class ios_simulator_x86_64_platform(x86_64_platform):
58
42
  target = 'x86_64-apple-ios-simulator'
59
43
  directory = 'darwin_ios'
@@ -117,13 +101,6 @@ class tvos_device_arm64_platform(arm64_platform):
117
101
  version_min = '-mtvos-version-min=9.0'
118
102
 
119
103
 
120
- class watchos_simulator_i386_platform(i386_platform):
121
- target = 'i386-apple-watchos-simulator'
122
- directory = 'darwin_watchos'
123
- sdk = 'watchsimulator'
124
- version_min = '-mwatchos-version-min=4.0'
125
-
126
-
127
104
  class watchos_simulator_x86_64_platform(x86_64_platform):
128
105
  target = 'x86_64-apple-watchos-simulator'
129
106
  directory = 'darwin_watchos'
@@ -210,7 +187,7 @@ def build_target(platform, platform_headers):
210
187
  mkdir_p(build_dir)
211
188
  env = dict(CC=xcrun_cmd('clang'),
212
189
  LD=xcrun_cmd('ld'),
213
- CFLAGS='%s -fembed-bitcode' % (platform.version_min))
190
+ CFLAGS='%s' % (platform.version_min))
214
191
  working_dir = os.getcwd()
215
192
  try:
216
193
  os.chdir(build_dir)
@@ -248,7 +225,6 @@ def generate_source_and_headers(
248
225
  copy_files('include', 'darwin_common/include', pattern='*.h')
249
226
 
250
227
  if generate_ios:
251
- copy_src_platform_files(ios_simulator_i386_platform)
252
228
  copy_src_platform_files(ios_simulator_x86_64_platform)
253
229
  copy_src_platform_files(ios_simulator_arm64_platform)
254
230
  copy_src_platform_files(ios_device_armv7_platform)
@@ -261,7 +237,6 @@ def generate_source_and_headers(
261
237
  copy_src_platform_files(tvos_simulator_arm64_platform)
262
238
  copy_src_platform_files(tvos_device_arm64_platform)
263
239
  if generate_watchos:
264
- copy_src_platform_files(watchos_simulator_i386_platform)
265
240
  copy_src_platform_files(watchos_simulator_x86_64_platform)
266
241
  copy_src_platform_files(watchos_simulator_arm64_platform)
267
242
  copy_src_platform_files(watchos_device_armv7k_platform)
@@ -270,7 +245,6 @@ def generate_source_and_headers(
270
245
  platform_headers = collections.defaultdict(set)
271
246
 
272
247
  if generate_ios:
273
- build_target(ios_simulator_i386_platform, platform_headers)
274
248
  build_target(ios_simulator_x86_64_platform, platform_headers)
275
249
  build_target(ios_simulator_arm64_platform, platform_headers)
276
250
  build_target(ios_device_armv7_platform, platform_headers)
@@ -283,7 +257,6 @@ def generate_source_and_headers(
283
257
  build_target(tvos_simulator_arm64_platform, platform_headers)
284
258
  build_target(tvos_device_arm64_platform, platform_headers)
285
259
  if generate_watchos:
286
- build_target(watchos_simulator_i386_platform, platform_headers)
287
260
  build_target(watchos_simulator_x86_64_platform, platform_headers)
288
261
  build_target(watchos_simulator_arm64_platform, platform_headers)
289
262
  build_target(watchos_device_armv7k_platform, platform_headers)
@@ -217,6 +217,8 @@ EGREP = @EGREP@
217
217
  ETAGS = @ETAGS@
218
218
  EXEEXT = @EXEEXT@
219
219
  FFI_EXEC_TRAMPOLINE_TABLE = @FFI_EXEC_TRAMPOLINE_TABLE@
220
+ FFI_VERSION_NUMBER = @FFI_VERSION_NUMBER@
221
+ FFI_VERSION_STRING = @FFI_VERSION_STRING@
220
222
  FGREP = @FGREP@
221
223
  FILECMD = @FILECMD@
222
224
  GREP = @GREP@
@@ -267,6 +269,7 @@ TARGET = @TARGET@
267
269
  TARGETDIR = @TARGETDIR@
268
270
  TARGET_OBJ = @TARGET_OBJ@
269
271
  VERSION = @VERSION@
272
+ WASM64_MEMORY64 = @WASM64_MEMORY64@
270
273
  abs_builddir = @abs_builddir@
271
274
  abs_srcdir = @abs_srcdir@
272
275
  abs_top_builddir = @abs_top_builddir@
@@ -275,6 +278,7 @@ ac_ct_AR = @ac_ct_AR@
275
278
  ac_ct_CC = @ac_ct_CC@
276
279
  ac_ct_CXX = @ac_ct_CXX@
277
280
  ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
281
+ ac_ct_READELF = @ac_ct_READELF@
278
282
  am__include = @am__include@
279
283
  am__leading_dot = @am__leading_dot@
280
284
  am__quote = @am__quote@
@@ -1,6 +1,6 @@
1
1
  /* -----------------------------------------------------------------*-C-*-
2
2
  libffi @VERSION@
3
- - Copyright (c) 2011, 2014, 2019, 2021, 2022, 2024 Anthony Green
3
+ - Copyright (c) 2011, 2014, 2019, 2021, 2022, 2024, 2025 Anthony Green
4
4
  - Copyright (c) 1996-2003, 2007, 2008 Red Hat, Inc.
5
5
 
6
6
  Permission is hereby granted, free of charge, to any person
@@ -314,6 +314,24 @@ void ffi_java_raw_to_ptrarray (ffi_cif *cif, ffi_java_raw *raw, void **args) __a
314
314
  FFI_API
315
315
  size_t ffi_java_raw_size (ffi_cif *cif) __attribute__((deprecated));
316
316
 
317
+ /* ---- Version API ------------------------------------------------------ */
318
+
319
+ #define FFI_VERSION_STRING "@FFI_VERSION_STRING@"
320
+ #define FFI_VERSION_NUMBER @FFI_VERSION_NUMBER@
321
+
322
+ #ifndef LIBFFI_ASM
323
+ /* Return a version string. */
324
+ FFI_API const char *ffi_get_version (void);
325
+
326
+ /* Return the version as an unsigned long value: (x * 10000 + y * 100 + z) */
327
+ FFI_API unsigned long ffi_get_version_number (void);
328
+ #endif
329
+
330
+ /* ---- Internals API ---------------------------------------------------- */
331
+
332
+ FFI_API unsigned int ffi_get_default_abi (void);
333
+ FFI_API size_t ffi_get_closure_size (void);
334
+
317
335
  /* ---- Definitions for closures ----------------------------------------- */
318
336
 
319
337
  #if FFI_CLOSURES
@@ -49,6 +49,7 @@
49
49
  # define cfi_personality(enc, exp) .cfi_personality enc, exp
50
50
  # define cfi_lsda(enc, exp) .cfi_lsda enc, exp
51
51
  # define cfi_escape(...) .cfi_escape __VA_ARGS__
52
+ # define cfi_window_save .cfi_window_save
52
53
 
53
54
  #else
54
55
 
@@ -71,6 +72,7 @@
71
72
  # define cfi_personality(enc, exp)
72
73
  # define cfi_lsda(enc, exp)
73
74
  # define cfi_escape(...)
75
+ # define cfi_window_save
74
76
 
75
77
  #endif /* HAVE_AS_CFI_PSEUDO_OP */
76
78
  #endif /* FFI_CFI_H */
@@ -83,6 +83,23 @@ char *alloca ();
83
83
  #include <stdio.h>
84
84
  #endif
85
85
 
86
+ #ifndef __SANITIZE_ADDRESS__
87
+ # ifdef __clang__
88
+ # if __has_feature(address_sanitizer)
89
+ # define FFI_ASAN
90
+ # endif
91
+ # endif
92
+ #endif
93
+ #ifdef __SANITIZE_ADDRESS__
94
+ #define FFI_ASAN
95
+ #endif
96
+
97
+ #ifdef FFI_ASAN
98
+ #define FFI_ASAN_NO_SANITIZE __attribute__((no_sanitize_address))
99
+ #else
100
+ #define FFI_ASAN_NO_SANITIZE
101
+ #endif
102
+
86
103
  #ifdef FFI_DEBUG
87
104
  NORETURN void ffi_assert(const char *expr, const char *file, int line);
88
105
  void ffi_stop_here(void);
@@ -23,7 +23,6 @@ LIBFFI_BASE_8.0 {
23
23
  ffi_type_longdouble;
24
24
  ffi_type_pointer;
25
25
 
26
- /* Exported functions. */
27
26
  ffi_call;
28
27
  ffi_prep_cif;
29
28
  ffi_prep_cif_var;
@@ -46,6 +45,19 @@ LIBFFI_BASE_8.0 {
46
45
  *;
47
46
  };
48
47
 
48
+ /* ----------------------------------------------------------------------
49
+ Symbols **added in libffi 3.5.0**.
50
+ Give them a fresh namespace so that package managers notice when
51
+ code requires a newer libffi than 3.4.x.
52
+ -------------------------------------------------------------------- */
53
+ LIBFFI_BASE_8.1 {
54
+ global:
55
+ ffi_get_version;
56
+ ffi_get_version_number;
57
+ ffi_get_default_abi;
58
+ ffi_get_closure_size;
59
+ } LIBFFI_BASE_8.0;
60
+
49
61
  #ifdef FFI_TARGET_HAS_COMPLEX_TYPE
50
62
  LIBFFI_COMPLEX_8.0 {
51
63
  global:
@@ -26,4 +26,4 @@
26
26
  # release, then set age to 0.
27
27
  #
28
28
  # CURRENT:REVISION:AGE
29
- 9:4:1
29
+ 10:0:2
@@ -1,13 +1,30 @@
1
+ dnl ------------------------------------------------------------------
2
+ dnl Check whether the assembler understands .cfi_* pseudo-ops.
3
+ dnl ------------------------------------------------------------------
1
4
  AC_DEFUN([GCC_AS_CFI_PSEUDO_OP],
2
- [AC_CACHE_CHECK([assembler .cfi pseudo-op support],
3
- gcc_cv_as_cfi_pseudo_op, [
4
- gcc_cv_as_cfi_pseudo_op=unknown
5
- AC_TRY_COMPILE([asm (".cfi_sections\n\t.cfi_startproc\n\t.cfi_endproc");],,
6
- [gcc_cv_as_cfi_pseudo_op=yes],
7
- [gcc_cv_as_cfi_pseudo_op=no])
8
- ])
9
- if test "x$gcc_cv_as_cfi_pseudo_op" = xyes; then
10
- AC_DEFINE(HAVE_AS_CFI_PSEUDO_OP, 1,
11
- [Define if your assembler supports .cfi_* directives.])
12
- fi
5
+ [
6
+ AC_CACHE_CHECK([assembler .cfi pseudo-op support],
7
+ [gcc_cv_as_cfi_pseudo_op],
8
+ [ AC_LANG_PUSH([C])
9
+ AC_COMPILE_IFELSE(
10
+ [AC_LANG_SOURCE([[
11
+ #ifdef _MSC_VER
12
+ Nope.
13
+ #endif
14
+ int foo (void)
15
+ {
16
+ __asm__ (".cfi_remember_state\n\t"
17
+ ".cfi_restore_state\n\t");
18
+ return 0;
19
+ }
20
+ ]])],
21
+ [gcc_cv_as_cfi_pseudo_op=yes],
22
+ [gcc_cv_as_cfi_pseudo_op=no])
23
+ AC_LANG_POP([C])
24
+ ])
25
+
26
+ if test "x$gcc_cv_as_cfi_pseudo_op" = xyes; then
27
+ AC_DEFINE([HAVE_AS_CFI_PSEUDO_OP], [1],
28
+ [Define if your assembler supports .cfi_* directives.])
29
+ fi
13
30
  ])
@@ -34,14 +34,24 @@
34
34
  # and this notice are preserved. This file is offered as-is, without any
35
35
  # warranty.
36
36
 
37
- #serial 6
37
+ #serial 11
38
38
 
39
39
  AC_DEFUN([AX_CHECK_COMPILE_FLAG],
40
40
  [AC_PREREQ(2.64)dnl for _AC_LANG_PREFIX and AS_VAR_IF
41
41
  AS_VAR_PUSHDEF([CACHEVAR],[ax_cv_check_[]_AC_LANG_ABBREV[]flags_$4_$1])dnl
42
- AC_CACHE_CHECK([whether _AC_LANG compiler accepts $1], CACHEVAR, [
42
+ AC_CACHE_CHECK([whether the _AC_LANG compiler accepts $1], CACHEVAR, [
43
43
  ax_check_save_flags=$[]_AC_LANG_PREFIX[]FLAGS
44
- _AC_LANG_PREFIX[]FLAGS="$[]_AC_LANG_PREFIX[]FLAGS $4 $1"
44
+ if test x"m4_case(_AC_LANG,
45
+ [C], [$GCC],
46
+ [C++], [$GXX],
47
+ [Fortran], [$GFC],
48
+ [Fortran 77], [$G77],
49
+ [Objective C], [$GOBJC],
50
+ [Objective C++], [$GOBJCXX],
51
+ [no])" = xyes ; then
52
+ add_gnu_werror="-Werror"
53
+ fi
54
+ _AC_LANG_PREFIX[]FLAGS="$[]_AC_LANG_PREFIX[]FLAGS $4 $1 $add_gnu_werror"
45
55
  AC_COMPILE_IFELSE([m4_default([$5],[AC_LANG_PROGRAM()])],
46
56
  [AS_VAR_SET(CACHEVAR,[yes])],
47
57
  [AS_VAR_SET(CACHEVAR,[no])])
@@ -201,6 +201,8 @@ EGREP = @EGREP@
201
201
  ETAGS = @ETAGS@
202
202
  EXEEXT = @EXEEXT@
203
203
  FFI_EXEC_TRAMPOLINE_TABLE = @FFI_EXEC_TRAMPOLINE_TABLE@
204
+ FFI_VERSION_NUMBER = @FFI_VERSION_NUMBER@
205
+ FFI_VERSION_STRING = @FFI_VERSION_STRING@
204
206
  FGREP = @FGREP@
205
207
  FILECMD = @FILECMD@
206
208
  GREP = @GREP@
@@ -251,6 +253,7 @@ TARGET = @TARGET@
251
253
  TARGETDIR = @TARGETDIR@
252
254
  TARGET_OBJ = @TARGET_OBJ@
253
255
  VERSION = @VERSION@
256
+ WASM64_MEMORY64 = @WASM64_MEMORY64@
254
257
  abs_builddir = @abs_builddir@
255
258
  abs_srcdir = @abs_srcdir@
256
259
  abs_top_builddir = @abs_top_builddir@
@@ -259,6 +262,7 @@ ac_ct_AR = @ac_ct_AR@
259
262
  ac_ct_CC = @ac_ct_CC@
260
263
  ac_ct_CXX = @ac_ct_CXX@
261
264
  ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
265
+ ac_ct_READELF = @ac_ct_READELF@
262
266
  am__include = @am__include@
263
267
  am__leading_dot = @am__leading_dot@
264
268
  am__quote = @am__quote@
@@ -63,7 +63,7 @@ struct call_context
63
63
  #if FFI_EXEC_TRAMPOLINE_TABLE
64
64
 
65
65
  #ifdef __MACH__
66
- #ifdef HAVE_PTRAUTH
66
+ #ifdef HAVE_ARM64E_PTRAUTH
67
67
  #include <ptrauth.h>
68
68
  #endif
69
69
  #include <mach/vm_param.h>
@@ -645,7 +645,10 @@ extern void ffi_call_SYSV (struct call_context *context, void *frame,
645
645
  void *closure) FFI_HIDDEN;
646
646
 
647
647
  /* Call a function with the provided arguments and capture the return
648
- value. */
648
+ value.
649
+ n.b. ffi_call_SYSV will steal the alloca'd `stack` variable here for use
650
+ _as its own stack_ - so we need to compile this function without ASAN */
651
+ FFI_ASAN_NO_SANITIZE
649
652
  static void
650
653
  ffi_call_int (ffi_cif *cif, void (*fn)(void), void *orig_rvalue,
651
654
  void **avalue, void *closure)
@@ -682,7 +685,7 @@ ffi_call_int (ffi_cif *cif, void (*fn)(void), void *orig_rvalue,
682
685
  else if (flags & AARCH64_RET_NEED_COPY)
683
686
  rsize = 16;
684
687
 
685
- /* Allocate consectutive stack for everything we'll need.
688
+ /* Allocate consecutive stack for everything we'll need.
686
689
  The frame uses 40 bytes for: lr, fp, rvalue, flags, sp */
687
690
  context = alloca (sizeof(struct call_context) + stack_bytes + 40 + rsize);
688
691
  stack = context + 1;
@@ -877,7 +880,7 @@ ffi_prep_closure_loc (ffi_closure *closure,
877
880
 
878
881
  #if FFI_EXEC_TRAMPOLINE_TABLE
879
882
  # ifdef __MACH__
880
- # ifdef HAVE_PTRAUTH
883
+ # ifdef HAVE_ARM64E_PTRAUTH
881
884
  codeloc = ptrauth_auth_data(codeloc, ptrauth_key_function_pointer, 0);
882
885
  # endif
883
886
  void **config = (void **)((uint8_t *)codeloc - PAGE_MAX_SIZE);
@@ -83,8 +83,8 @@ typedef enum ffi_abi
83
83
 
84
84
  #if defined (__APPLE__)
85
85
  #define FFI_EXTRA_CIF_FIELDS unsigned aarch64_nfixedargs
86
- #elif !defined(_WIN32)
87
- /* iOS and Windows reserve x18 for the system. Disable Go closures until
86
+ #elif !defined(_WIN32) && !defined(__ANDROID__)
87
+ /* iOS, Windows and Android reserve x18 for the system. Disable Go closures until
88
88
  a new static chain is chosen. */
89
89
  #define FFI_GO_CLOSURES 1
90
90
  #endif