From patchwork Tue Oct 18 17:13:41 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tsukasa OI X-Patchwork-Id: 59010 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id EF49E38582BE for ; Tue, 18 Oct 2022 17:14:14 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org EF49E38582BE DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1666113255; bh=mm9ucS3sVlHNijU5FWohP++znQpcF8tGHm5qXqKQAGg=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=dt4YWI2rK6iLlKKs2MDqZ54tx4mvSV0VuPEiyL/F8hvyIfuCySxKbsbEUC9ge88ew pVhmYzYmLLwhnw0Q6OGtZqZmP+EeIEn2zAJIVnhg99HUCkQV+4e6vkd4huOoIXpXAo tqUZuZHxDCAEwG4GapFLAx955bkqVqzAxm2S1LBM= X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from mail-sender-0.a4lg.com (mail-sender-0.a4lg.com [IPv6:2401:2500:203:30b:4000:6bfe:4757:0]) by sourceware.org (Postfix) with ESMTPS id E69353858D32 for ; Tue, 18 Oct 2022 17:13:51 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org E69353858D32 Received: from [127.0.0.1] (localhost [127.0.0.1]) by mail-sender-0.a4lg.com (Postfix) with ESMTPSA id 2DDF1300089; Tue, 18 Oct 2022 17:13:50 +0000 (UTC) To: Tsukasa OI , Tom de Vries , Andrew Burgess , Mike Frysinger Subject: [PATCH] sim, sim/m32c, sim/rl78: Use getopt_long Date: Tue, 18 Oct 2022 17:13:41 +0000 Message-Id: <24e83e920d728237c4efe6f4720643d6fbbf1084.1666113214.git.research_trasio@irq.a4lg.com> In-Reply-To: <3b7e769f-b5e9-4049-786f-d00d997f0280@irq.a4lg.com> References: <3b7e769f-b5e9-4049-786f-d00d997f0280@irq.a4lg.com> Mime-Version: 1.0 X-Spam-Status: No, score=-12.0 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, GIT_PATCH_0, KAM_SHORT, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Tsukasa OI via Gdb-patches From: Tsukasa OI Reply-To: Tsukasa OI Cc: gdb-patches@sourceware.org Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org Sender: "Gdb-patches" 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(-) base-commit: 04ea6b63141c43d9e96999e16917358088556fdd 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 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 . */ #include #include #include +#include #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) {