Skip to content

Commit

Permalink
Improve longjmp stubs. NFC (#18338)
Browse files Browse the repository at this point in the history
- Use `elif` here so its clear that we either include one block or the
  next, but never both.
- Fix signature of setjmp.
- Include the `_emscripten_throw_longjmp` stub regardless of
  `INCLUDE_FULL_LIBRARY` settings.

This final fix is a prerequisite for #16003.
  • Loading branch information
sbc100 committed Dec 8, 2022
1 parent b313178 commit 48ace16
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/library.js
Original file line number Diff line number Diff line change
Expand Up @@ -1241,9 +1241,7 @@ mergeInto(LibraryManager.library, {
#if SUPPORT_LONGJMP == 'emscripten'
_emscripten_throw_longjmp__sig: 'v',
_emscripten_throw_longjmp: function() { throw Infinity; },
#endif

#if !SUPPORT_LONGJMP
#elif !SUPPORT_LONGJMP
#if !INCLUDE_FULL_LIBRARY
// These are in order to print helpful error messages when either longjmp of
// setjmp is used.
Expand All @@ -1258,17 +1256,19 @@ mergeInto(LibraryManager.library, {
// built with SUPPORT_LONGJMP=1, the object file contains references of not
// longjmp but _emscripten_throw_longjmp, which is called from
// emscripten_longjmp.
_emscripten_throw_longjmp: function() { error('longjmp support was disabled (SUPPORT_LONGJMP=0), but it is required by the code (either set SUPPORT_LONGJMP=1, or remove uses of it in the project)'); },
get _emscripten_throw_longjmp__deps() {
return this.longjmp__deps;
},
#endif
_emscripten_throw_longjmp: function() {
error('longjmp support was disabled (SUPPORT_LONGJMP=0), but it is required by the code (either set SUPPORT_LONGJMP=1, or remove uses of it in the project)');
},
// will never be emitted, as the dep errors at compile time
longjmp: function(env, value) {
abort('longjmp not supported');
abort('longjmp not supported (build with -s SUPPORT_LONGJMP)');
},
setjmp: function(env, value) {
abort('setjmp not supported');
setjmp: function(env) {
abort('setjmp not supported (build with -s SUPPORT_LONGJMP)');
},
#endif

Expand Down

0 comments on commit 48ace16

Please sign in to comment.