koffi 1.1.4 → 1.1.5

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 (40) hide show
  1. package/CMakeLists.txt +19 -18
  2. package/README.md +2 -2
  3. package/benchmark/CMakeLists.txt +11 -3
  4. package/benchmark/raylib_cc.cc +9 -9
  5. package/build/qemu/1.1.5/koffi_darwin_x64.tar.gz +0 -0
  6. package/build/qemu/1.1.5/koffi_freebsd_arm64.tar.gz +0 -0
  7. package/build/qemu/1.1.5/koffi_freebsd_ia32.tar.gz +0 -0
  8. package/build/qemu/1.1.5/koffi_freebsd_x64.tar.gz +0 -0
  9. package/build/qemu/1.1.5/koffi_linux_arm.tar.gz +0 -0
  10. package/build/qemu/1.1.5/koffi_linux_arm64.tar.gz +0 -0
  11. package/build/qemu/1.1.5/koffi_linux_ia32.tar.gz +0 -0
  12. package/build/qemu/1.1.5/koffi_linux_riscv64.tar.gz +0 -0
  13. package/build/qemu/1.1.5/koffi_linux_x64.tar.gz +0 -0
  14. package/build/qemu/1.1.5/koffi_openbsd_ia32.tar.gz +0 -0
  15. package/build/qemu/1.1.5/koffi_openbsd_x64.tar.gz +0 -0
  16. package/build/qemu/1.1.5/koffi_win32_ia32.tar.gz +0 -0
  17. package/build/qemu/1.1.5/koffi_win32_x64.tar.gz +0 -0
  18. package/package.json +2 -2
  19. package/qemu/qemu.js +5 -0
  20. package/src/abi_arm32_fwd.S +1 -1
  21. package/src/abi_arm64_fwd.S +1 -1
  22. package/src/abi_arm64_fwd.asm +107 -0
  23. package/src/abi_riscv64_fwd.S +1 -1
  24. package/src/abi_x64_sysv_fwd.S +113 -1
  25. package/src/ffi.cc +20 -1
  26. package/src/ffi.hh +2 -0
  27. package/test/CMakeLists.txt +1 -1
  28. package/build/qemu/1.1.4/koffi_darwin_x64.tar.gz +0 -0
  29. package/build/qemu/1.1.4/koffi_freebsd_arm64.tar.gz +0 -0
  30. package/build/qemu/1.1.4/koffi_freebsd_ia32.tar.gz +0 -0
  31. package/build/qemu/1.1.4/koffi_freebsd_x64.tar.gz +0 -0
  32. package/build/qemu/1.1.4/koffi_linux_arm.tar.gz +0 -0
  33. package/build/qemu/1.1.4/koffi_linux_arm64.tar.gz +0 -0
  34. package/build/qemu/1.1.4/koffi_linux_ia32.tar.gz +0 -0
  35. package/build/qemu/1.1.4/koffi_linux_riscv64.tar.gz +0 -0
  36. package/build/qemu/1.1.4/koffi_linux_x64.tar.gz +0 -0
  37. package/build/qemu/1.1.4/koffi_openbsd_ia32.tar.gz +0 -0
  38. package/build/qemu/1.1.4/koffi_openbsd_x64.tar.gz +0 -0
  39. package/build/qemu/1.1.4/koffi_win32_ia32.tar.gz +0 -0
  40. package/build/qemu/1.1.4/koffi_win32_x64.tar.gz +0 -0
package/CMakeLists.txt CHANGED
@@ -18,11 +18,10 @@ find_package(CNoke)
18
18
 
19
19
  set(CMAKE_CXX_STANDARD 17)
20
20
  if(MSVC)
21
- add_compile_options(/W4 /wd4200 /wd4458 /wd4706 /wd4100 /wd4127 /wd4702)
21
+ add_compile_options(/W4 /wd4200 /wd4458 /wd4706 /wd4100 /wd4127 /wd4702 /wd4201)
22
22
  enable_language(ASM_MASM)
23
23
  else()
24
- add_compile_options(-Wall -Wextra -Wno-missing-field-initializers
25
- -Wno-unused-parameter -Wno-class-memaccess)
24
+ add_compile_options(-Wall -Wextra -Wno-missing-field-initializers -Wno-unused-parameter)
26
25
  if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
27
26
  add_compile_options(-Wno-unknown-warning-option)
