From: Pedro Alves Date: Mon, 24 Aug 2015 17:50:55 +0000 (+0100) Subject: Prepare for gnulib update X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=438e1e427e8393de73d22617abe4d8eba0270e72;p=binutils-gdb.git Prepare for gnulib update After the last gnulib import (Dec 2012), gnulib upstream started replacing mingw's 'struct timeval' with a version with 64-bit time_t, for POSIX compliance: commit f8e84098084b3b53bc6943a5542af1f607ffd477 Author: Bruno Haible Date: Sat Jan 28 18:12:10 2012 +0100 sys_time: Override 'struct timeval' on some native Windows platforms. See: https://lists.gnu.org/archive/html/bug-gnulib/2012-01/msg00372.html However, that results in conflicts with native Winsock2's 'select': select()'s argument http://sourceforge.net/p/mingw-w64/mailman/message/29610438/ ... and libiberty's timeval-utils.h timeval_add/timeval_sub, at the least. We don't really need the POSIX compliance, so this patch prepares us to simply not use gnulib's 'struct timeval' replacement once a more recent gnulib is imported, thus preserving the current behavior, by adding a sys/time.h wrapper header that undefs gnulib's replacements, and including that everywhere instead. The SIZE -> OSIZE change is necessary because newer gnulib's sys/time.h also includes windows.h/winsock2.h, which defines a conflicting SIZE symbol. Cross build-tested mingw-w64 32-bit and 64-bit. Regtested on x86_64 Fedora 20. gdb/ChangeLog: 2015-08-24 Pedro Alves * Makefile.in (HFILES_NO_SRCDIR): Add common/gdb_sys_time.h. * common/gdb_sys_time.h: New file. * event-loop.c: Include gdb_sys_time.h instead of sys/time.h. * gdb_select.h: Likewise. * gdb_usleep.c: Likewise. * maint.c: Likewise. * mi/mi-main.c: Likewise. * mi/mi-parse.h: Likewise. * remote-fileio.c: Likewise. * remote-m32r-sdi.c: Likewise. * remote.c: Likewise. * ser-base.c: Likewise. * ser-pipe.c: Likewise. * ser-tcp.c: Likewise. * ser-unix.c: Likewise. * symfile.c: Likewise. * symfile.c: Likewise. Rename OSIZE to SIZE throughout. * target-memory.c: Include gdb_sys_time.h instead of sys/time.h. * utils.c: Likewise. gdb/gdbserver/ChangeLog: 2015-08-24 Pedro Alves * debug.c: Include gdb_sys_time.h instead of sys/time.h. * event-loop.c: Likewise. * remote-utils.c: Likewise. * tracepoint.c: Likewise. --- diff --git a/gdb/ChangeLog b/gdb/ChangeLog index ee9783aa6e1..02d1b153559 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,25 @@ +2015-08-24 Pedro Alves + + * Makefile.in (HFILES_NO_SRCDIR): Add common/gdb_sys_time.h. + * common/gdb_sys_time.h: New file. + * event-loop.c: Include gdb_sys_time.h instead of sys/time.h. + * gdb_select.h: Likewise. + * gdb_usleep.c: Likewise. + * maint.c: Likewise. + * mi/mi-main.c: Likewise. + * mi/mi-parse.h: Likewise. + * remote-fileio.c: Likewise. + * remote-m32r-sdi.c: Likewise. + * remote.c: Likewise. + * ser-base.c: Likewise. + * ser-pipe.c: Likewise. + * ser-tcp.c: Likewise. + * ser-unix.c: Likewise. + * symfile.c: Likewise. + * symfile.c: Likewise. Rename OSIZE to SIZE throughout. + * target-memory.c: Include gdb_sys_time.h instead of sys/time.h. + * utils.c: Likewise. + 2015-08-24 Pedro Alves * NEWS: Mention removed support for the various ROM monitors. diff --git a/gdb/Makefile.in b/gdb/Makefile.in index 398ef6acd39..924979b92fb 100644 --- a/gdb/Makefile.in +++ b/gdb/Makefile.in @@ -986,7 +986,7 @@ common/common-debug.h common/cleanups.h common/gdb_setjmp.h \ common/common-exceptions.h target/target.h common/symbol.h \ common/common-regcache.h fbsd-tdep.h nat/linux-personality.h \ common/fileio.h nat/x86-linux.h nat/x86-linux-dregs.h \ -nat/linux-namespaces.h arch/arm.h +nat/linux-namespaces.h arch/arm.h common/gdb_sys_time.h # Header files that already have srcdir in them, or which are in objdir. diff --git a/gdb/common/gdb_sys_time.h b/gdb/common/gdb_sys_time.h new file mode 100644 index 00000000000..0f764f888b1 --- /dev/null +++ b/gdb/common/gdb_sys_time.h @@ -0,0 +1,38 @@ +/* Copyright (C) 2015 Free Software Foundation, Inc. + + This file is part of GDB. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +#ifndef GDB_SYS_TIME_H +#define GDB_SYS_TIME_H + +#include + +/* On MinGW-w64, gnulib's sys/time.h replaces 'struct timeval' and + gettimeofday with versions that support 64-bit time_t, for POSIX + compliance. However, the gettimeofday replacement does not ever + return time_t values larger than 31-bit, as it simply returns the + system's gettimeofday's (signed) 32-bit result as (signed) 64-bit. + Because we don't really need the POSIX compliance, and it ends up + causing conflicts with other libraries we use that don't use gnulib + and thus work with the native struct timeval, such as Winsock2's + native 'select' and libiberty, simply undefine away gnulib's + replacements. */ +#if GNULIB_defined_struct_timeval +# undef timeval +# undef gettimeofday +#endif + +#endif /* #ifndef GDB_SYS_TIME_H */ diff --git a/gdb/event-loop.c b/gdb/event-loop.c index 9ac49086f0c..df569be2c09 100644 --- a/gdb/event-loop.c +++ b/gdb/event-loop.c @@ -31,7 +31,7 @@ #endif #include -#include +#include "gdb_sys_time.h" #include "gdb_select.h" #include "observer.h" diff --git a/gdb/gdb_select.h b/gdb/gdb_select.h index b608f2a9651..9748a13974f 100644 --- a/gdb/gdb_select.h +++ b/gdb/gdb_select.h @@ -23,7 +23,7 @@ #ifdef HAVE_SYS_SELECT_H #include #else -#include +#include "gdb_sys_time.h" #endif #ifdef USE_WIN32API diff --git a/gdb/gdb_usleep.c b/gdb/gdb_usleep.c index 22ee6a08bac..67e43962595 100644 --- a/gdb/gdb_usleep.c +++ b/gdb/gdb_usleep.c @@ -18,8 +18,7 @@ #include "defs.h" #include "gdb_usleep.h" #include "gdb_select.h" - -#include +#include "gdb_sys_time.h" int gdb_usleep (int usec) diff --git a/gdb/gdbserver/ChangeLog b/gdb/gdbserver/ChangeLog index 12d8bb3aad9..017fd5d77d3 100644 --- a/gdb/gdbserver/ChangeLog +++ b/gdb/gdbserver/ChangeLog @@ -1,3 +1,10 @@ +2015-08-24 Pedro Alves + + * debug.c: Include gdb_sys_time.h instead of sys/time.h. + * event-loop.c: Likewise. + * remote-utils.c: Likewise. + * tracepoint.c: Likewise. + 2015-08-24 Pedro Alves * spu-low.c (spu_request_interrupt): Use lwpid_of instead of diff --git a/gdb/gdbserver/debug.c b/gdb/gdbserver/debug.c index 1a1e3332d45..5bbd3816621 100644 --- a/gdb/gdbserver/debug.c +++ b/gdb/gdbserver/debug.c @@ -17,7 +17,7 @@ along with this program. If not, see . */ #include "server.h" -#include +#include "gdb_sys_time.h" /* Enable miscellaneous debugging output. The name is historical - it was originally used to debug LinuxThreads support. */ diff --git a/gdb/gdbserver/event-loop.c b/gdb/gdbserver/event-loop.c index d1825aeb022..d27bc94ee95 100644 --- a/gdb/gdbserver/event-loop.c +++ b/gdb/gdbserver/event-loop.c @@ -22,7 +22,7 @@ #include "queue.h" #include -#include +#include "gdb_sys_time.h" #ifdef USE_WIN32API #include diff --git a/gdb/gdbserver/remote-utils.c b/gdb/gdbserver/remote-utils.c index 05563bea7e6..586ced80a24 100644 --- a/gdb/gdbserver/remote-utils.c +++ b/gdb/gdbserver/remote-utils.c @@ -51,7 +51,7 @@ #if HAVE_FCNTL_H #include #endif -#include +#include "gdb_sys_time.h" #include #if HAVE_ARPA_INET_H #include diff --git a/gdb/gdbserver/tracepoint.c b/gdb/gdbserver/tracepoint.c index 4455084e7e1..5d0ed73b190 100644 --- a/gdb/gdbserver/tracepoint.c +++ b/gdb/gdbserver/tracepoint.c @@ -25,7 +25,7 @@ #include #include #include -#include +#include "gdb_sys_time.h" #include #include "ax.h" #include "tdesc.h" diff --git a/gdb/maint.c b/gdb/maint.c index 1adea2f9e93..5d7fca50f1c 100644 --- a/gdb/maint.c +++ b/gdb/maint.c @@ -24,7 +24,7 @@ #include "arch-utils.h" #include #include -#include +#include "gdb_sys_time.h" #include #include "command.h" #include "gdbcmd.h" diff --git a/gdb/mi/mi-main.c b/gdb/mi/mi-main.c index b2513a1f7dd..3fa1bd6f265 100644 --- a/gdb/mi/mi-main.c +++ b/gdb/mi/mi-main.c @@ -55,7 +55,7 @@ #include "gdbcmd.h" #include -#include +#include "gdb_sys_time.h" #if defined HAVE_SYS_RESOURCE_H #include diff --git a/gdb/mi/mi-parse.h b/gdb/mi/mi-parse.h index 4c10f925531..5900a6f4e2e 100644 --- a/gdb/mi/mi-parse.h +++ b/gdb/mi/mi-parse.h @@ -20,7 +20,7 @@ #ifndef MI_PARSE_H #define MI_PARSE_H -#include +#include "gdb_sys_time.h" /* MI parser */ diff --git a/gdb/remote-fileio.c b/gdb/remote-fileio.c index a33acf91ef6..6569822c7f6 100644 --- a/gdb/remote-fileio.c +++ b/gdb/remote-fileio.c @@ -31,7 +31,7 @@ #include "filestuff.h" #include -#include +#include "gdb_sys_time.h" #ifdef __CYGWIN__ #include /* For cygwin_conv_path. */ #endif diff --git a/gdb/remote-m32r-sdi.c b/gdb/remote-m32r-sdi.c index 119bb6e594d..bb07e4e971f 100644 --- a/gdb/remote-m32r-sdi.c +++ b/gdb/remote-m32r-sdi.c @@ -36,7 +36,7 @@ #include #endif #include -#include +#include "gdb_sys_time.h" #include #include "gdb_bfd.h" #include "cli/cli-utils.h" diff --git a/gdb/remote.c b/gdb/remote.c index 12294bc1c1d..48a4f7d894c 100644 --- a/gdb/remote.c +++ b/gdb/remote.c @@ -47,7 +47,7 @@ #include "disasm.h" #include "location.h" -#include +#include "gdb_sys_time.h" #include "event-loop.h" #include "event-top.h" diff --git a/gdb/ser-base.c b/gdb/ser-base.c index 09aaceca030..2f12125df65 100644 --- a/gdb/ser-base.c +++ b/gdb/ser-base.c @@ -23,7 +23,7 @@ #include "event-loop.h" #include "gdb_select.h" -#include +#include "gdb_sys_time.h" #ifdef USE_WIN32API #include #endif diff --git a/gdb/ser-pipe.c b/gdb/ser-pipe.c index 07001326afc..1e777b7e4f6 100644 --- a/gdb/ser-pipe.c +++ b/gdb/ser-pipe.c @@ -27,7 +27,7 @@ #include #include -#include +#include "gdb_sys_time.h" #include #include "filestuff.h" diff --git a/gdb/ser-tcp.c b/gdb/ser-tcp.c index 35512e676e0..485ed6c082d 100644 --- a/gdb/ser-tcp.c +++ b/gdb/ser-tcp.c @@ -35,7 +35,7 @@ #include /* For FIONBIO. */ #endif -#include +#include "gdb_sys_time.h" #ifdef USE_WIN32API #include diff --git a/gdb/ser-unix.c b/gdb/ser-unix.c index 356e5e7d1a2..f2d9ca607c0 100644 --- a/gdb/ser-unix.c +++ b/gdb/ser-unix.c @@ -26,7 +26,7 @@ #include #include "terminal.h" #include -#include +#include "gdb_sys_time.h" #include "gdb_select.h" #include "gdbcmd.h" diff --git a/gdb/symfile.c b/gdb/symfile.c index 856572a747c..0b57c286cc7 100644 --- a/gdb/symfile.c +++ b/gdb/symfile.c @@ -62,7 +62,7 @@ #include #include #include -#include +#include "gdb_sys_time.h" #include "psymtab.h" @@ -3518,12 +3518,12 @@ overlay_command (char *args, int from_tty) In this simple implementation, the target data structures are as follows: unsigned _novlys; /# number of overlay sections #/ unsigned _ovly_table[_novlys][4] = { - {VMA, SIZE, LMA, MAPPED}, /# one entry per overlay section #/ + {VMA, OSIZE, LMA, MAPPED}, /# one entry per overlay section #/ {..., ..., ..., ...}, } unsigned _novly_regions; /# number of overlay regions #/ unsigned _ovly_region_table[_novly_regions][3] = { - {VMA, SIZE, MAPPED_TO_LMA}, /# one entry per overlay region #/ + {VMA, OSIZE, MAPPED_TO_LMA}, /# one entry per overlay region #/ {..., ..., ...}, } These functions will attempt to update GDB's mappedness state in the @@ -3541,7 +3541,7 @@ static unsigned cache_novlys = 0; static CORE_ADDR cache_ovly_table_base = 0; enum ovly_index { - VMA, SIZE, LMA, MAPPED + VMA, OSIZE, LMA, MAPPED }; /* Throw away the cached copy of _ovly_table. */ @@ -3641,14 +3641,14 @@ simple_overlay_update_1 (struct obj_section *osect) for (i = 0; i < cache_novlys; i++) if (cache_ovly_table[i][VMA] == bfd_section_vma (obfd, bsect) && cache_ovly_table[i][LMA] == bfd_section_lma (obfd, bsect) - /* && cache_ovly_table[i][SIZE] == size */ ) + /* && cache_ovly_table[i][OSIZE] == size */ ) { read_target_long_array (cache_ovly_table_base + i * word_size, (unsigned int *) cache_ovly_table[i], 4, word_size, byte_order); if (cache_ovly_table[i][VMA] == bfd_section_vma (obfd, bsect) && cache_ovly_table[i][LMA] == bfd_section_lma (obfd, bsect) - /* && cache_ovly_table[i][SIZE] == size */ ) + /* && cache_ovly_table[i][OSIZE] == size */ ) { osect->ovly_mapped = cache_ovly_table[i][MAPPED]; return 1; @@ -3714,7 +3714,7 @@ simple_overlay_update (struct obj_section *osect) for (i = 0; i < cache_novlys; i++) if (cache_ovly_table[i][VMA] == bfd_section_vma (obfd, bsect) && cache_ovly_table[i][LMA] == bfd_section_lma (obfd, bsect) - /* && cache_ovly_table[i][SIZE] == size */ ) + /* && cache_ovly_table[i][OSIZE] == size */ ) { /* obj_section matches i'th entry in ovly_table. */ osect->ovly_mapped = cache_ovly_table[i][MAPPED]; break; /* finished with inner for loop: break out. */ diff --git a/gdb/target-memory.c b/gdb/target-memory.c index 5e5b1d7d027..177deb6ef36 100644 --- a/gdb/target-memory.c +++ b/gdb/target-memory.c @@ -23,7 +23,7 @@ #include "target.h" #include "memory-map.h" -#include +#include "gdb_sys_time.h" static int compare_block_starting_address (const void *a, const void *b) diff --git a/gdb/utils.c b/gdb/utils.c index e5ad19586ea..a3c707658a9 100644 --- a/gdb/utils.c +++ b/gdb/utils.c @@ -62,7 +62,7 @@ #include "readline/readline.h" -#include +#include "gdb_sys_time.h" #include #include "gdb_usleep.h"