Changeset 3dbe2d1f in mainline
- Timestamp:
- 2007-04-07T18:00:18Z (18 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 2a98e58
- Parents:
- 5b303ba
- Location:
- uspace
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/kbd/generic/key_buffer.c
r5b303ba r3dbe2d1f 112 112 * @} 113 113 */ 114 -
uspace/libc/generic/io/io.c
r5b303ba r3dbe2d1f 38 38 #include <io/io.h> 39 39 40 static char nl = '\n';40 const static char nl = '\n'; 41 41 42 int puts(const char * 42 int puts(const char *str) 43 43 { 44 44 size_t count; 45 45 46 if (str == NULL) { 47 return putnchars("(NULL)",6 ); 48 } 46 if (str == NULL) 47 return putnchars("(NULL)", 6); 49 48 50 49 for (count = 0; str[count] != 0; count++); 51 if (write(1, (void * 50 if (write(1, (void *) str, count) == count) { 52 51 if (write(1, &nl, 1) == 1) 53 52 return 0; … … 62 61 * @return 0 on succes, EOF on fail 63 62 */ 64 int putnchars(const char * 63 int putnchars(const char *buf, size_t count) 65 64 { 66 if (write(1, (void * ) buf, count) == count) {65 if (write(1, (void *) buf, count) == count) 67 66 return 0; 68 }69 67 70 68 return EOF; … … 74 72 * 75 73 */ 76 int putstr(const char * 74 int putstr(const char *str) 77 75 { 78 76 size_t count; 79 77 80 if (str == NULL) { 81 return putnchars("(NULL)",6 ); 82 } 78 if (str == NULL) 79 return putnchars("(NULL)", 6); 83 80 84 81 for (count = 0; str[count] != 0; count++); 85 if (write(1, (void * ) str, count) == count) {82 if (write(1, (void *) str, count) == count) 86 83 return 0; 87 }88 84 89 85 return EOF; … … 93 89 { 94 90 unsigned char ch = c; 95 if (write(1, (void *) &ch , 1) == 1) {91 if (write(1, (void *) &ch, 1) == 1) 96 92 return c; 97 }98 93 99 94 return EOF; … … 103 98 { 104 99 unsigned char c; 105 if (read(0, (void *) &c , 1) == 1) {100 if (read(0, (void *) &c, 1) == 1) 106 101 return c; 107 }108 102 109 103 return EOF; -
uspace/libc/generic/io/printf.c
r5b303ba r3dbe2d1f 57 57 /** @} 58 58 */ 59 60 -
uspace/libc/generic/io/printf_core.c
r5b303ba r3dbe2d1f 41 41 #include <ctype.h> 42 42 #include <string.h> 43 /* For serialization */44 #include <async.h>45 43 46 44 #define __PRINTF_FLAG_PREFIX 0x00000001 /**< show prefixes 0x or 0*/ … … 93 91 size_t count; 94 92 95 if (str == NULL) {93 if (str == NULL) 96 94 return printf_putnchars("(NULL)", 6, ps); 97 }98 95 99 96 for (count = 0; str[count] != 0; count++); 100 97 101 if (ps->write((void *) str, count, ps->data) == count) {98 if (ps->write((void *) str, count, ps->data) == count) 102 99 return 0; 103 }104 100 105 101 return EOF; … … 448 444 uint64_t flags; 449 445 450 /* Don't let other threads interfere */451 async_serialize_start();452 453 446 counter = 0; 454 447 … … 682 675 } 683 676 684 async_serialize_end();685 677 return counter; 686 678 minus_out: 687 async_serialize_end();688 679 return -counter; 689 680 } -
uspace/libc/generic/io/vprintf.c
r5b303ba r3dbe2d1f 37 37 #include <unistd.h> 38 38 #include <io/printf_core.h> 39 #include <futex.h> 39 40 40 int vprintf_write(const char *str, size_t count, void *unused);41 atomic_t printf_futex = FUTEX_INITIALIZER; 41 42 42 int vprintf_write(const char *str, size_t count, void *unused)43 static int vprintf_write(const char *str, size_t count, void *unused) 43 44 { 44 45 return write(1, str, count); … … 52 53 int vprintf(const char *fmt, va_list ap) 53 54 { 54 struct printf_spec ps = {(int(*)(void *, size_t, void *))vprintf_write, NULL}; 55 return printf_core(fmt, &ps, ap); 56 55 struct printf_spec ps = {(int(*)(void *, size_t, void *)) vprintf_write, NULL}; 56 57 futex_down(&printf_futex); 58 int ret = printf_core(fmt, &ps, ap); 59 futex_up(&printf_futex); 60 61 return ret; 57 62 } 58 63 -
uspace/libc/generic/io/vsnprintf.c
r5b303ba r3dbe2d1f 44 44 }; 45 45 46 int vsnprintf_write(const char *str, size_t count, struct vsnprintf_data *data);47 48 46 /** Write string to given buffer. 49 47 * Write at most data->size characters including trailing zero. According to C99 has snprintf to return number … … 56 54 * @return number of characters to print (not characters really printed!) 57 55 */ 58 int vsnprintf_write(const char *str, size_t count, struct vsnprintf_data *data)56 static int vsnprintf_write(const char *str, size_t count, struct vsnprintf_data *data) 59 57 { 60 58 size_t i; … … 98 96 { 99 97 struct vsnprintf_data data = {size, 0, str}; 100 struct printf_spec ps = {(int(*)(void *, size_t, void *)) vsnprintf_write, &data};98 struct printf_spec ps = {(int(*)(void *, size_t, void *)) vsnprintf_write, &data}; 101 99 102 100 /* Print 0 at end of string - fix the case that nothing will be printed */ -
uspace/libc/generic/io/vsprintf.c
r5b303ba r3dbe2d1f 45 45 int vsprintf(char *str, const char *fmt, va_list ap) 46 46 { 47 return vsnprintf(str, (size_t) -1, fmt, ap);47 return vsnprintf(str, (size_t) - 1, fmt, ap); 48 48 } 49 49 -
uspace/libc/include/async.h
r5b303ba r3dbe2d1f 117 117 ipcarg_t arg3); 118 118 void async_msg_2(int phoneid, ipcarg_t method, ipcarg_t arg1, ipcarg_t arg2); 119 #define async_msg(ph, m,a1) async_msg_2(ph,m,a1,0)119 #define async_msg(ph, m, a1) async_msg_2(ph, m, a1, 0) 120 120 121 121 static inline void async_serialize_start(void) … … 123 123 psthread_inc_sercount(); 124 124 } 125 125 126 static inline void async_serialize_end(void) 126 127 {
Note:
See TracChangeset
for help on using the changeset viewer.