28
27
  endif()
@@ -32,12 +31,6 @@ endif()
32
31
 
33
32
  set(KOFFI_SRC
34
33
  src/call.cc
35
- src/abi_arm32.cc
36
- src/abi_arm64.cc
37
- src/abi_riscv64.cc
38
- src/abi_x64_sysv.cc
39
- src/abi_x64_win.cc
40
- src/abi_x86.cc
41
34
  src/ffi.cc
42
35
  src/parser.cc
43
36
  src/util.cc
@@ -45,21 +38,29 @@ set(KOFFI_SRC
45
38
  )
46
39
  if(CMAKE_SIZEOF_VOID_P EQUAL 8)
47
40
  if(CMAKE_SYSTEM_PROCESSOR MATCHES "aarch|arm")
48
- list(APPEND KOFFI_SRC src/abi_arm64_fwd.S)
41
+ if(WIN32)
42
+ list(APPEND KOFFI_SRC src/abi_arm64.cc src/abi_arm64_fwd.asm)
43
+ else()
44
+ list(APPEND KOFFI_SRC src/abi_arm64.cc src/abi_arm64_fwd.S)
45
+ endif()
49
46
  elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "riscv")
50
- list(APPEND KOFFI_SRC src/abi_riscv64_fwd.S)
51
- elseif(WIN32)
52
- list(APPEND KOFFI_SRC src/abi_x64_win_fwd.asm)
47
+ list(APPEND KOFFI_SRC src/abi_riscv64.cc src/abi_riscv64_fwd.S)
53
48
  else()
54
- list(APPEND KOFFI_SRC src/abi_x64_sysv_fwd.S)
49
+ if(WIN32)
50
+ list(APPEND KOFFI_SRC src/abi_x64_win.cc src/abi_x64_win_fwd.asm)
51
+ else()
52
+ list(APPEND KOFFI_SRC src/abi_x64_sysv.cc src/abi_x64_sysv_fwd.S)
53
+ endif()
55
54
  endif()
56
55
  elseif(CMAKE_SIZEOF_VOID_P EQUAL 4)
57
56
  if(CMAKE_SYSTEM_PROCESSOR MATCHES "arm")
58
- list(APPEND KOFFI_SRC src/abi_arm32_fwd.S)
59
- elseif(WIN32)
60
- list(APPEND KOFFI_SRC src/abi_x86_fwd.asm)
57
+ list(APPEND KOFFI_SRC src/abi_arm32.cc src/abi_arm32_fwd.S)
61
58
  else()
62
- list(APPEND KOFFI_SRC src/abi_x86_fwd.S)
59
+ if(WIN32)
60
+ list(APPEND KOFFI_SRC src/abi_x86.cc src/abi_x86_fwd.asm)
61
+ else()
62
+ list(APPEND KOFFI_SRC src/abi_x86.cc src/abi_x86_fwd.S)
63
+ endif()
63
64
  endif()
64
65
  endif()
65
66
 
package/README.md CHANGED
@@ -18,7 +18,7 @@
18
18
 
19
19
  # Introduction
20
20
 
21
- Koffi is a fast and easy-to-use FFI module for Node.js, with support for primitive and aggregate data types (structs), both by reference (pointer) and by value.
21
+ Koffi is a fast and easy-to-use C FFI module for Node.js, with support for primitive and aggregate data types (structs and fixed-size arrays), both by reference (pointer) and by value.
22
22
 
23
23
  The following features are planned in the near future:
24
24
 
@@ -38,7 +38,7 @@ RISC-V 64 [^4] | ⬜️ *N/A* | 🟩 Yes | ⬜️ *N/A* | 🟨 Proba
38
38
  [^1]: The following call conventions are supported: cdecl, stdcall, MS fastcall, thiscall.
39
39
  [^2]: The prebuilt binary uses the hard float ABI and expects a VFP coprocessor. Build from source to use Koffi with a different ABI (softfp, soft).
40
40
  [^3]: However, we don't provide prebuilt binaries for macOS on Apple M1.
41
- [^4]: Only the LP64D (double-precision float) gets tested. The LP64 ABI is supported in theory (untested), the LP64F ABI is not supported.
41
+ [^4]: Only the LP64D (double-precision float) ABI gets tested. The LP64 ABI is supported in theory (untested), the LP64F ABI is not supported.
42
42
 
