koffi 2.3.8 → 2.3.9

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 (72) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/LICENSE.txt +22 -165
  3. package/README.md +2 -2
  4. package/doc/index.rst +2 -2
  5. package/doc/static/custom.css +18 -10
  6. package/package.json +3 -3
  7. package/src/cnoke/LICENSE.txt +22 -165
  8. package/src/cnoke/assets/FindCNoke.cmake +18 -10
  9. package/src/cnoke/assets/win_delay_hook.c +18 -10
  10. package/src/cnoke/cnoke.js +18 -10
  11. package/src/cnoke/package.json +1 -1
  12. package/src/cnoke/src/builder.js +18 -10
  13. package/src/cnoke/src/index.js +18 -10
  14. package/src/cnoke/src/tools.js +18 -10
  15. package/src/core/libcc/libcc.cc +20 -12
  16. package/src/core/libcc/libcc.hh +20 -12
  17. package/src/koffi/CMakeLists.txt +27 -19
  18. package/src/koffi/build/{2.3.8 → 2.3.9}/koffi_linux_arm32hf/koffi.node +0 -0
  19. package/src/koffi/build/{2.3.8 → 2.3.9}/koffi_linux_arm64/koffi.node +0 -0
  20. package/src/koffi/build/{2.3.8 → 2.3.9}/koffi_linux_ia32/koffi.node +0 -0
  21. package/src/koffi/build/{2.3.8 → 2.3.9}/koffi_linux_riscv64hf64/koffi.node +0 -0
  22. package/src/koffi/build/{2.3.8 → 2.3.9}/koffi_openbsd_ia32/koffi.node +0 -0
  23. package/src/koffi/build/{2.3.8 → 2.3.9}/koffi_openbsd_x64/koffi.node +0 -0
  24. package/src/koffi/build/{2.3.8 → 2.3.9}/koffi_win32_arm64/koffi.node +0 -0
  25. package/src/koffi/build/{2.3.8 → 2.3.9}/koffi_win32_ia32/koffi.node +0 -0
  26. package/src/koffi/build/{2.3.8 → 2.3.9}/koffi_win32_x64/koffi.node +0 -0
  27. package/src/koffi/src/abi_arm32.cc +19 -11
  28. package/src/koffi/src/abi_arm32_asm.S +211 -0
  29. package/src/koffi/src/abi_arm64.cc +19 -11
  30. package/src/koffi/src/abi_arm64_asm.S +238 -0
  31. package/src/koffi/src/abi_arm64_asm.asm +207 -0
  32. package/src/koffi/src/abi_riscv64.cc +19 -11
  33. package/src/koffi/src/abi_riscv64_asm.S +239 -0
  34. package/src/koffi/src/abi_x64_sysv.cc +19 -11
  35. package/src/koffi/src/abi_x64_sysv_asm.S +272 -0
  36. package/src/koffi/src/abi_x64_win.cc +19 -11
  37. package/src/koffi/src/abi_x64_win_asm.asm +203 -0
  38. package/src/koffi/src/abi_x86.cc +19 -11
  39. package/src/koffi/src/abi_x86_asm.S +213 -0
  40. package/src/koffi/src/abi_x86_asm.asm +191 -0
  41. package/src/koffi/src/call.cc +18 -10
  42. package/src/koffi/src/call.hh +18 -10
  43. package/src/koffi/src/ffi.cc +18 -10
  44. package/src/koffi/src/ffi.hh +18 -10
  45. package/src/koffi/src/index.d.ts +22 -14
  46. package/src/koffi/src/index.js +18 -10
  47. package/src/koffi/src/parser.cc +18 -10
  48. package/src/koffi/src/parser.hh +18 -10
  49. package/src/koffi/src/{abi_arm64_fwd.asm → trampolines/armasm.inc} +18 -193
  50. package/src/koffi/src/{abi_arm64_fwd.S → trampolines/gnu.inc} +18 -226
  51. package/src/koffi/src/{abi_x86_fwd.asm → trampolines/masm32.inc} +1042 -1203
  52. package/src/koffi/src/{abi_x64_win_fwd.asm → trampolines/masm64.inc} +1042 -1215
  53. package/src/koffi/src/{abi_trampolines.inc → trampolines/prototypes.inc} +18 -10
  54. package/src/koffi/src/util.cc +18 -10
  55. package/src/koffi/src/util.hh +18 -10
  56. package/src/koffi/src/win32.hh +18 -10
  57. package/src/koffi/src/abi_arm32_fwd.S +0 -6344
  58. package/src/koffi/src/abi_riscv64_fwd.S +0 -6375
  59. package/src/koffi/src/abi_x64_sysv_fwd.S +0 -6410
  60. package/src/koffi/src/abi_x86_fwd.S +0 -6346
  61. /package/src/koffi/build/{2.3.8 → 2.3.9}/koffi_darwin_arm64/koffi.node +0 -0
  62. /package/src/koffi/build/{2.3.8 → 2.3.9}/koffi_darwin_x64/koffi.node +0 -0
  63. /package/src/koffi/build/{2.3.8 → 2.3.9}/koffi_freebsd_arm64/koffi.node +0 -0
  64. /package/src/koffi/build/{2.3.8 → 2.3.9}/koffi_freebsd_ia32/koffi.node +0 -0
  65. /package/src/koffi/build/{2.3.8 → 2.3.9}/koffi_freebsd_x64/koffi.node +0 -0
  66. /package/src/koffi/build/{2.3.8 → 2.3.9}/koffi_linux_x64/koffi.node +0 -0
  67. /package/src/koffi/build/{2.3.8 → 2.3.9}/koffi_win32_arm64/koffi.exp +0 -0
  68. /package/src/koffi/build/{2.3.8 → 2.3.9}/koffi_win32_arm64/koffi.lib +0 -0
  69. /package/src/koffi/build/{2.3.8 → 2.3.9}/koffi_win32_ia32/koffi.exp +0 -0
  70. /package/src/koffi/build/{2.3.8 → 2.3.9}/koffi_win32_ia32/koffi.lib +0 -0
  71. /package/src/koffi/build/{2.3.8 → 2.3.9}/koffi_win32_x64/koffi.exp +0 -0
  72. /package/src/koffi/build/{2.3.8 → 2.3.9}/koffi_win32_x64/koffi.lib +0 -0
