Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions system/include/emscripten/bind.h
Original file line number Diff line number Diff line change
Expand Up @@ -607,6 +607,13 @@ struct SignatureCode<size_t> {
}
};

template<>
struct SignatureCode<long long> {
static constexpr char get() {
return 'j';
}
};

#ifdef __wasm64__
template<>
struct SignatureCode<long> {
Expand All @@ -629,6 +636,8 @@ template<> struct SignatureTranslator<double> { using type = double; };
#ifdef __wasm64__
template<> struct SignatureTranslator<long> { using type = long; };
#endif
template<> struct SignatureTranslator<long long> { using type = long long; };
template<> struct SignatureTranslator<unsigned long long> { using type = long long; };
template<> struct SignatureTranslator<size_t> { using type = size_t; };
template<typename PtrType>
struct SignatureTranslator<PtrType*> { using type = void*; };
Expand Down
23 changes: 23 additions & 0 deletions test/embind/test_embind_long_long.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#include <cstdint>
#include <emscripten.h>
#include <emscripten/bind.h>

int64_t getInt64() {
return 1000000000000;
}

uint64_t getUint64() {
return -1000000000000;
}

int main() {
EM_ASM(
console.log(Module.getInt64());
console.log(Module.getUint64());
);
}

EMSCRIPTEN_BINDINGS(my_module) {
emscripten::function("getInt64", &getInt64);
emscripten::function("getUint64", &getUint64);
}
8 changes: 8 additions & 0 deletions test/test_other.py
Original file line number Diff line number Diff line change
Expand Up @@ -3296,6 +3296,14 @@ def test_embind_return_value_policy(self):

self.do_runf('embind/test_return_value_policy.cpp')

@parameterized({
'': [[]],
'asyncify': [['-sASYNCIFY=1']]
})
def test_embind_long_long(self, args):
self.do_runf('embind/test_embind_long_long.cpp', '1000000000000n\n-1000000000000n',
emcc_args=['-lembind', '-sWASM_BIGINT'] + args)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wow I guess we just never had anyone try this before?

Why does this require -sWASM_BIGINT to expose the issue? It looks like that lack of a long long mapping is a problem regardless of this setting?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems only ASYNCIFY exposed this because it uses the signature to create a DYNCALL with the legacy mode. Without asyncify bigints were working fine.


@requires_jspi
@parameterized({
'': [['-sJSPI_EXPORTS=async*']],
Expand Down
Loading