os: cross platform ioctl() wrapper

Reducing the ifdef-zoo a bit by moving the platform specific socket
ioctl calls into separate function. On win32, this also checks the
retval and potentially query for error. On Unix, just calling ioctl().

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
This commit is contained in:
Enrico Weigelt, metux IT consult
2025-07-30 12:11:39 +02:00
committed by Enrico Weigelt
parent fe795fa7b8
commit ec20354aec
4 changed files with 26 additions and 18 deletions

View File

@@ -117,13 +117,6 @@ Xtransport_table Xtransports[] = {
#define NUMTRANS (sizeof(Xtransports)/sizeof(Xtransport_table))
#ifdef WIN32
#define ioctl ioctlsocket
#endif
/*
* These are a few utility function used by the public interface functions.
*/
@@ -564,7 +557,7 @@ int _XSERVTransNonBlock(XtransConnInfo ciptr)
{
int arg;
arg = 1;
ret = ioctl (fd, FIOSNBIO, &arg);
ret = ossock_ioctl (fd, FIOSNBIO, &arg);
}
#else
#if defined(WIN32)
@@ -572,7 +565,7 @@ int _XSERVTransNonBlock(XtransConnInfo ciptr)
u_long arg_ret = 1;
/* IBM TCP/IP understands this option too well: it causes _XSERVTransRead to fail
* eventually with EWOULDBLOCK */
ret = ioctl (fd, FIONBIO, &arg_ret);
ret = ossock_ioctl (fd, FIONBIO, &arg_ret);
}
#else
ret = fcntl (fd, F_GETFL, 0);