43
43
  This is still in development, bugs are to be expected. More tests will come in the near future.
44
44
 
@@ -12,12 +12,10 @@
12
12
  # along with this program. If not, see https://www.gnu.org/licenses/.
13
13
 
14
14
  cmake_minimum_required(VERSION 3.12)
15
- project(koffi C CXX ASM)
15
+ project(koffi_benchmark C CXX)
16
16
 
17
17
  find_package(CNoke)
18
18
 
19
- set(CMAKE_CXX_STANDARD 20)
20
-
21
19
  set(THREADS_PREFER_PTHREAD_FLAG ON)
22
20
  find_package(Threads REQUIRED)
23
21
 
@@ -26,6 +24,16 @@ if(NOT TARGET koffi)
26
24
  endif()
27
25
  add_subdirectory(../test test)
28
26
 
27
+ set(CMAKE_CXX_STANDARD 17)
28
+ if(MSVC)
29
+ add_compile_options(/W4 /wd4200 /wd4458 /wd4706 /wd4100 /wd4127 /wd4702 /wd4201)
30
+ else()
31
+ add_compile_options(-Wall -Wextra -Wno-missing-field-initializers -Wno-unused-parameter)
32
+ if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
33
+ add_compile_options(-Wno-unknown-warning-option)
34
+ endif()
35
+ endif()
36
+
29
37
  # ---- atoi ----
30
38
 
31
39
  add_executable(atoi_cc atoi_cc.cc ../vendor/libcc/libcc.cc)
@@ -31,28 +31,28 @@ int Main(int argc, char **argv)
31
31
  SetWindowState(FLAG_WINDOW_HIDDEN);
32
32
  InitWindow(640, 480, "Raylib Test");
33
33
 
34
- Image img = GenImageColor(800, 600, Color { .r = 0, .g = 0, .b = 0, .a = 255 });
34
+ Image img = GenImageColor(800, 600, Color { 0, 0, 0, 255 });
35
35
  Font font = GetFontDefault();
36
36
 
37
37
  int64_t start = GetMonotonicTime();
38
38
 
