]> git.proxmox.com Git - wasi-libc.git/blob - libc-bottom-half/crt/crt1-command.c
706ab97e69b0272aa7bd9a57ce095051944f09c9
[wasi-libc.git] / libc-bottom-half / crt / crt1-command.c
1 #include <wasi/api.h>
2 #include <stdlib.h>
3 extern void __wasm_call_ctors(void);
4 extern int __main_void(void);
5 extern void __wasm_call_dtors(void);
6
7 __attribute__((export_name("_start")))
8 void _start(void) {
9 // Call `__main_void` which will either be the application's zero-argument
10 // `__main_void` function or a libc routine which obtains the command-line
11 // arguments and calls `__main_argv_argc`.
12 int r = __main_void();
13
14 // If main exited successfully, just return, otherwise call `exit`.
15 if (r != 0) {
16 exit(r);
17 }
18 }