koffi 1.1.3 → 1.1.4
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 +3 -0
- package/README.md +13 -14
- package/build/qemu/1.1.4/koffi_darwin_x64.tar.gz +0 -0
- package/build/qemu/1.1.4/koffi_freebsd_arm64.tar.gz +0 -0
- package/build/qemu/1.1.4/koffi_freebsd_ia32.tar.gz +0 -0
- package/build/qemu/1.1.4/koffi_freebsd_x64.tar.gz +0 -0
- package/build/qemu/1.1.4/koffi_linux_arm.tar.gz +0 -0
- package/build/qemu/1.1.4/koffi_linux_arm64.tar.gz +0 -0
- package/build/qemu/1.1.4/koffi_linux_ia32.tar.gz +0 -0
- package/build/qemu/1.1.4/koffi_linux_riscv64.tar.gz +0 -0
- package/build/qemu/1.1.4/koffi_linux_x64.tar.gz +0 -0
- package/build/qemu/1.1.4/koffi_openbsd_ia32.tar.gz +0 -0
- package/build/qemu/1.1.4/koffi_openbsd_x64.tar.gz +0 -0
- package/build/qemu/1.1.4/koffi_win32_ia32.tar.gz +0 -0
- package/build/qemu/1.1.4/koffi_win32_x64.tar.gz +0 -0
- package/package.json +1 -1
- package/qemu/qemu.js +13 -10
- package/qemu/registry/machines.json +91 -0
- package/qemu/registry/sha256sum.txt +11 -0
- package/src/abi_arm32.cc +23 -49
- package/src/abi_arm64.cc +15 -16
- package/src/abi_riscv64.cc +468 -0
- package/src/abi_riscv64_fwd.S +129 -0
- package/src/abi_x64_sysv.cc +8 -9
- package/src/abi_x64_win.cc +4 -7
- package/src/abi_x86.cc +3 -4
- package/src/call.cc +6 -18
- package/src/call.hh +13 -23
- package/src/ffi.cc +24 -3
- package/src/ffi.hh +6 -3
- package/src/parser.cc +2 -2
- package/src/util.cc +26 -57
- package/src/util.hh +17 -1
- package/test/misc.c +34 -0
- package/vendor/_patches/glfw_001_fix_openbsd_xlib_soname.patch +145 -0
- package/vendor/libcc/libcc.hh +4 -1
- 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.3/koffi_darwin_x64.tar.gz +0 -0
- package/build/qemu/1.1.3/koffi_freebsd_arm64.tar.gz +0 -0
- package/build/qemu/1.1.3/koffi_freebsd_ia32.tar.gz +0 -0
- package/build/qemu/1.1.3/koffi_freebsd_x64.tar.gz +0 -0
- package/build/qemu/1.1.3/koffi_linux_arm.tar.gz +0 -0
- package/build/qemu/1.1.3/koffi_linux_arm64.tar.gz +0 -0
- package/build/qemu/1.1.3/koffi_linux_ia32.tar.gz +0 -0
- package/build/qemu/1.1.3/koffi_linux_x64.tar.gz +0 -0
- package/build/qemu/1.1.3/koffi_openbsd_x64.tar.gz +0 -0
- package/build/qemu/1.1.3/koffi_win32_ia32.tar.gz +0 -0
- package/build/qemu/1.1.3/koffi_win32_x64.tar.gz +0 -0
package/src/call.cc
CHANGED
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
namespace RG {
|
|
22
22
|
|
|
23
23
|
CallData::CallData(Napi::Env env, InstanceData *instance, const FunctionInfo *func, InstanceMemory *mem)
|
|
24
|
-
: env(env), instance(instance), func(func),
|
|
24
|
+
: env(env), instance(instance), func(func),
|
|
25
25
|
mem(mem), old_stack_mem(mem->stack), old_heap_mem(mem->heap)
|
|
26
26
|
{
|
|
27
27
|
mem->depth++;
|
|
@@ -565,13 +565,11 @@ void CallData::PopObject(Napi::Object obj, const uint8_t *src, const TypeInfo *t
|
|
|
565
565
|
obj.Set(member.name, value);
|
|
566
566
|
} break;
|
|
567
567
|
case PrimitiveKind::Float32: {
|
|
568
|
-
float f;
|
|
569
|
-
memcpy(&f, src, 4);
|
|
568
|
+
float f = *(float *)src;
|
|
570
569
|
obj.Set(member.name, Napi::Number::New(env, (double)f));
|
|
571
570
|
} break;
|
|
572
571
|
case PrimitiveKind::Float64: {
|
|
573
|
-
double d;
|
|
574
|
-
memcpy(&d, src, 8);
|
|
572
|
+
double d = *(double *)src;
|
|
575
573
|
obj.Set(member.name, Napi::Number::New(env, d));
|
|
576
574
|
} break;
|
|
577
575
|
}
|
|
@@ -762,19 +760,6 @@ Napi::Value CallData::PopArray(const uint8_t *src, const TypeInfo *type, int16_t
|
|
|
762
760
|
RG_UNREACHABLE();
|
|
763
761
|
}
|
|
764
762
|
|
|
765
|
-
Napi::Value CallData::Run(const Napi::CallbackInfo &info)
|
|
766
|
-
{
|
|
767
|
-
if (!RG_UNLIKELY(Prepare(info)))
|
|
768
|
-
return env.Null();
|
|
769
|
-
|
|
770
|
-
if (debug) {
|
|
771
|
-
DumpDebug();
|
|
772
|
-
}
|
|
773
|
-
Execute();
|
|
774
|
-
|
|
775
|
-
return Complete();
|
|
776
|
-
}
|
|
777
|
-
|
|
778
763
|
static void DumpMemory(const char *type, Span<const uint8_t> bytes)
|
|
779
764
|
{
|
|
780
765
|
if (bytes.len) {
|
|
@@ -805,6 +790,9 @@ void CallData::DumpDebug() const
|
|
|
805
790
|
}
|
|
806
791
|
PrintLn(stderr, "Return: %1 (%2)", func->ret.type->name, FmtMemSize(func->ret.type->size));
|
|
807
792
|
|
|
793
|
+
Span<const uint8_t> stack = MakeSpan(mem->stack.end(), old_stack_mem.end() - mem->stack.end());
|
|
794
|
+
Span<const uint8_t> heap = MakeSpan(old_heap_mem.ptr, mem->heap.ptr - old_heap_mem.ptr);
|
|
795
|
+
|
|
808
796
|
DumpMemory("Stack", stack);
|
|
809
797
|
DumpMemory("Heap", heap);
|
|
810
798
|
}
|
package/src/call.hh
CHANGED
|
@@ -34,16 +34,12 @@ class CallData {
|
|
|
34
34
|
InstanceData *instance;
|
|
35
35
|
const FunctionInfo *func;
|
|
36
36
|
|
|
37
|
-
bool debug;
|
|
38
|
-
|
|
39
37
|
InstanceMemory *mem;
|
|
40
38
|
Span<uint8_t> old_stack_mem;
|
|
41
39
|
Span<uint8_t> old_heap_mem;
|
|
42
40
|
|
|
43
41
|
LocalArray<OutObject, MaxOutParameters> out_objects;
|
|
44
|
-
|
|
45
|
-
Span<uint8_t> heap;
|
|
46
|
-
Span<uint8_t> stack;
|
|
42
|
+
uint8_t *sp;
|
|
47
43
|
|
|
48
44
|
union {
|
|
49
45
|
uint32_t u32;
|
|
@@ -65,15 +61,13 @@ public:
|
|
|
65
61
|
void Execute();
|
|
66
62
|
Napi::Value Complete();
|
|
67
63
|
|
|
68
|
-
Napi::Value Run(const Napi::CallbackInfo &info);
|
|
69
|
-
|
|
70
64
|
void DumpDebug() const;
|
|
71
65
|
|
|
72
66
|
private:
|
|
73
67
|
template <typename T = void>
|
|
74
|
-
bool AllocStack(Size size, Size align, T **out_ptr
|
|
68
|
+
bool AllocStack(Size size, Size align, T **out_ptr);
|
|
75
69
|
template <typename T = void>
|
|
76
|
-
bool AllocHeap(Size size, Size align, T **out_ptr
|
|
70
|
+
bool AllocHeap(Size size, Size align, T **out_ptr);
|
|
77
71
|
|
|
78
72
|
const char *PushString(const Napi::Value &value);
|
|
79
73
|
const char16_t *PushString16(const Napi::Value &value);
|
|
@@ -86,7 +80,7 @@ private:
|
|
|
86
80
|
};
|
|
87
81
|
|
|
88
82
|
template <typename T>
|
|
89
|
-
bool CallData::AllocStack(Size size, Size align, T **out_ptr)
|
|
83
|
+
inline bool CallData::AllocStack(Size size, Size align, T **out_ptr)
|
|
90
84
|
{
|
|
91
85
|
uint8_t *ptr = AlignDown(mem->stack.end() - size, align);
|
|
92
86
|
Size delta = mem->stack.end() - ptr;
|
|
@@ -96,20 +90,18 @@ bool CallData::AllocStack(Size size, Size align, T **out_ptr)
|
|
|
96
90
|
return false;
|
|
97
91
|
}
|
|
98
92
|
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
93
|
+
#ifdef RG_DEBUG
|
|
94
|
+
memset(ptr, 0, delta);
|
|
95
|
+
#endif
|
|
102
96
|
|
|
103
97
|
mem->stack.len -= delta;
|
|
104
98
|
|
|
105
|
-
|
|
106
|
-
*out_ptr = (T *)ptr;
|
|
107
|
-
}
|
|
99
|
+
*out_ptr = (T *)ptr;
|
|
108
100
|
return true;
|
|
109
101
|
}
|
|
110
102
|
|
|
111
103
|
template <typename T>
|
|
112
|
-
bool CallData::AllocHeap(Size size, Size align, T **out_ptr)
|
|
104
|
+
inline bool CallData::AllocHeap(Size size, Size align, T **out_ptr)
|
|
113
105
|
{
|
|
114
106
|
uint8_t *ptr = AlignUp(mem->heap.ptr, align);
|
|
115
107
|
Size delta = size + (ptr - mem->heap.ptr);
|
|
@@ -119,16 +111,14 @@ bool CallData::AllocHeap(Size size, Size align, T **out_ptr)
|
|
|
119
111
|
return false;
|
|
120
112
|
}
|
|
121
113
|
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
114
|
+
#ifdef RG_DEBUG
|
|
115
|
+
memset(mem->heap.ptr, 0, (size_t)delta);
|
|
116
|
+
#endif
|
|
125
117
|
|
|
126
118
|
mem->heap.ptr += delta;
|
|
127
119
|
mem->heap.len -= delta;
|
|
128
120
|
|
|
129
|
-
|
|
130
|
-
*out_ptr = (T *)ptr;
|
|
131
|
-
}
|
|
121
|
+
*out_ptr = (T *)ptr;
|
|
132
122
|
return true;
|
|
133
123
|
}
|
|
134
124
|
|
package/src/ffi.cc
CHANGED
|
@@ -106,6 +106,11 @@ static Napi::Value CreateStructType(const Napi::CallbackInfo &info, bool pad)
|
|
|
106
106
|
type->members.Append(member);
|
|
107
107
|
}
|
|
108
108
|
|
|
109
|
+
if (!type->size) {
|
|
110
|
+
ThrowError<Napi::TypeError>(env, "Empty struct '%1' is not allowed in C", type->name);
|
|
111
|
+
return env.Null();
|
|
112
|
+
}
|
|
113
|
+
|
|
109
114
|
type->size = (int16_t)AlignLen(type->size, type->align);
|
|
110
115
|
|
|
111
116
|
// If the insert succeeds, we cannot fail anymore
|
|
@@ -296,7 +301,7 @@ static Napi::Value CreateArrayType(const Napi::CallbackInfo &info)
|
|
|
296
301
|
if (!ref)
|
|
297
302
|
return env.Null();
|
|
298
303
|
if (len <= 0) {
|
|
299
|
-
ThrowError<Napi::TypeError>(env, "Array length must be non-zero
|
|
304
|
+
ThrowError<Napi::TypeError>(env, "Array length must be positive and non-zero");
|
|
300
305
|
return env.Null();
|
|
301
306
|
}
|
|
302
307
|
if (len > INT16_MAX / ref->size) {
|
|
@@ -427,7 +432,15 @@ static Napi::Value TranslateNormalCall(const Napi::CallbackInfo &info)
|
|
|
427
432
|
InstanceMemory *mem = instance->memories[0];
|
|
428
433
|
CallData call(env, instance, func, mem);
|
|
429
434
|
|
|
430
|
-
|
|
435
|
+
if (!RG_UNLIKELY(call.Prepare(info)))
|
|
436
|
+
return env.Null();
|
|
437
|
+
|
|
438
|
+
if (instance->debug) {
|
|
439
|
+
call.DumpDebug();
|
|
440
|
+
}
|
|
441
|
+
call.Execute();
|
|
442
|
+
|
|
443
|
+
return call.Complete();
|
|
431
444
|
}
|
|
432
445
|
|
|
433
446
|
static Napi::Value TranslateVariadicCall(const Napi::CallbackInfo &info)
|
|
@@ -487,7 +500,15 @@ static Napi::Value TranslateVariadicCall(const Napi::CallbackInfo &info)
|
|
|
487
500
|
InstanceMemory *mem = instance->memories[0];
|
|
488
501
|
CallData call(env, instance, &func, mem);
|
|
489
502
|
|
|
490
|
-
|
|
503
|
+
if (!RG_UNLIKELY(call.Prepare(info)))
|
|
504
|
+
return env.Null();
|
|
505
|
+
|
|
506
|
+
if (instance->debug) {
|
|
507
|
+
call.DumpDebug();
|
|
508
|
+
}
|
|
509
|
+
call.Execute();
|
|
510
|
+
|
|
511
|
+
return call.Complete();
|
|
491
512
|
}
|
|
492
513
|
|
|
493
514
|
class AsyncCall: public Napi::AsyncWorker {
|
package/src/ffi.hh
CHANGED
|
@@ -141,6 +141,11 @@ struct ParameterInfo {
|
|
|
141
141
|
#elif defined(__i386__) || defined(_M_IX86)
|
|
142
142
|
bool trivial; // Only matters for return value
|
|
143
143
|
bool fast;
|
|
144
|
+
#elif __riscv_xlen == 64
|
|
145
|
+
bool use_memory;
|
|
146
|
+
int8_t gpr_count;
|
|
147
|
+
int8_t vec_count;
|
|
148
|
+
bool gpr_first; // Only for structs
|
|
144
149
|
#endif
|
|
145
150
|
};
|
|
146
151
|
|
|
@@ -162,7 +167,7 @@ struct FunctionInfo {
|
|
|
162
167
|
// ABI-specific part
|
|
163
168
|
|
|
164
169
|
Size args_size;
|
|
165
|
-
#if defined(__arm__) || defined(__aarch64__) || defined(__x86_64__) || defined(_WIN64)
|
|
170
|
+
#if defined(__arm__) || defined(__aarch64__) || defined(__x86_64__) || defined(_WIN64) || defined(__riscv)
|
|
166
171
|
bool forward_fp;
|
|
167
172
|
#endif
|
|
168
173
|
#if defined(__i386__) || defined(_M_IX86)
|
|
@@ -176,8 +181,6 @@ struct FunctionInfo {
|
|
|
176
181
|
};
|
|
177
182
|
|
|
178
183
|
struct InstanceMemory {
|
|
179
|
-
LinkedAllocator mem_alloc;
|
|
180
|
-
|
|
181
184
|
Span<uint8_t> stack;
|
|
182
185
|
Span<uint8_t> heap;
|
|
183
186
|
|
package/src/parser.cc
CHANGED
|
@@ -159,9 +159,9 @@ const TypeInfo *PrototypeParser::ParseType()
|
|
|
159
159
|
}
|
|
160
160
|
if (offset == start) {
|
|
161
161
|
if (offset < tokens.len) {
|
|
162
|
-
MarkError("Unexpected token '%1', expected
|
|
162
|
+
MarkError("Unexpected token '%1', expected type", tokens[offset]);
|
|
163
163
|
} else {
|
|
164
|
-
MarkError("Unexpected end of prototype, expected
|
|
164
|
+
MarkError("Unexpected end of prototype, expected type");
|
|
165
165
|
}
|
|
166
166
|
return instance->types_map.FindValue("void", nullptr);
|
|
167
167
|
}
|
package/src/util.cc
CHANGED
|
@@ -126,76 +126,45 @@ bool CheckValueTag(const InstanceData *instance, Napi::Value value, const void *
|
|
|
126
126
|
return match;
|
|
127
127
|
}
|
|
128
128
|
|
|
129
|
-
|
|
130
|
-
uint32_t primitives;
|
|
131
|
-
Size count;
|
|
132
|
-
|
|
133
|
-
public:
|
|
134
|
-
bool Analyse(const TypeInfo *type, int min, int max);
|
|
135
|
-
|
|
136
|
-
private:
|
|
137
|
-
void AnalyseStruct(const TypeInfo *type);
|
|
138
|
-
void AnalyseArray(const TypeInfo *type);
|
|
139
|
-
};
|
|
140
|
-
|
|
141
|
-
bool HfaAnalyser::Analyse(const TypeInfo *type, int min, int max)
|
|
129
|
+
static int AnalyseFlatRec(const TypeInfo *type, int offset, int count, FunctionRef<void(const TypeInfo *type, int offset, int count)> func)
|
|
142
130
|
{
|
|
143
|
-
primitives = 0;
|
|
144
|
-
count = 0;
|
|
145
|
-
|
|
146
131
|
if (type->primitive == PrimitiveKind::Record) {
|
|
147
|
-
|
|
132
|
+
for (int i = 0; i < count; i++) {
|
|
133
|
+
for (const RecordMember &member: type->members) {
|
|
134
|
+
offset = AnalyseFlatRec(member.type, offset, 1, func);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
148
137
|
} else if (type->primitive == PrimitiveKind::Array) {
|
|
149
|
-
|
|
138
|
+
count *= type->size / type->ref->size;
|
|
139
|
+
offset = AnalyseFlatRec(type->ref, offset, count, func);
|
|
150
140
|
} else {
|
|
151
|
-
|
|
141
|
+
func(type, offset, count);
|
|
142
|
+
offset += count;
|
|
152
143
|
}
|
|
153
144
|
|
|
154
|
-
|
|
155
|
-
return hfa;
|
|
145
|
+
return offset;
|
|
156
146
|
}
|
|
157
147
|
|
|
158
|
-
|
|
148
|
+
int AnalyseFlat(const TypeInfo *type, FunctionRef<void(const TypeInfo *type, int offset, int count)> func)
|
|
159
149
|
{
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
for (const RecordMember &member: type->members) {
|
|
163
|
-
if (member.type->primitive == PrimitiveKind::Record) {
|
|
164
|
-
AnalyseStruct(member.type);
|
|
165
|
-
} else if (member.type->primitive == PrimitiveKind::Array) {
|
|
166
|
-
AnalyseArray(member.type);
|
|
167
|
-
} else if (member.type->primitive == PrimitiveKind::Float32 ||
|
|
168
|
-
member.type->primitive == PrimitiveKind::Float64) {
|
|
169
|
-
primitives |= 1u << (int)member.type->primitive;
|
|
170
|
-
count++;
|
|
171
|
-
} else {
|
|
172
|
-
primitives = UINT_MAX;
|
|
173
|
-
return;
|
|
174
|
-
}
|
|
175
|
-
}
|
|
150
|
+
return AnalyseFlatRec(type, 0, 1, func);
|
|
176
151
|
}
|
|
177
152
|
|
|
178
|
-
|
|
153
|
+
int IsHFA(const TypeInfo *type, int min, int max)
|
|
179
154
|
{
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
if (type->ref->primitive == PrimitiveKind::Record) {
|
|
183
|
-
AnalyseStruct(type->ref);
|
|
184
|
-
} else if (type->ref->primitive == PrimitiveKind::Array) {
|
|
185
|
-
AnalyseArray(type->ref);
|
|
186
|
-
} else if (type->ref->primitive == PrimitiveKind::Float32 ||
|
|
187
|
-
type->ref->primitive == PrimitiveKind::Float64) {
|
|
188
|
-
primitives |= 1u << (int)type->ref->primitive;
|
|
189
|
-
count += type->size / type->ref->size;;
|
|
190
|
-
} else {
|
|
191
|
-
primitives = UINT_MAX;
|
|
192
|
-
}
|
|
193
|
-
}
|
|
155
|
+
uint32_t primitives = 0;
|
|
156
|
+
int count = 0;
|
|
194
157
|
|
|
195
|
-
|
|
196
|
-
{
|
|
197
|
-
|
|
198
|
-
|
|
158
|
+
count = AnalyseFlat(type, [&](const TypeInfo *type, int, int) {
|
|
159
|
+
if (IsFloat(type)) {
|
|
160
|
+
primitives |= 1u << (int)type->primitive;
|
|
161
|
+
} else {
|
|
162
|
+
primitives = UINT32_MAX;
|
|
163
|
+
}
|
|
164
|
+
});
|
|
165
|
+
|
|
166
|
+
bool hfa = (count >= min && count <= max && PopCount(primitives) == 1);
|
|
167
|
+
return hfa ? count : 0;
|
|
199
168
|
}
|
|
200
169
|
|
|
201
170
|
}
|
package/src/util.hh
CHANGED
|
@@ -53,6 +53,20 @@ static inline T *AlignDown(T *ptr, Size align)
|
|
|
53
53
|
return (T *)aligned;
|
|
54
54
|
}
|
|
55
55
|
|
|
56
|
+
static inline bool IsInteger(const TypeInfo *type)
|
|
57
|
+
{
|
|
58
|
+
bool integer = ((int)type->primitive >= (int)PrimitiveKind::Int8 &&
|
|
59
|
+
(int)type->primitive <= (int)PrimitiveKind::UInt64);
|
|
60
|
+
return integer;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
static inline bool IsFloat(const TypeInfo *type)
|
|
64
|
+
{
|
|
65
|
+
bool fp = (type->primitive == PrimitiveKind::Float32 ||
|
|
66
|
+
type->primitive == PrimitiveKind::Float64);
|
|
67
|
+
return fp;
|
|
68
|
+
}
|
|
69
|
+
|
|
56
70
|
const TypeInfo *ResolveType(const InstanceData *instance, Napi::Value value, int *out_directions = nullptr);
|
|
57
71
|
const TypeInfo *GetPointerType(InstanceData *instance, const TypeInfo *type);
|
|
58
72
|
|
|
@@ -89,6 +103,8 @@ T CopyNumber(const Napi::Value &value)
|
|
|
89
103
|
RG_UNREACHABLE();
|
|
90
104
|
}
|
|
91
105
|
|
|
92
|
-
|
|
106
|
+
int AnalyseFlat(const TypeInfo *type, FunctionRef<void(const TypeInfo *type, int offset, int count)> func);
|
|
107
|
+
|
|
108
|
+
int IsHFA(const TypeInfo *type, int min, int max);
|
|
93
109
|
|
|
94
110
|
}
|
package/test/misc.c
CHANGED
|
@@ -75,6 +75,15 @@ typedef struct Double3 {
|
|
|
75
75
|
} s;
|
|
76
76
|
} Double3;
|
|
77
77
|
|
|
78
|
+
typedef struct FloatInt {
|
|
79
|
+
float f;
|
|
80
|
+
int i;
|
|
81
|
+
} FloatInt;
|
|
82
|
+
typedef struct IntFloat {
|
|
83
|
+
int i;
|
|
84
|
+
float f;
|
|
85
|
+
} IntFloat;
|
|
86
|
+
|
|
78
87
|
typedef struct IJK1 { int8_t i; int8_t j; int8_t k; } IJK1;
|
|
79
88
|
typedef struct IJK4 { int32_t i; int32_t j; int32_t k; } IJK4;
|
|
80
89
|
typedef struct IJK8 { int64_t i; int64_t j; int64_t k; } IJK8;
|
|
@@ -188,6 +197,11 @@ EXPORT Float2 PackFloat2(float a, float b, Float2 *out)
|
|
|
188
197
|
return ret;
|
|
189
198
|
}
|
|
190
199
|
|
|
200
|
+
EXPORT Float2 ThroughFloat2(Float2 f2)
|
|
201
|
+
{
|
|
202
|
+
return f2;
|
|
203
|
+
}
|
|
204
|
+
|
|
191
205
|
EXPORT Float3 PackFloat3(float a, float b, float c, Float3 *out)
|
|
192
206
|
{
|
|
193
207
|
Float3 ret;
|
|
@@ -228,6 +242,26 @@ EXPORT Double3 PackDouble3(double a, double b, double c, Double3 *out)
|
|
|
228
242
|
return ret;
|
|
229
243
|
}
|
|
230
244
|
|
|
245
|
+
EXPORT IntFloat ReverseFloatInt(FloatInt sfi)
|
|
246
|
+
{
|
|
247
|
+
IntFloat sif;
|
|
248
|
+
|
|
249
|
+
sif.i = (int)sfi.f;
|
|
250
|
+
sif.f = (float)sfi.i;
|
|
251
|
+
|
|
252
|
+
return sif;
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
EXPORT FloatInt ReverseIntFloat(IntFloat sif)
|
|
256
|
+
{
|
|
257
|
+
FloatInt sfi;
|
|
258
|
+
|
|
259
|
+
sfi.i = (int)sif.f;
|
|
260
|
+
sfi.f = (float)sif.i;
|
|
261
|
+
|
|
262
|
+
return sfi;
|
|
263
|
+
}
|
|
264
|
+
|
|
231
265
|
EXPORT int64_t ConcatenateToInt1(int8_t a, int8_t b, int8_t c, int8_t d, int8_t e, int8_t f,
|
|
232
266
|
int8_t g, int8_t h, int8_t i, int8_t j, int8_t k, int8_t l)
|
|
233
267
|
{
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
diff --git a/koffi/vendor/raylib/src/external/glfw/src/egl_context.c b/koffi/vendor/raylib/src/external/glfw/src/egl_context.c
|
|
2
|
+
index 975c67be..4edd3dac 100644
|
|
3
|
+
--- a/koffi/vendor/raylib/src/external/glfw/src/egl_context.c
|
|
4
|
+
+++ b/koffi/vendor/raylib/src/external/glfw/src/egl_context.c
|
|
5
|
+
@@ -316,6 +316,8 @@ GLFWbool _glfwInitEGL(void)
|
|
6
|
+
"libEGL.dylib",
|
|
7
|
+
#elif defined(__CYGWIN__)
|
|
8
|
+
"libEGL-1.so",
|
|
9
|
+
+#elif defined(__OpenBSD__) || defined(__NetBSD__)
|
|
10
|
+
+ "libEGL.so",
|
|
11
|
+
#else
|
|
12
|
+
"libEGL.so.1",
|
|
13
|
+
#endif
|
|
14
|
+
@@ -686,6 +688,8 @@ GLFWbool _glfwCreateContextEGL(_GLFWwindow* window,
|
|
15
|
+
"libGLES_CM.dll",
|
|
16
|
+
#elif defined(_GLFW_COCOA)
|
|
17
|
+
"libGLESv1_CM.dylib",
|
|
18
|
+
+#elif defined(__OpenBSD__) || defined(__NetBSD__)
|
|
19
|
+
+ "libGLESv1_CM.so",
|
|
20
|
+
#else
|
|
21
|
+
"libGLESv1_CM.so.1",
|
|
22
|
+
"libGLES_CM.so.1",
|
|
23
|
+
@@ -703,6 +707,8 @@ GLFWbool _glfwCreateContextEGL(_GLFWwindow* window,
|
|
24
|
+
"libGLESv2.dylib",
|
|
25
|
+
#elif defined(__CYGWIN__)
|
|
26
|
+
"libGLESv2-2.so",
|
|
27
|
+
+#elif defined(__OpenBSD__) || defined(__NetBSD__)
|
|
28
|
+
+ "libGLESv2.so",
|
|
29
|
+
#else
|
|
30
|
+
"libGLESv2.so.2",
|
|
31
|
+
#endif
|
|
32
|
+
diff --git a/koffi/vendor/raylib/src/external/glfw/src/osmesa_context.c b/koffi/vendor/raylib/src/external/glfw/src/osmesa_context.c
|
|
33
|
+
index 70e8675b..62c31678 100644
|
|
34
|
+
--- a/koffi/vendor/raylib/src/external/glfw/src/osmesa_context.c
|
|
35
|
+
+++ b/koffi/vendor/raylib/src/external/glfw/src/osmesa_context.c
|
|
36
|
+
@@ -124,6 +124,8 @@ GLFWbool _glfwInitOSMesa(void)
|
|
37
|
+
"libOSMesa.8.dylib",
|
|
38
|
+
#elif defined(__CYGWIN__)
|
|
39
|
+
"libOSMesa-8.so",
|
|
40
|
+
+#elif defined(__OpenBSD__) || defined(__NetBSD__)
|
|
41
|
+
+ "libOSMesa.so",
|
|
42
|
+
#else
|
|
43
|
+
"libOSMesa.so.8",
|
|
44
|
+
"libOSMesa.so.6",
|
|
45
|
+
diff --git a/koffi/vendor/raylib/src/external/glfw/src/vulkan.c b/koffi/vendor/raylib/src/external/glfw/src/vulkan.c
|
|
46
|
+
index b5340520..7eb4fdf0 100644
|
|
47
|
+
--- a/koffi/vendor/raylib/src/external/glfw/src/vulkan.c
|
|
48
|
+
+++ b/koffi/vendor/raylib/src/external/glfw/src/vulkan.c
|
|
49
|
+
@@ -59,6 +59,8 @@ GLFWbool _glfwInitVulkan(int mode)
|
|
50
|
+
_glfw.vk.handle = _glfw_dlopen("libvulkan.1.dylib");
|
|
51
|
+
if (!_glfw.vk.handle)
|
|
52
|
+
_glfw.vk.handle = _glfwLoadLocalVulkanLoaderNS();
|
|
53
|
+
+#elif defined(__OpenBSD__) || defined(__NetBSD__)
|
|
54
|
+
+ _glfw.vk.handle = _glfw_dlopen("libvulkan.so");
|
|
55
|
+
#else
|
|
56
|
+
_glfw.vk.handle = _glfw_dlopen("libvulkan.so.1");
|
|
57
|
+
#endif
|
|
58
|
+
diff --git a/koffi/vendor/raylib/src/external/glfw/src/x11_init.c b/koffi/vendor/raylib/src/external/glfw/src/x11_init.c
|
|
59
|
+
index fc9ac427..c2233f56 100644
|
|
60
|
+
--- a/koffi/vendor/raylib/src/external/glfw/src/x11_init.c
|
|
61
|
+
+++ b/koffi/vendor/raylib/src/external/glfw/src/x11_init.c
|
|
62
|
+
@@ -601,7 +601,11 @@ static void detectEWMH(void)
|
|
63
|
+
//
|
|
64
|
+
static GLFWbool initExtensions(void)
|
|
65
|
+
{
|
|
66
|
+
+#if defined(__OpenBSD__) || defined(__NetBSD__)
|
|
67
|
+
+ _glfw.x11.vidmode.handle = _glfw_dlopen("libXxf86vm.so");
|
|
68
|
+
+#else
|
|
69
|
+
_glfw.x11.vidmode.handle = _glfw_dlopen("libXxf86vm.so.1");
|
|
70
|
+
+#endif
|
|
71
|
+
if (_glfw.x11.vidmode.handle)
|
|
72
|
+
{
|
|
73
|
+
_glfw.x11.vidmode.QueryExtension = (PFN_XF86VidModeQueryExtension)
|
|
74
|
+
@@ -621,6 +625,8 @@ static GLFWbool initExtensions(void)
|
|
75
|
+
|
|
76
|
+
#if defined(__CYGWIN__)
|
|
77
|
+
_glfw.x11.xi.handle = _glfw_dlopen("libXi-6.so");
|
|
78
|
+
+#elif defined(__OpenBSD__) || defined(__NetBSD__)
|
|
79
|
+
+ _glfw.x11.xi.handle = _glfw_dlopen("libXi.so");
|
|
80
|
+
#else
|
|
81
|
+
_glfw.x11.xi.handle = _glfw_dlopen("libXi.so.6");
|
|
82
|
+
#endif
|
|
83
|
+
@@ -651,6 +657,8 @@ static GLFWbool initExtensions(void)
|
|
84
|
+
|
|
85
|
+
#if defined(__CYGWIN__)
|
|
86
|
+
_glfw.x11.randr.handle = _glfw_dlopen("libXrandr-2.so");
|
|
87
|
+
+#elif defined(__OpenBSD__) || defined(__NetBSD__)
|
|
88
|
+
+ _glfw.x11.randr.handle = _glfw_dlopen("libXrandr.so");
|
|
89
|
+
#else
|
|
90
|
+
_glfw.x11.randr.handle = _glfw_dlopen("libXrandr.so.2");
|
|
91
|
+
#endif
|
|
92
|
+
@@ -743,6 +751,8 @@ static GLFWbool initExtensions(void)
|
|
93
|
+
|
|
94
|
+
#if defined(__CYGWIN__)
|
|
95
|
+
_glfw.x11.xcursor.handle = _glfw_dlopen("libXcursor-1.so");
|
|
96
|
+
+#elif defined(__OpenBSD__) || defined(__NetBSD__)
|
|
97
|
+
+ _glfw.x11.xcursor.handle = _glfw_dlopen("libXcursor.so");
|
|
98
|
+
#else
|
|
99
|
+
_glfw.x11.xcursor.handle = _glfw_dlopen("libXcursor.so.1");
|
|
100
|
+
#endif
|
|
101
|
+
@@ -764,6 +774,8 @@ static GLFWbool initExtensions(void)
|
|
102
|
+
|
|
103
|
+
#if defined(__CYGWIN__)
|
|
104
|
+
_glfw.x11.xinerama.handle = _glfw_dlopen("libXinerama-1.so");
|
|
105
|
+
+#elif defined(__OpenBSD__) || defined(__NetBSD__)
|
|
106
|
+
+ _glfw.x11.xinerama.handle = _glfw_dlopen("libXinerama.so");
|
|
107
|
+
#else
|
|
108
|
+
_glfw.x11.xinerama.handle = _glfw_dlopen("libXinerama.so.1");
|
|
109
|
+
#endif
|
|
110
|
+
@@ -817,6 +829,8 @@ static GLFWbool initExtensions(void)
|
|
111
|
+
{
|
|
112
|
+
#if defined(__CYGWIN__)
|
|
113
|
+
_glfw.x11.x11xcb.handle = _glfw_dlopen("libX11-xcb-1.so");
|
|
114
|
+
+#elif defined(__OpenBSD__) || defined(__NetBSD__)
|
|
115
|
+
+ _glfw.x11.x11xcb.handle = _glfw_dlopen("libX11-xcb.so");
|
|
116
|
+
#else
|
|
117
|
+
_glfw.x11.x11xcb.handle = _glfw_dlopen("libX11-xcb.so.1");
|
|
118
|
+
#endif
|
|
119
|
+
@@ -830,6 +844,8 @@ static GLFWbool initExtensions(void)
|
|
120
|
+
|
|
121
|
+
#if defined(__CYGWIN__)
|
|
122
|
+
_glfw.x11.xrender.handle = _glfw_dlopen("libXrender-1.so");
|
|
123
|
+
+#elif defined(__OpenBSD__) || defined(__NetBSD__)
|
|
124
|
+
+ _glfw.x11.xrender.handle = _glfw_dlopen("libXrender.so");
|
|
125
|
+
#else
|
|
126
|
+
_glfw.x11.xrender.handle = _glfw_dlopen("libXrender.so.1");
|
|
127
|
+
#endif
|
|
128
|
+
@@ -857,6 +873,8 @@ static GLFWbool initExtensions(void)
|
|
129
|
+
|
|
130
|
+
#if defined(__CYGWIN__)
|
|
131
|
+
_glfw.x11.xshape.handle = _glfw_dlopen("libXext-6.so");
|
|
132
|
+
+#elif defined(__OpenBSD__) || defined(__NetBSD__)
|
|
133
|
+
+ _glfw.x11.xshape.handle = _glfw_dlopen("libXext.so");
|
|
134
|
+
#else
|
|
135
|
+
_glfw.x11.xshape.handle = _glfw_dlopen("libXext.so.6");
|
|
136
|
+
#endif
|
|
137
|
+
@@ -1120,6 +1138,8 @@ int _glfwPlatformInit(void)
|
|
138
|
+
|
|
139
|
+
#if defined(__CYGWIN__)
|
|
140
|
+
_glfw.x11.xlib.handle = _glfw_dlopen("libX11-6.so");
|
|
141
|
+
+#elif defined(__OpenBSD__) || defined(__NetBSD__)
|
|
142
|
+
+ _glfw.x11.xlib.handle = _glfw_dlopen("libX11.so");
|
|
143
|
+
#else
|
|
144
|
+
_glfw.x11.xlib.handle = _glfw_dlopen("libX11.so.6");
|
|
145
|
+
#endif
|
package/vendor/libcc/libcc.hh
CHANGED
|
@@ -94,7 +94,7 @@ extern "C" const char *FelixTarget;
|
|
|
94
94
|
extern "C" const char *FelixVersion;
|
|
95
95
|
extern "C" const char *FelixCompiler;
|
|
96
96
|
|
|
97
|
-
#if defined(__x86_64__) || defined(_M_X64) || defined(__aarch64__)
|
|
97
|
+
#if defined(__x86_64__) || defined(_M_X64) || defined(__aarch64__) || __riscv_xlen == 64
|
|
98
98
|
typedef int64_t Size;
|
|
99
99
|
#define RG_SIZE_MAX INT64_MAX
|
|
100
100
|
#elif defined(_WIN32) || defined(__APPLE__) || defined(__unix__)
|
|
@@ -116,6 +116,7 @@ extern "C" const char *FelixCompiler;
|
|
|
116
116
|
#if ULLONG_MAX != 0xFFFFFFFFFFFFFFFFull
|
|
117
117
|
#error This code base is not designed to support non-64-bits long long types
|
|
118
118
|
#endif
|
|
119
|
+
static_assert(sizeof(double) == 8, "This code base is not designed to support single-precision double floats");
|
|
119
120
|
|
|
120
121
|
#define RG_STRINGIFY_(a) #a
|
|
121
122
|
#define RG_STRINGIFY(a) RG_STRINGIFY_(a)
|
|
@@ -196,6 +197,8 @@ extern "C" void AssertMessage(const char *filename, int line, const char *cond);
|
|
|
196
197
|
#define RG_DEBUG_BREAK() __asm__ __volatile__(".inst 0xd4200000")
|
|
197
198
|
#elif defined(__arm__)
|
|
198
199
|
#define RG_DEBUG_BREAK() __asm__ __volatile__(".inst 0xe7f001f0")
|
|
200
|
+
#elif defined(__riscv)
|
|
201
|
+
#define RG_DEBUG_BREAK() __asm__ __volatile__("ebreak")
|
|
199
202
|
#endif
|
|
200
203
|
|
|
201
204
|
#define RG_CRITICAL(Cond, ...) \
|
|
@@ -316,6 +316,8 @@ GLFWbool _glfwInitEGL(void)
|
|
|
316
316
|
"libEGL.dylib",
|
|
317
317
|
#elif defined(__CYGWIN__)
|
|
318
318
|
"libEGL-1.so",
|
|
319
|
+
#elif defined(__OpenBSD__) || defined(__NetBSD__)
|
|
320
|
+
"libEGL.so",
|
|
319
321
|
#else
|
|
320
322
|
"libEGL.so.1",
|
|
321
323
|
#endif
|
|
@@ -686,6 +688,8 @@ GLFWbool _glfwCreateContextEGL(_GLFWwindow* window,
|
|
|
686
688
|
"libGLES_CM.dll",
|
|
687
689
|
#elif defined(_GLFW_COCOA)
|
|
688
690
|
"libGLESv1_CM.dylib",
|
|
691
|
+
#elif defined(__OpenBSD__) || defined(__NetBSD__)
|
|
692
|
+
"libGLESv1_CM.so",
|
|
689
693
|
#else
|
|
690
694
|
"libGLESv1_CM.so.1",
|
|
691
695
|
"libGLES_CM.so.1",
|
|
@@ -703,6 +707,8 @@ GLFWbool _glfwCreateContextEGL(_GLFWwindow* window,
|
|
|
703
707
|
"libGLESv2.dylib",
|
|
704
708
|
#elif defined(__CYGWIN__)
|
|
705
709
|
"libGLESv2-2.so",
|
|
710
|
+
#elif defined(__OpenBSD__) || defined(__NetBSD__)
|
|
711
|
+
"libGLESv2.so",
|
|
706
712
|
#else
|
|
707
713
|
"libGLESv2.so.2",
|
|
708
714
|
#endif
|
|
@@ -59,6 +59,8 @@ GLFWbool _glfwInitVulkan(int mode)
|
|
|
59
59
|
_glfw.vk.handle = _glfw_dlopen("libvulkan.1.dylib");
|
|
60
60
|
if (!_glfw.vk.handle)
|
|
61
61
|
_glfw.vk.handle = _glfwLoadLocalVulkanLoaderNS();
|
|
62
|
+
#elif defined(__OpenBSD__) || defined(__NetBSD__)
|
|
63
|
+
_glfw.vk.handle = _glfw_dlopen("libvulkan.so");
|
|
62
64
|
#else
|
|
63
65
|
_glfw.vk.handle = _glfw_dlopen("libvulkan.so.1");
|
|
64
66
|
#endif
|