diff options
Diffstat (limited to 'sys/rt/boot.c')
-rw-r--r-- | sys/rt/boot.c | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/sys/rt/boot.c b/sys/rt/boot.c new file mode 100644 index 0000000..197e861 --- /dev/null +++ b/sys/rt/boot.c @@ -0,0 +1,34 @@ +#include <rt.h> + +int +rt·boot( + int (*main)(int,char **,char **), int argc, char **argv, + int (*init)(int, char **, char **), void (*fini)(void), + void (*exit)(void) +) +{ + char **envp = argv+argc+1; + rt·environ = envp; + + if(exit) + rt·context.exit = exit; + + if(fini) + rt·context.fini = fini; + + if(init){ + rt·context.init = init; + init(argc, argv, envp); + } + + /* XXX: + * we could call __libc_start_main of musl here: + * this would give us the normal C runtime along with ours + * which would allow seamless linking to other libraries + * or we can implement a compatibility layer + */ + rt·exit(main(argc, argv, envp)); + + /* should never get here */ + return 0; +} |