Prepare for gnulib update
authorPedro Alves <palves@redhat.com>
Mon, 24 Aug 2015 17:50:55 +0000 (18:50 +0100)
committerPedro Alves <palves@redhat.com>
Mon, 24 Aug 2015 17:50:55 +0000 (18:50 +0100)
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 <bruno@clisp.org>
 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  <palves@redhat.com>

* 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  <palves@redhat.com>

* debug.c: Include gdb_sys_time.h instead of sys/time.h.
* event-loop.c: Likewise.
* remote-utils.c: Likewise.
* tracepoint.c: Likewise.

24 files changed:
gdb/ChangeLog
gdb/Makefile.in
gdb/common/gdb_sys_time.h [new file with mode: 0644]
gdb/event-loop.c
gdb/gdb_select.h
gdb/gdb_usleep.c
gdb/gdbserver/ChangeLog
gdb/gdbserver/debug.c
gdb/gdbserver/event-loop.c
gdb/gdbserver/remote-utils.c
gdb/gdbserver/tracepoint.c
gdb/maint.c
gdb/mi/mi-main.c
gdb/mi/mi-parse.h
gdb/remote-fileio.c
gdb/remote-m32r-sdi.c
gdb/remote.c
gdb/ser-base.c
gdb/ser-pipe.c
gdb/ser-tcp.c
gdb/ser-unix.c
gdb/symfile.c
gdb/target-memory.c
gdb/utils.c

index ee9783aa6e1f2586ffaf77e2a6d465043c66fccd..02d1b15355989f90d71e13798c31933c28a4d856 100644 (file)
@@ -1,3 +1,25 @@
+2015-08-24  Pedro Alves  <palves@redhat.com>
+
+       * 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  <palves@redhat.com>
 
        * NEWS: Mention removed support for the various ROM monitors.
index 398ef6acd39f58c2560cbded9f48dd08d2c74c24..924979b92fbb0623558b92867f4101ba5e540a42 100644 (file)
@@ -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 (file)
index 0000000..0f764f8
--- /dev/null
@@ -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 <http://www.gnu.org/licenses/>.  */
+
+#ifndef GDB_SYS_TIME_H
+#define GDB_SYS_TIME_H
+
+#include <sys/time.h>
+
+/* 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 */
index 9ac49086f0c33fab4880a76c6773bb27d4c70e1c..df569be2c09453e39e036780ba0c542d0af98d28 100644 (file)
@@ -31,7 +31,7 @@
 #endif
 
 #include <sys/types.h>
-#include <sys/time.h>
+#include "gdb_sys_time.h"
 #include "gdb_select.h"
 #include "observer.h"
 
index b608f2a965161d968c60c2172ad173de76aa45c8..9748a13974f641f3b5fb9073aba7a2b40f181c05 100644 (file)
@@ -23,7 +23,7 @@
 #ifdef HAVE_SYS_SELECT_H
 #include <sys/select.h>
 #else
-#include <sys/time.h>
+#include "gdb_sys_time.h"
 #endif
 
 #ifdef USE_WIN32API
index 22ee6a08bacfab9821df96cd40a4f8403e2145e5..67e439625959be2f3f459bb9c73e38bb921695b8 100644 (file)
@@ -18,8 +18,7 @@
 #include "defs.h"
 #include "gdb_usleep.h"
 #include "gdb_select.h"
-
-#include <sys/time.h>
+#include "gdb_sys_time.h"
 
 int
 gdb_usleep (int usec)
index 12d8bb3aad91dcef041490ab7084d93eb543cbcf..017fd5d77d3c749cf60f6cef1667a8a9ddfe4279 100644 (file)
@@ -1,3 +1,10 @@
+2015-08-24  Pedro Alves  <palves@redhat.com>
+
+       * 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  <palves@redhat.com>
 
        * spu-low.c (spu_request_interrupt): Use lwpid_of instead of
index 1a1e3332d455af8288ff930974e6a8a6f6e8e5f9..5bbd38166217602c134fac2910ed80216d7b1e70 100644 (file)
@@ -17,7 +17,7 @@
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
 #include "server.h"
-#include <sys/time.h>
+#include "gdb_sys_time.h"
 
 /* Enable miscellaneous debugging output.  The name is historical - it
    was originally used to debug LinuxThreads support.  */
index d1825aeb022f5f50ef540ff161909a001b8eded2..d27bc94ee95d1066096046aa9625f2129f747dfc 100644 (file)
@@ -22,7 +22,7 @@
 #include "queue.h"
 
 #include <sys/types.h>
-#include <sys/time.h>
+#include "gdb_sys_time.h"
 
 #ifdef USE_WIN32API
 #include <windows.h>
index 05563bea7e6e4f4139d3f5b35596482d9f90e5e5..586ced80a242426dc2757f831b62d08255572bd8 100644 (file)
@@ -51,7 +51,7 @@
 #if HAVE_FCNTL_H
 #include <fcntl.h>
 #endif
-#include <sys/time.h>
+#include "gdb_sys_time.h"
 #include <unistd.h>
 #if HAVE_ARPA_INET_H
 #include <arpa/inet.h>
index 4455084e7e10f0bc6b14a263f81c6ec13258857a..5d0ed73b19009dfd525d5a95e378e5b0cc21d3d9 100644 (file)
@@ -25,7 +25,7 @@
 #include <ctype.h>
 #include <fcntl.h>
 #include <unistd.h>
