]> git.proxmox.com Git - wasi-libc.git/blame - libc-bottom-half/crt/crt1-command.c
Use bulk memory opcodes when possible
[wasi-libc.git] / libc-bottom-half / crt / crt1-command.c
CommitLineData
614d783e
DG
1#include <wasi/api.h>
2#include <stdlib.h>
3extern void __wasm_call_ctors(void);
4extern int __original_main(void);
5extern void __wasm_call_dtors(void);
6
7__attribute__((export_name("_start")))
8void _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}