File tree 3 files changed +28
-2
lines changed
3 files changed +28
-2
lines changed Original file line number Diff line number Diff line change 15
15
#include < emscripten/wire.h>
16
16
#include < array>
17
17
#include < vector>
18
+ #include < climits>
18
19
19
20
20
21
namespace emscripten {
@@ -189,10 +190,15 @@ namespace emscripten {
189
190
union {
190
191
unsigned u;
191
192
float f;
193
+ #if __ILP32__
192
194
const void * p;
195
+ #endif
193
196
} w[2 ];
194
197
double d;
195
198
uint64_t u;
199
+ #if __LP64__
200
+ const void * p;
201
+ #endif
196
202
};
197
203
static_assert (sizeof (GenericWireType) == 8 , " GenericWireType must be 8 bytes" );
198
204
static_assert (alignof(GenericWireType) == 8 , " GenericWireType must be 8-byte-aligned" );
@@ -219,14 +225,29 @@ namespace emscripten {
219
225
220
226
template <typename T>
221
227
void writeGenericWireType (GenericWireType*& cursor, T* wt) {
228
+ #if __ILP32__
222
229
cursor->w [0 ].p = wt;
230
+ #else
231
+ cursor->p = wt;
232
+ // FIXME: This requires the JS reading code to be audited to be compatible with it.
233
+ assert (false );
234
+ abort ();
235
+ #endif
223
236
++cursor;
224
237
}
225
238
226
239
template <typename ElementType>
227
240
inline void writeGenericWireType (GenericWireType*& cursor, const memory_view<ElementType>& wt) {
228
241
cursor->w [0 ].u = wt.size ;
242
+ #if __ILP32__
229
243
cursor->w [1 ].p = wt.data ;
244
+ #else
245
+ // FIXME: need to change GenericWireType such that it can store a 64-bit pointer?
246
+ // This requires the JS reading code to be audited to be compatible with it.
247
+ cursor->w [1 ].u = 0 ;
248
+ assert (false );
249
+ abort ();
250
+ #endif
230
251
++cursor;
231
252
}
232
253
Original file line number Diff line number Diff line change @@ -400,7 +400,8 @@ namespace emscripten {
400
400
return (std::is_floating_point<T>::value &&
401
401
(sizeof (T) == 4 || sizeof (T) == 8 )) ||
402
402
(std::is_integral<T>::value &&
403
- (sizeof (T) == 1 || sizeof (T) == 2 || sizeof (T) == 4 ));
403
+ (sizeof (T) == 1 || sizeof (T) == 2 ||
404
+ sizeof (T) == 4 || sizeof (T) == 8 ));
404
405
}
405
406
}
406
407
Original file line number Diff line number Diff line change @@ -77,6 +77,9 @@ enum TypedArrayIndex {
77
77
Uint32Array,
78
78
Float32Array,
79
79
Float64Array,
80
+ // Only available if WASM_BIGINT
81
+ Int64Array,
82
+ Uint64Array,
80
83
};
81
84
82
85
template <typename T> constexpr TypedArrayIndex getTypedArrayIndex () {
@@ -86,7 +89,8 @@ template <typename T> constexpr TypedArrayIndex getTypedArrayIndex() {
86
89
: (sizeof (T) == 1
87
90
? (std::is_signed<T>::value ? Int8Array : Uint8Array)
88
91
: (sizeof (T) == 2 ? (std::is_signed<T>::value ? Int16Array : Uint16Array)
89
- : (std::is_signed<T>::value ? Int32Array : Uint32Array)));
92
+ : (sizeof (T) == 4 ? (std::is_signed<T>::value ? Int32Array : Uint32Array)
93
+ : (std::is_signed<T>::value ? Int64Array : Uint64Array))));
90
94
}
91
95
92
96
template <typename T> static void register_memory_view (const char * name) {
You can’t perform that action at this time.
0 commit comments