Skip to content

Commit

Permalink
Add some comments regarding __c_longjmp. NFC (#21442)
Browse files Browse the repository at this point in the history
  • Loading branch information
sbc100 authored Feb 27, 2024
1 parent c0cda71 commit 1b3950d
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion system/lib/compiler-rt/emscripten_setjmp.c
Original file line number Diff line number Diff line change
Expand Up @@ -81,13 +81,17 @@ struct __WasmLongjmpArgs {

thread_local struct __WasmLongjmpArgs __wasm_longjmp_args;

// llvm uses `1` for the __c_longjmp tag.
// See https://github.com/llvm/llvm-project/blob/main/llvm/include/llvm/CodeGen/WasmEHFuncInfo.h
#define C_LONGJMP 1

// Wasm EH allows us to throw and catch multiple values, but that requires
// multivalue support in the toolchain, whch is not reliable at the time.
// TODO Consider switching to throwing two values at the same time later.
void __wasm_longjmp(void *env, int val) {
__wasm_longjmp_args.env = env;
__wasm_longjmp_args.val = val;
__builtin_wasm_throw(1, &__wasm_longjmp_args);
__builtin_wasm_throw(C_LONGJMP, &__wasm_longjmp_args);
}

#endif

0 comments on commit 1b3950d

Please sign in to comment.