Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/c/generic/libc.c

    r47b7006 rdf908b3  
    4141 */
    4242
     43#include <libc.h>
    4344#include <stdio.h>
    4445#include <unistd.h>
    45 #include <stdlib.h>
    4646#include <malloc.h>
    4747#include <tls.h>
     48#include <thread.h>
    4849#include <fibril.h>
    49 #include <task.h>
     50#include <ipc/ipc.h>
     51#include <async.h>
     52#include <async_rel.h>
     53#include <as.h>
    5054#include <loader/pcb.h>
    51 #include "private/libc.h"
    52 #include "private/async.h"
    53 #include "private/async_sess.h"
    54 #include "private/malloc.h"
    55 #include "private/io.h"
    5655
    57 static bool env_setup = false;
     56extern int main(int argc, char *argv[]);
     57
     58void _exit(int status)
     59{
     60        thread_exit(status);
     61}
    5862
    5963void __main(void *pcb_ptr)
    6064{
    6165        /* Initialize user task run-time environment */
    62         __malloc_init();
     66        __heap_init();
    6367        __async_init();
    64         __async_sess_init();
    65        
     68        (void) async_rel_init();
    6669        fibril_t *fibril = fibril_setup();
    67         if (fibril == NULL)
    68                 abort();
    69        
    7070        __tcb_set(fibril->tcb);
    7171       
     
    7373        __pcb = (pcb_t *) pcb_ptr;
    7474       
    75         /* The basic run-time environment is setup */
    76         env_setup = true;
    77        
    7875        int argc;
    7976        char **argv;
    8077       
    81         /*
    82          * Get command line arguments and initialize
    83          * standard input and output
    84          */
     78        /* Get command line arguments and initialize
     79           standard input and output */
    8580        if (__pcb == NULL) {
    8681                argc = 0;
     
    9489        }
    9590       
    96         /*
    97          * Run main() and set task return value
    98          * according the result
    99          */
    100         int retval = main(argc, argv);
    101         exit(retval);
     91        /* Run main() and set task return value
     92           according the result */
     93        (void) task_retval(main(argc, argv));
    10294}
    10395
    104 void exit(int status)
     96void __exit(void)
    10597{
    106         if (env_setup) {
    107                 __stdio_done();
    108                 task_retval(status);
    109                 fibril_teardown(__tcb_get()->fibril_data);
    110         }
    111        
    112         __SYSCALL1(SYS_TASK_EXIT, false);
    113        
    114         /* Unreachable */
    115         while (1);
    116 }
    117 
    118 void abort(void)
    119 {
    120         __SYSCALL1(SYS_TASK_EXIT, true);
    121        
    122         /* Unreachable */
    123         while (1);
     98        __stdio_done();
     99        fibril_teardown(__tcb_get()->fibril_data);
     100        _exit(0);
    124101}
    125102
Note: See TracChangeset for help on using the changeset viewer.