Skip to content

Commit

Permalink
Reactor support. (#74)
Browse files Browse the repository at this point in the history
* Add support for the Reactor model.

* Mark _activate and _start as wasm exports.

* Rename _activate to _initialize.

* Don't define `_fini`.

* Rename reactor-crt1.c to crt1-reactor.c.
  • Loading branch information
sunfishcode authored May 29, 2020
1 parent 3e9892f commit a6d0b4c
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 2 deletions.
1 change: 1 addition & 0 deletions basics/crt/crt1.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ extern int __original_main(void);
extern void __prepare_for_exit(void);
void _Exit(int) __attribute__((noreturn));

__attribute__((export_name("_start")))
void _start(void) {
// The linker synthesizes this to call constructors.
__wasm_call_ctors();
Expand Down
2 changes: 1 addition & 1 deletion expected/wasm32-wasi/defined-symbols.txt
Original file line number Diff line number Diff line change
Expand Up @@ -273,8 +273,8 @@ __xpg_strerror_r
__year_to_secs
_environ
_exit
_fini
_flushlbf
_initialize
_start
a64l
abort
Expand Down
7 changes: 7 additions & 0 deletions libc-bottom-half/crt/crt1-reactor.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
extern void __wasm_call_ctors(void);

__attribute__((export_name("_initialize")))
void _initialize(void) {
// The linker synthesizes this to call constructors.
__wasm_call_ctors();
}
1 change: 1 addition & 0 deletions libc-bottom-half/crt/crt1.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ extern void __wasm_call_ctors(void);
extern int __original_main(void);
extern void __prepare_for_exit(void);

__attribute__((export_name("_start")))
void _start(void) {
// The linker synthesizes this to call constructors.
__wasm_call_ctors();
Expand Down
2 changes: 1 addition & 1 deletion libc-top-half/musl/src/exit/exit.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ static void dummy()
* as a consequence of linking either __toread.c or __towrite.c. */
weak_alias(dummy, __funcs_on_exit);
weak_alias(dummy, __stdio_exit);
#ifdef __wasilibc_unmodified_upstream // fini
weak_alias(dummy, _fini);

#ifdef __wasilibc_unmodified_upstream // fini
extern weak hidden void (*const __fini_array_start)(void), (*const __fini_array_end)(void);

static void libc_exit_fini(void)
Expand Down

0 comments on commit a6d0b4c

Please sign in to comment.