diff options
author | Tsukasa OI <research_trasio@irq.a4lg.com> | 2022-10-17 15:47:23 +0000 |
---|---|---|
committer | Tsukasa OI <research_trasio@irq.a4lg.com> | 2022-10-29 05:39:52 +0000 |
commit | dd6c5a9217002033149a92bc48999370c451d025 (patch) | |
tree | ba00985e941bb4100b9ece07769148e0eb77ea57 /sim/m32c/main.c | |
parent | bb94ac4f95dd11c87d84eea533fe4f3218a48583 (diff) | |
download | gdb-dd6c5a9217002033149a92bc48999370c451d025.zip gdb-dd6c5a9217002033149a92bc48999370c451d025.tar.gz gdb-dd6c5a9217002033149a92bc48999370c451d025.tar.bz2 |
sim, sim/{m32c,ppc,rl78}: Use getopt_long
Because of a Libiberty hack, getopt on GNU libc (2.25 or earlier) is
currently unusable on sim, causing a regression on CentOS 7.
This is caused as follows:
1. If HAVE_DECL_GETOPT is defined (getopt declaration with known prototype
is detected while configuration), a declaration of getopt in
"include/getopt.h" is suppressed.
The author started to define HAVE_DECL_GETOPT in sim with the commit
340aa4f6872c ("sim: Check known getopt definition existence").
2. GNU libc (2.25 or earlier)'s <unistd.h> includes <getopt.h> with a
special purpose macro defined to declare only getopt function but due
to include path (not tested while configuration), it causes <unistd.h>
to include Libiberty's "include/getopt.h".
3. If both 1. and 2. are satisfied, despite that <unistd.h> tries to
declare getopt by including <getopt.h>, "include/getopt.h" does not do
so, causing getopt function undeclared.
Getting rid of "include/getopt.h" (e.g. renaming this header file) is the
best solution to avoid hacking but as a short-term solution, this commit
replaces getopt with getopt_long under sim/.
Diffstat (limited to 'sim/m32c/main.c')
-rw-r--r-- | sim/m32c/main.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/sim/m32c/main.c b/sim/m32c/main.c index 958ca27..5ed912a 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 + static const struct option 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", longopts, NULL)) + != -1) switch (o) { case 't': |