Changes in uspace/lib/c/generic/libc.c [8a1fb09:df908b3] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/c/generic/libc.c
r8a1fb09 rdf908b3 42 42 43 43 #include <libc.h> 44 #include <stdlib.h> 44 #include <stdio.h> 45 #include <unistd.h> 46 #include <malloc.h> 45 47 #include <tls.h> 48 #include <thread.h> 46 49 #include <fibril.h> 47 #include <task.h> 50 #include <ipc/ipc.h> 51 #include <async.h> 52 #include <async_rel.h> 53 #include <as.h> 48 54 #include <loader/pcb.h> 49 #include "private/libc.h"50 #include "private/async.h"51 #include "private/async_sess.h"52 #include "private/malloc.h"53 #include "private/io.h"54 55 55 #ifdef CONFIG_RTLD 56 #include <rtld/rtld.h> 57 #endif 56 extern int main(int argc, char *argv[]); 58 57 59 static bool env_setup = false; 58 void _exit(int status) 59 { 60 thread_exit(status); 61 } 60 62 61 63 void __main(void *pcb_ptr) 62 64 { 63 65 /* Initialize user task run-time environment */ 64 __ malloc_init();66 __heap_init(); 65 67 __async_init(); 66 __async_sess_init(); 67 68 (void) async_rel_init(); 68 69 fibril_t *fibril = fibril_setup(); 69 if (fibril == NULL)70 abort();71 72 70 __tcb_set(fibril->tcb); 73 71 … … 75 73 __pcb = (pcb_t *) pcb_ptr; 76 74 77 /* The basic run-time environment is setup */78 env_setup = true;79 80 75 int argc; 81 76 char **argv; 82 77 83 #ifdef __IN_SHARED_LIBC__ 84 if (__pcb != NULL && __pcb->rtld_runtime != NULL) { 85 runtime_env = (runtime_env_t *) __pcb->rtld_runtime; 86 } 87 #endif 88 /* 89 * Get command line arguments and initialize 90 * standard input and output 91 */ 78 /* Get command line arguments and initialize 79 standard input and output */ 92 80 if (__pcb == NULL) { 93 81 argc = 0; … … 101 89 } 102 90 103 /* 104 * Run main() and set task return value 105 * according the result 106 */ 107 int retval = main(argc, argv); 108 exit(retval); 91 /* Run main() and set task return value 92 according the result */ 93 (void) task_retval(main(argc, argv)); 109 94 } 110 95 111 void exit(int status)96 void __exit(void) 112 97 { 113 if (env_setup) { 114 __stdio_done(); 115 task_retval(status); 116 fibril_teardown(__tcb_get()->fibril_data); 117 } 118 119 __SYSCALL1(SYS_TASK_EXIT, false); 120 121 /* Unreachable */ 122 while (1); 123 } 124 125 void abort(void) 126 { 127 __SYSCALL1(SYS_TASK_EXIT, true); 128 129 /* Unreachable */ 130 while (1); 98 __stdio_done(); 99 fibril_teardown(__tcb_get()->fibril_data); 100 _exit(0); 131 101 } 132 102
Note:
See TracChangeset
for help on using the changeset viewer.