koffi 2.6.3 → 2.6.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.
package/CHANGELOG.md CHANGED
@@ -4,6 +4,15 @@
4
4
 
5
5
  ### Koffi 2.6
6
6
 
7
+ #### Koffi 2.6.5 (2023-10-28)
8
+
9
+ - Allow self-referential structs and unions
10
+ - Fix rare Node.js "FATAL ERROR" with some invalid types specifiers
11
+
12
+ #### Koffi 2.6.4 (2023-10-26)
13
+
14
+ - Fix build issue with recent Visual Studio versions
15
+
7
16
  #### Koffi 2.6.3 (2023-10-17)
8
17
 
9
18
  - Add indirect loading script to help some bundlers
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
package/doc/benchmarks.md CHANGED
@@ -10,8 +10,8 @@ Here is a quick overview of the execution time of Koffi calls on three benchmark
10
10
 
11
11
  <table style="margin: 0 auto;">
12
12
  <tr>
13
- <td><a href="_static/perf_linux_20220812.png" target="_blank"><img src="_static/perf_linux_20220812.png" alt="Linux x86_64 performance" style="width: 350px;"/></a></td>
14
- <td><a href="_static/perf_windows_20220812.png" target="_blank"><img src="_static/perf_windows_20220812.png" alt="Windows x86_64 performance" style="width: 350px;"/></a></td>
13
+ <td><a href="_static/perf_linux_20231028.png" target="_blank"><img src="_static/perf_linux_20231028.png" alt="Linux x86_64 performance" style="width: 350px;"/></a></td>
14
+ <td><a href="_static/perf_windows_20231028.png" target="_blank"><img src="_static/perf_windows_20231028.png" alt="Windows x86_64 performance" style="width: 350px;"/></a></td>
15
15
  </tr>
16
16
  </table>
17
17
 
@@ -31,9 +31,9 @@ This test is based around repeated calls to a simple standard C function `rand`,
31
31
 
32
32
  Benchmark | Iteration time | Relative performance | Overhead
33
33
  ------------- | -------------- | -------------------- | --------
34
- rand_napi | 842 ns | x1.00 | (ref)
35
- rand_koffi | 1114 ns | x0.76 | +32%
36
- rand_node_ffi | 44845 ns | x0.02 | +5224%
34
+ rand_napi | 700 ns | x1.00 | (ref)
35
+ rand_koffi | 1152 ns | x0.61 | +64%
36
+ rand_node_ffi | 32750 ns | x0.02 | +4576%
37
37
 
38
38
  Because rand is a pretty small function, the FFI overhead is clearly visible.
39
39
 
@@ -43,9 +43,9 @@ This test is similar to the rand one, but it is based on `atoi`, which takes a s
43
43
 
44
44
  Benchmark | Iteration time | Relative performance | Overhead
45
45
  ------------- | -------------- | -------------------- | --------
46
- atoi_napi | 921 ns | x1.00 | (ref)
47
- atoi_koffi | 1357 ns | x0.68 | +47%
48
- atoi_node_ffi | 152550 ns | x0.006 | +16472%
46
+ atoi_napi | 1028 ns | x1.00 | (ref)
47
+ atoi_koffi | 1730 ns | x0.59 | +68%
48
+ atoi_node_ffi | 121670 ns | x0.008 | +11738%
49
49
 
50
50
  Because atoi is a pretty small function, the FFI overhead is clearly visible.
51
51
 
@@ -58,10 +58,10 @@ This benchmark uses the CPU-based image drawing functions in Raylib. The calls a
58
58
 
59
59
  Benchmark | Iteration time | Relative performance | Overhead
60
60
  ------------------ | -------------- | -------------------- | --------
61
- raylib_cc | 215.7 µs | x1.20 | -17%
62
- raylib_node_raylib | 258.9 µs | x1.00 | (ref)
63
- raylib_koffi | 311.6 µs | x0.83 | +20%
64
- raylib_node_ffi | 928.4 µs | x0.28 | +259%
61
+ raylib_cc | 18.5 µs | x1.42 | -30%
62
+ raylib_node_raylib | 26.3 µs | x1.00 | (ref)
63
+ raylib_koffi | 28.0 µs | x0.94 | +6%
64
+ raylib_node_ffi | 87.0 µs | x0.30 | +230%
65
65
 
