native: don't use RIOT read/write in UART
This commit is contained in:
parent
a6fd531783
commit
0b75a11291
@ -57,7 +57,7 @@ int uart0_puts(char *astring, int length)
|
|||||||
|
|
||||||
while (
|
while (
|
||||||
(length - offset > 0) && (
|
(length - offset > 0) && (
|
||||||
(nwritten = write(
|
(nwritten = _native_write(
|
||||||
STDOUT_FILENO,
|
STDOUT_FILENO,
|
||||||
astring+offset,
|
astring+offset,
|
||||||
length-offset)
|
length-offset)
|
||||||
@ -168,7 +168,7 @@ void handle_uart_in()
|
|||||||
|
|
||||||
DEBUG("handle_uart_in\n");
|
DEBUG("handle_uart_in\n");
|
||||||
|
|
||||||
nread = read(STDIN_FILENO, buf, sizeof(buf));
|
nread = _native_read(STDIN_FILENO, buf, sizeof(buf));
|
||||||
if (nread == -1) {
|
if (nread == -1) {
|
||||||
err(1, "handle_uart_in(): read()");
|
err(1, "handle_uart_in(): read()");
|
||||||
}
|
}
|
||||||
|
|||||||
@ -61,6 +61,8 @@ extern char **_native_argv;
|
|||||||
extern fd_set _native_rfds;
|
extern fd_set _native_rfds;
|
||||||
#endif
|
#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
|
* register interrupt handler handler for interrupt sig
|
||||||
|
|||||||
@ -219,7 +219,7 @@ int8_t send_buf(radio_packet_t *packet)
|
|||||||
|
|
||||||
DEBUG("send_buf: trying to send %d bytes\n", to_send);
|
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");
|
warn("write");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -131,7 +131,7 @@ void *realloc(void *ptr, size_t size)
|
|||||||
return r;
|
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;
|
ssize_t r;
|
||||||
|
|
||||||
@ -142,12 +142,11 @@ ssize_t read(int fd, void *buf, size_t count)
|
|||||||
return r;
|
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;
|
ssize_t r;
|
||||||
|
|
||||||
_native_syscall_enter();
|
_native_syscall_enter();
|
||||||
//real_write(fd, "real_write: ", 12);
|
|
||||||
r = real_write(fd, buf, count);
|
r = real_write(fd, buf, count);
|
||||||
_native_syscall_leave();
|
_native_syscall_leave();
|
||||||
|
|
||||||
@ -155,14 +154,14 @@ ssize_t write(int fd, const void *buf, size_t count)
|
|||||||
}
|
}
|
||||||
|
|
||||||
int putchar(int c) {
|
int putchar(int c) {
|
||||||
write(STDOUT_FILENO, &c, 1);
|
_native_write(STDOUT_FILENO, &c, 1);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int puts(const char *s)
|
int puts(const char *s)
|
||||||
{
|
{
|
||||||
int r;
|
int r;
|
||||||
r = write(STDOUT_FILENO, (char*)s, strlen(s));
|
r = _native_write(STDOUT_FILENO, (char*)s, strlen(s));
|
||||||
putchar('\n');
|
putchar('\n');
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
@ -203,7 +202,7 @@ int printf(const char *format, ...)
|
|||||||
if ((m = make_message(format, argp)) == NULL) {
|
if ((m = make_message(format, argp)) == NULL) {
|
||||||
err(EXIT_FAILURE, "malloc");
|
err(EXIT_FAILURE, "malloc");
|
||||||
}
|
}
|
||||||
r = write(STDOUT_FILENO, m, strlen(m));
|
r = _native_write(STDOUT_FILENO, m, strlen(m));
|
||||||
va_end(argp);
|
va_end(argp);
|
||||||
free(m);
|
free(m);
|
||||||
|
|
||||||
@ -219,7 +218,7 @@ int vprintf(const char *format, va_list argp)
|
|||||||
if ((m = make_message(format, argp)) == NULL) {
|
if ((m = make_message(format, argp)) == NULL) {
|
||||||
err(EXIT_FAILURE, "malloc");
|
err(EXIT_FAILURE, "malloc");
|
||||||
}
|
}
|
||||||
r = write(STDOUT_FILENO, m, strlen(m));
|
r = _native_write(STDOUT_FILENO, m, strlen(m));
|
||||||
free(m);
|
free(m);
|
||||||
|
|
||||||
return r;
|
return r;
|
||||||
@ -233,15 +232,15 @@ void vwarn(const char *fmt, va_list args)
|
|||||||
e = strerror(errno);
|
e = strerror(errno);
|
||||||
|
|
||||||
if ((m = make_message(fmt, args)) == NULL) {
|
if ((m = make_message(fmt, args)) == NULL) {
|
||||||
write(STDERR_FILENO, "malloc\n", 7);
|
_native_write(STDERR_FILENO, "malloc\n", 7);
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
write(STDERR_FILENO, _progname, strlen(_progname));
|
_native_write(STDERR_FILENO, _progname, strlen(_progname));
|
||||||
write(STDERR_FILENO, ": ", 2);
|
_native_write(STDERR_FILENO, ": ", 2);
|
||||||
write(STDERR_FILENO, m, strlen(m));
|
_native_write(STDERR_FILENO, m, strlen(m));
|
||||||
write(STDERR_FILENO, ": ", 2);
|
_native_write(STDERR_FILENO, ": ", 2);
|
||||||
write(STDERR_FILENO, e, strlen(e));
|
_native_write(STDERR_FILENO, e, strlen(e));
|
||||||
write(STDERR_FILENO, "\n", 1);
|
_native_write(STDERR_FILENO, "\n", 1);
|
||||||
free(m);
|
free(m);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -250,13 +249,13 @@ void vwarnx(const char *fmt, va_list args)
|
|||||||
char *m;
|
char *m;
|
||||||
|
|
||||||
if ((m = make_message(fmt, args)) == NULL) {
|
if ((m = make_message(fmt, args)) == NULL) {
|
||||||
write(STDERR_FILENO, "malloc\n", 7);
|
_native_write(STDERR_FILENO, "malloc\n", 7);
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
write(STDERR_FILENO, _progname, strlen(_progname));
|
_native_write(STDERR_FILENO, _progname, strlen(_progname));
|
||||||
write(STDERR_FILENO, ": ", 2);
|
_native_write(STDERR_FILENO, ": ", 2);
|
||||||
write(STDERR_FILENO, m, strlen(m));
|
_native_write(STDERR_FILENO, m, strlen(m));
|
||||||
write(STDERR_FILENO, "\n", 1);
|
_native_write(STDERR_FILENO, "\n", 1);
|
||||||
free(m);
|
free(m);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user