wasi-libc/basics/crt/crt1.c
Dan Gohman ad03c82d65 Implement reallocarray.
reallocarray is non-standard but present in GLIBC and BSDs.
2019-04-23 15:00:07 -07:00

21 lines
532 B
C

extern void __wasm_call_ctors(void);
extern int main(int, char *[]);
extern void __prepare_for_exit(void);
void _Exit(int) __attribute__((noreturn));
void _start(void) {
/* The linker synthesizes this to call constructors. */
__wasm_call_ctors();
/* Call main with no arguments. */
int r = main(0, 0);
/* Call atexit functions, destructors, stdio cleanup, etc. */
__prepare_for_exit();
/* If main exited successfully, just return, otherwise call _Exit. */
if (r != 0) {
_Exit(r);
}
}