diff options
author | Jukka Jylanki <jujjyl@gmail.com> | 2022-11-21 22:13:21 +0200 |
---|---|---|
committer | Ivan Maidanski <ivmai@mail.ru> | 2022-11-22 18:15:10 +0300 |
commit | e4247e8e31621563d53af29910d51ffe1427d3f2 (patch) | |
tree | 2e7fa7bc8cc9e0a13c052b5d6c4965961af70595 /os_dep.c | |
parent | 11253c7cda2bbc4d954c45607d8bc666d80701f6 (diff) | |
download | bdwgc-e4247e8e31621563d53af29910d51ffe1427d3f2.tar.gz |
Use emscripten_stack_get_base instead of emscripten_scan_stack
Issue #504 (bdwgc).
Simplify obtaining the stack base for Emscripten by using the direct
emscripten_stack_get_base(), instead of the ASYNCIFY-only
emscripten_scan_stack().
The previous variant of getting the stack base (using
emscripten_scan_stack function) is still available, it could be
chosen by passing -D USE_EMSCRIPTEN_SCAN_STACK to CFLAGS.
* os_dep.c [!ECOS && !NOSYS && !SYMBIAN && EMSCRIPTEN]: Include
emscripten.h only if USE_EMSCRIPTEN_SCAN_STACK; add comment.
* os_dep.c [!ECOS && !NOSYS && !SYMBIAN && EMSCRIPTEN]
(emscripten_stack_base, scan_stack_cb): Define only if
USE_EMSCRIPTEN_SCAN_STACK.
* os_dep.c [!ECOS && !NOSYS && !SYMBIAN && EMSCRIPTEN
&& !USE_EMSCRIPTEN_SCAN_STACK]: Include emscripten/stack.h.
* os_dep.c [!ECOS && !NOSYS && !SYMBIAN && EMSCRIPTEN]
(GC_get_main_stack_base): Call emscripten_stack_get_base() instead of
emscripten_scan_stack(scan_stack_cb) unless USE_EMSCRIPTEN_SCAN_STACK
is defined.
Diffstat (limited to 'os_dep.c')
-rw-r--r-- | os_dep.c | 29 |
1 files changed, 20 insertions, 9 deletions
@@ -1241,20 +1241,31 @@ GC_INNER size_t GC_page_size = 0; } # define GET_MAIN_STACKBASE_SPECIAL #elif defined(EMSCRIPTEN) -# include <emscripten.h> - static void* emscripten_stack_base; +# ifdef USE_EMSCRIPTEN_SCAN_STACK + /* According to the documentation, emscripten_scan_stack() is only */ + /* guaranteed to be available when building with ASYNCIFY. */ +# include <emscripten.h> - static void scan_stack_cb(void *begin, void *end) - { - (void)begin; - emscripten_stack_base = end; - } + static void *emscripten_stack_base; + + static void scan_stack_cb(void *begin, void *end) + { + (void)begin; + emscripten_stack_base = end; + } +# else +# include <emscripten/stack.h> +# endif ptr_t GC_get_main_stack_base(void) { - emscripten_scan_stack(scan_stack_cb); - return (ptr_t)emscripten_stack_base; +# ifdef USE_EMSCRIPTEN_SCAN_STACK + emscripten_scan_stack(scan_stack_cb); + return (ptr_t)emscripten_stack_base; +# else + return (ptr_t)emscripten_stack_get_base(); +# endif } # define GET_MAIN_STACKBASE_SPECIAL #elif !defined(AMIGA) && !defined(HAIKU) && !defined(OS2) \ |