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