-#include <sys/time.h>
+#include "gdb_sys_time.h"
 #include <inttypes.h>
 #include "ax.h"
 #include "tdesc.h"
index 1adea2f9e933757de5d30285d694a8b1d7f2fc12..5d7fca50f1c875a3beab748bc20e4dfcc478779d 100644 (file)
@@ -24,7 +24,7 @@
 #include "arch-utils.h"
 #include <ctype.h>
 #include <signal.h>
-#include <sys/time.h>
+#include "gdb_sys_time.h"
 #include <time.h>
 #include "command.h"
 #include "gdbcmd.h"
index b2513a1f7dd0815a5d9a07943aea435ff55b7d76..3fa1bd6f26515251ee55e8c9ac4c19d0bd163394 100644 (file)
@@ -55,7 +55,7 @@
 #include "gdbcmd.h"
 
 #include <ctype.h>
-#include <sys/time.h>
+#include "gdb_sys_time.h"
 
 #if defined HAVE_SYS_RESOURCE_H
 #include <sys/resource.h>
index 4c10f9255316c47cc04390397ba75aa4d66db171..5900a6f4e2ee596dcc2cfad1a7c2ad57ae5defa2 100644 (file)
@@ -20,7 +20,7 @@
 #ifndef MI_PARSE_H
 #define MI_PARSE_H
 
-#include <sys/time.h>
+#include "gdb_sys_time.h"
 
 /* MI parser */
 
index a33acf91ef6c3d60c89807b24a9e85700796a087..6569822c7f6cca00882b8b9525cdfffb5b02379f 100644 (file)
@@ -31,7 +31,7 @@
 #include "filestuff.h"
 
 #include <fcntl.h>
-#include <sys/time.h>
+#include "gdb_sys_time.h"
 #ifdef __CYGWIN__
 #include <sys/cygwin.h>                /* For cygwin_conv_path.  */
 #endif
index 119bb6e594da55951a290fb70325a5abdc77bc85..bb07e4e971fd96e1aea0a7adbd3bc848db6bc8c6 100644 (file)
@@ -36,7 +36,7 @@
 #include <netinet/in.h>
 #endif
 #include <sys/types.h>
-#include <sys/time.h>
+#include "gdb_sys_time.h"
 #include <time.h>
 #include "gdb_bfd.h"
 #include "cli/cli-utils.h"
index 12294bc1c1d20f0d44f71ba55ab31d5107f7b4ff..48a4f7d894c2cb3476e15b41fa46083cba89e8b4 100644 (file)
@@ -47,7 +47,7 @@
 #include "disasm.h"
 #include "location.h"
 
-#include <sys/time.h>
+#include "gdb_sys_time.h"
 
 #include "event-loop.h"
 #include "event-top.h"
index 09aaceca0300030c5c0cbeb9ce22525f8415f6e4..2f12125df65dcd178314cf4818021f3341640e5f 100644 (file)
@@ -23,7 +23,7 @@
 #include "event-loop.h"
 
 #include "gdb_select.h"
-#include <sys/time.h>
+#include "gdb_sys_time.h"
 #ifdef USE_WIN32API
 #include <winsock2.h>
 #endif
index 07001326afcbc056fd1499d9f18b7a4f1b795336..1e777b7e4f6ee7fa8745f7ca4fb94901cde27797 100644 (file)
@@ -27,7 +27,7 @@
 
 #include <sys/types.h>
 #include <sys/socket.h>
-#include <sys/time.h>
+#include "gdb_sys_time.h"
 #include <fcntl.h>
 #include "filestuff.h"
 
index 35512e676e06a01bf5ec9407b8ffe44abe0ba32f..485ed6c082d78df0f9f49e7e34f563f592a55a80 100644 (file)
@@ -35,7 +35,7 @@
 #include <sys/ioctl.h>  /* For FIONBIO.  */
 #endif
 
-#include <sys/time.h>
+#include "gdb_sys_time.h"
 
 #ifdef USE_WIN32API
 #include <winsock2.h>
index 356e5e7d1a29ec8c09e799eb61f538f0bad89762..f2d9ca607c0a105d4f9a19b4e28b8df53b161385 100644 (file)
@@ -26,7 +26,7 @@
 #include <sys/types.h>
 #include "terminal.h"
 #include <sys/socket.h>
-#include <sys/time.h>
+#include "gdb_sys_time.h"
 
 #include "gdb_select.h"
 #include "gdbcmd.h"
index 856572a747c0dc0c76d7caab8df89409d2774bc1..0b57c286cc784872d391f948b7ec2ec0202329fb 100644 (file)
@@ -62,7 +62,7 @@
 #include <sys/stat.h>
 #include <ctype.h>
 #include <time.h>
-#include <sys/time.h>
+#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.  */
index 5e5b1d7d02731a118d65342057a35b6b8f6843e8..177deb6ef3681e926645f78db4b04c435c969cec 100644 (file)
@@ -23,7 +23,7 @@
 #include "target.h"
 #include "memory-map.h"
 
-#include <sys/time.h>
+#include "gdb_sys_time.h"
 
 static int
 compare_block_starting_address (const void *a, const void *b)
index e5ad19586eac5f5e01bd4db64b4d0700a4aef439..a3c707658a942fdc8d44a7b25e110ac1f7c7f08c 100644 (file)
@@ -62,7 +62,7 @@
 
 #include "readline/readline.h"
 
-#include <sys/time.h>
+#include "gdb_sys_time.h"
 #include <time.h>
 
 #include "gdb_usleep.h"