[glib] win32: work around broken winsock prototypes



commit aa1418c427ea904e22c9bfe812a569f4aee1e3f7
Author: Dan Winship <danw gnome org>
Date:   Sun Nov 11 13:05:16 2012 -0500

    win32: work around broken winsock prototypes
    
    Re-#define a few socket functions to work around winsock's prototypes
    having, eg, "int *" rather than "unsigned int *", or "char *" rather
    than "void *".
    
    (Also fix two places that mistakenly assumed guint==guint32.)
    
    https://bugzilla.gnome.org/show_bug.cgi?id=688109

 gio/gsocket.c |   18 ++++++++++++++++--
 1 files changed, 16 insertions(+), 2 deletions(-)
---
diff --git a/gio/gsocket.c b/gio/gsocket.c
index a2ebdcf..9074285 100644
--- a/gio/gsocket.c
+++ b/gio/gsocket.c
@@ -260,6 +260,20 @@ _win32_unset_event_mask (GSocket *socket, int mask)
 #define win32_unset_event_mask(_socket, _mask)
 #endif
 
+/* Windows has broken prototypes... */
+#ifdef G_OS_WIN32
+#define getsockopt(sockfd, level, optname, optval, optlen) \
+  getsockopt (sockfd, level, optname, (gpointer) optval, (int*) optlen)
+#define setsockopt(sockfd, level, optname, optval, optlen) \
+  setsockopt (sockfd, level, optname, (gpointer) optval, optlen)
+#define getsockname(sockfd, addr, addrlen) \
+  getsockname (sockfd, addr, (int *)addrlen)
+#define getpeername(sockfd, addr, addrlen) \
+  getpeername (sockfd, addr, (int *)addrlen)
+#define recv(sockfd, buf, len, flags) \
+  recv (sockfd, (gpointer)buf, len, flags)
+#endif
+
 static void
 set_fd_nonblocking (int fd)
 {
@@ -1731,7 +1745,7 @@ g_socket_get_local_address (GSocket  *socket,
 			    GError  **error)
 {
   struct sockaddr_storage buffer;
-  guint32 len = sizeof (buffer);
+  guint len = sizeof (buffer);
 
   g_return_val_if_fail (G_IS_SOCKET (socket), NULL);
 
@@ -1764,7 +1778,7 @@ g_socket_get_remote_address (GSocket  *socket,
 			     GError  **error)
 {
   struct sockaddr_storage buffer;
-  guint32 len = sizeof (buffer);
+  guint len = sizeof (buffer);
 
   g_return_val_if_fail (G_IS_SOCKET (socket), NULL);
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]