[binutils-gdb] Declare 'ioarg' (from ser-tcp.c:try_connect) as 'u_long' when on Windows (and unbreak build on mingw

Sergio Durigan Junior sergiodj@sourceware.org
Thu Jul 12 17:12:00 GMT 2018


https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=64b5847236593f23564bd37afb0ea503f751165c

commit 64b5847236593f23564bd37afb0ea503f751165c
Author: Sergio Durigan Junior <sergiodj@redhat.com>
Date:   Thu Jul 12 13:03:31 2018 -0400

    Declare 'ioarg' (from ser-tcp.c:try_connect) as 'u_long' when on Windows (and unbreak build on mingw32)
    
    When building GDB on mingw32, it fails with:
    
      ../../binutils-gdb/gdb/ser-tcp.c: In function 'int try_connect(const addrinfo*, unsigned int*)':
      ../../binutils-gdb/gdb/ser-tcp.c:176:25: error: invalid conversion from 'int*' to 'u_long* {aka long unsigned int*}' [-fpermissive]
         ioctl (sock, FIONBIO, &ioarg);
    			   ^~~~~~
      In file included from ../../binutils-gdb/gdb/serial.h:23:0,
    		   from ../../binutils-gdb/gdb/ser-tcp.c:21:
      /usr/x86_64-w64-mingw32/sys-root/mingw/include/winsock2.h:977:34: note:   initializing argument 3 of 'int ioctlsocket(SOCKET, long int, u_long*)'
         WINSOCK_API_LINKAGE int WSAAPI ioctlsocket(SOCKET s,__LONG32 cmd,u_long *argp);
    				    ^~~~~~~~~~~
      make[2]: *** [Makefile:1610: ser-tcp.o] Error 1
    
    The problem happens because the IPv6
    commit (c7ab0aef11d91b637bf091aa9176b8dc4aadee46) wrongly removed the
    code responsible for declaring 'ioarg' with a different type if
    building for Windows.  This patch restores that.
    
    gdb/ChangeLog:
    2018-07-12  Sergio Durigan Junior  <sergiodj@redhat.com>
    
    	* ser-tcp.c (try_connect): Declare 'ioarg' as 'u_long' if building
    	on Windows.

Diff:
---
 gdb/ChangeLog | 5 +++++
 gdb/ser-tcp.c | 4 ++++
 2 files changed, 9 insertions(+)

diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 933a04e..1a37862 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,8 @@
+2018-07-12  Sergio Durigan Junior  <sergiodj@redhat.com>
+
+	* ser-tcp.c (try_connect): Declare 'ioarg' as 'u_long' if building
+	on Windows.
+
 2018-07-11  Sergio Durigan Junior  <sergiodj@redhat.com>
 	    Jan Kratochvil  <jan.kratochvil@redhat.com>
 	    Paul Fertser  <fercerpav@gmail.com>
diff --git a/gdb/ser-tcp.c b/gdb/ser-tcp.c
index 8f165bc..618d2d9 100644
--- a/gdb/ser-tcp.c
+++ b/gdb/ser-tcp.c
@@ -171,7 +171,11 @@ try_connect (const struct addrinfo *ainfo, unsigned int *polls)
     return -1;
 
   /* Set socket nonblocking.  */
+#ifdef USE_WIN32API
+  u_long ioarg = 1;
+#else
   int ioarg = 1;
+#endif
 
   ioctl (sock, FIONBIO, &ioarg);



More information about the Gdb-cvs mailing list