Changeset 6fa9a99d in mainline for uspace/lib/c
- Timestamp:
- 2014-01-05T17:50:01Z (12 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 91db0280
- Parents:
- 208b5f5
- Location:
- uspace/lib/c
- Files:
-
- 5 edited
- 2 moved
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/c/Makefile
r208b5f5 r6fa9a99d 107 107 generic/io/log.c \ 108 108 generic/io/logctl.c \ 109 generic/io/k log.c \109 generic/io/kio.c \ 110 110 generic/io/snprintf.c \ 111 111 generic/io/vprintf.c \ -
uspace/lib/c/generic/assert.c
r208b5f5 r6fa9a99d 33 33 #include <assert.h> 34 34 #include <stdio.h> 35 #include <io/k log.h>35 #include <io/kio.h> 36 36 #include <stdlib.h> 37 37 #include <atomic.h> … … 44 44 { 45 45 /* 46 * Send the message safely to k log. Nested asserts should not occur.46 * Send the message safely to kio. Nested asserts should not occur. 47 47 */ 48 k log_printf("Assertion failed (%s) in file \"%s\", line %u.\n",48 kio_printf("Assertion failed (%s) in file \"%s\", line %u.\n", 49 49 cond, file, line); 50 50 -
uspace/lib/c/generic/io/io.c
r208b5f5 r6fa9a99d 42 42 #include <malloc.h> 43 43 #include <async.h> 44 #include <io/k log.h>44 #include <io/kio.h> 45 45 #include <vfs/vfs.h> 46 46 #include <vfs/vfs_sess.h> … … 57 57 .error = true, 58 58 .eof = true, 59 .k log= false,59 .kio = false, 60 60 .sess = NULL, 61 61 .btype = _IONBF, … … 67 67 }; 68 68 69 static FILE stdout_k log= {69 static FILE stdout_kio = { 70 70 .fd = -1, 71 71 .error = false, 72 72 .eof = false, 73 .k log= true,73 .kio = true, 74 74 .sess = NULL, 75 75 .btype = _IOLBF, … … 81 81 }; 82 82 83 static FILE stderr_k log= {83 static FILE stderr_kio = { 84 84 .fd = -1, 85 85 .error = false, 86 86 .eof = false, 87 .k log= true,87 .kio = true, 88 88 .sess = NULL, 89 89 .btype = _IONBF, … … 113 113 stdout = fdopen(1, "w"); 114 114 } else { 115 stdout = &stdout_k log;115 stdout = &stdout_kio; 116 116 list_append(&stdout->link, &files); 117 117 } … … 120 120 stderr = fdopen(2, "w"); 121 121 } else { 122 stderr = &stderr_k log;122 stderr = &stderr_kio; 123 123 list_append(&stderr->link, &files); 124 124 } … … 267 267 stream->error = false; 268 268 stream->eof = false; 269 stream->k log= false;269 stream->kio = false; 270 270 stream->sess = NULL; 271 271 stream->need_sync = false; … … 289 289 stream->error = false; 290 290 stream->eof = false; 291 stream->k log= false;291 stream->kio = false; 292 292 stream->sess = NULL; 293 293 stream->need_sync = false; … … 314 314 315 315 if ((stream != &stdin_null) 316 && (stream != &stdout_k log)317 && (stream != &stderr_k log))316 && (stream != &stdout_kio) 317 && (stream != &stderr_kio)) 318 318 free(stream); 319 319 … … 382 382 ssize_t wr; 383 383 384 if (stream->k log)385 wr = k log_write(buf + done, left);384 if (stream->kio) 385 wr = kio_write(buf + done, left); 386 386 else 387 387 wr = write(stream->fd, buf + done, left); … … 705 705 _fflushbuf(stream); 706 706 707 if (stream->k log) {708 k log_update();707 if (stream->kio) { 708 kio_update(); 709 709 return EOK; 710 710 } … … 740 740 int fileno(FILE *stream) 741 741 { 742 if (stream->k log) {742 if (stream->kio) { 743 743 errno = EBADF; 744 744 return -1; -
uspace/lib/c/generic/io/kio.c
r208b5f5 r6fa9a99d 39 39 #include <unistd.h> 40 40 #include <errno.h> 41 #include <abi/k log.h>42 #include <io/k log.h>41 #include <abi/kio.h> 42 #include <io/kio.h> 43 43 #include <io/printf_core.h> 44 44 45 size_t k log_write(const void *buf, size_t size)45 size_t kio_write(const void *buf, size_t size) 46 46 { 47 ssize_t ret = (ssize_t) __SYSCALL3(SYS_K LOG, KLOG_WRITE, (sysarg_t) buf, size);47 ssize_t ret = (ssize_t) __SYSCALL3(SYS_KIO, KIO_WRITE, (sysarg_t) buf, size); 48 48 49 49 if (ret >= 0) … … 53 53 } 54 54 55 void k log_update(void)55 void kio_update(void) 56 56 { 57 (void) __SYSCALL3(SYS_K LOG, KLOG_UPDATE, (uintptr_t) NULL, 0);57 (void) __SYSCALL3(SYS_KIO, KIO_UPDATE, (uintptr_t) NULL, 0); 58 58 } 59 59 60 void k log_command(const void *buf, size_t size)60 void kio_command(const void *buf, size_t size) 61 61 { 62 (void) __SYSCALL3(SYS_K LOG, KLOG_COMMAND, (sysarg_t) buf, (sysarg_t) size);62 (void) __SYSCALL3(SYS_KIO, KIO_COMMAND, (sysarg_t) buf, (sysarg_t) size); 63 63 } 64 64 65 /** Print formatted text to k log.65 /** Print formatted text to kio. 66 66 * 67 67 * @param fmt Format string … … 70 70 * 71 71 */ 72 int k log_printf(const char *fmt, ...)72 int kio_printf(const char *fmt, ...) 73 73 { 74 74 va_list args; 75 75 va_start(args, fmt); 76 76 77 int ret = k log_vprintf(fmt, args);77 int ret = kio_vprintf(fmt, args); 78 78 79 79 va_end(args); … … 82 82 } 83 83 84 static int k log_vprintf_str_write(const char *str, size_t size, void *data)84 static int kio_vprintf_str_write(const char *str, size_t size, void *data) 85 85 { 86 size_t wr = k log_write(str, size);86 size_t wr = kio_write(str, size); 87 87 return str_nlength(str, wr); 88 88 } 89 89 90 static int k log_vprintf_wstr_write(const wchar_t *str, size_t size, void *data)90 static int kio_vprintf_wstr_write(const wchar_t *str, size_t size, void *data) 91 91 { 92 92 size_t offset = 0; … … 98 98 99 99 if (chr_encode(str[chars], buf, &sz, STR_BOUNDS(1)) == EOK) 100 k log_write(buf, sz);100 kio_write(buf, sz); 101 101 102 102 chars++; … … 107 107 } 108 108 109 /** Print formatted text to k log.109 /** Print formatted text to kio. 110 110 * 111 111 * @param fmt Format string … … 115 115 * 116 116 */ 117 int k log_vprintf(const char *fmt, va_list ap)117 int kio_vprintf(const char *fmt, va_list ap) 118 118 { 119 119 printf_spec_t ps = { 120 k log_vprintf_str_write,121 k log_vprintf_wstr_write,120 kio_vprintf_str_write, 121 kio_vprintf_wstr_write, 122 122 NULL 123 123 }; -
uspace/lib/c/generic/private/stdio.h
r208b5f5 r6fa9a99d 53 53 int eof; 54 54 55 /** K logindicator */56 int k log;55 /** KIO indicator */ 56 int kio; 57 57 58 58 /** Session to the file provider */ -
uspace/lib/c/include/io/kio.h
r208b5f5 r6fa9a99d 33 33 */ 34 34 35 #ifndef LIBC_IO_K LOG_H_36 #define LIBC_IO_K LOG_H_35 #ifndef LIBC_IO_KIO_H_ 36 #define LIBC_IO_KIO_H_ 37 37 38 38 #include <sys/types.h> … … 40 40 #include <io/verify.h> 41 41 42 extern size_t k log_write(const void *, size_t);43 extern void k log_update(void);44 extern void k log_command(const void *, size_t);45 extern int k log_printf(const char *, ...)42 extern size_t kio_write(const void *, size_t); 43 extern void kio_update(void); 44 extern void kio_command(const void *, size_t); 45 extern int kio_printf(const char *, ...) 46 46 PRINTF_ATTRIBUTE(1, 2); 47 extern int k log_vprintf(const char *, va_list);47 extern int kio_vprintf(const char *, va_list); 48 48 49 49 #endif -
uspace/lib/c/include/stdio.h
r208b5f5 r6fa9a99d 40 40 #include <str.h> 41 41 #include <io/verify.h> 42 #include <abi/k log.h>42 #include <abi/kio.h> 43 43 44 44 #define EOF (-1) … … 52 52 int _n = snprintf(_buf, sizeof(_buf), fmt, ##__VA_ARGS__); \ 53 53 if (_n > 0) \ 54 (void) __SYSCALL3(SYS_K LOG, KLOG_WRITE, (sysarg_t) _buf, str_size(_buf)); \54 (void) __SYSCALL3(SYS_KIO, KIO_WRITE, (sysarg_t) _buf, str_size(_buf)); \ 55 55 } 56 56
Note:
See TracChangeset
for help on using the changeset viewer.