Changeset ba661bc in mainline
- Timestamp:
- 2008-06-03T15:03:23Z (17 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- eda8b8b
- Parents:
- 663c5a6
- Location:
- uspace/lib/libc
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/libc/generic/io/stream.c
r663c5a6 rba661bc 57 57 ssize_t read_stdin(void *buf, size_t count) 58 58 { 59 ipcarg_t r0, r1; 60 size_t i = 0; 61 62 while (i < count) { 63 if (async_req_0_2(console_phone, CONSOLE_GETCHAR, &r0, 64 &r1) < 0) { 65 return -1; 59 open_console(); 60 if (console_phone >= 0) { 61 ipcarg_t r0, r1; 62 size_t i = 0; 63 64 while (i < count) { 65 if (async_req_0_2(console_phone, CONSOLE_GETCHAR, &r0, &r1) < 0) 66 return -1; 67 ((char *) buf)[i++] = r0; 66 68 } 67 ((char *) buf)[i++] = r0;69 return i; 68 70 } 69 return i;70 71 } 71 72 72 73 ssize_t write_stdout(const void *buf, size_t count) 73 74 { 74 int i; 75 76 for (i = 0; i < count; i++) 77 async_msg_1(console_phone, CONSOLE_PUTCHAR, 78 ((const char *) buf)[i]); 75 open_console(); 76 if (console_phone >= 0) { 77 int i; 79 78 80 return count; 79 for (i = 0; i < count; i++) 80 async_msg_1(console_phone, CONSOLE_PUTCHAR, 81 ((const char *) buf)[i]); 82 83 return count; 84 } else 85 return __SYSCALL3(SYS_IO, 1, (sysarg_t) buf, count); 81 86 } 82 87 83 void open_ stdin(void)88 void open_console(void) 84 89 { 85 90 if (console_phone < 0) { 86 while ((console_phone = ipc_connect_me_to(PHONE_NS, 87 SERVICE_CONSOLE, 0, 0)) < 0) { 88 usleep(10000); 89 } 90 } 91 } 92 93 void open_stdout(void) 94 { 95 if (console_phone < 0) { 96 while ((console_phone = ipc_connect_me_to(PHONE_NS, 97 SERVICE_CONSOLE, 0, 0)) < 0) { 98 usleep(10000); 99 } 91 int phone = ipc_connect_me_to(PHONE_NS, SERVICE_CONSOLE, 0, 0); 92 if (phone >= 0) 93 console_phone = phone; 100 94 } 101 95 } … … 103 97 int get_cons_phone(void) 104 98 { 99 open_console(); 105 100 return console_phone; 106 101 } -
uspace/lib/libc/include/io/stream.h
r663c5a6 rba661bc 40 40 #define EMFILE -17 41 41 42 extern void open_stdin(void); 43 extern void open_stdout(void); 42 extern void open_console(void); 44 43 45 44 extern ssize_t read_stdin(void *, size_t);
Note:
See TracChangeset
for help on using the changeset viewer.