Skip to content

Commit 8cd9752

Browse files
committed
feat(libffi) update to 3.8.0
1 parent 5f1f080 commit 8cd9752

8 files changed

Lines changed: 73 additions & 13 deletions

File tree

‎doc/notes/3.4.3.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ _Not Released Yet_
99
- glfw: Updated to 3.5.1 (up from 3.4)
1010
- harfbuzz: Updated to 14.3.1 (up from 14.2.1)
1111
- KTX: Updated to 5.0.0-rc2 (up from 5.0.0-rc1)
12+
- libffi: Updated to 3.8.0 (up from 3.7.1)
1213
- lmdb: Updated to 1.0.1 (up from 0.9.35)
1314
* LMDB v1.0 is incompatible with earlier versions.
1415
* Use v0.9 `mdb_dump` with v1.0 `mdb_load` to migrate existing databases.

‎modules/lwjgl/core/src/generated/c/org_lwjgl_system_libffi_LibFFI.c‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,12 @@ JNIEXPORT void JNICALL Java_org_lwjgl_system_libffi_LibFFI_nffi_1call_1plan_1fre
297297
ffi_call_plan_free(plan);
298298
}
299299

300+
JNIEXPORT jlong JNICALL Java_org_lwjgl_system_libffi_LibFFI_nffi_1call_1plan_1size(JNIEnv *__env, jclass clazz, jlong planAddress) {
301+
ffi_call_plan *plan = (ffi_call_plan *)(uintptr_t)planAddress;
302+
UNUSED_PARAMS(__env, clazz)
303+
return (jlong)ffi_call_plan_size(plan);
304+
}
305+
300306
JNIEXPORT jint JNICALL Java_org_lwjgl_system_libffi_LibFFI_nffi_1get_1struct_1offsets(JNIEnv *__env, jclass clazz, jint abi, jlong struct_typeAddress, jlong offsetsAddress) {
301307
ffi_type *struct_type = (ffi_type *)(uintptr_t)struct_typeAddress;
302308
size_t *offsets = (size_t *)(uintptr_t)offsetsAddress;

‎modules/lwjgl/core/src/generated/java/org/lwjgl/system/libffi/LibFFI.java‎

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ public class LibFFI {
2020

2121
static { Library.initialize(); }
2222

23-
public static final String FFI_VERSION_STRING = "3.6.0";
23+
public static final String FFI_VERSION_STRING = "3.8.0";
2424

25-
public static final int FFI_VERSION_NUMBER = 0x7788;
25+
public static final int FFI_VERSION_NUMBER = 0x7850;
2626

2727
public static final short
2828
FFI_TYPE_VOID = 0,
@@ -42,7 +42,8 @@ public class LibFFI {
4242
FFI_TYPE_POINTER = 14,
4343
FFI_TYPE_COMPLEX = 15,
4444
FFI_TYPE_UINT128 = 16,
45-
FFI_TYPE_SINT128 = 17;
45+
FFI_TYPE_SINT128 = 17,
46+
FFI_TYPE_VECTOR = 18;
4647

4748
public static final int
4849
FFI_FIRST_ABI = FFI_FIRST_ABI(),
@@ -521,6 +522,20 @@ public static void ffi_call_plan_free(@NativeType("ffi_call_plan *") long plan)
521522
nffi_call_plan_free(plan);
522523
}
523524

525+
// --- [ ffi_call_plan_size ] ---
526+
527+
/** {@code size_t ffi_call_plan_size(ffi_call_plan * plan)} */
528+
public static native long nffi_call_plan_size(long plan);
529+
530+
/** {@code size_t ffi_call_plan_size(ffi_call_plan * plan)} */
531+
@NativeType("size_t")
532+
public static long ffi_call_plan_size(@NativeType("ffi_call_plan *") long plan) {
533+
if (CHECKS) {
534+
check(plan);
535+
}
536+
return nffi_call_plan_size(plan);
537+
}
538+
524539
// --- [ ffi_get_struct_offsets ] ---
525540

526541
/** {@code ffi_status ffi_get_struct_offsets(ffi_abi abi, ffi_type * struct_type, size_t * offsets)} */

‎modules/lwjgl/core/src/main/c/libffi/aarch64/ffitarget.h‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,10 @@ typedef enum ffi_abi
9898
#define FFI_TARGET_HAS_COMPLEX_TYPE
9999
#endif
100100

101+
/* AAPCS64 passes 8- and 16-byte vectors in V/Q registers and homogeneous
102+
vector aggregates in consecutive V/Q registers; see is_vfp_type. */
103+
#define FFI_TARGET_HAS_VECTOR_TYPE
104+
101105
#define FFI_TARGET_HAS_INT128 1
102106

103107
#endif

‎modules/lwjgl/core/src/main/c/libffi/ffi.h‎

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* -----------------------------------------------------------------*-C-*-
22
libffi @VERSION@
3-
- Copyright (c) 2011, 2014, 2019, 2021, 2022, 2024 Anthony Green
3+
- Copyright (c) 2011, 2014, 2019, 2021, 2022, 2024, 2025, 2026 Anthony Green
44
- Copyright (c) 1996-2003, 2007, 2008 Red Hat, Inc.
55
66
Permission is hereby granted, free of charge, to any person
@@ -88,9 +88,10 @@ extern "C" {
8888
#define FFI_TYPE_COMPLEX 15
8989
#define FFI_TYPE_UINT128 16
9090
#define FFI_TYPE_SINT128 17
91+
#define FFI_TYPE_VECTOR 18
9192

9293
/* This should always refer to the last type code (for sanity checks). */
93-
#define FFI_TYPE_LAST FFI_TYPE_SINT128
94+
#define FFI_TYPE_LAST FFI_TYPE_VECTOR
9495

9596
#include <ffitarget.h>
9697

@@ -332,8 +333,8 @@ size_t ffi_java_raw_size (ffi_cif *cif) __attribute__((deprecated));
332333

333334
/* ---- Version API ------------------------------------------------------ */
334335

335-
#define FFI_VERSION_STRING "3.7.0"
336-
#define FFI_VERSION_NUMBER 30700
336+
#define FFI_VERSION_STRING "3.8.0"
337+
#define FFI_VERSION_NUMBER 30800
337338

338339
#ifndef LIBFFI_ASM
339340
/* Return a version string. */
@@ -544,7 +545,11 @@ void ffi_call(ffi_cif *cif,
544545
ffi_call_plan_alloc returns NULL only on allocation failure; a signature
545546
with no fast path is still valid and ffi_call_plan_invoke falls back to
546547
ffi_call for it. A plan is immutable once built, so it may be shared and
547-
invoked concurrently from multiple threads. */
548+
invoked concurrently from multiple threads.
549+
550+
ffi_call_plan_size reports the total number of bytes libffi allocated for a
551+
plan, so that callers tracking the footprint of long-lived plans do not have
552+
to guess at the size of an opaque type. */
548553
typedef struct ffi_call_plan ffi_call_plan;
549554

550555
FFI_API
@@ -559,6 +564,9 @@ void ffi_call_plan_invoke (ffi_call_plan *plan,
559564
FFI_API
560565
void ffi_call_plan_free (ffi_call_plan *plan);
561566

567+
FFI_API
568+
size_t ffi_call_plan_size (ffi_call_plan *plan);
569+
562570
FFI_API
563571
ffi_status ffi_get_struct_offsets (ffi_abi abi, ffi_type *struct_type,
564572
size_t *offsets);

‎modules/lwjgl/core/src/main/c/libffi/ppc64le/ffitarget.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/* -----------------------------------------------------------------*-C-*-
2-
ffitarget.h - Copyright (c) 2012 Anthony Green
2+
ffitarget.h - Copyright (c) 2012, 2026 Anthony Green
33
Copyright (C) 2007, 2008, 2010 Free Software Foundation, Inc
44
Copyright (c) 1996-2003 Red Hat, Inc.
55

‎modules/lwjgl/core/src/main/c/libffi/x86/ffitarget.h‎

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/* -----------------------------------------------------------------*-C-*-
2-
ffitarget.h - Copyright (c) 2012, 2014, 2018 Anthony Green
2+
ffitarget.h - Copyright (c) 2012, 2014, 2018, 2026 Anthony Green
33
Copyright (c) 1996-2003, 2010 Red Hat, Inc.
44
Copyright (C) 2008 Free Software Foundation, Inc.
55
@@ -58,6 +58,13 @@
5858
#define FFI_TARGET_HAS_INT128
5959
#endif
6060

61+
/* The System V x86-64 psABI passes 8- and 16-byte vectors in SSE registers;
62+
this is implemented by the ffi64.c (FFI_UNIX64) backend only. 32-bit x86
63+
and the Windows x86-64 backend (ffiw64.c) do not marshal vectors. */
64+
#if defined(X86_64) && !defined(X86_WIN64)
65+
#define FFI_TARGET_HAS_VECTOR_TYPE
66+
#endif
67+
6168
/* ---- Generic type definitions ----------------------------------------- */
6269

6370
#ifndef LIBFFI_ASM
@@ -166,6 +173,18 @@ typedef enum ffi_abi {
166173
#define FFI_TYPE_SMALL_STRUCT_4B (FFI_TYPE_LAST + 3)
167174
#define FFI_TYPE_MS_STRUCT (FFI_TYPE_LAST + 4)
168175

176+
/* Tripwire: the win64.S / win64_intel.S return-value jump tables use one
177+
8-byte slot per code value and place the FFI_TYPE_SMALL_STRUCT_* pseudo-types
178+
(which are FFI_TYPE_LAST-relative) immediately after the generic FFI_TYPE_*
179+
codes. Adding a new generic type bumps FFI_TYPE_LAST, shifts those codes,
180+
and opens a gap in the tables that silently misaligns small-struct returns.
181+
When this fires: add a matching E() slot for the new type in both win64.S
182+
and win64_intel.S, then bump FFI_X86_TYPE_LAST to match. */
183+
#define FFI_X86_TYPE_LAST FFI_TYPE_VECTOR
184+
#if FFI_TYPE_LAST != FFI_X86_TYPE_LAST
185+
# error "new FFI_TYPE_* added: sync the win64.S/win64_intel.S jump tables and bump FFI_X86_TYPE_LAST"
186+
#endif
187+
169188
#if defined (X86_64) || defined(X86_WIN64) \
170189
|| (defined (__x86_64__) && defined (X86_DARWIN))
171190
/* 4 bytes of ENDBR64 + 7 bytes of LEA + 6 bytes of JMP + 7 bytes of NOP

‎modules/lwjgl/core/src/templates/kotlin/core/libffi/templates/LibFFI.kt‎

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,8 @@ typedef void (*FFI_CLOSURE_FUN)(ffi_cif*, void*, void**, void*);
5353
#define FFI_VFP -1
5454
#endif""")
5555

56-
StringConstant("VERSION_STRING".."3.6.0")
57-
IntConstant("VERSION_NUMBER"..30600)
56+
StringConstant("VERSION_STRING".."3.8.0")
57+
IntConstant("VERSION_NUMBER"..30800)
5858

5959
ShortConstant(
6060
"TYPE_VOID".."0",
@@ -74,7 +74,8 @@ typedef void (*FFI_CLOSURE_FUN)(ffi_cif*, void*, void**, void*);
7474
"TYPE_POINTER".."14",
7575
"TYPE_COMPLEX".."15",
7676
"TYPE_UINT128".."16",
77-
"TYPE_SINT128".."17"
77+
"TYPE_SINT128".."17",
78+
"TYPE_VECTOR".."18"
7879
)
7980

8081
macro(variable=true)..private..short(
@@ -223,6 +224,12 @@ typedef void (*FFI_CLOSURE_FUN)(ffi_cif*, void*, void**, void*);
223224
ffi_call_plan.p("plan")
224225
)
225226

227+
size_t(
228+
"call_plan_size",
229+
230+
ffi_call_plan.p("plan")
231+
)
232+
226233
ffi_status(
227234
"get_struct_offsets",
228235

0 commit comments

Comments
 (0)