From b981d7096356e3e92b66f0813881754fc69bf41d Mon Sep 17 00:00:00 2001 From: Daniel Jacobowitz Date: Thu, 11 Oct 2007 18:40:29 +0000 Subject: [PATCH] 2007-10-11 Jesper Nilsson * callback.c (cb_is_stdin): Add. * syscall.c (cb_syscall): Test for stdin, not just fd 0. 2007-10-11 Jesper Nilsson * callback.h (cb_is_stdin): Add prototype. --- include/gdb/ChangeLog | 4 ++++ include/gdb/callback.h | 3 +++ sim/common/ChangeLog | 5 +++++ sim/common/callback.c | 7 +++++++ sim/common/syscall.c | 2 +- 5 files changed, 20 insertions(+), 1 deletion(-) diff --git a/include/gdb/ChangeLog b/include/gdb/ChangeLog index e3a3f51..70266e2 100644 --- a/include/gdb/ChangeLog +++ b/include/gdb/ChangeLog @@ -1,3 +1,7 @@ +2007-10-11 Jesper Nilsson + + * callback.h (cb_is_stdin): Add prototype. + 2007-08-23 Joel Brobecker Switch the license of all .h files to GPLv3. diff --git a/include/gdb/callback.h b/include/gdb/callback.h index f1e7d24..2245c87 100644 --- a/include/gdb/callback.h +++ b/include/gdb/callback.h @@ -315,6 +315,9 @@ int cb_host_to_target_stat PARAMS ((host_callback *, const struct stat *, PTR)); /* Translate a value to target endian. */ void cb_store_target_endian PARAMS ((host_callback *, char *, int, long)); +/* Test if the fd is stdin. */ +int cb_is_stdin PARAMS ((host_callback *, int)); + /* Perform a system call. */ CB_RC cb_syscall PARAMS ((host_callback *, CB_SYSCALL *)); diff --git a/sim/common/ChangeLog b/sim/common/ChangeLog index b31a19e..bd09a5c 100644 --- a/sim/common/ChangeLog +++ b/sim/common/ChangeLog @@ -1,3 +1,8 @@ +2007-10-11 Jesper Nilsson + + * callback.c (cb_is_stdin): Add. + * syscall.c (cb_syscall): Test for stdin, not just fd 0. + 2007-08-10 Nick Clifton * sim-memopt.c (memory_options): Mention that the diff --git a/sim/common/callback.c b/sim/common/callback.c index fec1d14..f83dd54 100644 --- a/sim/common/callback.c +++ b/sim/common/callback.c @@ -1136,3 +1136,10 @@ sim_cb_eprintf (host_callback *p, const char *fmt, ...) p->evprintf_filtered (p, fmt, ap); va_end (ap); } + +int +cb_is_stdin (host_callback *cb, int fd) +{ + return fdbad (cb, fd) ? 0 : fdmap (cb, fd) == 0; +} + diff --git a/sim/common/syscall.c b/sim/common/syscall.c index 379f7e1..a3e7560 100644 --- a/sim/common/syscall.c +++ b/sim/common/syscall.c @@ -291,7 +291,7 @@ cb_syscall (cb, sc) while (count > 0) { - if (fd == 0) + if (cb_is_stdin (cb, fd)) result = (int) (*cb->read_stdin) (cb, buf, (count < FILE_XFR_SIZE ? count : FILE_XFR_SIZE)); -- 2.7.4