koffi 1.1.2 → 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.
- package/CMakeLists.txt +23 -19
- package/README.md +16 -27
- package/benchmark/CMakeLists.txt +11 -3
- package/benchmark/raylib_cc.cc +9 -9
- package/build/qemu/1.1.5/koffi_darwin_x64.tar.gz +0 -0
- package/build/qemu/1.1.5/koffi_freebsd_arm64.tar.gz +0 -0
- package/build/qemu/1.1.5/koffi_freebsd_ia32.tar.gz +0 -0
- package/build/qemu/1.1.5/koffi_freebsd_x64.tar.gz +0 -0
- package/build/qemu/1.1.5/koffi_linux_arm.tar.gz +0 -0
- package/build/qemu/1.1.5/koffi_linux_arm64.tar.gz +0 -0
- package/build/qemu/1.1.5/koffi_linux_ia32.tar.gz +0 -0
- package/build/qemu/1.1.5/koffi_linux_riscv64.tar.gz +0 -0
- package/build/qemu/1.1.5/koffi_linux_x64.tar.gz +0 -0
- package/build/qemu/1.1.5/koffi_openbsd_ia32.tar.gz +0 -0
- package/build/qemu/1.1.5/koffi_openbsd_x64.tar.gz +0 -0
- package/build/qemu/1.1.5/koffi_win32_ia32.tar.gz +0 -0
- package/build/qemu/1.1.5/koffi_win32_x64.tar.gz +0 -0
- package/package.json +2 -2
- package/qemu/qemu.js +18 -10
- package/qemu/registry/machines.json +138 -3
- package/qemu/registry/sha256sum.txt +27 -12
- package/src/abi_arm32.cc +29 -16
- package/src/abi_arm32_fwd.S +1 -1
- package/src/abi_arm64.cc +33 -17
- package/src/abi_arm64_fwd.S +1 -1
- package/src/abi_arm64_fwd.asm +107 -0
- package/src/abi_riscv64.cc +468 -0
- package/src/abi_riscv64_fwd.S +129 -0
- package/src/abi_x64_sysv.cc +9 -10
- package/src/abi_x64_sysv_fwd.S +113 -1
- package/src/abi_x64_win.cc +5 -8
- package/src/abi_x86.cc +11 -6
- package/src/call.cc +6 -18
- package/src/call.hh +13 -23
- package/src/ffi.cc +87 -25
- package/src/ffi.hh +14 -4
- package/src/parser.cc +18 -6
- package/src/util.cc +26 -57
- package/src/util.hh +17 -1
- package/test/CMakeLists.txt +4 -1
- package/test/misc.c +34 -0
- package/vendor/_patches/glfw_001_fix_openbsd_xlib_soname.patch +145 -0
- package/vendor/libcc/libcc.cc +7 -7
- package/vendor/libcc/libcc.hh +8 -2
- package/vendor/raylib/src/external/glfw/src/egl_context.c +6 -0
- package/vendor/raylib/src/external/glfw/src/osmesa_context.c +2 -0
- package/vendor/raylib/src/external/glfw/src/vulkan.c +2 -0
- package/vendor/raylib/src/external/glfw/src/x11_init.c +20 -0
- package/build/qemu/1.1.2/koffi_darwin_x64.tar.gz +0 -0
- package/build/qemu/1.1.2/koffi_freebsd_arm64.tar.gz +0 -0
- package/build/qemu/1.1.2/koffi_freebsd_ia32.tar.gz +0 -0
- package/build/qemu/1.1.2/koffi_freebsd_x64.tar.gz +0 -0
- package/build/qemu/1.1.2/koffi_linux_arm.tar.gz +0 -0
- package/build/qemu/1.1.2/koffi_linux_arm64.tar.gz +0 -0
- package/build/qemu/1.1.2/koffi_linux_ia32.tar.gz +0 -0
- package/build/qemu/1.1.2/koffi_linux_x64.tar.gz +0 -0
- package/build/qemu/1.1.2/koffi_win32_ia32.tar.gz +0 -0
- package/build/qemu/1.1.2/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,31 +31,36 @@ 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_x64_sysv.cc
|
|
38
|
-
src/abi_x64_win.cc
|
|
39
|
-
src/abi_x86.cc
|
|
40
34
|
src/ffi.cc
|
|
41
35
|
src/parser.cc
|
|
42
36
|
src/util.cc
|
|
43
37
|
vendor/libcc/libcc.cc
|
|
44
38
|
)
|
|
45
39
|
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
|
|
46
|
-
if(
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
40
|
+
if(CMAKE_SYSTEM_PROCESSOR MATCHES "aarch|arm")
|
|
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()
|
|
46
|
+
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "riscv")
|
|
47
|
+
list(APPEND KOFFI_SRC src/abi_riscv64.cc src/abi_riscv64_fwd.S)
|
|
50
48
|
else()
|
|
51
|
-
|
|
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()
|
|
52
54
|
endif()
|
|
53
55
|
elseif(CMAKE_SIZEOF_VOID_P EQUAL 4)
|
|
54
|
-
if(
|
|
55
|
-
list(APPEND KOFFI_SRC src/
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
56
|
+
if(CMAKE_SYSTEM_PROCESSOR MATCHES "arm")
|
|
57
|
+
list(APPEND KOFFI_SRC src/abi_arm32.cc src/abi_arm32_fwd.S)
|
|
58
|
+
else()
|
|
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()
|
|
60
64
|
endif()
|
|
61
65
|
endif()
|
|
62
66
|
|
package/README.md
CHANGED
|
@@ -13,43 +13,32 @@
|
|
|
13
13
|
* [Raylib results](#raylib-results)
|
|
14
14
|
- [Tests](#tests)
|
|
15
15
|
- [Compilation](#compilation)
|
|
16
|
-
* [Windows](#windows)
|
|
16
|
+
* [Windows](#windows-1)
|
|
17
17
|
* [Other platforms](#other-platforms)
|
|
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
|
|
|
25
25
|
* 1.2: C to JS callbacks
|
|
26
26
|
* 1.3: Type parser
|
|
27
27
|
|
|
28
|
-
The following
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
macOS | ARM64 (M1) Little Endian | 🟩 Yes | 🟩 Yes | 🟥 No | 🟥 No
|
|
43
|
-
OpenBSD | x86_64 | 🟧 Maybe | 🟧 Maybe | 🟥 No | 🟥 No
|
|
44
|
-
OpenBSD | x86 | 🟧 Maybe | 🟧 Maybe | 🟥 No | 🟥 No
|
|
45
|
-
OpenBSD | ARM64 Little Endian | 🟧 Maybe | 🟧 Maybe | 🟥 No | 🟥 No
|
|
46
|
-
NetBSD | x86_64 | 🟧 Maybe | 🟧 Maybe | 🟥 No | 🟥 No
|
|
47
|
-
NetBSD | x86 | 🟧 Maybe | 🟧 Maybe | 🟥 No | 🟥 No
|
|
48
|
-
NetBSD | ARM64 Little Endian | 🟧 Maybe | 🟧 Maybe | 🟥 No | 🟥 No
|
|
49
|
-
|
|
50
|
-
🟩 Tested, fully operational
|
|
51
|
-
🟧 May work, but not actively tested
|
|
52
|
-
🟥 Does not work yet
|
|
28
|
+
The following combinations of OS and architectures __are officially supported and tested__ at the moment:
|
|
29
|
+
|
|
30
|
+
ISA / OS | Windows | Linux | macOS | FreeBSD | OpenBSD
|
|
31
|
+
------------------ | ----------- | -------- | ----------- | ----------- | --------
|
|
32
|
+
x86 (IA32) [^1] | 🟩 Yes | 🟩 Yes | ⬜️ *N/A* | 🟩 Yes | 🟩 Yes
|
|
33
|
+
x86_64 (AMD64) | 🟩 Yes | 🟩 Yes | 🟩 Yes | 🟩 Yes | 🟩 Yes
|
|
34
|
+
ARM32 LE [^2] | ⬜️ *N/A* | 🟩 Yes | ⬜️ *N/A* | 🟨 Probably | 🟨 Probably
|
|
35
|
+
ARM64 (AArch64) LE | 🟧 Maybe | 🟩 Yes | 🟩 Yes [^3] | 🟩 Yes | 🟨 Probably
|
|
36
|
+
RISC-V 64 [^4] | ⬜️ *N/A* | 🟩 Yes | ⬜️ *N/A* | 🟨 Probably | 🟨 Probably
|
|
37
|
+
|
|
38
|
+
[^1]: The following call conventions are supported: cdecl, stdcall, MS fastcall, thiscall.
|
|
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
|
+
[^3]: However, we don't provide prebuilt binaries for macOS on Apple M1.
|
|
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.
|
|
53
42
|
|
|
54
43
|
This is still in development, bugs are to be expected. More tests will come in the near future.
|
|
55
44
|
|
package/benchmark/CMakeLists.txt
CHANGED
|
@@ -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(
|
|
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)
|
package/benchmark/raylib_cc.cc
CHANGED
|
@@ -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 {
|
|
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 {
|
|
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
|
-
|
|
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
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
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
|
-
|
|
55
|
-
|
|
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);
|
|
Binary file
|
|
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/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "koffi",
|
|
3
|
-
"version": "1.1.
|
|
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
|
@@ -124,13 +124,12 @@ async function main() {
|
|
|
124
124
|
machine.started = false;
|
|
125
125
|
|
|
126
126
|
machine.qemu.accelerate = null;
|
|
127
|
-
if (accelerate
|
|
127
|
+
if (accelerate && (machine.qemu.binary == 'qemu-system-x86_64' ||
|
|
128
|
+
machine.qemu.binary == 'qemu-system-i386')) {
|
|
128
129
|
if (process.platform == 'linux') {
|
|
129
|
-
|
|
130
|
-
machine.qemu.accelerate = 'kvm';
|
|
130
|
+
machine.qemu.accelerate = 'kvm';
|
|
131
131
|
} else if (process.platform == 'win32') {
|
|
132
|
-
|
|
133
|
-
machine.qemu.accelerate = 'whpx';
|
|
132
|
+
machine.qemu.accelerate = 'whpx';
|
|
134
133
|
}
|
|
135
134
|
}
|
|
136
135
|
}
|
|
@@ -141,19 +140,23 @@ async function main() {
|
|
|
141
140
|
|
|
142
141
|
for (let pattern of patterns) {
|
|
143
142
|
let re = minimatch.makeRe(pattern);
|
|
143
|
+
let match = false;
|
|
144
144
|
|
|
145
145
|
for (let name in machines_map) {
|
|
146
146
|
let machine = machines_map[name];
|
|
147
147
|
|
|
148
|
-
if (name.match(re) || machine.name.match(re))
|
|
148
|
+
if (name.match(re) || machine.name.match(re)) {
|
|
149
149
|
machines.add(name);
|
|
150
|
+
match = true;
|
|
151
|
+
}
|
|
150
152
|
}
|
|
151
|
-
}
|
|
152
153
|
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
154
|
+
if (!match) {
|
|
155
|
+
console.log(`Pattern '${pattern}' does not match any machine`);
|
|
156
|
+
process.exit(1);
|
|
157
|
+
}
|
|
156
158
|
}
|
|
159
|
+
|
|
157
160
|
} else {
|
|
158
161
|
machines = new Set(Object.keys(machines_map));
|
|
159
162
|
|
|
@@ -300,6 +303,8 @@ async function pack() {
|
|
|
300
303
|
ignore.add(machine);
|
|
301
304
|
}
|
|
302
305
|
|
|
306
|
+
let ready = ignore.size;
|
|
307
|
+
|
|
303
308
|
success &= await start(false);
|
|
304
309
|
success &= await copy(machine => Object.values(machine.builds).map(build => build.directory));
|
|
305
310
|
|
|
@@ -402,6 +407,9 @@ async function pack() {
|
|
|
402
407
|
if (machines.some(machine => machine.started))
|
|
403
408
|
success &= await stop(false);
|
|
404
409
|
|
|
410
|
+
if (ignore.size > ready)
|
|
411
|
+
throw new Error('Some machines are missing, refusing to pack');
|
|
412
|
+
|
|
405
413
|
return success;
|
|
406
414
|
}
|
|
407
415
|
|
|
@@ -253,7 +253,7 @@
|
|
|
253
253
|
},
|
|
254
254
|
|
|
255
255
|
"info": {
|
|
256
|
-
"version":
|
|
256
|
+
"version": 2,
|
|
257
257
|
"platform": "freebsd",
|
|
258
258
|
"arch": "x64",
|
|
259
259
|
|
|
@@ -298,7 +298,7 @@
|
|
|
298
298
|
},
|
|
299
299
|
|
|
300
300
|
"info": {
|
|
301
|
-
"version":
|
|
301
|
+
"version": 2,
|
|
302
302
|
"platform": "freebsd",
|
|
303
303
|
"arch": "ia32",
|
|
304
304
|
|
|
@@ -343,7 +343,7 @@
|
|
|
343
343
|
},
|
|
344
344
|
|
|
345
345
|
"info": {
|
|
346
|
-
"version":
|
|
346
|
+
"version": 2,
|
|
347
347
|
"platform": "freebsd",
|
|
348
348
|
"arch": "arm64",
|
|
349
349
|
|
|
@@ -421,5 +421,140 @@
|
|
|
421
421
|
}
|
|
422
422
|
}
|
|
423
423
|
}
|
|
424
|
+
},
|
|
425
|
+
|
|
426
|
+
"openbsd_x64": {
|
|
427
|
+
"name": "OpenBSD x64",
|
|
428
|
+
|
|
429
|
+
"qemu": {
|
|
430
|
+
"binary": "qemu-system-x86_64",
|
|
431
|
+
"arguments": ["-m", "1G", "-smp", 2, "-hda", "disk.qcow2", "-netdev", "user,id=mynet,hostfwd=tcp::22210-:22", "-device", "e1000,netdev=mynet", "-vnc", "127.0.0.1:20"]
|
|
432
|
+
},
|
|
433
|
+
|
|
434
|
+
"info": {
|
|
435
|
+
"version": 1,
|
|
436
|
+
"platform": "openbsd",
|
|
437
|
+
"arch": "x64",
|
|
438
|
+
|
|
439
|
+
"ssh_port": 22210,
|
|
440
|
+
"vnc_port": 5920,
|
|
441
|
+
|
|
442
|
+
"username": "openbsd",
|
|
443
|
+
"password": "openbsd",
|
|
444
|
+
|
|
445
|
+
"shutdown": "sudo shutdown -p now"
|
|
446
|
+
},
|
|
447
|
+
|
|
448
|
+
"builds": {
|
|
449
|
+
"OpenBSD x64": {
|
|
450
|
+
"directory": "/home/openbsd/luigi",
|
|
451
|
+
"build": "node ../cnoke/cnoke.js"
|
|
452
|
+
}
|
|
453
|
+
},
|
|
454
|
+
|
|
455
|
+
"tests": {
|
|
456
|
+
"OpenBSD x64": {
|
|
457
|
+
"directory": "/home/openbsd/luigi",
|
|
458
|
+
"build": {
|
|
459
|
+
"Build": "node ../cnoke/cnoke.js -C test"
|
|
460
|
+
},
|
|
461
|
+
"commands": {
|
|
462
|
+
"Test Sync": "node test/sync.js",
|
|
463
|
+
"Test Async": "node test/async.js",
|
|
464
|
+
"Test Raylib": "xvfb-run node test/raylib.js",
|
|
465
|
+
"Test SQLite": "node test/sqlite.js"
|
|
466
|
+
}
|
|
467
|
+
}
|
|
468
|
+
}
|
|
469
|
+
},
|
|
470
|
+
|
|
471
|
+
"openbsd_i386": {
|
|
472
|
+
"name": "OpenBSD i386",
|
|
473
|
+
|
|
474
|
+
"qemu": {
|
|
475
|
+
"binary": "qemu-system-x86_64",
|
|
476
|
+
"arguments": ["-m", "1G", "-smp", 2, "-hda", "disk.qcow2", "-netdev", "user,id=mynet,hostfwd=tcp::22211-:22", "-device", "e1000,netdev=mynet", "-vnc", "127.0.0.1:21"]
|
|
477
|
+
},
|
|
478
|
+
|
|
479
|
+
"info": {
|
|
480
|
+
"version": 1,
|
|
481
|
+
"platform": "openbsd",
|
|
482
|
+
"arch": "ia32",
|
|
483
|
+
|
|
484
|
+
"ssh_port": 22211,
|
|
485
|
+
"vnc_port": 5921,
|
|
486
|
+
|
|
487
|
+
"username": "openbsd",
|
|
488
|
+
"password": "openbsd",
|
|
489
|
+
|
|
490
|
+
"shutdown": "sudo shutdown -p now"
|
|
491
|
+
},
|
|
492
|
+
|
|
493
|
+
"builds": {
|
|
494
|
+
"OpenBSD i386": {
|
|
495
|
+
"directory": "/home/openbsd/luigi",
|
|
496
|
+
"build": "node ../cnoke/cnoke.js"
|
|
497
|
+
}
|
|
498
|
+
},
|
|
499
|
+
|
|
500
|
+
"tests": {
|
|
501
|
+
"OpenBSD i386": {
|
|
502
|
+
"directory": "/home/openbsd/luigi",
|
|
503
|
+
"build": {
|
|
504
|
+
"Build": "node ../cnoke/cnoke.js -C test"
|
|
505
|
+
},
|
|
506
|
+
"commands": {
|
|
507
|
+
"Test Sync": "node test/sync.js",
|
|
508
|
+
"Test Async": "node test/async.js",
|
|
509
|
+
"Test Raylib": "xvfb-run node test/raylib.js",
|
|
510
|
+
"Test SQLite": "node test/sqlite.js"
|
|
511
|
+
}
|
|
512
|
+
}
|
|
513
|
+
}
|
|
514
|
+
},
|
|
515
|
+
|
|
516
|
+
"debian_riscv64": {
|
|
517
|
+
"name": "Debian RISC-V 64",
|
|
518
|
+
|
|
519
|
+
"qemu": {
|
|
520
|
+
"binary": "qemu-system-riscv64",
|
|
521
|
+
"arguments": ["-machine", "virt", "-cpu", "rv64", "-m", "1G", "-smp", 2, "-device", "virtio-blk-device,drive=hd", "-drive", "file=disk.qcow2,if=none,id=hd", "-device", "virtio-net-device,netdev=net", "-netdev", "user,id=net,hostfwd=tcp::22212-:22", "-bios", "fw_jump.elf", "-kernel", "uboot.elf", "-append", "root=LABEL=rootfs console=ttyS0", "-vnc", "127.0.0.1:22"]
|
|
522
|
+
},
|
|
523
|
+
|
|
524
|
+
"info": {
|
|
525
|
+
"version": 1,
|
|
526
|
+
"platform": "linux",
|
|
527
|
+
"arch": "riscv64",
|
|
528
|
+
|
|
529
|
+
"ssh_port": 22212,
|
|
530
|
+
"vnc_port": 5912,
|
|
531
|
+
|
|
532
|
+
"username": "debian",
|
|
533
|
+
"password": "debian",
|
|
534
|
+
|
|
535
|
+
"shutdown": "sudo poweroff"
|
|
536
|
+
},
|
|
537
|
+
|
|
538
|
+
"builds": {
|
|
539
|
+
"Linux RISC-V 64": {
|
|
540
|
+
"directory": "/home/debian/luigi",
|
|
541
|
+
"build": "node ../cnoke/cnoke.js"
|
|
542
|
+
}
|
|
543
|
+
},
|
|
544
|
+
|
|
545
|
+
"tests": {
|
|
546
|
+
"Linux RISC-V 64": {
|
|
547
|
+
"directory": "/home/debian/luigi",
|
|
548
|
+
"build": {
|
|
549
|
+
"Build": "node ../cnoke/cnoke.js -C test"
|
|
550
|
+
},
|
|
551
|
+
"commands": {
|
|
552
|
+
"Test Sync": "node test/sync.js",
|
|
553
|
+
"Test Async": "node test/async.js",
|
|
554
|
+
"Test Raylib": "xvfb-run node test/raylib.js",
|
|
555
|
+
"Test SQLite": "node test/sqlite.js"
|
|
556
|
+
}
|
|
557
|
+
}
|
|
558
|
+
}
|
|
424
559
|
}
|
|
425
560
|
}
|
|
@@ -22,20 +22,20 @@ ed05b84b7759ec945bb5422305a3a3c5b61d89e231844656ea31e07d89451a20 *qemu/debian_i3
|
|
|
22
22
|
292a61c415a99a9c63a9337f1e074bea6c5df594e16bc40ded76141963c67ea4 *qemu/debian_i386/install.sh
|
|
23
23
|
8dc1360e1c23ea21931f5eb94461d15fac6bcec00cf42bf1e590b7fb937e80c1 *qemu/debian_i386/initrd.img-5.10.0-12-686-pae
|
|
24
24
|
338602d969f953cd88c2df736b9f8f7ee53029d233c83c7398258ae5bcb4e286 *qemu/debian_i386/disk.qcow2
|
|
25
|
-
|
|
26
|
-
5daea533330eb8d2f8df946561680e09f8dacc467fbf03d28caa2115d94386b5 *qemu/freebsd_arm64/QEMU_EFI.img
|
|
27
|
-
a083e4e1f58f477e4a9e8ae30f75660e82275b88f77b5e2c7f5d6ee1deb43b41 *qemu/freebsd_arm64/varstore.img
|
|
25
|
+
e5d9d3e1e4a5c980fce4ef3aab5e29b9607b8e5da6e9fe58c3f396009e283cff *qemu/freebsd_arm64/disk.qcow2
|
|
28
26
|
53a4dc48317e1c9de4a088cd45ba39a1810f0bafad75c7f810e18d4e3eb340e3 *qemu/freebsd_arm64/install.sh
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
10f2bc603b171368cacda43485f8f72567af0a9a490b7e0fa0c14c983ae66f16 *qemu/freebsd_x64/xvfb-run.sh
|
|
35
|
-
6b86b273ff34fce19d6b804eff5a3f5747ada4eaa22f1d49c01e52ddb7875b4b *qemu/freebsd_i386/VERSION
|
|
27
|
+
5daea533330eb8d2f8df946561680e09f8dacc467fbf03d28caa2115d94386b5 *qemu/freebsd_arm64/QEMU_EFI.img
|
|
28
|
+
8ac20d46117a5a15761bf3070e365141b96ee3283250824f113029e106c62a50 *qemu/freebsd_arm64/varstore.img
|
|
29
|
+
d4735e3a265e16eee03f59718b9b5d03019c07d8b6c51f90da3a666eec13ab35 *qemu/freebsd_arm64/VERSION
|
|
30
|
+
73837b3991eae13f6c346955ea4aa419c8c168cadf70e0a38446db60cf47b0e9 *qemu/freebsd_arm64/xvfb-run.sh
|
|
31
|
+
fd0e51c43d7848564a81ddcb3eecf49103251bffcf25315ef87db01350ad4ac5 *qemu/freebsd_i386/disk.qcow2
|
|
36
32
|
bdeac2cca1d22d70c2d388a50709d5cba3069bbd4bd1bcb102955b0ee12ca3e9 *qemu/freebsd_i386/install.sh
|
|
37
|
-
|
|
38
|
-
|
|
33
|
+
d4735e3a265e16eee03f59718b9b5d03019c07d8b6c51f90da3a666eec13ab35 *qemu/freebsd_i386/VERSION
|
|
34
|
+
73837b3991eae13f6c346955ea4aa419c8c168cadf70e0a38446db60cf47b0e9 *qemu/freebsd_i386/xvfb-run.sh
|
|
35
|
+
41649d2f5959388e1c5d8ee89bb084795470a8b9e68d87861b4e95e4102b62cf *qemu/freebsd_x64/disk.qcow2
|
|
36
|
+
06eef544fe9c61d3905b0e588c306d1dedac7ee7d4c01df154ff6ed64e25ef77 *qemu/freebsd_x64/install.sh
|
|
37
|
+
d4735e3a265e16eee03f59718b9b5d03019c07d8b6c51f90da3a666eec13ab35 *qemu/freebsd_x64/VERSION
|
|
38
|
+
73837b3991eae13f6c346955ea4aa419c8c168cadf70e0a38446db60cf47b0e9 *qemu/freebsd_x64/xvfb-run.sh
|
|
39
39
|
16a4f09b3e70b97f5cfb1cf9b913d67d0ec45c4342d202cc9a2b2cfee852a8de *qemu/macos_x64/ESP.qcow2
|
|
40
40
|
5d2ac383371b408398accee7ec27c8c09ea5b74a0de0ceea6513388b15be5d1e *qemu/macos_x64/OVMF_VARS.fd
|
|
41
41
|
d79538ac489f1948b04b65f12c5618c28e4a5de0be062f5cf1d73e422a091a37 *qemu/macos_x64/install.txt
|
|
@@ -43,3 +43,18 @@ d79538ac489f1948b04b65f12c5618c28e4a5de0be062f5cf1d73e422a091a37 *qemu/macos_x64
|
|
|
43
43
|
5cc2d42949c7e4e763db0abeb88299972bafef991d87dbf744a5108ef9190f6f *qemu/macos_x64/OVMF_VARS-1024x768.fd
|
|
44
44
|
53c234e5e8472b6ac51c1ae1cab3fe06fad053beb8ebfd8977b010655bfdd3c3 *qemu/macos_x64/VERSION
|
|
45
45
|
2a247500e8ad9aa479994097ba5976bd881fde4de1516abd14491f3dba9fe060 *qemu/macos_x64/OVMF_CODE.fd
|
|
46
|
+
3a3395f70240d8e3137dfe06ef7dd76255dc597626e087d33abdcc65710f3dff *qemu/openbsd_x64/disk.qcow2
|
|
47
|
+
9dcdabfc12ad2ba2da1b9c3d95dc46311a12d6e3190f1bfd0c9b184ac1577c94 *qemu/openbsd_x64/install.sh
|
|
48
|
+
6b86b273ff34fce19d6b804eff5a3f5747ada4eaa22f1d49c01e52ddb7875b4b *qemu/openbsd_x64/VERSION
|
|
49
|
+
7b66bdf8b77fd1c6256ffdab623e37ce099797ad657dcd25af5df0486fadce37 *qemu/openbsd_x64/xvfb-run.sh
|
|
50
|
+
570bc6da16ca3b2b068963e7960e76fd23df3ada54398dfc6b6ddf97348ef5d7 *qemu/openbsd_i386/disk.qcow2
|
|
51
|
+
b82c940781ee678499851e1d2aa4868b7154a16ecc4f01c6c56940276c02748f *qemu/openbsd_i386/install.sh
|
|
52
|
+
6b86b273ff34fce19d6b804eff5a3f5747ada4eaa22f1d49c01e52ddb7875b4b *qemu/openbsd_i386/VERSION
|
|
53
|
+
7b66bdf8b77fd1c6256ffdab623e37ce099797ad657dcd25af5df0486fadce37 *qemu/openbsd_i386/xvfb-run.sh
|
|
54
|
+
64048432020bda960f397b5a138ea98aa6bbd42db02e8bb34ff3b9320763e36d *qemu/debian_riscv64/uboot.elf
|
|
55
|
+
0bdd93879f87c338d62422a65fdcba4d8c834848f2305f31b916539cb523e9e8 *qemu/debian_riscv64/readme.txt
|
|
56
|
+
76a5819cdacc8fe284370f441820620e911877122068a3b391fa064b7e9eb180 *qemu/debian_riscv64/initrd
|
|
57
|
+
6b86b273ff34fce19d6b804eff5a3f5747ada4eaa22f1d49c01e52ddb7875b4b *qemu/debian_riscv64/VERSION
|
|
58
|
+
7b6a36b0c2cdd85f3bbee4156de6c65a6f9b01b6bdf95eeb327b6182807ef111 *qemu/debian_riscv64/disk.qcow2
|
|
59
|
+
45755dd1fec10b7d5d67156bf806d3069a9285d18c5b16f06050e5115cc93f18 *qemu/debian_riscv64/kernel
|
|
60
|
+
16a1077672903239e2e4451e6898f9d813b369f9ceede30da8937a1361a050d7 *qemu/debian_riscv64/fw_jump.elf
|
package/src/abi_arm32.cc
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
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
|
|
|
14
|
-
#if defined(__arm__)
|
|
14
|
+
#if defined(__arm__) || (defined(__M_ARM) && !defined(_M_ARM64))
|
|
15
15
|
|
|
16
16
|
#include "vendor/libcc/libcc.hh"
|
|
17
17
|
#include "ffi.hh"
|
|
@@ -19,6 +19,8 @@
|
|
|
19
19
|
#include "util.hh"
|
|
20
20
|
|
|
21
21
|
#include <napi.h>
|
|
22
|
+
#include <signal.h>
|
|
23
|
+
#include <setjmp.h>
|
|
22
24
|
|
|
23
25
|
namespace RG {
|
|
24
26
|
|
|
@@ -37,11 +39,19 @@ extern "C" uint64_t ForwardCallXGG(const void *func, uint8_t *sp);
|
|
|
37
39
|
extern "C" float ForwardCallXF(const void *func, uint8_t *sp);
|
|
38
40
|
extern "C" HfaRet ForwardCallXDDDD(const void *func, uint8_t *sp);
|
|
39
41
|
|
|
42
|
+
static inline int IsHFA(const TypeInfo *type)
|
|
43
|
+
{
|
|
44
|
+
#ifdef __ARM_PCS_VFP
|
|
45
|
+
return IsHFA(type, 1, 4);
|
|
46
|
+
#else
|
|
47
|
+
return false;
|
|
48
|
+
#endif
|
|
49
|
+
}
|
|
50
|
+
|
|
40
51
|
bool AnalyseFunction(InstanceData *, FunctionInfo *func)
|
|
41
52
|
{
|
|
42
|
-
if (IsHFA(func->ret.type
|
|
43
|
-
func->ret.vec_count =
|
|
44
|
-
(func->ret.type->members[0].type->size / 4);
|
|
53
|
+
if (int hfa = IsHFA(func->ret.type); hfa) {
|
|
54
|
+
func->ret.vec_count = hfa;
|
|
45
55
|
} else if (func->ret.type->primitive != PrimitiveKind::Record ||
|
|
46
56
|
func->ret.type->size <= 4) {
|
|
47
57
|
func->ret.gpr_count = (func->ret.type->size > 4) ? 2 : 1;
|
|
@@ -84,13 +94,12 @@ bool AnalyseFunction(InstanceData *, FunctionInfo *func)
|
|
|
84
94
|
}
|
|
85
95
|
} break;
|
|
86
96
|
case PrimitiveKind::Record: {
|
|
87
|
-
|
|
88
|
-
int vec_count = (int)(param.type->members.len *
|
|
89
|
-
param.type->members[0].type->size / 4);
|
|
97
|
+
int hfa = IsHFA(param.type);
|
|
90
98
|
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
99
|
+
if (hfa) {
|
|
100
|
+
if (hfa <= vec_avail) {
|
|
101
|
+
param.vec_count = hfa;
|
|
102
|
+
vec_avail -= hfa;
|
|
94
103
|
} else {
|
|
95
104
|
vec_avail = 0;
|
|
96
105
|
started_stack = true;
|
|
@@ -112,8 +121,13 @@ bool AnalyseFunction(InstanceData *, FunctionInfo *func)
|
|
|
112
121
|
case PrimitiveKind::Array: { RG_UNREACHABLE(); } break;
|
|
113
122
|
case PrimitiveKind::Float32:
|
|
114
123
|
case PrimitiveKind::Float64: {
|
|
115
|
-
|
|
124
|
+
#ifdef __ARM_PCS_VFP
|
|
116
125
|
bool vfp = !param.variadic;
|
|
126
|
+
#else
|
|
127
|
+
bool vfp = false;
|
|
128
|
+
#endif
|
|
129
|
+
|
|
130
|
+
Size need = param.type->size / 4;
|
|
117
131
|
|
|
118
132
|
if (vfp) {
|
|
119
133
|
if (need <= vec_avail) {
|
|
@@ -374,8 +388,7 @@ bool CallData::Prepare(const Napi::CallbackInfo &info)
|
|
|
374
388
|
}
|
|
375
389
|
}
|
|
376
390
|
|
|
377
|
-
|
|
378
|
-
heap = MakeSpan(old_heap_mem.ptr, mem->heap.ptr - old_heap_mem.ptr);
|
|
391
|
+
sp = mem->stack.end();
|
|
379
392
|
|
|
380
393
|
return true;
|
|
381
394
|
}
|
|
@@ -384,8 +397,8 @@ void CallData::Execute()
|
|
|
384
397
|
{
|
|
385
398
|
#define PERFORM_CALL(Suffix) \
|
|
386
399
|
([&]() { \
|
|
387
|
-
auto ret = (func->forward_fp ? ForwardCallX ## Suffix(func->func,
|
|
388
|
-
: ForwardCall ## Suffix(func->func,
|
|
400
|
+
auto ret = (func->forward_fp ? ForwardCallX ## Suffix(func->func, sp) \
|
|
401
|
+
: ForwardCall ## Suffix(func->func, sp)); \
|
|
389
402
|
return ret; \
|
|
390
403
|
})()
|
|
391
404
|
|
|
@@ -407,7 +420,7 @@ void CallData::Execute()
|
|
|
407
420
|
case PrimitiveKind::Record: {
|
|
408
421
|
if (func->ret.vec_count) {
|
|
409
422
|
HfaRet ret = PERFORM_CALL(DDDD);
|
|
410
|
-
|
|
423
|
+
memcpy(&result.buf, &ret, RG_SIZE(ret));
|
|
411
424
|
} else {
|
|
412
425
|
result.u64 = PERFORM_CALL(GG);
|
|
413
426
|
}
|
package/src/abi_arm32_fwd.S
CHANGED
|
@@ -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
|
|