commit 0051b11c99779f8aa9ea912919c8421dea3e7a24
Merge: 3056d57c 928b9559
Author: Anthony Green <green@moxielogic.com>
Date:   Fri Dec 4 07:59:14 2026 -0500

    Merge pull request #1201 from libffi/release/3.8.3
    
    Release 3.8.3

commit 928b95596aafe8f5fa29f55c8eafa2c8231cb597
Author: Anthony Green <green@moxielogic.com>
Date:   Fri Dec 4 08:46:12 2026 +0000

    Release 3.8.3
    
    Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>

commit 4074458d11728b74ef85a7f2de50ffe5491c682e
Author: Anthony Green <green@moxielogic.com>
Date:   Fri Dec 4 08:46:11 2026 +0000

    Distribute src/pa/ffi64.c
    
    configure.host builds ffi64.c for hppa*64-*-hpux*, but the file was not
    listed in EXTRA_libffi_la_SOURCES, so release tarballs did not contain
    it.
    
    Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>

commit 3056d57c60c0da37a396c617a12d5b11a2c5a250
Merge: 6342f6c8 3491b4db
Author: Anthony Green <green@moxielogic.com>
Date:   Fri Dec 4 06:21:06 2026 -0500

    Merge pull request #1198 from libffi/mips-n64-abi-fixes
    
    mips: fix N32/N64 fp-struct, long-double-struct and complex returns and args

