diff --git a/boards/native/drivers/native-uart0.c b/boards/native/drivers/native-uart0.c index c28ca05c1ff9cd84f5893bc8e9c968b2db6aad09..1f2fb3c4081a45a04cd612b43acf5208fa9e9a2b 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 ca075ea45108ea6231f9f0acf1bd4f8ac518b308..a55f20edd017e3afd844eb34c2ff851ea5ba76a9 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 3fc5cbc6bf913c1ddc5eddeef725130bac4f7188..03920dc2117725d4f0e3c8ddaa2d30222b1502c3 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 3fbc979678d44ef877594e8e97906ac701fb4382..6e94aeba1bcb2e31c6c1996f2bd62efa089868cc 100644 --- a/cpu/native/syscalls.c +++ b/cpu/native/syscalls.c @@ -141,7 +141,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; @@ -152,12 +152,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(); @@ -165,14 +164,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; } @@ -213,7 +212,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); @@ -229,7 +228,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; @@ -243,15 +242,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); } @@ -260,13 +259,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); }