66
66
  ## Windows x86_64
67
67
 
@@ -77,9 +77,9 @@ This test is based around repeated calls to a simple standard C function `rand`,
77
77
 
78
78
  Benchmark | Iteration time | Relative performance | Overhead
79
79
  ------------- | -------------- | -------------------- | --------
80
- rand_napi | 964 ns | x1.00 | (ref)
81
- rand_koffi | 1274 ns | x0.76 | +32%
82
- rand_node_ffi | 42300 ns | x0.02 | +4289%
80
+ rand_napi | 859 ns | x1.00 | (ref)
81
+ rand_koffi | 1352 ns | x0.64 | +57%
82
+ rand_node_ffi | 35640 ns | x0.02 | +4048%
83
83
 
84
84
  Because rand is a pretty small function, the FFI overhead is clearly visible.
85
85
 
@@ -91,9 +91,9 @@ The results below were measured on my x86_64 Windows machine (Intel® Core™ i5
91
91
 
92
92
  Benchmark | Iteration time | Relative performance | Overhead
93
93
  ------------- | -------------- | -------------------- | --------
94
- atoi_napi | 1415 ns | x1.00 | (ref)
95
- atoi_koffi | 2193 ns | x0.65 | +55%
96
- atoi_node_ffi | 168300 ns | x0.008 | +11792%
94
+ atoi_napi | 1336 ns | x1.00 | (ref)
95
+ atoi_koffi | 2440 ns | x0.55 | +83%
96
+ atoi_node_ffi | 136890 ns | x0.010 | +10144%
97
97
 
98
98
  Because atoi is a pretty small function, the FFI overhead is clearly visible.
99
99
 
@@ -106,26 +106,19 @@ This benchmark uses the CPU-based image drawing functions in Raylib. The calls a
106
106
 
107
107
  Benchmark | Iteration time | Relative performance | Overhead
108
108
  ------------------ | -------------- | -------------------- | --------
109
- raylib_cc | 211.8 µs | x1.25 | -20%
110
- raylib_node_raylib | 264.4 µs | x1.00 | (ref)
111
- raylib_koffi | 318.9 µs | x0.83 | +21%
112
- raylib_node_ffi | 1146.2 µs | x0.23 | +334%
113
-
114
- Please note that in order to get fair numbers for raylib_node_raylib, it was recompiled with clang-cl before running the benchmark with the following commands:
115
-
116
- ```batch
117
- cd node_modules\raylib
118
- rmdir /S /Q bin build
119
- npx cmake-js compile -t ClangCL
120
- ```
109
+ raylib_cc | 18.2 µs | x1.50 | -33%
110
+ raylib_node_raylib | 27.3 µs | x1.00 | (ref)
111
+ raylib_koffi | 29.8 µs | x0.92 | +9%
112
+ raylib_node_ffi | 96.3 µs | x0.28 | +253%
121
113
 
122
114
  ## Running benchmarks
123
115
 
124
- Open a console, go to `koffi/benchmark` and run `../../cnoke/cnoke.js` (or `node ..\..\cnoke\cnoke.js` on Windows) before doing anything else.
125
-
126
- Please note that all benchmark results are made with Clang-built binaries.
116
+ Please note that all benchmark results on this page are made with Clang-built binaries.
127
117
 
128
118
  ```sh
119
+ cd koffi
120
+ node ../../cnoke/cnoke.js --prefer-clang
121
+
129
122
  cd koffi/benchmark
130
123
  node ../../cnoke/cnoke.js --prefer-clang
131
124
  ```
Binary file
package/doc/contribute.md CHANGED
@@ -139,7 +139,7 @@ Once this is done, you can publish a new release with the following commands:
139
139
 
140
140
  ```sh
141
141
  node tools/qemu.js test # If not done before
142
- node tools/qemu.js dist
142
+ node tools/qemu.js build
143
143
 
144
144
  cd build/dist
145
145
  npm publish
package/doc/packaging.md CHANGED
@@ -1,6 +1,8 @@
1
1
  # Bundlers and Koffi
2
2
 
3
- ## Bundling and native modules
3
+ ## Bundling
4
+
5
+ ### Native modules
4
6
 
5
7
  *Simplified in Koffi 2.5.9*
6
8
 
@@ -36,7 +38,7 @@ resources/
36
38
  MyApp.exe
37
39
  ```
38
40
 
39
- ## Indirect loader
41
+ ### Indirect loader
40
42
 
41
43
  *New in Koffi 2.6.2*
42
44
 
package/index.js CHANGED
@@ -378,8 +378,8 @@ var require_package = __commonJS({
378
378
  "build/dist/src/koffi/package.json"(exports2, module2) {
379
379
  module2.exports = {
380
380
  name: "koffi",
381
- version: "2.6.3",
382
- stable: "2.6.3",
381
+ version: "2.6.5",
382
+ stable: "2.6.5",
383
383
  description: "Fast and simple C FFI (foreign function interface) for Node.js",
384
384
  keywords: [
385
385
  "foreign",
@@ -413,10 +413,9 @@ var require_package = __commonJS({
413
413
  chalk: "^4.1.2",
414
414
  esbuild: "^0.19.2",
415
415
  "ffi-napi": "^4.0.3",
416
- "ffi-rs": "^1.0.12",
417
416
  minimatch: "^5.0.1",
418
417
  "node-ssh": "^12.0.3",
419
- raylib: "^0.9.2",
418
+ raylib: "^0.14.0",
420
419
  "ref-napi": "^3.0.3",
421
420
  "ref-struct-di": "^1.1.1",
422
421
  tar: "^6.1.11"
package/indirect.js CHANGED
@@ -378,8 +378,8 @@ var require_package = __commonJS({
378
378
  "build/dist/src/koffi/package.json"(exports2, module2) {
379
379
  module2.exports = {
380
380
  name: "koffi",
381
- version: "2.6.3",
382
- stable: "2.6.3",
381
+ version: "2.6.5",
382
+ stable: "2.6.5",
383
383
  description: "Fast and simple C FFI (foreign function interface) for Node.js",
384
384
  keywords: [
385
385
  "foreign",
@@ -413,10 +413,9 @@ var require_package = __commonJS({
413
413
  chalk: "^4.1.2",
414
414
  esbuild: "^0.19.2",
415
415
  "ffi-napi": "^4.0.3",
416
- "ffi-rs": "^1.0.12",
417
416
  minimatch: "^5.0.1",
418
417
  "node-ssh": "^12.0.3",
419
- raylib: "^0.9.2",
418
+ raylib: "^0.14.0",
420
419
  "ref-napi": "^3.0.3",
421
420
  "ref-struct-di": "^1.1.1",
422
421
  tar: "^6.1.11"
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "koffi",
3
- "version": "2.6.3",
4
- "stable": "2.6.3",
3
+ "version": "2.6.5",
4
+ "stable": "2.6.5",
5
5
  "description": "Fast and simple C FFI (foreign function interface) for Node.js",
6
6
  "keywords": [
7
7
  "foreign",
@@ -340,9 +340,9 @@ function Builder(config = {}) {
340
340
 
341
341
  function get_cache_directory() {
342
342
  if (process.platform == 'win32') {
343
- let cache_dir = process.env['APPDATA'];
343
+ let cache_dir = process.env['LOCALAPPDATA'] || process.env['APPDATA'];
344
344
  if (cache_dir == null)
345
- throw new Error('Missing APPDATA environment variable');
345
+ throw new Error('Missing LOCALAPPDATA and APPDATA environment variable');
346
346
 
347
347
  cache_dir = path.join(cache_dir, 'cnoke');
348
348
  return cache_dir;