Changeset eec616b in mainline for kernel/generic/src/printf/vprintf.c
- Timestamp:
- 2009-03-24T14:43:25Z (15 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 8f29e336
- Parents:
- 74c8da2c
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/generic/src/printf/vprintf.c
r74c8da2c reec616b 27 27 */ 28 28 29 /** @addtogroup generic 29 /** @addtogroup generic 30 30 * @{ 31 31 */ … … 40 40 #include <arch/types.h> 41 41 #include <typedefs.h> 42 #include <string.h> 42 43 43 SPINLOCK_INITIALIZE(printf_lock); 44 SPINLOCK_INITIALIZE(printf_lock); /**< vprintf spinlock */ 44 45 45 static int vprintf_write (const char *str, size_t count, void *unused)46 static int vprintf_write_utf8(const char *str, size_t size, void *data) 46 47 { 47 size_t i; 48 for (i = 0; i < count; i++) 49 putchar(str[i]); 50 return i; 48 index_t index = 0; 49 index_t chars = 0; 50 51 while (index < size) { 52 putchar(utf8_decode(str, &index, size - 1)); 53 index++; 54 chars++; 55 } 56 57 return chars; 51 58 } 52 59 53 int puts(const char *s)60 static int vprintf_write_utf32(const wchar_t *str, size_t size, void *data) 54 61 { 55 size_t i; 56 for (i = 0; s[i] != 0; i++) 57 putchar(s[i]); 58 return i; 62 index_t index = 0; 63 64 while (index < (size / sizeof(wchar_t))) { 65 putchar(str[index]); 66 index++; 67 } 68 69 return index; 70 } 71 72 int puts(const char *str) 73 { 74 index_t index = 0; 75 index_t chars = 0; 76 wchar_t uc; 77 78 while ((uc = utf8_decode(str, &index, UTF8_NO_LIMIT)) != 0) { 79 putchar(uc); 80 index++; 81 chars++; 82 } 83 84 return chars; 59 85 } 60 86 61 87 int vprintf(const char *fmt, va_list ap) 62 88 { 63 struct printf_spec ps = {(int(*)(void *, size_t, void *)) vprintf_write, NULL}; 89 printf_spec_t ps = { 90 vprintf_write_utf8, 91 vprintf_write_utf32, 92 NULL 93 }; 64 94 65 95 ipl_t ipl = interrupts_disable();
Note:
See TracChangeset
for help on using the changeset viewer.