Skip to content

Commit 12cce78

Browse files
committed
deps,src,test: fixed failures.
Signed-off-by: Paolo Insogna <paolo@cowtech.it>
1 parent 9165f84 commit 12cce78

5 files changed

Lines changed: 39 additions & 10 deletions

File tree

deps/libffi/libffi.gyp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
'src/java_raw_api.c',
77
'src/prep_cif.c',
88
'src/raw_api.c',
9+
'src/tramp.c',
910
'src/types.c',
1011
],
1112
'libffi_defines%': [],
@@ -137,8 +138,10 @@
137138
'<(python)',
138139
'generate-headers.py',
139140
'--output-dir=<(INTERMEDIATE_DIR)',
140-
'--target-arch=<(target_arch)',
141-
'--os=<(OS)',
141+
'--target-arch',
142+
'<(target_arch)',
143+
'--os',
144+
'<(OS)',
142145
],
143146
},
144147
],

node.gyp

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -999,8 +999,16 @@
999999
'dependencies': [
10001000
'deps/libffi/libffi.gyp:libffi',
10011001
],
1002-
'include_dirs': [
1003-
'<(PRODUCT_DIR)/obj.target/libffi/geni',
1002+
'conditions': [
1003+
[ 'OS=="win"', {
1004+
'include_dirs': [
1005+
'<(PRODUCT_DIR)/obj/libffi',
1006+
],
1007+
}, {
1008+
'include_dirs': [
1009+
'<(PRODUCT_DIR)/obj.target/libffi/geni',
1010+
],
1011+
}],
10041012
],
10051013
}],
10061014
],
@@ -1069,8 +1077,16 @@
10691077
'dependencies': [
10701078
'deps/libffi/libffi.gyp:libffi',
10711079
],
1072-
'include_dirs': [
1073-
'<(PRODUCT_DIR)/obj.target/libffi/geni',
1080+
'conditions': [
1081+
[ 'OS=="win"', {
1082+
'include_dirs': [
1083+
'<(PRODUCT_DIR)/obj/libffi',
1084+
],
1085+
}, {
1086+
'include_dirs': [
1087+
'<(PRODUCT_DIR)/obj.target/libffi/geni',
1088+
],
1089+
}],
10741090
],
10751091
}],
10761092
],

src/node_ffi.cc

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,8 +135,11 @@ bool DynamicLibrary::PrepareFunction(Environment* env,
135135

136136
*should_cache_symbol = symbols_.find(name) == symbols_.end();
137137

138-
fn = std::make_shared<FFIFunction>(FFIFunction{
139-
.closed = false, .ptr = ptr, .args = args, .return_type = return_type});
138+
fn = std::make_shared<FFIFunction>(FFIFunction{.closed = false,
139+
.ptr = ptr,
140+
.cif = {},
141+
.args = args,
142+
.return_type = return_type});
140143

141144
ffi_status status = ffi_prep_cif(&fn->cif,
142145
FFI_DEFAULT_ABI,
@@ -669,6 +672,9 @@ void DynamicLibrary::RegisterCallback(const FunctionCallbackInfo<Value>& args) {
669672
.env = env,
670673
.thread_id = std::this_thread::get_id(),
671674
.fn = Global<Function>(isolate, fn),
675+
.closure = nullptr,
676+
.ptr = nullptr,
677+
.cif = {},
672678
.args = std::move(callback_args),
673679
.return_type = return_type};
674680

test/ffi/test-ffi-memory.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,17 @@ const common = require('../common');
55
common.skipIfFFIMissing();
66
const { constants: bufferConstants } = require('node:buffer');
77
const assert = require('node:assert');
8-
const { test } = require('node:test');
8+
const { after, test } = require('node:test');
99
const ffi = require('node:ffi');
1010
const { fixtureSymbols, libraryPath } = require('./ffi-test-common');
1111

12-
const { functions: symbols } = ffi.dlopen(libraryPath, {
12+
const { lib, functions: symbols } = ffi.dlopen(libraryPath, {
1313
allocate_memory: fixtureSymbols.allocate_memory,
1414
deallocate_memory: fixtureSymbols.deallocate_memory,
1515
});
1616

17+
after(() => lib.close());
18+
1719
function withAllocations(fn) {
1820
const allocations = new Set();
1921

tools/nix/sharedLibDeps.nix

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
inherit (pkgs)
1111
ada
1212
brotli
13+
libffi
1314
gtest
1415
libuv
1516
merve
@@ -20,6 +21,7 @@
2021
zlib
2122
zstd
2223
;
24+
ffi = libffi;
2325
cares = pkgs.c-ares;
2426
hdr-histogram = pkgs.hdrhistogram_c;
2527
http-parser = pkgs.llhttp;

0 commit comments

Comments
 (0)