@@ -1,231 +1,23 @@
1
- # This program is free software: you can redistribute it and/or modify
2
- # it under the terms of the GNU Lesser 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.
1
+ # Copyright 2023 Niels Martignène <niels.martignene@protonmail.com>
5
2
  #
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 Lesser General Public License for more details.
3
+ # Permission is hereby granted, free of charge, to any person obtaining a copy of
4
+ # this software and associated documentation files (the “Software”), to deal in
5
+ # the Software without restriction, including without limitation the rights to use,
6
+ # copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
7
+ # Software, and to permit persons to whom the Software is furnished to do so,
8
+ # subject to the following conditions:
10
9
  #
11
- # You should have received a copy of the GNU Lesser General Public License
12
- # along with this program. If not, see https://www.gnu.org/licenses/.
13
-
14
- #ifdef __APPLE__
15
- #define SYMBOL(Symbol) _ ## Symbol
16
- #else
17
- #define SYMBOL(Symbol) Symbol
18
- #endif
19
-
20
- # Forward
21
- # ----------------------------
22
-
23
- #ifdef __APPLE__
24
- # Fix "arm64 function not 4-byte aligned" linker warnings
25
- .p2align 2
26
- #endif
27
-
28
- # These three are the same, but they differ (in the C side) by their return type.
29
- # Unlike the three next functions, these ones don't forward XMM argument registers.
30
- .global SYMBOL(ForwardCallGG)
31
- .global SYMBOL(ForwardCallF)
32
- .global SYMBOL(ForwardCallDDDD)
33
-
34
- # The X variants are slightly slower, and are used when XMM arguments must be forwarded.
35
- .global SYMBOL(ForwardCallXGG)
36
- .global SYMBOL(ForwardCallXF)
37
- .global SYMBOL(ForwardCallXDDDD)
38
-
39
- # Copy function pointer to r9, in order to save it through argument forwarding.
40
- # Also make a copy of the SP to CallData::old_sp because the callback system might need it.
41
- # Save RSP in r29 (non-volatile), and use carefully assembled stack provided by caller.
42
- .macro prologue
43
- .cfi_startproc
44
- hint #34
45
- stp x29, x30, [sp, -16]!
46
- .cfi_def_cfa sp, 16
47
- .cfi_offset 29, 16
48
- .cfi_offset 30, 8
49
- mov x29, sp
50
- .cfi_def_cfa x29, 16
51
- str x29, [x2, 0]
52
- mov x9, x0
53
- add sp, x1, #136
54
- .endm
55
-
56
- # Call native function.
57
- # Once done, restore normal stack pointer and return.
58
- # The return value is passed untouched through r0, r1, v0 and/or v1.
59
- .macro epilogue
60
- blr x9
61
- mov sp, x29
62
- .cfi_def_cfa sp, 16
63
- ldp x29, x30, [sp], 16
64
- .cfi_def_cfa sp, 0
65
- .cfi_restore 30
66
- .cfi_restore 29
67
- ret
68
- .cfi_endproc
69
- .endm
70
-
71
- # Prepare general purpose argument registers from array passed by caller.
72
- .macro forward_gpr
73
- ldr x8, [x1, 64]
74
- ldp x6, x7, [x1, 48]
75
- ldp x4, x5, [x1, 32]
76
- ldp x2, x3, [x1, 16]
77
- ldp x0, x1, [x1, 0]
78
- .endm
79
-
80
- # Prepare vector argument registers from array passed by caller.
81
- .macro forward_vec
82
- ldp d6, d7, [x1, 120]
83
- ldp d4, d5, [x1, 104]
84
- ldp d2, d3, [x1, 88]
85
- ldp d0, d1, [x1, 72]
86
- .endm
87
-
88
- SYMBOL(ForwardCallGG):
89
- prologue
90
- forward_gpr
91
- epilogue
92
-
93
- SYMBOL(ForwardCallF):
94
- prologue
95
- forward_gpr
96
- epilogue
97
-
98
- SYMBOL(ForwardCallDDDD):
99
- prologue
100
- forward_gpr
101
- epilogue
102
-
103
- SYMBOL(ForwardCallXGG):
104
- prologue
105
- forward_vec
106
- forward_gpr
107
- epilogue
108
-
109
- SYMBOL(ForwardCallXF):
110
- prologue
111
- forward_vec
112
- forward_gpr
113
- epilogue
114
-
115
- SYMBOL(ForwardCallXDDDD):
116
- prologue
117
- forward_vec
118
- forward_gpr
119
- epilogue
120
-
121
- # Callbacks
122
- # ----------------------------
123
-
124
- .global SYMBOL(RelayCallback)
125
- .global SYMBOL(CallSwitchStack)
126
-
127
- # First, make a copy of the GPR argument registers (x0 to x7).
128
- # Then call the C function RelayCallback with the following arguments:
129
- # static trampoline ID, a pointer to the saved GPR array, a pointer to the stack
130
- # arguments of this call, and a pointer to a struct that will contain the result registers.
131
- # After the call, simply load these registers from the output struct.
132
- .macro trampoline id
133
- .cfi_startproc
134
- hint #34
135
- stp x29, x30, [sp, -16]!
136
- .cfi_def_cfa sp, 16
137
- .cfi_offset 29, 16
138
- .cfi_offset 30, 8
139
- sub sp, sp, #192
140
- .cfi_def_cfa sp, 208
141
- stp x0, x1, [sp, 0]
142
- stp x2, x3, [sp, 16]
143
- stp x4, x5, [sp, 32]
144
- stp x6, x7, [sp, 48]
145
- str x8, [sp, 64]
146
- mov x0, \id
147
- mov x1, sp
148
- add x2, sp, #208
149
- add x3, sp, #136
150
- bl SYMBOL(RelayCallback)
151
- ldp x0, x1, [sp, 136]
152
- add sp, sp, #192
153
- .cfi_def_cfa sp, 16
154
- ldp x29, x30, [sp], 16
155
- .cfi_def_cfa sp, 0
156
- .cfi_restore 30
157
- .cfi_restore 29
158
- ret
159
- .cfi_endproc
160
- .endm
161
-
162
- # Same thing, but also forwards the floating-point argument registers and loads them at the end.
163
- .macro trampoline_vec id
164
- .cfi_startproc
165
- hint #34
166
- stp x29, x30, [sp, -16]!
167
- .cfi_def_cfa sp, 16
168
- .cfi_offset 29, 16
169
- .cfi_offset 30, 8
170
- sub sp, sp, #192
171
- .cfi_def_cfa sp, 208
172
- stp x0, x1, [sp, 0]
173
- stp x2, x3, [sp, 16]
174
- stp x4, x5, [sp, 32]
175
- stp x6, x7, [sp, 48]
176
- str x8, [sp, 64]
177
- stp d0, d1, [sp, 72]
178
- stp d2, d3, [sp, 88]
179
- stp d4, d5, [sp, 104]
180
- stp d6, d7, [sp, 120]
181
- mov x0, \id
182
- mov x1, sp
183
- add x2, sp, #208
184
- add x3, sp, #136
185
- bl SYMBOL(RelayCallback)
186
- ldp x0, x1, [sp, 136]
187
- ldp d0, d1, [sp, 152]
188
- ldp d2, d3, [sp, 168]
189
- add sp, sp, #192
190
- .cfi_def_cfa sp, 16
191
- ldp x29, x30, [sp], 16
192
- .cfi_def_cfa sp, 0
193
- .cfi_restore 30
194
- .cfi_restore 29
195
- ret
196
- .cfi_endproc
197
- .endm
198
-
199
- # When a callback is relayed, Koffi will call into Node.js and V8 to execute Javascript.
200
- # The problem is that we're still running on the separate Koffi stack, and V8 will
201
- # probably misdetect this as a "stack overflow". We have to restore the old
202
- # stack pointer, call Node.js/V8 and go back to ours.
203
- # The first three parameters (x0, x1, x2) are passed through untouched.
204
- SYMBOL(CallSwitchStack):
205
- .cfi_startproc
206
- hint #34
207
- stp x29, x30, [sp, -16]!
208
- .cfi_def_cfa sp, 16
209
- .cfi_offset 29, 16
210
- .cfi_offset 30, 8
211
- mov x29, sp
212
- ldr x9, [x4, 0]
213
- sub x9, sp, x9
214
- and x9, x9, #-16
215
- str x9, [x4, 8]
216
- mov sp, x3
217
- blr x5
218
- mov sp, x29
219
- .cfi_def_cfa sp, 16
220
- ldp x29, x30, [sp], 16
221
- .cfi_def_cfa sp, 0
222
- .cfi_restore 30
223
- .cfi_restore 29
224
- ret
225
- .cfi_endproc
226
-
227
- # Trampolines
228
- # ----------------------------
10
+ # The above copyright notice and this permission notice shall be included in all
11
+ # copies or substantial portions of the Software.
12
+ #
13
+ # THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND,
14
+ # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
15
+ # OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
16
+ # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
17
+ # HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
18
+ # WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19
+ # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20
+ # OTHER DEALINGS IN THE SOFTWARE.
229
21
 
230
22
  .global SYMBOL(Trampoline0)
231
23
  .global SYMBOL(Trampoline1)