public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Tsukasa OI <research_trasio@irq.a4lg.com>
To: Tsukasa OI <research_trasio@irq.a4lg.com>,
	Tom de Vries <tdevries@suse.de>,
	Andrew Burgess <aburgess@redhat.com>,
	Mike Frysinger <vapier@gentoo.org>
Cc: gdb-patches@sourceware.org
Subject: [PATCH] sim, sim/m32c, sim/rl78: Use getopt_long
Date: Tue, 18 Oct 2022 17:13:41 +0000	[thread overview]
Message-ID: <24e83e920d728237c4efe6f4720643d6fbbf1084.1666113214.git.research_trasio@irq.a4lg.com> (raw)
In-Reply-To: <3b7e769f-b5e9-4049-786f-d00d997f0280@irq.a4lg.com>

Because of Binutils/GCC hack, getopt on GNU libc (2.25 or before) is
currently unusable on sim, causing a regression on CentOS 7.  Getting rid of
include/getopt.h is the best solution to avoid hacking but as a short-term
solution, this commit replaces calls to getopt to call getopt_long.
---
 sim/igen/igen.c | 6 ++++--
 sim/m32c/main.c | 5 ++++-
 sim/rl78/main.c | 4 +++-
 3 files changed, 11 insertions(+), 4 deletions(-)

diff --git a/sim/igen/igen.c b/sim/igen/igen.c
index ba856401fa9..22cfd30ec43 100644
--- a/sim/igen/igen.c
+++ b/sim/igen/igen.c
@@ -989,6 +989,7 @@ main (int argc, char **argv, char **envp)
   char *real_file_name = NULL;
   int is_header = 0;
   int ch;
+  struct option dummy_longopts = { 0 };
   lf *standard_out =
     lf_open ("-", "stdout", lf_omit_references, lf_is_text, "igen");
 
@@ -1162,8 +1163,9 @@ main (int argc, char **argv, char **envp)
       printf ("  -t <output-file>      output itable\n");
     }
 
-  while ((ch = getopt (argc, argv,
-		       "B:D:F:G:H:I:M:N:P:T:W:o:k:i:n:hc:d:e:m:r:s:t:f:x"))
+  while ((ch = getopt_long (argc, argv,
+			    "B:D:F:G:H:I:M:N:P:T:W:o:k:i:n:hc:d:e:m:r:s:t:f:x",
+			    &dummy_longopts, NULL))
 	 != -1)
     {
 #if 0  /* For debugging.  */
diff --git a/sim/m32c/main.c b/sim/m32c/main.c
index 958ca27ab2b..5560adea60a 100644
--- a/sim/m32c/main.c
+++ b/sim/m32c/main.c
@@ -29,6 +29,7 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 #include <setjmp.h>
 #include <signal.h>
 #include <sys/types.h>
+#include <getopt.h>
 
 #ifdef HAVE_SYS_SOCKET_H
 #ifdef HAVE_NETINET_IN_H
@@ -135,12 +136,14 @@ main (int argc, char **argv)
 #ifdef HAVE_networking
   char *console_port_s = 0;
 #endif
+  struct option dummy_longopts = { 0 };
 
   setbuf (stdout, 0);
 
   in_gdb = 0;
 
-  while ((o = getopt (argc, argv, "tc:vdm:C")) != -1)
+  while ((o = getopt_long (argc, argv, "tc:vdm:C", &dummy_longopts, NULL))
+	 != -1)
     switch (o)
       {
       case 't':
diff --git a/sim/rl78/main.c b/sim/rl78/main.c
index c9459c7bc78..436f370a338 100644
--- a/sim/rl78/main.c
+++ b/sim/rl78/main.c
@@ -64,10 +64,12 @@ main (int argc, char **argv)
   int save_trace;
   bfd *prog;
   int rc;
+  struct option dummy_longopts = { 0 };
 
   xmalloc_set_program_name (argv[0]);
 
-  while ((o = getopt (argc, argv, "tvdr:D:M:")) != -1)
+  while ((o = getopt_long (argc, argv, "tvdr:D:M:", &dummy_longopts, NULL))
+	 != -1)
     {
       switch (o)
 	{

base-commit: 04ea6b63141c43d9e96999e16917358088556fdd
-- 
2.34.1


       reply	other threads:[~2022-10-18 17:13 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <3b7e769f-b5e9-4049-786f-d00d997f0280@irq.a4lg.com>
2022-10-18 17:13 ` Tsukasa OI [this message]
2022-10-21 16:27   ` Tom Tromey
2022-10-24  7:51     ` Tsukasa OI
2022-10-25  5:53       ` Tsukasa OI
2022-10-25 16:54       ` Tom Tromey
2022-10-25 17:17         ` Tsukasa OI
2022-10-25 19:42           ` Tom Tromey
2022-10-25  6:27   ` [PATCH v2] sim, sim/{m32c,ppc,rl78}: " Tsukasa OI
2022-10-26  8:59     ` Mike Frysinger
2022-10-26 10:57       ` Tsukasa OI
2022-10-26 16:01         ` Mike Frysinger
2022-10-27  1:29           ` Tsukasa OI
2022-10-26 10:59     ` [PATCH v3] " Tsukasa OI
2022-10-27  1:23       ` [PATCH v4] " Tsukasa OI

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=24e83e920d728237c4efe6f4720643d6fbbf1084.1666113214.git.research_trasio@irq.a4lg.com \
    --to=research_trasio@irq.a4lg.com \
    --cc=aburgess@redhat.com \
    --cc=gdb-patches@sourceware.org \
    --cc=tdevries@suse.de \
    --cc=vapier@gentoo.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).