]>
Commit | Line | Data |
---|---|---|
614d783e DG |
1 | #include <wasi/api.h> |
2 | #include <stdlib.h> | |
3 | extern void __wasm_call_ctors(void); | |
4 | extern int __original_main(void); | |
5 | extern void __wasm_call_dtors(void); | |
6 | ||
7 | __attribute__((export_name("_start"))) | |
8 | void _start(void) { | |
9 | // Call `__original_main` which will either be the application's zero-argument | |
10 | // `__original_main` function or a libc routine which calls `__main_void`. | |
11 | // TODO: Call `main` directly once we no longer have to support old compilers. | |
12 | int r = __original_main(); | |
13 | ||
14 | // If main exited successfully, just return, otherwise call `exit`. | |
15 | if (r != 0) { | |
16 | exit(r); | |
17 | } | |
18 | } |