39
39
  for (int i = 0; i < iterations; i++) {
40
- ImageClearBackground(&img, Color { .r = 0, .g = 0, .b = 0, .a = 255 });
40
+ ImageClearBackground(&img, Color { 0, 0, 0, 255 });
41
41
 
42
42
  for (int j = 0; j < 3600; j++) {
43
43
  const char *text = "Hello World!";
44
- int text_width = MeasureTextEx(font, text, 10, 1).x;
44
+ float text_width = MeasureTextEx(font, text, 10, 1).x;
45
45
 
46
46
  double angle = (j * 7) * PI / 180;
47
47
  Color color = {
48
- .r = (unsigned char)(127.5 + 127.5 * sin(angle)),
49
- .g = (unsigned char)(127.5 + 127.5 * sin(angle + PI / 2)),
50
- .b = (unsigned char)(127.5 + 127.5 * sin(angle + PI)),
51
- .a = 255
48
+ (unsigned char)(127.5 + 127.5 * sin(angle)),
49
+ (unsigned char)(127.5 + 127.5 * sin(angle + PI / 2)),
50
+ (unsigned char)(127.5 + 127.5 * sin(angle + PI)),
51
+ 255
52
52
  };
53
53
  Vector2 pos = {
54
- .x = (float)((img.width / 2 - text_width / 2) + j * 0.1 * cos(angle - PI / 2)),
55
- .y = (float)((img.height / 2 - 16) + j * 0.1 * sin(angle - PI / 2))
54
+ (float)((img.width / 2 - text_width / 2) + j * 0.1 * cos(angle - PI / 2)),
55
+ (float)((img.height / 2 - 16) + j * 0.1 * sin(angle - PI / 2))
56
56
  };
57
57
 
58
58
  ImageDrawTextEx(&img, font, text, pos, 10, 1, color);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "koffi",
3
- "version": "1.1.4",
4
- "description": "Fast and simple FFI (foreign function interface) for Node.js",
3
+ "version": "1.1.5",
4
+ "description": "Fast and simple C FFI (foreign function interface) for Node.js",
5
5
  "keywords": [
6
6
  "foreign",
7
7
  "function",
package/qemu/qemu.js CHANGED
@@ -303,6 +303,8 @@ async function pack() {
303
303
  ignore.add(machine);
304
304
  }
305
305
 
306
+ let ready = ignore.size;
307
+
306
308
  success &= await start(false);
307
309
  success &= await copy(machine => Object.values(machine.builds).map(build => build.directory));
308
310
 
@@ -405,6 +407,9 @@ async function pack() {
405
407
  if (machines.some(machine => machine.started))
406
408
  success &= await stop(false);
407
409
 
410
+ if (ignore.size > ready)
411
+ throw new Error('Some machines are missing, refusing to pack');
412
+
408
413
  return success;
409
414
  }
410
415
 
@@ -7,7 +7,7 @@
7
7
  // but WITHOUT ANY WARRANTY; without even the implied warranty of
8
8
  // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
9
9
  // GNU Affero General Public License for more details.
10
-
10
+ //
11
11
  // You should have received a copy of the GNU Affero General Public License
12
12
  // along with this program. If not, see https://www.gnu.org/licenses/.
13
13
 
@@ -7,7 +7,7 @@
7
7
  // but WITHOUT ANY WARRANTY; without even the implied warranty of
8
8
  // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
9
9
  // GNU Affero General Public License for more details.
10
-
10
+ //
11
11
  // You should have received a copy of the GNU Affero General Public License
12
12
  // along with this program. If not, see https://www.gnu.org/licenses/.
13
13
 
@@ -0,0 +1,107 @@
1
+ ; This program is free software: you can redistribute it and/or modify
2
+ ; it under the terms of the GNU Affero General Public License as published by
3
+ ; the Free Software Foundation, either version 3 of the License, or
4
+ ; (at your option) any later version.
5
+ ;
6
+ ; This program is distributed in the hope that it will be useful,
7
+ ; but WITHOUT ANY WARRANTY; without even the implied warranty of
8
+ ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
9
+ ; GNU Affero General Public License for more details.
10
+ ;
11
+ ; You should have received a copy of the GNU Affero General Public License
12
+ ; along with this program. If not, see https://www.gnu.org/licenses/.
13
+
14
+ AREA |.text|, CODE
15
+
16
+ ; Copy function pointer to r9, in order to save it through argument forwarding.
17
+ ; Save RSP in r29 (non-volatile), and use carefully assembled stack provided by caller.
18
+ MACRO
19
+ prologue
20
+
21
+ stp x29, x30, [sp, -16]!
22
+ mov x29, sp
23
+ mov x9, x0
24
+ add sp, x1, #136
25
+ MEND
26
+
27
+ ; Call native function.
28
+ ; Once done, restore normal stack pointer and return.
29
+ ; The return value is passed untouched through r0, r1, v0 and/or v1.
30
+ MACRO
31
+ epilogue
32
+
33
+ blr x9
34
+ mov sp, x29
35
+ ldp x29, x30, [sp], 16
36
+ ret
37
+ MEND
38
+
39
+ ; Prepare general purpose argument registers from array passed by caller.
40
+ MACRO
41
+ forward_int
42
+
43
+ ldr x8, [x1, 64]
44
+ ldr x7, [x1, 56]
45
+ ldr x6, [x1, 48]
46
+ ldr x5, [x1, 40]
47
+ ldr x4, [x1, 32]
48
+ ldr x3, [x1, 24]
49
+ ldr x2, [x1, 16]
50
+ ldr x0, [x1, 0]
51
+ ldr x1, [x1, 8]
52
+ MEND
53
+
54
+ ; Prepare vector argument registers from array passed by caller.
55
+ MACRO
56
+ forward_vec
57
+
58
+ ldr d7, [x1, 128]
59
+ ldr d6, [x1, 120]
60
+ ldr d5, [x1, 112]
61
+ ldr d4, [x1, 104]
62
+ ldr d3, [x1, 96]
63
+ ldr d2, [x1, 88]
64
+ ldr d1, [x1, 80]
65
+ ldr d0, [x1, 72]
66
+ MEND
67
+
68
+ ForwardCallGG PROC
69
+ prologue
70
+ forward_int
71
+ epilogue
72
+ ENDP
73
+
74
+ ForwardCallF PROC
75
+ prologue
76
+ forward_int
77
+ epilogue
78
+ ENDP
79
+
80
+ ForwardCallDDDD PROC
81
+ prologue
82
+ forward_int
83
+ epilogue
84
+ ENDP
85
+
86
+ ForwardCallXGG PROC
87
+ prologue
88
+ forward_vec
89
+ forward_int
90
+ epilogue
91
+ ENDP
92
+
93
+ ForwardCallXF PROC
94
+ prologue
95
+ forward_vec
96
+ forward_int
97
+ epilogue
98
+ ENDP
99
+
100
+ ForwardCallXDDDD PROC
101
+ prologue
102
+ forward_vec
103
+ forward_int
104
+ epilogue
105
+ ENDP
106
+
107
+ END
@@ -7,7 +7,7 @@
7
7
  // but WITHOUT ANY WARRANTY; without even the implied warranty of
8
8
  // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
9
9
  // GNU Affero General Public License for more details.
10
-
10
+ //
11
11
  // You should have received a copy of the GNU Affero General Public License
12
12
  // along with this program. If not, see https://www.gnu.org/licenses/.
13
13
 
@@ -7,7 +7,7 @@
7
7
  // but WITHOUT ANY WARRANTY; without even the implied warranty of
8
8
  // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
9
9
  // GNU Affero General Public License for more details.
10
-
10
+ //
11
11
  // You should have received a copy of the GNU Affero General Public License
12
12
  // along with this program. If not, see https://www.gnu.org/licenses/.
13
13
 
@@ -17,6 +17,8 @@
17
17
  #define SYMBOL(Symbol) Symbol
18
18
  #endif
19
19
 
20
+ // Forward
21
+
20
22
  // These five are the same, but they differ (in the C side) by their return type.
21
23
  // Unlike the five next functions, these ones don't forward XMM argument registers.
22
24
  .global SYMBOL(ForwardCallGG)
@@ -144,3 +146,113 @@ SYMBOL(ForwardCallXDD):
144
146
  forward_int
145
147
  movb $8, %al
146
148
  epilogue
149
+
150
+ // Callbacks
151
+
152
+ .global SYMBOL(CallBack0)
153
+ .global SYMBOL(CallBack1)
154
+ .global SYMBOL(CallBack2)
155
+ .global SYMBOL(CallBack3)
156
+ .global SYMBOL(CallBack4)
157
+ .global SYMBOL(CallBack5)
158
+ .global SYMBOL(CallBack6)
159
+ .global SYMBOL(CallBack7)
160
+ .global SYMBOL(CallBackX0)
161
+ .global SYMBOL(CallBackX1)
162
+ .global SYMBOL(CallBackX2)
163
+ .global SYMBOL(CallBackX3)
164
+ .global SYMBOL(CallBackX4)
165
+ .global SYMBOL(CallBackX5)
166
+ .global SYMBOL(CallBackX6)
167
+ .global SYMBOL(CallBackX7)
168
+ .global SYMBOL(RelayCallBack)
169
+
170
+ .macro jumper id
171
+ .cfi_startproc
172
+ .cfi_def_cfa rsp, 8
173
+ endbr64
174
+ subq $152, %rsp
175
+ .cfi_def_cfa rsp, 160
176
+ movq %rdi, 0(%rsp)
177
+ movq %rsi, 8(%rsp)
178
+ movq %rdx, 16(%rsp)
179
+ movq %rcx, 24(%rsp)
180
+ movq %r8, 32(%rsp)
181
+ movq %r9, 40(%rsp)
182
+ leaq 112(%rsp), %rdi
183
+ movq $\id, %rsi
184
+ movq %rsp, %rdx
185
+ call SYMBOL(RelayCallBack)
186
+ movq 8(%rax), %rdx
187
+ movq 0(%rax), %rax
188
+ addq $152, %rsp
189
+ ret
190
+ .cfi_endproc
191
+ .endm
192
+
193
+ .macro jumperx id
194
+ .cfi_startproc
195
+ .cfi_def_cfa rsp, 8
196
+ endbr64
197
+ subq $152, %rsp
198
+ .cfi_def_cfa rsp, 160
199
+ movq %rdi, 0(%rsp)
200
+ movq %rsi, 8(%rsp)
201
+ movq %rdx, 16(%rsp)
202
+ movq %rcx, 24(%rsp)
203
+ movq %r8, 32(%rsp)
204
+ movq %r9, 40(%rsp)
205
+ movsd %xmm0, 48(%rsp)
206
+ movsd %xmm1, 56(%rsp)
207
+ movsd %xmm2, 64(%rsp)
208
+ movsd %xmm3, 72(%rsp)
209
+ movsd %xmm4, 80(%rsp)
210
+ movsd %xmm5, 88(%rsp)
211
+ movsd %xmm6, 96(%rsp)
212
+ movsd %xmm7, 104(%rsp)
213
+ leaq 112(%rsp), %rdi
214
+ movq $\id, %rsi
215
+ movq %rsp, %rdx
216
+ call SYMBOL(RelayCallBack)
217
+ movsd 16(%rax), %xmm0
218
+ movsd 24(%rax), %xmm1
219
+ movq 8(%rax), %rdx
220
+ movq 0(%rax), %rax
221
+ addq $152, %rsp
222
+ ret
223
+ .cfi_endproc
224
+ .endm
225
+
226
+ SYMBOL(CallBack0):
227
+ jumper 0
228
+ SYMBOL(CallBack1):
229
+ jumper 1
230
+ SYMBOL(CallBack2):
231
+ jumper 2
232
+ SYMBOL(CallBack3):
233
+ jumper 3
234
+ SYMBOL(CallBack4):
235
+ jumper 4
236
+ SYMBOL(CallBack5):
237
+ jumper 5
238
+ SYMBOL(CallBack6):
239
+ jumper 6
240
+ SYMBOL(CallBack7):
241
+ jumper 7
242
+
243
+ SYMBOL(CallBackX0):
244
+ jumperx 0
245
+ SYMBOL(CallBackX1):
246
+ jumperx 1
247
+ SYMBOL(CallBackX2):
248
+ jumperx 2
249
+ SYMBOL(CallBackX3):
250
+ jumperx 3
251
+ SYMBOL(CallBackX4):
252
+ jumperx 4
253
+ SYMBOL(CallBackX5):
254
+ jumperx 5
255
+ SYMBOL(CallBackX6):
256
+ jumperx 6
257
+ SYMBOL(CallBackX7):
258
+ jumperx 7
package/src/ffi.cc CHANGED
@@ -449,7 +449,7 @@ static Napi::Value TranslateVariadicCall(const Napi::CallbackInfo &info)
449
449
  InstanceData *instance = env.GetInstanceData<InstanceData>();
450
450
 
451
451
  FunctionInfo func;
452
- memcpy(&func, info.Data(), RG_SIZE(FunctionInfo));
452
+ memcpy((void *)&func, info.Data(), RG_SIZE(FunctionInfo));
453
453
  func.lib = nullptr;
454
454
 
455
455
  // This makes variadic calls non-reentrant
@@ -956,6 +956,25 @@ void FunctionInfo::Unref() const
956
956
  }
957
957
  }
958
958
 
959
+ InstanceMemory::~InstanceMemory()
960
+ {
961
+ #ifdef _WIN32
962
+ if (stack.ptr) {
963
+ VirtualFree(stack.ptr, 0, MEM_RELEASE);
964
+ }
965
+ if (heap.ptr) {
966
+ VirtualFree(heap.ptr, 0, MEM_RELEASE);
967
+ }
968
+ #else
969
+ if (stack.ptr) {
970
+ munmap(stack.ptr, stack.len);
971
+ }
972
+ if (heap.ptr) {
973
+ munmap(heap.ptr, heap.len);
974
+ }
975
+ #endif
976
+ }
977
+
959
978
  InstanceData::InstanceData()
960
979
  {
961
980
  InstanceMemory *mem = new InstanceMemory();
package/src/ffi.hh CHANGED
@@ -181,6 +181,8 @@ struct FunctionInfo {
181
181
  };
182
182
 
183
183
  struct InstanceMemory {
184
+ ~InstanceMemory();
185
+
184
186
  Span<uint8_t> stack;
185
187
  Span<uint8_t> heap;
186
188
 
@@ -12,7 +12,7 @@
12
12
  # along with this program. If not, see https://www.gnu.org/licenses/.
13
13
 
14
14
  cmake_minimum_required(VERSION 3.12)
15
- project(koffi C CXX)
15
+ project(koffi_test C CXX)
16
16
 
17
17
  if(NOT TARGET koffi)
18
18
  add_subdirectory(.. koffi)