Changes in uspace/lib/c/generic/libc.c [4791e3c:47b7006] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/c/generic/libc.c
r4791e3c r47b7006 41 41 */ 42 42 43 #include <libc.h>44 43 #include <stdio.h> 45 44 #include <unistd.h> 45 #include <stdlib.h> 46 46 #include <malloc.h> 47 47 #include <tls.h> 48 #include <thread.h>49 48 #include <fibril.h> 50 #include <ipc/ipc.h> 51 #include <async.h> 52 #include <as.h> 49 #include <task.h> 53 50 #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" 54 56 55 extern int main(int argc, char *argv[]); 56 57 void _exit(int status) 58 { 59 thread_exit(status); 60 } 57 static bool env_setup = false; 61 58 62 59 void __main(void *pcb_ptr) 63 60 { 64 61 /* Initialize user task run-time environment */ 65 __ heap_init();62 __malloc_init(); 66 63 __async_init(); 64 __async_sess_init(); 65 67 66 fibril_t *fibril = fibril_setup(); 67 if (fibril == NULL) 68 abort(); 69 68 70 __tcb_set(fibril->tcb); 69 71 … … 71 73 __pcb = (pcb_t *) pcb_ptr; 72 74 75 /* The basic run-time environment is setup */ 76 env_setup = true; 77 73 78 int argc; 74 79 char **argv; 75 80 76 /* Get command line arguments and initialize 77 standard input and output */ 81 /* 82 * Get command line arguments and initialize 83 * standard input and output 84 */ 78 85 if (__pcb == NULL) { 79 86 argc = 0; … … 87 94 } 88 95 89 /* Run main() and set task return value 90 according the result */ 91 (void) task_retval(main(argc, argv)); 96 /* 97 * Run main() and set task return value 98 * according the result 99 */ 100 int retval = main(argc, argv); 101 exit(retval); 92 102 } 93 103 94 void __exit(void)104 void exit(int status) 95 105 { 96 __stdio_done(); 97 fibril_teardown(__tcb_get()->fibril_data); 98 _exit(0); 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); 99 124 } 100 125
Note:
See TracChangeset
for help on using the changeset viewer.