* [PATCH/committed 1/2] sim: erc32: fix build w/out termios.h
@ 2021-06-15 3:30 Mike Frysinger
2021-06-15 3:30 ` [PATCH/committed 2/2] sim: erc32: fix build w/out F_{G,S}ETFL Mike Frysinger
0 siblings, 1 reply; 2+ messages in thread
From: Mike Frysinger @ 2021-06-15 3:30 UTC (permalink / raw)
To: gdb-patches
Add conditional logic around termios.h usage to fix builds on systems
that don't have it (e.g. Windows).
---
sim/erc32/ChangeLog | 8 ++++++++
sim/erc32/erc32.c | 12 ++++++++++++
2 files changed, 20 insertions(+)
diff --git a/sim/erc32/ChangeLog b/sim/erc32/ChangeLog
index 311da252b6b8..a5035d058f15 100644
--- a/sim/erc32/ChangeLog
+++ b/sim/erc32/ChangeLog
@@ -1,3 +1,11 @@
+2021-06-14 Mike Frysinger <vapier@gentoo.org>
+
+ * erc32.c [HAVE_TERMIOS_H]: Include termios.h and declare ioc1,
+ ioc2, iocold1, & iocold2.
+ (init_stdio) [HAVE_TERMIOS_H]: Only call tcsetattr.
+ (restore_stdio) [HAVE_TERMIOS_H]: Likewise.
+ (port_init) [HAVE_TERMIOS_H]: Only call tcgetattr.
+
2021-06-12 Mike Frysinger <vapier@gentoo.org>
* erc32.c (uart_rx): Change caddr_t to void*.
diff --git a/sim/erc32/erc32.c b/sim/erc32/erc32.c
index 91f734c07dbe..e7a816f86bff 100644
--- a/sim/erc32/erc32.c
+++ b/sim/erc32/erc32.c
@@ -24,7 +24,9 @@
#include <sys/types.h>
#include <stdio.h>
#include <string.h>
+#ifdef HAVE_TERMIOS_H
#include <termios.h>
+#endif
#include <sys/fcntl.h>
#include <sys/file.h>
#include <unistd.h>
@@ -235,7 +237,9 @@ static char wbufa[UARTBUF], wbufb[UARTBUF];
static unsigned wnuma;
static unsigned wnumb;
static FILE *f1in, *f1out, *f2in, *f2out;
+#ifdef HAVE_TERMIOS_H
static struct termios ioc1, ioc2, iocold1, iocold2;
+#endif
static int f1open = 0, f2open = 0;
static char uarta_sreg, uarta_hreg, uartb_sreg, uartb_hreg;
@@ -926,10 +930,12 @@ init_stdio(void)
{
if (dumbio)
return; /* do nothing */
+#ifdef HAVE_TERMIOS_H
if (!ifd1)
tcsetattr(0, TCSANOW, &ioc1);
if (!ifd2)
tcsetattr(0, TCSANOW, &ioc2);
+#endif
}
void
@@ -937,10 +943,12 @@ restore_stdio(void)
{
if (dumbio)
return; /* do nothing */
+#ifdef HAVE_TERMIOS_H
if (!ifd1)
tcsetattr(0, TCSANOW, &iocold1);
if (!ifd2)
tcsetattr(0, TCSANOW, &iocold2);
+#endif
}
#define DO_STDIO_READ( _fd_, _buf_, _len_ ) \
@@ -979,11 +987,13 @@ port_init(void)
if (sis_verbose)
printf("serial port A on stdin/stdout\n");
if (!dumbio) {
+#ifdef HAVE_TERMIOS_H
tcgetattr(ifd1, &ioc1);
iocold1 = ioc1;
ioc1.c_lflag &= ~(ICANON | ECHO);
ioc1.c_cc[VMIN] = 0;
ioc1.c_cc[VTIME] = 0;
+#endif
}
f1open = 1;
}
@@ -1008,11 +1018,13 @@ port_init(void)
if (sis_verbose)
printf("serial port B on stdin/stdout\n");
if (!dumbio) {
+#ifdef HAVE_TERMIOS_H
tcgetattr(ifd2, &ioc2);
iocold2 = ioc2;
ioc2.c_lflag &= ~(ICANON | ECHO);
ioc2.c_cc[VMIN] = 0;
ioc2.c_cc[VTIME] = 0;
+#endif
}
f2open = 1;
}
--
2.31.1
^ permalink raw reply [flat|nested] 2+ messages in thread
* [PATCH/committed 2/2] sim: erc32: fix build w/out F_{G,S}ETFL
2021-06-15 3:30 [PATCH/committed 1/2] sim: erc32: fix build w/out termios.h Mike Frysinger
@ 2021-06-15 3:30 ` Mike Frysinger
0 siblings, 0 replies; 2+ messages in thread
From: Mike Frysinger @ 2021-06-15 3:30 UTC (permalink / raw)
To: gdb-patches
Add conditional logic around fcntl.h F_{G,S}ETFL usage to fix builds
on systems that don't have it (e.g. Windows). The code is only used
to save & restore limited terminal stdin state.
---
sim/erc32/ChangeLog | 6 ++++++
sim/erc32/interf.c | 7 +++++--
sim/erc32/sis.c | 2 ++
3 files changed, 13 insertions(+), 2 deletions(-)
diff --git a/sim/erc32/ChangeLog b/sim/erc32/ChangeLog
index a5035d058f15..0a82427cb5f4 100644
--- a/sim/erc32/ChangeLog
+++ b/sim/erc32/ChangeLog
@@ -1,3 +1,9 @@
+2021-06-14 Mike Frysinger <vapier@gentoo.org>
+
+ * interf.c (sim_open) [F_GETFL]: Only set termsave.
+ (sim_close) [F_SETFL]: Only call fcntl.
+ * sis.c (main) [F_GETFL]: Only set termsave.
+
2021-06-14 Mike Frysinger <vapier@gentoo.org>
* erc32.c [HAVE_TERMIOS_H]: Include termios.h and declare ioc1,
diff --git a/sim/erc32/interf.c b/sim/erc32/interf.c
index 28c981bbb924..0cd655517630 100644
--- a/sim/erc32/interf.c
+++ b/sim/erc32/interf.c
@@ -241,7 +241,9 @@ sim_open (SIM_OPEN_KIND kind, struct host_callback_struct *callback,
}
sregs.freq = freq ? freq : 15;
+#ifdef F_GETFL
termsave = fcntl(0, F_GETFL, 0);
+#endif
INIT_DISASSEMBLE_INFO(dinfo, stdout,(fprintf_ftype)fprintf);
#ifdef HOST_LITTLE_ENDIAN
dinfo.endian = BFD_ENDIAN_LITTLE;
@@ -263,9 +265,10 @@ sim_close(SIM_DESC sd, int quitting)
{
exit_sim();
+#ifdef F_SETFL
fcntl(0, F_SETFL, termsave);
-
-};
+#endif
+}
SIM_RC
sim_load(SIM_DESC sd, const char *prog, bfd *abfd, int from_tty)
diff --git a/sim/erc32/sis.c b/sim/erc32/sis.c
index 749d25620b44..b49e5a606098 100644
--- a/sim/erc32/sis.c
+++ b/sim/erc32/sis.c
@@ -219,7 +219,9 @@ main(int argc, char **argv)
dinfo.endian = BFD_ENDIAN_BIG;
#endif
+#ifdef F_GETFL
termsave = fcntl(0, F_GETFL, 0);
+#endif
using_history();
init_signals();
ebase.simtime = 0;
--
2.31.1
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-06-15 3:30 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-15 3:30 [PATCH/committed 1/2] sim: erc32: fix build w/out termios.h Mike Frysinger
2021-06-15 3:30 ` [PATCH/committed 2/2] sim: erc32: fix build w/out F_{G,S}ETFL Mike Frysinger
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).