public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Mike Frysinger <vapier@gentoo.org>
To: gdb-patches@sourceware.org
Subject: [PATCH/committed 2/2] sim: erc32: fix build w/out F_{G,S}ETFL
Date: Mon, 14 Jun 2021 23:30:42 -0400	[thread overview]
Message-ID: <20210615033042.24482-2-vapier@gentoo.org> (raw)
In-Reply-To: <20210615033042.24482-1-vapier@gentoo.org>

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


      reply	other threads:[~2021-06-15  3:30 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210615033042.24482-2-vapier@gentoo.org \
    --to=vapier@gentoo.org \
    --cc=gdb-patches@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).