1
0
mirror of https://gitlab.xiph.org/xiph/icecast-common.git synced 2024-06-16 06:15:24 +00:00

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

autoconf feng shui

svn path=/trunk/net/; revision=5490
This commit is contained in:
brendan 2003-10-20 03:08:46 +00:00
parent c6313c016c
commit 5a30452547
3 changed files with 33 additions and 9 deletions

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;