[xiph-cvs] cvs commit: timing timing.c

Brendan brendan at xiph.org
Sun Oct 19 20:08:46 PDT 2003



brendan     03/10/19 23:08:46

  Modified:    .        xiph_net.m4
               src      util.c
               .        sock.c sock.h
               .        timing.c
  Log:
  Leigh Smith's MINGW32 compatibility patch, with modifications for better
  autoconf feng shui

Revision  Changes    Path
1.3       +3 -0      m4/xiph_net.m4

Index: xiph_net.m4
===================================================================
RCS file: /usr/local/cvsroot/m4/xiph_net.m4,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -p -u -r1.2 -r1.3
--- xiph_net.m4	7 Jul 2003 03:40:00 -0000	1.2
+++ xiph_net.m4	20 Oct 2003 03:08:45 -0000	1.3
@@ -5,6 +5,9 @@ AC_DEFUN([XIPH_NET],
 AC_REQUIRE([XIPH_TYPE_SOCKLEN_T])
 AC_REQUIRE([XIPH_FUNC_VA_COPY])
 AC_CHECK_HEADERS([sys/select.h sys/uio.h])
+AC_CHECK_HEADER([winsock2.h],
+  [AC_DEFINE([HAVE_WINSOCK2_H], [1], [Define if you have winsock2.h on MINGW])
+   LIBS="$LIBS -lwsock32"])
 
 # These tests are ordered based on solaris 8 tests
 AC_SEARCH_LIBS([sethostent], [nsl],

<p><p>1.19      +5 -0      libshout/src/util.c

Index: util.c
===================================================================
RCS file: /usr/local/cvsroot/libshout/src/util.c,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -p -u -r1.18 -r1.19
--- util.c	13 Jul 2003 16:31:20 -0000	1.18
+++ util.c	20 Oct 2003 03:08:45 -0000	1.19
@@ -26,7 +26,12 @@
 #include <stdlib.h>
 
 #include <sys/types.h>
+#ifdef HAVE_SYS_SOCKET_H
 #include <sys/socket.h>
+#endif
+#ifdef HAVE_WINSOCK2_H
+#include <winsock2.h>
+#endif
 
 #include <shout/shout.h>
 #include "util.h"

<p><p>1.36      +16 -6     net/sock.c

Index: sock.c
===================================================================
RCS file: /usr/local/cvsroot/net/sock.c,v
retrieving revision 1.35
retrieving revision 1.36
diff -u -p -u -r1.35 -r1.36
--- sock.c	14 Jul 2003 02:14:59 -0000	1.35
+++ sock.c	20 Oct 2003 03:08:45 -0000	1.36
@@ -50,13 +50,14 @@
 #define EWOULDBLOCK WSAEWOULDBLOCK
 #define EALREADY WSAEALREADY
 #define socklen_t    int
+#ifndef __MINGW32__
 #define va_copy(ap1, ap2) memcpy(&ap1, &ap2, sizeof(va_list))
 #endif
+#endif
 
 #include "sock.h"
 #include "resolver.h"
 
-
 /* sock_initialize
 **
 ** initializes the socket library.  you must call this
@@ -160,7 +161,8 @@ int sock_valid_socket(sock_t sock)
     socklen_t optlen;
 
     optlen = sizeof(int);
-    ret = getsockopt(sock, SOL_SOCKET, SO_TYPE, &optval, &optlen);
+    /* apparently on windows getsockopt.optval is a char * */
+    ret = getsockopt(sock, SOL_SOCKET, SO_TYPE, (void*) &optval, &optlen);
 
     return (ret == 0);
 }
@@ -193,8 +195,12 @@ int inet_aton(const char *s, struct in_a
 int sock_set_blocking(sock_t sock, const int block)
 {
 #ifdef _WIN32
+#ifdef __MINGW32__
+    u_long varblock = block;
+#else
     int varblock = block;
 #endif
+#endif
 
     if ((!sock_valid_socket(sock)) || (block < 0) || (block > 1))
         return SOCK_ERROR;
@@ -433,10 +439,14 @@ int sock_connected (int sock, unsigned t
 
     switch (select(sock + 1, NULL, &wfds, NULL, &tv))
     {
-        case 0:  return SOCK_TIMEOUT;
-        default: if (getsockopt(sock, SOL_SOCKET, SO_ERROR, &val, &size) < 0)
-                     val = SOCK_ERROR;
-        case -1: return val;
+        case 0:
+	    return SOCK_TIMEOUT;
+        default:
+	    /* on windows getsockopt.val is defined as char* */
+	    if (getsockopt(sock, SOL_SOCKET, SO_ERROR, (void*) &val, &size) < 0)
+		val = SOCK_ERROR;
+        case -1:
+	    return val;
     }
 }
 

<p><p>1.17      +6 -3      net/sock.h

Index: sock.h
===================================================================
RCS file: /usr/local/cvsroot/net/sock.h,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -p -u -r1.16 -r1.17
--- sock.h	7 Jul 2003 01:32:42 -0000	1.16
+++ sock.h	20 Oct 2003 03:08:46 -0000	1.17
@@ -24,11 +24,14 @@
 
 #include <stdarg.h>
 
-#ifdef _WIN32
+#ifdef HAVE_WINSOCK2_H
 #include <winsock2.h>
-#include <os.h>
-#else
+#endif
+
+#ifdef HAVE_UNISTD_H
 #include <unistd.h>
+#elif _WIN32
+#include <os.h>
 #endif
 
 #ifdef HAVE_SYS_UIO_H

<p><p>1.12      +11 -0     timing/timing.c

Index: timing.c
===================================================================
RCS file: /usr/local/cvsroot/timing/timing.c,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -p -u -r1.11 -r1.12
--- timing.c	4 Jul 2003 23:18:26 -0000	1.11
+++ timing.c	20 Oct 2003 03:08:46 -0000	1.12
@@ -24,6 +24,10 @@
 #include <sys/select.h>
 #endif
 
+#ifdef __MINGW32__
+#include <sys/timeb.h>
+#endif
+
 #include "timing.h"
 
 /* see timing.h for an explanation of _mangle() */
@@ -34,7 +38,14 @@
 uint64_t timing_get_time(void)
 {
 #ifdef _WIN32
+#ifdef __MINGW32__
+  struct timeb t;
+
+  ftime(&t);
+  return t.time * 1000 + t.millitm)
+#else
     return timeGetTime();
+#endif
 #else 
     struct timeval mtv;
 

<p><p>--- >8 ----
List archives:  http://www.xiph.org/archives/
Ogg project homepage: http://www.xiph.org/ogg/
To unsubscribe from this list, send a message to 'cvs-request at xiph.org'
containing only the word 'unsubscribe' in the body.  No subject is needed.
Unsubscribe messages sent to the list will be ignored/filtered.



More information about the commits mailing list