commit 3491b4db7dfc711edeec19dc35e41f6a8fd0fdea
Author: Anthony Green <green@moxielogic.com>
Date:   Fri Dec 4 02:53:06 2026 +0000

    mips: fix N32/N64 fp-struct, long-double-struct and complex returns and args (#1071)
    
    - ffi_closure_N32's return dispatch jumped from the COMPLEX_DD check
      past the STRUCT_FF one, and loaded the second float of a struct of two
      floats from offset 8 instead of 4, so closures returned such structs
      in v0/v1.
    
    - GCC returns a struct of one 128-bit long double in $f0 and $f1, not
      in $f0 and $f2 like a plain long double; libffi returned it in v0/v1
      like any 16-byte struct, which -O0 callers read by chance.  Add
      FFI_TYPE_STRUCT_LD for it, in calls and closures.  Use n32_fp_type
      for the fields so that a struct of a long double that is a double is
      returned like a struct of a double.
    
    - A named _Complex float in FPRs takes two argument slots; the closure
      decoder advanced past one, so later arguments were read from the
      wrong registers.
    
    - A _Complex long double result is returned through a hidden pointer in
      a0 and the arguments start at a1, as for any struct returned in
      memory.  libffi skipped two slots (in ffi_prep_args, the closure
      decoder, and by shifting the FP flags in ffi_call_N32), which only
      agreed with GCC when the first argument was 16-byte aligned, and did
      not count the hidden slot in cif->bytes.
    
    Remove the mips64 xfails from cls_struct_fp_return.c,
    cls_struct_ld_return.c, complex_regs_float.c and
    complex_regs_longdouble.c.
    
    Fixes #1071.
    
    Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

commit 6342f6c806e962f7b2e7991e6ec4e020449c6050
Merge: d91a4827 7d959140
Author: Anthony Green <green@moxielogic.com>
Date:   Fri Dec 4 06:20:22 2026 -0500

    Merge pull request #1199 from libffi/ppc64-elfv1-struct-long-double
    
    powerpc64: pass a struct of one IBM long double like the scalar on ELFv1

commit d91a4827be0804e9ae3569573f8a021e668b6c6d
Merge: 2975a983 09b285ec
Author: Anthony Green <green@moxielogic.com>
Date:   Fri Dec 4 06:20:02 2026 -0500

    Merge pull request #1197 from libffi/aarch64-win-variadic-hfa-named
    
    aarch64: disable MSVC /RTCs in ffi_call_int; test a named HFA in a variadic call

commit 2975a983a58dbaa6ca55b396dc29687cedcbe680
Merge: b342a06e 3dad7709
Author: Anthony Green <green@moxielogic.com>
Date:   Fri Dec 4 06:19:49 2026 -0500

    Merge pull request #1196 from libffi/x86-msvc-raw-closure-dispatch
    
    x86: fix the MSVC raw closure return dispatch

commit b342a06e886c72ab51cc9e0f8b27c14b51bc3a44
Merge: 000e6b6b fe771312
Author: Anthony Green <green@moxielogic.com>
Date:   Fri Dec 4 06:19:35 2026 -0500

    Merge pull request #1195 from libffi/x86-64-binary128-struct-return
    
    x86-64: return a struct of one binary128 long double in %xmm0

commit 09b285ec13709a6b8466f2ade49bfae982533305
Author: Anthony Green <green@moxielogic.com>
Date:   Fri Dec 4 09:01:35 2026 +0000

    testsuite: skip va_hfa_named_return.c on SPARC64
    
    The struct in this test has an array member, described to libffi as
    four doubles.  The SPARC64 ABI classifies array members differently
    from separate fields, which libffi's array emulation cannot express, so
    the test failed there.  Skip it on SPARC64 as callback.c and
    callback2.c already are, for the same reason.
    
    Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>

commit 3dad77098d7c0de552eb836668f371459fff4e13
Author: Anthony Green <green@moxielogic.com>
Date:   Fri Dec 4 09:01:17 2026 +0000

    x86: accept FFI_MS_CDECL in ffi_prep_raw_closure_loc
    
    FFI_MS_CDECL is the default ABI on 32-bit Windows, but
    ffi_prep_raw_closure_loc only accepted FFI_SYSV and FFI_THISCALL and
    returned FFI_BAD_ABI for it, so raw closures could not be used with the
    default ABI there and closure_raw.c failed under MSVC.  The two ABIs
    pass arguments alike and differ only in how structs are returned;
    raw closures with an in-memory result are refused earlier, and the
    register struct returns are handled by ffi_closure_raw_SYSV's return
    table.  Use that entry point for FFI_MS_CDECL too.
    
    Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>

commit 7d959140735a851aa01e2656350be0c5bc5c899d
Author: Anthony Green <green@moxielogic.com>
Date:   Fri Dec 4 02:47:47 2026 +0000

    powerpc64: pass a struct of one IBM long double like the scalar on ELFv1
    
    Under the 64-bit ELFv1 ABI the compiler gives a struct with a single
    floating-point member the mode of that member and passes it like the
    scalar.  libffi did that for float and double, but not for a single IBM
    long double, which counts as two elements: it treated such a struct as
    an ordinary aggregate, copied to the general registers and aligned to
    16 bytes in the parameter save area.  The compiler passes it in two
    FPRs and in the next two doublewords, without that alignment, so the
    value and every argument after it were misplaced, in ffi_call and in
    closures.
    
    Let discover_homogeneous_aggregate accept a struct whose only member is
    an IBM long double on ELFv1, exempt structs passed as floating-point
    elements from the struct alignment under both ABIs, and send such a
    struct through the scalar IBM long double code in ffi_prep_args64 and
    the closure helper.
    
    Enable mips_misc_cls_align_longdouble_odd.c on powerpc64 again; it was
    skipped there because of this.
    
    Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>

commit 087ec6f21013b6362ed724dfe9439441879a87f1
Author: multigr8 agent <agent@multigr8.invalid>
Date:   Fri Dec 4 02:43:33 2026 +0000

    aarch64: disable MSVC /RTCs in ffi_call_int; test a named HFA in a variadic call (#1059)
    
    ffi_call_SYSV takes over the alloca'd area below `context' as its stack,
    so a callee can overwrite the tracking data MSVC's /RTCs stack checks
    keep there, and a /RTC1 Debug build crashes on return.  Turn the checks
    off around ffi_call_int, as src/x86/ffi.c and ffiw64.c already do.
    Suggested by the reporter of #1059.
    
    b11c7f36 fixed the ABI half of #1059, but arm_va_hfa_struct.c only
    passes HFAs as variadic arguments.  Add the reporter's shape: an HFA as
    the named argument and the return value of a variadic function, with
    doubles as the variadic arguments.
    
    Fixes #1059.
    
    Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

commit fe7713122ec216c447b720b768501a2d6c51c5e0
Author: multigr8 agent <agent@multigr8.invalid>
Date:   Thu Dec 3 15:18:51 2026 +0000

    x86-64: return a struct of one binary128 long double in %xmm0 (#1076)
    
    Where long double is IEEE binary128 (x86_64 Android, -mlong-double-128),
    struct { long double } classifies as SSE + SSEUP, which is one %xmm
    register.  ffi_prep_cif_machdep treated SSEUP as a second SSE eightbyte
    and chose UNIX64_RET_ST_XMM0_XMM1, so the upper half of the value was
    read from %xmm1 (ffi_call) or placed there (closures).  Return it with
    UNIX64_RET_XMM128, as for a plain binary128 long double.  Argument
    passing already handled SSEUP correctly.
    
    Reproduced on x86_64-linux-gnu with CC="gcc -mlong-double-128": the fix
    makes cls_struct_ld_return.c pass at -O0 and -O2 and changes no other
    result, there or in a default build.  Drop the Android xfail.
    
    Fixes #1076.
    
    Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

commit a85f388ddb3cdd39726bf6b16cc8b5a81df74f4c
Author: multigr8 agent <agent@multigr8.invalid>
Date:   Thu Dec 3 15:21:32 2026 +0000

    x86: fix the MSVC raw closure return dispatch (#1074)
    
    In the MASM translation of the i386 raw closures, ffi_closure_raw_SYSV
    computed its return-handler address as load_table4 + type + 8 instead of
    load_table4 + type * 8, and both ffi_closure_raw_SYSV and
    ffi_closure_raw_THISCALL then jumped through the memory at that address
    (jmp dword ptr [ecx]) rather than to it (jmp ecx), as the GAS version in
    sysv.S and the other dispatch sites in sysv_intel.S do.  Every raw
    closure on i686 MSVC therefore returned to a garbage address.  Fix both,
    align load_table5 to 8 like the other tables, and drop the MSVC xfail
    from closure_raw.c.
    
    Fixes #1074.
    
    Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

commit 000e6b6b641017616715e2d78ae1e6fdb0423ca6
Merge: 11ce7283 f8e9d298
Author: Anthony Green <green@moxielogic.com>
Date:   Thu Dec 3 10:10:25 2026 -0500

    Merge pull request #1193 from libffi/tramp-loader-name-fallback
    
    tramp: find the trampoline file through the loader if the maps path fails

commit f8e9d298abb648bc71a06ce94cc6ba94a576640a
Author: Anthony Green <green@moxielogic.com>
Date:   Thu Dec 3 11:29:19 2026 +0000

    tramp: find the trampoline file through the loader if the maps path fails
    
    ffi_tramp_get_libffi () maps the static trampoline code table from the
    file that backs it, which it finds by reopening the path that
    /proc/self/maps reports.  That path is the kernel's name for the file.
    A process in another mount namespace, an application sandbox for
    instance, may be unable to open it, or may find a different inode
    there.  Static trampolines were then not used, and where the temp-file
    fallback is forbidden as well (a W^X policy that allows only file-backed
    executable mappings), ffi_closure_alloc () failed.
    
    If the maps path cannot be opened or fails the inode check, ask the
    dynamic loader for its name of the object that contains the code table
    (dl_iterate_phdr; /proc/self/exe for the main program) and open that.
    Only absolute names are used.  The inode of this file cannot be
    compared with the maps entry, so it is trusted only through the check
    tramp_table_map () already makes: every code table mapped from the
    descriptor must be identical to the code table in libffi's own text
    before a trampoline is handed out; otherwise the mapping is dropped and
    the temp-file fallback follows.  A shortage of descriptors or memory
    while opening either name is still reported as transient.
    
    Based on the patch by hqzing in #1085, ported to the current
    ffi_tramp_get_libffi ().
    
    Fixes #1084
    
    Co-authored-by: hqzing <hqzing@outlook.com>
    Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>

commit 11ce72839c2d3245fecdde5ec89d041fff3d9624
Merge: 4080c0c8 75873d3d
Author: Anthony Green <green@moxielogic.com>
Date:   Thu Dec 3 06:24:05 2026 -0500

    Merge pull request #1191 from libffi/testsuite-dualmap-growth-32bit
    
    testsuite: run generic_dualmap_growth.c on 32-bit hosts; pa: hide closure entry points

commit 75873d3d080415b2c29daec2bdd50cce8f8d3930
Author: Anthony Green <green@moxielogic.com>
Date:   Thu Dec 3 07:00:07 2026 +0000

    testsuite: run generic_dualmap_growth.c on 32-bit glibc hosts again
    
    7056bafa restricted the test to LP64 because, under _FILE_OFFSET_BITS=64,
    its mmap wrapper became mmap64 but forwarded to the 32-bit mmap from
    dlsym.  6f4b4595 fixed that by looking up "mmap64" in that case, so the
    restriction is no longer needed, and it excluded the hosts the test was
    written for: the closure file offset only wraps on 32-bit.  Keep the
    glibc requirement and drop __LP64__.
    
    Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

commit 4080c0c809fa36a7cf4791e3e9612b057d32b837
Merge: b4f01ff5 10d947e1
Author: Anthony Green <green@moxielogic.com>
Date:   Thu Dec 3 06:17:42 2026 -0500

    Merge pull request #1192 from libffi/pa-hidden-closure-entry
    
    pa: keep ffi_closure_pa32 hidden so closures copy a resolved descriptor

commit 10d947e17aaab3a3f535834cd25e104954bb1d6c
Author: Anthony Green <green@moxielogic.com>
Date:   Thu Dec 3 11:05:56 2026 +0000

    pa: keep ffi_closure_pa32 hidden so closures copy a resolved descriptor
    
    On 32-bit hppa Linux a function pointer refers to a function
    descriptor, and ffi_prep_closure_loc copies the descriptor of
    ffi_closure_pa32 (code address and gp) into every closure.  The symbol
    had default visibility.  When a static libffi is linked into an
    executable with --export-dynamic, the symbol is exported and its
    descriptor is bound lazily: until the function is first called through
    it, it holds the dynamic linker's resolver stub and a relocation index
    instead of the code address and gp.  libffi copied that unresolved pair
    into the closure and replaced the gp with the closure address, so the
    first call of any closure entered the resolver with a bogus argument
    and crashed (SIGILL in the dynamic linker, seen with
    generic_dualmap_growth.c under qemu-hppa).
    
    Give the symbol hidden visibility, in linux.S and in its declaration,
    so that the descriptor is resolved when libffi is linked.
    
    Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>

commit b4f01ff5b8bb656209dec3392632763c72e1fbd1
Merge: 09c3b8e0 ccffcde1
Author: Anthony Green <green@moxielogic.com>
Date:   Thu Dec 3 04:45:05 2026 -0500

    Merge pull request #1189 from libffi/testsuite-closure-raw-cygwin-xpass
    
    testsuite: limit closure_raw's i686 xfail to MSVC

commit 09c3b8e008e96d4d1f95526a28563b7378ab9039
Merge: 66a9c7e0 8db3ea7e
Author: Anthony Green <green@moxielogic.com>
Date:   Thu Dec 3 01:59:51 2026 -0500

    Merge pull request #1190 from libffi/testsuite-distribute-the-new-regression-tests
    
    testsuite: distribute the new regression tests

commit 8db3ea7e451a1311da8e588d889b40aa966d93af
Author: Anthony Green <green@moxielogic.com>
Date:   Wed Dec 2 13:03:03 2026 +0000

    testsuite: distribute the new regression tests
    
    Add the tests that accompany the recent fixes to
    EXTRA_DIST so they are part of the release tarball.
    
    Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>

commit 66a9c7e07ce109280966b73ebc361e6793902210
Merge: 9ee17676 aa9acfb6
Author: Anthony Green <green@moxielogic.com>
Date:   Thu Dec 3 01:59:36 2026 -0500

    Merge pull request #1188 from libffi/closures-give-a-forked-child-a-private-copy-of-t
    
    closures: give a forked child a private copy of the dual-mapped heap

commit aa9acfb627bd5101c73d5e9a1354a893a5d0eeb8
Author: Anthony Green <green@moxielogic.com>
Date:   Wed Dec 2 12:31:41 2026 +0000

    closures: give a forked child a private copy of the dual-mapped heap
    
    When writable and executable memory is refused and static trampolines
    are not in use, dlmmap_locked () maps one memfd or temp file twice with
    MAP_SHARED, an r-x view for code and an rw- view for data.  Nothing
    handled fork (): a child kept the writable view of the parent's closure
    code and the read-write execfd, so a worker that dropped privileges
    could rewrite closures its parent (or a sibling) later calls, and parent
    and child handed out the same chunks from their duplicated allocator
    state.
    
    Register pthread_atfork () handlers before the first dual mapping.  The
    prepare handler locks the allocator and the exec-file mutex, records
    every dual-mapped segment and copies them into a new temporary file
    (checked to be mappable PROT_EXEC).  The child maps the copy over both
    views at the same addresses, closes the parent's execfd and adopts the
    copy.  If no copy could be made, the child gets inaccessible memory in
    place of the views rather than abort (), so a child that never uses its
    inherited closures, e.g. one that execs, is unaffected.  The parent
    just closes the copy.  The cost is one copy of the closure heap per
    fork () in processes that use the dual mapping.
    
    Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

commit ccffcde113d896d1271cda9e60fc460645535a94
Author: multigr8 agent <agent@multigr8.invalid>
Date:   Thu Dec 3 06:59:08 2026 +0000

    testsuite: limit closure_raw's i686 xfail to MSVC
    
    The xfail for libffi #1074 matched i686-pc-cygwin, which is the triplet
    DejaGnu reports for both the i686 MSVC build and the native i686 Cygwin
    GCC build.  Only MSVC fails; the Cygwin GCC jobs XPASS at -O0 and -O2.
    Add an "msvc" effective target keyed on compiler_vendor and require it
    in the selector, so the GCC build reports a plain PASS and an XPASS no
    longer has to be tolerated by the CI policy.
    
    Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

commit 9ee1767658e2dac3b51183dc526b450edfff9f32
Merge: bc746eda 6f4b4595
Author: Anthony Green <green@moxielogic.com>
Date:   Thu Dec 3 00:20:45 2026 -0500

    Merge pull request #1160 from libffi/ci-wave1-cross-qemu
    
    ci: test MIPS o32/n32/n64-BE, m68k and ARM soft-float under qemu-user (+ fixes they found)

commit 6f4b459545974fc502fd483f0053cb440e64214e
Author: multigr8 agent <agent@multigr8.invalid>
Date:   Thu Dec 3 04:41:03 2026 +0000

    testsuite: forward generic_dualmap_growth's mmap to mmap64 under 64-bit off_t
    
    Debian and Ubuntu's 32-bit toolchains now default to
    _FILE_OFFSET_BITS=64.  <sys/mman.h> then renames the test's mmap
    interposer to mmap64 (which is what libffi calls), but the interposer
    still looked up the real "mmap", whose off_t is 32 bits.  The 64-bit
    offset landed in the wrong argument slot, every mapping of the closure
    file started at offset 0, the new segment aliased live closures and
    dlmalloc looped forever: the test timed out on o32 MIPS, armel and
    m68k.  Look up mmap64 in that configuration.
    
    Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

commit bc746eda4f9c80ab7877c16a8ebfec95a3a13fb6
Merge: 7d133e5c 8f6e4106
Author: Anthony Green <green@moxielogic.com>
Date:   Wed Dec 2 21:44:29 2026 -0500

    Merge pull request #1187 from libffi/testsuite-skip-generic-threads-segments-c-on-was
    
    testsuite: skip generic_threads_segments.c on wasm

commit 7d133e5c79a135492a95d7ec4863593c20af707a
Merge: 3cc5e5cc aa4e1f7d
Author: Anthony Green <green@moxielogic.com>
Date:   Wed Dec 2 21:44:20 2026 -0500

    Merge pull request #1186 from libffi/testsuite-don-t-expect-non-writable-closure-code
    
    testsuite: don't expect non-writable closure code on ppc64 ELFv1

commit 3cc5e5cc3dac01f08bc6e58b0f6095c66f860cb2
Merge: ce9b4fd6 7056bafa
Author: Anthony Green <green@moxielogic.com>
Date:   Wed Dec 2 21:44:11 2026 -0500

    Merge pull request #1185 from libffi/testsuite-run-generic-dualmap-growth-c-only-on-l
    
    testsuite: run generic_dualmap_growth.c only on LP64 glibc targets

commit ce9b4fd6fc65ab41e6292624eb9417f38c108b03
Merge: 693c8e23 dc2b66e1
Author: Anthony Green <green@moxielogic.com>
Date:   Wed Dec 2 21:44:00 2026 -0500

    Merge pull request #1184 from libffi/closures-parenthesize-the-argument-of-ffi-fn-in
    
    closures: parenthesize the argument of FFI_FN in ffi_closure_alloc

commit d3b715da486249285b221e53f0e17257af65b40e
Merge: e6910e04 693c8e23
Author: multigr8 agent <agent@multigr8.invalid>
Date:   Thu Dec 3 02:43:12 2026 +0000

    Merge branch 'master' into ci-wave1-cross-qemu
    
    Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

commit 8f6e4106388e6e272bb0bac472434ce064a9505f
Author: Anthony Green <green@moxielogic.com>
Date:   Thu Dec 3 02:22:31 2026 +0000

    testsuite: skip generic_threads_segments.c on wasm
    
    Emscripten's target triplet matches *-*-linux*, so the test was built
    there with -pthread although it does nothing on that target.  The first
    -pthread compile makes emcc build its threaded system libraries and
    print progress messages, which DejaGnu reports as excess errors (seen
    on wasm64).  Skip the test for wasm targets.
    
    Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>

commit aa4e1f7dfc87fce8d5a3a1e6a3f260692a6cb97e
Author: Anthony Green <green@moxielogic.com>
Date:   Thu Dec 3 02:22:31 2026 +0000

    testsuite: don't expect non-writable closure code on ppc64 ELFv1
    
    generic_fd_shortage.c checks that the code pointer of a closure does
    not point into writable memory.  Under the 64-bit PowerPC ELFv1 ABI
    that pointer is a function descriptor stored in the closure itself,
    which is ordinary writable data, so the check aborted there.  Skip it
    on that ABI.
    
    Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>

commit 7056bafaa021f05a7b6016ea3567b0a4846f14ac
Author: Anthony Green <green@moxielogic.com>
Date:   Thu Dec 3 02:22:31 2026 +0000

    testsuite: run generic_dualmap_growth.c only on LP64 glibc targets
    
    The test interposes mmap and forwards to the real one found with dlsym
    (RTLD_NEXT, "mmap").  On 32-bit targets whose toolchain defaults to
    64-bit file offsets, the wrapper is compiled as mmap64 with a 64-bit
    off_t while dlsym returns the mmap that takes a 32-bit one, so every
    forwarded call passed a misplaced offset and the test aborted or hung
    (hppa, powerpc and arm under QEMU).  Restrict the test to LP64, where
    the two cannot differ.
    
    Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>

commit dc2b66e1ea2f17c8fbeb0a955559e68d27d9de03
Author: Anthony Green <green@moxielogic.com>
Date:   Thu Dec 3 02:22:31 2026 +0000

    closures: parenthesize the argument of FFI_FN in ffi_closure_alloc
    
    FFI_FN (f) expands to ((void (*)(void))f), so FFI_FN ((char *) ptr +
    exec_offset) cast PTR to a function pointer and then added the offset
    to that.  GCC accepts arithmetic on function pointers as an extension;
    the Microsoft compiler does not, and the Visual C++ builds failed with
    error C2296.  Parenthesize the sum.
    
    Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>

commit 693c8e231032a81a652c5c2a60136a50fbeb6adb
Merge: 74009dbc fde2da7f
Author: Anthony Green <green@moxielogic.com>
Date:   Wed Dec 2 20:11:38 2026 -0500

    Merge pull request #1183 from libffi/closures-map-powerpc64-elfv1-closure-memory-with
    
    closures: map powerpc64 ELFv1 closure memory without PROT_EXEC

commit fde2da7f468b4feeaddf3cbd41599f18886c7518
Author: Anthony Green <green@moxielogic.com>
Date:   Wed Dec 2 13:04:01 2026 +0000

    closures: map powerpc64 ELFv1 closure memory without PROT_EXEC
    
    Under the 64-bit ELFv1 ABI a closure is a function descriptor that the
    caller reads; nothing in it is ever executed.  Static trampolines cannot
    be used with function descriptors and are now reported as unsupported on
    that ABI, so dlmmap () fell through to the writable and executable
    mapping (or the dual mapping).  Map closure memory read/write only
    there.
    
    Not built or run on PowerPC.
    
    Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>

commit 74009dbc57fe49fa8eb007f50ebbd87d77d1d931
Merge: e19ce9c1 ae239d61
Author: Anthony Green <green@moxielogic.com>
Date:   Wed Dec 2 20:11:24 2026 -0500

    Merge pull request #1182 from libffi/closures-keep-dual-mapped-segments-so-the-exec-f
    
    closures: keep dual-mapped segments so the exec file cannot grow or wrap

commit ae239d61ceab2e8d14ddb7020cef14f511767008
Author: Anthony Green <green@moxielogic.com>
Date:   Wed Dec 2 12:30:21 2026 +0000

    closures: keep dual-mapped segments so the exec file cannot grow or wrap
    
    dlmmap_locked () takes every new segment at execsize, which only ever
    grows, and dlmunmap () forgot the file range of a released segment.
    Since dlmalloc 2.8.6, dlfree () periodically releases empty segments,
    so a host that creates and frees closures in bursts grew the memfd or
    temp file without bound (memory invisible to RSS, or disk), and on
    32-bit hosts execsize eventually wrapped to 0 and new segments were
    mapped over live closures and allocator metadata.
    
    Make dlmunmap () refuse to release a dual-mapped segment; dlmalloc
    keeps segments it cannot unmap, so the file never grows past the peak
    closure footprint, as before 3.6.  Anonymous segments are still
    released.  Also refuse a segment whose end would wrap execsize or not
    fit in off_t, and have allocate_space () write at the segment's offset
    instead of at the file position, which a failed mapping that truncated
    the file back would have left past the end.
    
    Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

commit e19ce9c15b1988de2f9c063ff2bd8dde173a3185
Merge: f786a58f 117a2df7
Author: Anthony Green <green@moxielogic.com>
Date:   Wed Dec 2 20:10:50 2026 -0500

    Merge pull request #1181 from libffi/closures-walk-dlmalloc-s-segment-list-only-under
    
    closures: walk dlmalloc's segment list only under the allocator lock

commit 117a2df73c16a37e0e059317308ef6ff3b28d113
Author: Anthony Green <green@moxielogic.com>
Date:   Wed Dec 2 12:27:18 2026 +0000

    closures: walk dlmalloc's segment list only under the allocator lock
    
    ffi_closure_alloc (), ffi_data_to_code_pointer () and
    ffi_tramp_is_present () (reached from every ffi_prep_closure_loc () on
    static-trampoline ports) called segment_holding () without gm->mutex.
    All but the newest segment record live inside the closure segments, and
    since dlmalloc 2.8.6 dlfree () periodically unmaps empty segments, so a
    thread freeing closures in batches made a concurrent lookup on another
    thread read unmapped memory, or miss and leave a static trampoline
    unbound while ffi_prep_closure_loc () returned FFI_OK.
    
    Add closure_exec_offset (), which does the lookup under PREACTION/
    POSTACTION and copies out the exec offset, and use it at all three
    sites; also lock the (currently unused) FFI_CLOSURE_FREE_CODE lookup.
    Add a two-thread closures test; it needs more than one CPU to have a
    chance of hitting the race.
    
    Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

commit f786a58f57ba97aab5e64d3dfccd6f3221056c0a
Merge: 866c3903 94bc7944
Author: Anthony Green <green@moxielogic.com>
Date:   Wed Dec 2 20:10:35 2026 -0500

    Merge pull request #1180 from libffi/closures-tramp-open-closure-backing-descriptors
    
    closures, tramp: open closure-backing descriptors close-on-exec

commit 94bc794455c412aa713fc305c2c3472931dc44bc
Author: Anthony Green <green@moxielogic.com>
Date:   Wed Dec 2 12:26:06 2026 +0000

    closures, tramp: open closure-backing descriptors close-on-exec
    
    open_temp_exec_file_name () only passes O_CLOEXEC in a HAVE_MKOSTEMP
    branch, and the mkostemp configure check was dropped in 2b2f61f6, so
    every build uses plain mkstemp ().  When memfd_create and O_TMPFILE are
    unavailable, the read-write descriptor of the file that backs closure
    code (execfd of the dual-mapping allocator) is inherited by programs
    the host execs, e.g. a helper run under a lower uid, which can then
    overwrite code the host executes.
    
    Restore the mkostemp check in configure.ac, and set FD_CLOEXEC right
    after mkstemp () where mkostemp () does not exist.  Also open
    /proc/self/maps close-on-exec in ffi_tramp_get_libffi (), so a program
    exec'd by another thread during the first closure allocation does not
    get a descriptor to the host's address-space layout.
    
    Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

commit 866c39035fe9fa0559c0ad4ae21b66b6ec9202db
Merge: 382b1590 bbd0f93d
Author: Anthony Green <green@moxielogic.com>
Date:   Wed Dec 2 20:10:21 2026 -0500

    Merge pull request #1179 from libffi/tramp-do-not-cache-a-setup-failure-caused-by-fd
    
    tramp: do not cache a setup failure caused by fd or memory shortage

commit bbd0f93d7b2720c270429f3d7837eeedf8978905
Author: Anthony Green <green@moxielogic.com>
Date:   Wed Dec 2 12:22:08 2026 +0000

    tramp: do not cache a setup failure caused by fd or memory shortage
    
    ffi_tramp_init () recorded TRAMP_GLOBALS_FAILED whenever
    ffi_tramp_init_os () failed, including when /proc/self/maps, the
    library and every temporary file could not be opened with EMFILE, or a
    table could not be allocated with ENOMEM.  The verdict was never
    retried, so a process that had no free descriptor at its first
    ffi_closure_alloc () put that closure and every later one in writable
    and executable memory for the rest of its life; a remote client can
    cause this by holding all of a server's descriptors at the right time.
    
    Classify the failing call's errno: EMFILE, ENFILE, ENOMEM and EAGAIN
    mean "could not be set up this time" (-1), anything else "cannot be
    used" (0).  Pass the three-way result up, cache only 1 or 0, and only
    try the temp file after a definite 0.  dlmmap () fails the allocation
    on -1 instead of falling back to a writable and executable mapping, so
    ffi_closure_alloc () returns NULL while the shortage lasts.  No closure
    segment exists before a definite verdict, so the other callers of
    ffi_tramp_is_supported () never see -1.
    
    Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

commit 382b159076ec7a749bb99ca87b2a0913e6f2cb5f
Merge: 09d9dc19 83042ebe
Author: Anthony Green <green@moxielogic.com>
Date:   Wed Dec 2 20:10:07 2026 -0500

    Merge pull request #1178 from libffi/tramp-closures-do-not-trust-a-cached-descriptor
    
    tramp, closures: do not trust a cached descriptor number

commit 83042ebec68727080f227223570503b2872e5465
Author: Anthony Green <green@moxielogic.com>
Date:   Wed Dec 2 12:19:01 2026 +0000

    tramp, closures: do not trust a cached descriptor number
    
    libffi keeps the descriptor of the file holding the static trampoline
    code table (tramp_globals.fd) and of the dual-mapping backing file
    (execfd) for the life of the process, and maps every later table or
    segment from that number.  The host does not know about them; a host
    that closes descriptors it did not open (closefrom (3) when it becomes a
    daemon) and then opens a data file gets that file on libffi's number,
    and the next trampoline table is a PROT_EXEC mapping of it.  In the
    dual-mapping allocator the host's file is extended with zeros and mapped
    writable and executable.
    
    Record st_dev/st_ino when the file is opened and check them before the
    descriptor is used for a new mapping.  On a mismatch the number is left
    to its new owner and the file is acquired again (static trampolines) or
    a new backing file is started (dual mapping).
    
    Add a closures test that closes every descriptor after the first
    closure, puts a file of zeros on the freed number and then uses more
    closures than one trampoline table holds.
    
    Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

commit 09d9dc190313f3ef2bee526b029b294b14b4125b
Merge: 3894eada ed17db10
Author: Anthony Green <green@moxielogic.com>
Date:   Wed Dec 2 20:09:53 2026 -0500

    Merge pull request #1177 from libffi/tramp-read-proc-self-maps-whole-and-verify-the-m
    
    tramp: read /proc/self/maps whole and verify the mapped code table

commit ed17db10ee051411127fc77cf56d84e8e1f0f142
Author: Anthony Green <green@moxielogic.com>
Date:   Wed Dec 2 12:12:33 2026 +0000

    tramp: read /proc/self/maps whole and verify the mapped code table
    
    ffi_tramp_get_libffi () chose the file it maps PROT_EXEC as the static
    trampoline code table from a maps file, in two unsafe ways:
    
      * It opened /proc/<getpid ()>/maps.  getpid () is relative to the
        caller's PID namespace, the numbered /proc entries to the namespace
        procfs was mounted for.  In a PID namespace that still sees an outer
        /proc that is another process's map, whose owner chooses which file
        it lists at libffi's text address.
      * It read the map with fgets () into a fixed buffer and parsed every
        piece of an over-long line as an entry, so directory names of a long
        mapped path could forge the entry for libffi's text, inode included.
    
    Open /proc/self/maps, and read whole lines with getline () so only text
    the kernel starts a line with is parsed.  As defence in depth, compare
    every code table libffi maps with the code table in its own text before
    handing out trampolines from it; on a mismatch the mapping is dropped and
    the temp-file fallback (or an allocation failure) follows.
    
    Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

commit 3894eadaea8f8d8be33c1ab76f7f413981cdad9a
Merge: 7ce8d42e 6e8cc651
Author: Anthony Green <green@moxielogic.com>
Date:   Wed Dec 2 19:35:59 2026 -0500

    Merge pull request #1176 from libffi/prep-cif-visit-each-aggregate-once-when-looking
    
    prep_cif: visit each aggregate once when looking for vector types

commit 6e8cc6517f0911325e4b2d8354d4415bc76897a4
Author: Anthony Green <green@moxielogic.com>
Date:   Wed Dec 2 13:25:47 2026 +0000

    prep_cif: visit each aggregate once when looking for vector types
    
    ffi_type_contains_vector walked every path through a type, so
    ffi_prep_cif took time exponential in the nesting depth for a type
    whose nested aggregates list the same member more than once.  It runs
    on every port without vector support and in the x86-64 Windows ABI
    backend.  Remember the aggregates already entered and visit each one
    once; an emulated array, which repeats one member, is looked at once.
    
    Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>

commit 7ce8d42ebee2887eea839ca3b5e95d09795cb339
Merge: 38122b7b 22598ab9
Author: Anthony Green <green@moxielogic.com>
Date:   Wed Dec 2 19:35:45 2026 -0500

    Merge pull request #1175 from libffi/prep-cif-bound-struct-nesting-depth-in-layout-an
    
    prep_cif: bound struct nesting depth in layout and vector checks

commit 22598ab92279bbcec2c0eea20b5243a103c5e8e8
Author: Anthony Green <green@moxielogic.com>
Date:   Wed Dec 2 12:32:53 2026 +0000

    prep_cif: bound struct nesting depth in layout and vector checks
    
    initialize_aggregate () and ffi_type_contains_vector () recursed once
    per level of struct nesting with no limit, so a well-formed chain of
    one-member structs some 175000 levels deep (built as the manual
    describes) exhausted the stack in ffi_prep_cif, ffi_prep_cif_var or
    ffi_get_struct_offsets instead of returning an error.  Reject types
    nested more than FFI_MAX_AGGREGATE_NESTING (256) levels with
    FFI_BAD_TYPEDEF.  The x86-64 classify_argument () recursion, which also
    runs on every call, needs a matching change in src/x86/ffi64.c.
    
    Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

commit 38122b7b8ef00bf052199df5fd02e7f7c42ad0f2
Merge: 8d47d37f 474f0535
Author: Anthony Green <green@moxielogic.com>
Date:   Wed Dec 2 19:35:09 2026 -0500

    Merge pull request #1174 from libffi/aix-report-the-aix-struct-layout-from-ffi-get-st
    
    AIX: report the AIX struct layout from ffi_get_struct_offsets

commit 474f0535a89e8a45e9b38cd476ab1a739b6434f1
Author: Anthony Green <green@moxielogic.com>
Date:   Wed Dec 2 12:32:41 2026 +0000

    AIX: report the AIX struct layout from ffi_get_struct_offsets
    
    AIX fixes up the generic struct layout only in ffi_prep_cif_machdep ():
    aix_adjust_aggregate_sizes () pads structs whose first member is a
    double to a multiple of 8.  ffi_get_struct_offsets () returned the
    uncorrected generic layout, so on AIX it reported undersized structs
    and wrong member offsets, and a host that sized objects from it
    overflowed them.
    
    Add a hook: a port that defines FFI_TARGET_SPECIFIC_STRUCT_LAYOUT
    provides ffi_adjust_struct_layout_machdep (abi, type, offsets), which
    ffi_get_struct_offsets () calls after the generic layout.  Implement it
    for AIX: aix_adjust_aggregate_sizes () can now record member offsets.
    The alignment of the type is not raised to 8 there, so that the type
    can still be nested as a later member.  No other port defines the hook.
    
    Compile-checked in an AIX-like configuration on the host; not built or
    run on AIX.
    
    Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>

commit 8d47d37fa1419d417690675bc2d97034edd7dc6e
Merge: 699c1817 4b7331c2
Author: Anthony Green <green@moxielogic.com>
Date:   Wed Dec 2 19:34:55 2026 -0500

    Merge pull request #1173 from libffi/prep-cif-don-t-lay-out-a-laid-out-type-again-in
    
    prep_cif: don't lay out a laid-out type again in ffi_get_struct_offsets

commit 4b7331c2db840e29211643d19cc1ae4c884ae4ea
Author: Anthony Green <green@moxielogic.com>
Date:   Wed Dec 2 12:32:32 2026 +0000

    prep_cif: don't lay out a laid-out type again in ffi_get_struct_offsets
    
    ffi_get_struct_offsets () ran initialize_aggregate () on its argument
    unconditionally, and that starts by zeroing size and alignment.  A
    union emulated with the manual's recipe (one listed element, size and
    alignment set by the caller) lost its layout for good, so structs
    containing it came out smaller than the compiler's and a function
    returning one through ffi_call wrote past a buffer of that size; while
    the call ran, other threads also saw a transient size of 0.
    
    Like ffi_prep_cif, never lay out again a type whose size is already
    set: compute the offsets on a private copy instead.  Add a regression
    test.
    
    Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

commit 699c18174918ecc7a2d8ff5724f5f317755816fe
Merge: 3198b593 d06393ec
Author: Anthony Green <green@moxielogic.com>
Date:   Wed Dec 2 19:34:41 2026 -0500

    Merge pull request #1172 from libffi/prep-cif-refuse-to-build-when-ffi-raw-is-wider-t
    
    prep_cif: refuse to build when ffi_raw is wider than FFI_SIZEOF_ARG

commit d06393ecf87fa5a1caac8f61d1224fb2f38ba998
Author: Anthony Green <green@moxielogic.com>
Date:   Wed Dec 2 12:32:21 2026 +0000

    prep_cif: refuse to build when ffi_raw is wider than FFI_SIZEOF_ARG
    
    Generic argument sizing (STACK_ARG_SIZE, ffi_raw_size) works in
    FFI_SIZEOF_ARG units while the ports and ffi_ptrarray_to_raw store a
    whole ffi_arg / ffi_raw per slot.  A port that widens ffi_arg without
    defining FFI_SIZEOF_ARG, as ia64 does for ILP32 (32-bit HP-UX), gets
    the LONG_MAX-derived 4 and undersizes the ffi_call argument block and
    the raw buffers, so ffi_call writes past its alloca'd block.  Make that
    mismatch a compile-time error.  The ia64 port itself still needs to
    define FFI_SIZEOF_ARG as 8 in src/ia64/ffitarget.h.
    
    Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

commit 3198b59351d79fcfd59f6dda6437f6cb48d89f87
Merge: 03bc4c98 b5e994e6
Author: Anthony Green <green@moxielogic.com>
Date:   Wed Dec 2 19:34:28 2026 -0500

    Merge pull request #1171 from libffi/raw-api-take-the-size-of-long-double-from-the-ci
    
    raw_api: take the size of long double from the cif's ABI

commit b5e994e6a839b5b95c788644fb7de6be4a64124a
Author: Anthony Green <green@moxielogic.com>
Date:   Wed Dec 2 13:04:33 2026 +0000

    raw_api: take the size of long double from the cif's ABI
    
    Where long double has more than one width (powerpc), ffi_prep_cif ()
    resizes the global ffi_type_longdouble for the ABI of the cif prepared
    last.  ffi_raw_size (), ffi_ptrarray_to_raw () and ffi_raw_to_ptrarray ()
    read that global at call time, so a raw block sized for one cif could be
    filled or walked with the width of another, overrunning the block.
    
    Add a hidden ffi_long_double_size (abi) that applies the same test as
    ffi_prep_types (), and use it for long double arguments in the raw API.
    Other targets keep reading type->size.
    
    Not built or run on PowerPC.
    
    Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>

commit 03bc4c9846c507bf78f4a779f98da4c86d93a3a8
Merge: edc5d2f2 14e09512
Author: Anthony Green <green@moxielogic.com>
Date:   Wed Dec 2 19:34:14 2026 -0500

    Merge pull request #1170 from libffi/raw-api-step-ffi-raw-to-ptrarray-by-ffi-sizeof-a
    
    raw_api: step ffi_raw_to_ptrarray by FFI_SIZEOF_ARG on little-endian targets

commit 14e09512a8c5fb36743edccd98483070d5fb2533
Author: Anthony Green <green@moxielogic.com>
Date:   Wed Dec 2 12:31:55 2026 +0000

    raw_api: step ffi_raw_to_ptrarray by FFI_SIZEOF_ARG on little-endian targets
    
    The little-endian branch of ffi_raw_to_ptrarray () advanced its ffi_raw
    cursor in units of sizeof (void *), unlike ffi_raw_size (),
    ffi_ptrarray_to_raw () and the big-endian branch, which use
    FFI_SIZEOF_ARG.  Where an ffi_raw slot is wider than a pointer (x32,
    aarch64 ILP32, little-endian MIPS N32) every argument after an 8-byte
    one was taken from a later slot, eventually from past the end of the
    raw buffer.  Use FFI_SIZEOF_ARG.  Object code is unchanged where the two
    sizes are equal.  Add a raw API regression test.
    
    Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

commit e6910e04121377fda667a22f0e4042ab0a1a64f1
Author: multigr8 agent <agent@multigr8.invalid>
Date:   Thu Dec 3 00:18:18 2026 +0000

    ci: run the m68k cross job on Ubuntu 24.04
    
    GCC 15, the m68k-linux-gnu default on Ubuntu 26.04 (ubuntu-latest),
    miscompiles libffi.closures/cls_3float.c and nested_struct13.c at -O2:
    after SRA a float result is spilled as a 12-byte extended value and
    reloaded as a single-precision word from the wrong offset, so the test's
    own CHECK_FLOAT_EQ aborts.  It reproduces without libffi and goes away
    with -fno-tree-sra.  GCC 13 on Ubuntu 24.04 passes the whole testsuite.
    
    Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

commit edc5d2f2602b95e346cdd0b359f4c9456463e9f7
Merge: 4449c999 dc8c4531
Author: Anthony Green <green@moxielogic.com>
Date:   Wed Dec 2 19:08:18 2026 -0500

    Merge pull request #1169 from libffi/x86-64-bound-the-work-of-classifying-degenerate
    
    x86-64: bound the work of classifying degenerate aggregates

commit dc8c4531f0e78e5ec9759ce8ef4cf806b0849c3f
Author: Anthony Green <green@moxielogic.com>
Date:   Wed Dec 2 12:22:31 2026 +0000

    x86-64: bound the work of classifying degenerate aggregates
    
    classify_argument walks the full element tree of an aggregate on every
    ffi_prep_cif, ffi_call and closure entry, bounded only by the 32-byte
    size cap.  An aggregate may list the same element type several times,
    and the size of an emulated union (as CPython's ctypes describes one,
    listing every member) does not grow with nesting, so
    union Uk { union U(k-1) a, b; } costs 2^k visits for k+1 ffi_types:
