File tree Expand file tree Collapse file tree 2 files changed +26
-0
lines changed Expand file tree Collapse file tree 2 files changed +26
-0
lines changed Original file line number Diff line number Diff line change @@ -597,3 +597,4 @@ a license to everyone to use it as detailed in LICENSE.)
597597* James Hu <jameshu2022@gmail.com>
598598* Jerry Zhuang <jerry.zhuang@jwzg.com>
599599* Taisei Kon <kinsei0916@gmail.com>
600+ * YAMAMOTO Takashi <yamamoto@midokura.com>
Original file line number Diff line number Diff line change 55* found in the LICENSE file.
66*/
77
8+ #include <assert.h>
89#include <stdint.h>
910#include <stdlib.h>
1011#include <setjmp.h>
@@ -102,4 +103,28 @@ void __wasm_longjmp(void *env, int val) {
102103 __builtin_wasm_throw (C_LONGJMP , & __wasm_longjmp_args );
103104}
104105
106+ // jmp_buf should have large enough size and alignment to contain
107+ // this structure.
108+ struct jmp_buf_impl {
109+ void * func_invocation_id ;
110+ uint32_t label ;
111+ };
112+
113+ void __wasm_setjmp (void * env , uint32_t label , void * func_invocation_id ) {
114+ struct jmp_buf_impl * jb = env ;
115+ assert (label != 0 ); // ABI contract
116+ assert (func_invocation_id != NULL ); // sanity check
117+ jb -> func_invocation_id = func_invocation_id ;
118+ jb -> label = label ;
119+ }
120+
121+ uint32_t __wasm_setjmp_test (void * env , void * func_invocation_id ) {
122+ struct jmp_buf_impl * jb = env ;
123+ assert (jb -> label != 0 ); // ABI contract
124+ assert (func_invocation_id != NULL ); // sanity check
125+ if (jb -> func_invocation_id == func_invocation_id ) {
126+ return jb -> label ;
127+ }
128+ return 0 ;
129+ }
105130#endif
You can’t perform that action at this time.
0 commit comments