aboutsummaryrefslogtreecommitdiff
path: root/sys/rt/boot.c
blob: 197e8616a4aa5cdcaadcdbce36cc6659bcca2951 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
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;
}