1
0
mirror of https://gitlab.xiph.org/xiph/icecast-server.git synced 2024-11-03 04:17:17 -05:00

Leigh Smith's MINGW32 compatibility patch, with modifications for better

autoconf feng shui

svn path=/trunk/m4/; revision=5490
This commit is contained in:
brendan 2003-10-20 03:08:46 +00:00
parent 42256bc3d8
commit 2bfba7c60a
4 changed files with 36 additions and 9 deletions

View File

@ -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],

View File

@ -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,7 +195,11 @@ int inet_aton(const char *s, struct in_addr *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))
@ -433,10 +439,14 @@ int sock_connected (int sock, unsigned timeout)
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;
}
}

View File

@ -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

View File

@ -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;