node-ctypes 2.13.2 → 2.14.0

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.
package/CHANGELOG.md CHANGED
@@ -7,6 +7,49 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [2.14.0] - 2026-11-15
11
+
12
+ ### Added
13
+
14
+ - **`Version.libffi`**: the version of the libffi node-ctypes is built with
15
+ (`ffi_get_version()`), for example `"3.8.1"`.
16
+
17
+ ### Changed
18
+
19
+ - **Callbacks on hardened Linux**: libffi is built as its `configure` does on
20
+ Linux x86-64 and AArch64, with static trampolines and `memfd_create`.
21
+ - The code of a callback now comes from a table inside `ctypes.node`, mapped
22
+ read and execute: closures no longer need a page that is writable and
23
+ executable. When the table cannot be mapped, libffi falls back to the
24
+ dynamic trampolines.
25
+ - In that fallback, when writable and executable pages are refused (SELinux,
26
+ PaX, Memory-Deny-Write-Execute), libffi maps an anonymous memory file
27
+ twice instead of looking for a temporary file in `TMPDIR`, `/tmp`,
28
+ `/var/tmp`, `/dev/shm` or `HOME`. Before, a process with no directory both
29
+ writable and executable (a read-only container running as a regular user,
30
+ for example) could not create callbacks: `Failed to allocate FFI closure`.
31
+ - `ctypes.node` now imports `memfd_create` (glibc 2.27), within the glibc
32
+ 2.28 baseline of the Linux binaries; musl has had it since 1.1.20.
33
+
34
+ ### Fixed
35
+
36
+ - **`ffi_closure` layout on macOS ARM64**: the generated `ffi.h` chose the
37
+ layout of `ffi_closure` with `FFI_EXEC_TRAMPOLINE_TABLE`, a macro of
38
+ `fficonfig.h` that it does not include. node-ctypes, and the libffi sources
39
+ that include `ffi.h` first, saw a 48-byte closure with `cif` at offset 24,
40
+ while the closure allocator and `ffi_prep_closure_loc` used the 40-byte
41
+ layout with `cif` at 16, as the header generated by Autotools does. The
42
+ header now tests the platform itself (macOS ARM64), so every source sees the
43
+ same layout. Callbacks were not affected: node-ctypes only allocates a closure
44
+ (48 bytes were enough) and never reads its fields.
45
+ - **`FFI_TYPE_LONGDOUBLE` where `long double` is a `double`**: the generated
46
+ `ffi.h` kept it distinct from `FFI_TYPE_DOUBLE` everywhere, while libffi's
47
+ `configure` makes them equal unless `long double` is larger (not on macOS
48
+ ARM64 nor with MSVC). On AArch64 libffi would then have treated an 8-byte
49
+ `long double` as the 128-bit type. The header now applies the same rule, from
50
+ the compiler's `__LDBL_MANT_DIG__` and `__DBL_MANT_DIG__`. node-ctypes does
51
+ not use `long double` yet, so nothing changes for existing code.
52
+
10
53
  ## [2.13.2] - 2026-11-15
11
54
 
12
55
  ### Fixed
@@ -1467,7 +1510,8 @@ It contains breaking changes: see [Migrating from 1.x](guides/python.md#migratin
1467
1510
 
1468
1511
  Initial releases.
1469
1512
 
1470
- [Unreleased]: https://github.com/dmazzella/node-ctypes/compare/v2.13.2...HEAD
1513
+ [Unreleased]: https://github.com/dmazzella/node-ctypes/compare/v2.14.0...HEAD
1514
+ [2.14.0]: https://github.com/dmazzella/node-ctypes/compare/v2.13.2...v2.14.0
1471
1515
  [2.13.2]: https://github.com/dmazzella/node-ctypes/compare/v2.13.1...v2.13.2
1472
1516
  [2.13.1]: https://github.com/dmazzella/node-ctypes/compare/v2.13.0...v2.13.1
1473
1517
  [2.13.0]: https://github.com/dmazzella/node-ctypes/compare/v2.12.2...v2.13.0
Binary file
Binary file
package/lib/index.d.ts CHANGED
@@ -135,6 +135,7 @@ export type FFIType = AnyType | StructureClass | PointerTypeDef | ArrayTypeDef |
135
135
  * ```javascript
136
136
  * import { Version } from 'node-ctypes';
137
137
  * console.log(Version.toString()); // "2.8.0"
138
+ * console.log(Version.libffi); // "3.8.1"
138
139
  * ```
139
140
  *
140
141
  * @category Library Loading
@@ -143,6 +144,8 @@ export class Version {
143
144
  static get major(): number;
144
145
  static get minor(): number;
145
146
  static get patch(): number;
147
+ /** Version of the libffi node-ctypes is built with. */
148
+ static get libffi(): string;
146
149
  static toString(): string;
147
150
  }
148
151
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "node-ctypes",
3
- "version": "2.13.2",
3
+ "version": "2.14.0",
4
4
  "description": "Python ctypes-like FFI for Node.js using libffi",
5
5
  "author": "Damiano Mazzella",
6
6
  "license": "MIT",