0
0
Fork 0
mirror of https://git.code.sf.net/p/quake/quakeforge synced 2025-03-21 18:01:15 +00:00

Check for ioctl availability.

This gets networking compiling. Now the build gets all the way to qfcc,
where it dies with waidpid/execvp errors :P
This commit is contained in:
Bill Currie 2012-08-18 22:02:02 +09:00
parent 60596038d2
commit bf41851bd9
3 changed files with 29 additions and 10 deletions

View file

@ -11,9 +11,9 @@ AC_FUNC_VA_COPY
AC_FUNC__VA_COPY
AC_CHECK_FUNCS(
access _access gethostname gethostbyname connect gettimeofday getuid \
getwd mkdir _mkdir ftime _ftime fcntl stat putenv select socket strerror \
strcasestr strnlen strstr snprintf _snprintf vsnprintf _vsnprintf \
strsep dlopen getaddrinfo getnameinfo mprotect getpagesize
getwd ioctl mkdir _mkdir ftime _ftime fcntl stat putenv select socket \
strerror strcasestr strnlen strstr snprintf _snprintf vsnprintf \
_vsnprintf strsep dlopen getaddrinfo getnameinfo mprotect getpagesize
)
DL_LIBS=""

View file

@ -344,17 +344,24 @@ UDP_OpenSocket (int port)
#ifdef _WIN32
#define ioctl ioctlsocket
unsigned long _true = true;
unsigned long flags;
#else
int _true = 1;
int flags;
#endif
memset (&address, 0, sizeof(address));
if ((newsocket = socket (PF_INET, SOCK_DGRAM, IPPROTO_UDP)) == -1)
Sys_Error ("UDP_OpenSocket: socket: %s", strerror (errno));
if (ioctl (newsocket, FIONBIO, &_true) == -1)
#if defined (HAVE_IOCTL) || defined (_WIN32)
flags = 1;
if (ioctl (newsocket, FIONBIO, &flags) == -1)
Sys_Error ("UDP_OpenSocket: ioctl FIONBIO: %s", strerror (errno));
#else
flags = fcntl(newsocket, F_GETFL, 0);
if (fcntl (newsocket, F_SETFL, flags | O_NONBLOCK) == -1)
Sys_Error ("UDP_OpenSocket: fcntl O_NONBLOCK: %s", strerror (errno));
#endif
address.s4.sin_family = AF_INET;
// ZOID -- check for interface binding option
if ((i = COM_CheckParm ("-ip")) != 0 && i < com_argc) {

View file

@ -311,9 +311,9 @@ UDP_OpenSocket (int port)
struct sockaddr_in address;
#ifdef _WIN32
#define ioctl ioctlsocket
unsigned long _true = true;
unsigned long flags;
#else
int _true = true;
int flags;
#endif
#ifdef HAVE_IN_PKTINFO
int ip_pktinfo = 1;
@ -322,8 +322,15 @@ UDP_OpenSocket (int port)
if ((newsocket = socket (PF_INET, SOCK_DGRAM, IPPROTO_UDP)) == -1)
return -1;
if (ioctl (newsocket, FIONBIO, &_true) == -1)
#if defined (HAVE_IOCTL) || defined (_WIN32)
flags = 1;
if (ioctl (newsocket, FIONBIO, &flags) == -1)
goto ErrorReturn;
#else
flags = fcntl (newsocket, F_GETFL, 0);
if (fcntl (newsocket, F_SETFL, flags | O_NONBLOCK) == -1)
goto ErrorReturn;
#endif
#ifdef HAVE_IN_PKTINFO
if (setsockopt (newsocket, SOL_IP, IP_PKTINFO, &ip_pktinfo,
sizeof (ip_pktinfo)) == -1) {
@ -425,14 +432,16 @@ UDP_Connect (int socket, netadr_t *addr)
int
UDP_CheckNewConnections (void)
{
#if defined (HAVE_IOCTL) || defined (_WIN32)
int available;
AF_address_t from;
socklen_t fromlen = sizeof (from);
char buff[1];
#endif
if (net_acceptsocket == -1)
return -1;
#if defined (HAVE_IOCTL) || defined (_WIN32)
if (ioctl (net_acceptsocket, FIONREAD, &available) == -1)
Sys_Error ("UDP: ioctlsocket (FIONREAD) failed");
if (available)
@ -443,6 +452,9 @@ UDP_CheckNewConnections (void)
// we don't care about the interface on which the packet arrived
recvfrom (net_acceptsocket, buff, 0, 0, &from.sa, &fromlen);
return -1;
#else
return net_acceptsocket;
#endif
}
int