Changeset 04803bf in mainline for uspace/lib/c/generic/libc.c
- Timestamp:
- 2011-03-21T22:00:17Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 143932e3
- Parents:
- b50b5af2 (diff), 7308e84 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - File:
-
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/c/generic/libc.c
rb50b5af2 r04803bf 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 <as.h> 47 #include <task.h> 53 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" 54 54 55 55 /* From librtld. */ 56 56 #include <rtld.h> 57 #include <string.h>57 //#include <string.h> 58 58 59 extern int main(int argc, char *argv[]); 60 61 void _exit(int status) 62 { 63 thread_exit(status); 64 } 59 static bool env_setup = false; 65 60 66 61 void __main(void *pcb_ptr) 67 62 { 68 int retval; 69 70 __heap_init(); 63 /* Initialize user task run-time environment */ 64 __malloc_init(); 71 65 __async_init(); 66 __async_sess_init(); 67 72 68 fibril_t *fibril = fibril_setup(); 69 if (fibril == NULL) 70 abort(); 71 73 72 __tcb_set(fibril->tcb); 74 73 75 74 /* Save the PCB pointer */ 76 75 __pcb = (pcb_t *) pcb_ptr; 76 77 /* The basic run-time environment is setup */ 78 env_setup = true; 77 79 78 80 int argc; … … 84 86 } 85 87 #endif 86 88 /* 89 * Get command line arguments and initialize 90 * standard input and output 91 */ 87 92 if (__pcb == NULL) { 88 93 argc = 0; … … 93 98 argv = __pcb->argv; 94 99 __stdio_init(__pcb->filc, __pcb->filv); 100 (void) chdir(__pcb->cwd); 95 101 } 96 102 97 retval = main(argc, argv); 98 99 __stdio_done(); 100 (void) task_retval(retval); 103 /* 104 * Run main() and set task return value 105 * according the result 106 */ 107 int retval = main(argc, argv); 108 exit(retval); 101 109 } 102 110 103 void __exit(void)111 void exit(int status) 104 112 { 105 fibril_teardown(__tcb_get()->fibril_data); 106 _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); 107 131 } 108 132
Note:
See TracChangeset
for help on using the changeset viewer.