diff --git a/boards/native/drivers/native-uart0.c b/boards/native/drivers/native-uart0.c index c28ca05c1f..1f2fb3c408 100644 --- a/boards/native/drivers/native-uart0.c +++ b/boards/native/drivers/native-uart0.c @@ -57,7 +57,7 @@ int uart0_puts(char *astring, int length) while ( (length - offset > 0) && ( - (nwritten = write( + (nwritten = _native_write( STDOUT_FILENO, astring+offset, length-offset) @@ -168,7 +168,7 @@ void handle_uart_in() DEBUG("handle_uart_in\n"); - nread = read(STDIN_FILENO, buf, sizeof(buf)); + nread = _native_read(STDIN_FILENO, buf, sizeof(buf)); if (nread == -1) { err(1, "handle_uart_in(): read()"); } diff --git a/cpu/native/include/native_internal.h b/cpu/native/include/native_internal.h index ca075ea451..a55f20edd0 100644 --- a/cpu/native/include/native_internal.h +++ b/cpu/native/include/native_internal.h @@ -61,6 +61,8 @@ extern char **_native_argv; extern fd_set _native_rfds; #endif +ssize_t _native_read(int fd, void *buf, size_t count); +ssize_t _native_write(int fd, const void *buf, size_t count); /** * register interrupt handler handler for interrupt sig diff --git a/cpu/native/net/tap.c b/cpu/native/net/tap.c index 3fc5cbc6bf..03920dc211 100644 --- a/cpu/native/net/tap.c +++ b/cpu/native/net/tap.c @@ -219,7 +219,7 @@ int8_t send_buf(radio_packet_t *packet) DEBUG("send_buf: trying to send %d bytes\n", to_send); - if ((nsent = write(_native_tap_fd, buf, to_send)) == -1) {; + if ((nsent = _native_write(_native_tap_fd, buf, to_send)) == -1) {; warn("write"); return -1; } diff --git a/cpu/native/syscalls.c b/cpu/native/syscalls.c index 032396a0d2..9535a7dab9 100644 --- a/cpu/native/syscalls.c +++ b/cpu/native/syscalls.c @@ -131,7 +131,7 @@ void *realloc(void *ptr, size_t size) return r; } -ssize_t read(int fd, void *buf, size_t count) +ssize_t _native_read(int fd, void *buf, size_t count) { ssize_t r; @@ -142,12 +142,11 @@ ssize_t read(int fd, void *buf, size_t count) return r; } -ssize_t write(int fd, const void *buf, size_t count) +ssize_t _native_write(int fd, const void *buf, size_t count) { ssize_t r; _native_syscall_enter(); - //real_write(fd, "real_write: ", 12); r = real_write(fd, buf, count); _native_syscall_leave(); @@ -155,14 +154,14 @@ ssize_t write(int fd, const void *buf, size_t count) } int putchar(int c) { - write(STDOUT_FILENO, &c, 1); + _native_write(STDOUT_FILENO, &c, 1); return 0; } int puts(const char *s) { int r; - r = write(STDOUT_FILENO, (char*)s, strlen(s)); + r = _native_write(STDOUT_FILENO, (char*)s, strlen(s)); putchar('\n'); return r; } @@ -203,7 +202,7 @@ int printf(const char *format, ...) if ((m = make_message(format, argp)) == NULL) { err(EXIT_FAILURE, "malloc"); } - r = write(STDOUT_FILENO, m, strlen(m)); + r = _native_write(STDOUT_FILENO, m, strlen(m)); va_end(argp); free(m); @@ -219,7 +218,7 @@ int vprintf(const char *format, va_list argp) if ((m = make_message(format, argp)) == NULL) { err(EXIT_FAILURE, "malloc"); } - r = write(STDOUT_FILENO, m, strlen(m)); + r = _native_write(STDOUT_FILENO, m, strlen(m)); free(m); return r; @@ -233,15 +232,15 @@ void vwarn(const char *fmt, va_list args) e = strerror(errno); if ((m = make_message(fmt, args)) == NULL) { - write(STDERR_FILENO, "malloc\n", 7); + _native_write(STDERR_FILENO, "malloc\n", 7); exit(EXIT_FAILURE); } - write(STDERR_FILENO, _progname, strlen(_progname)); - write(STDERR_FILENO, ": ", 2); - write(STDERR_FILENO, m, strlen(m)); - write(STDERR_FILENO, ": ", 2); - write(STDERR_FILENO, e, strlen(e)); - write(STDERR_FILENO, "\n", 1); + _native_write(STDERR_FILENO, _progname, strlen(_progname)); + _native_write(STDERR_FILENO, ": ", 2); + _native_write(STDERR_FILENO, m, strlen(m)); + _native_write(STDERR_FILENO, ": ", 2); + _native_write(STDERR_FILENO, e, strlen(e)); + _native_write(STDERR_FILENO, "\n", 1); free(m); } @@ -250,13 +249,13 @@ void vwarnx(const char *fmt, va_list args) char *m; if ((m = make_message(fmt, args)) == NULL) { - write(STDERR_FILENO, "malloc\n", 7); + _native_write(STDERR_FILENO, "malloc\n", 7); exit(EXIT_FAILURE); } - write(STDERR_FILENO, _progname, strlen(_progname)); - write(STDERR_FILENO, ": ", 2); - write(STDERR_FILENO, m, strlen(m)); - write(STDERR_FILENO, "\n", 1); + _native_write(STDERR_FILENO, _progname, strlen(_progname)); + _native_write(STDERR_FILENO, ": ", 2); + _native_write(STDERR_FILENO, m, strlen(m)); + _native_write(STDERR_FILENO, "\n", 1); free(m); }