win32/win32_compat.c: Reformat this file

This file has been reformatted with clang-format --style=file and the Linux
kernel .clang-format style file.

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
This commit is contained in:
Bart Van Assche
2021-05-23 12:20:07 -07:00
parent 2a5a0b3291
commit ca9c585ef6

View File

@@ -62,14 +62,11 @@ int win32_inet_pton(int af, const char * src, void * dst)
strncpy(srcNonConst, src, strLen);
#endif
if( WSAStringToAddress(srcNonConst,af,NULL,(LPSOCKADDR)&sa,&len) == 0 )
{
if (WSAStringToAddress(srcNonConst, af, NULL, (LPSOCKADDR)&sa, &len) ==
0) {
ret = 1;
}
else
{
if( WSAGetLastError() == WSAEINVAL )
{
} else {
if (WSAGetLastError() == WSAEINVAL) {
ret = -1;
}
}
@@ -89,16 +86,13 @@ int win32_poll(struct pollfd *fds, unsigned int nfds, int timo)
FD_ZERO(&ifds);
FD_ZERO(&ofds);
FD_ZERO(&efds);
for (i = 0, op = ip = 0; i < nfds; ++i)
{
for (i = 0, op = ip = 0; i < nfds; ++i) {
fds[i].revents = 0;
if(fds[i].events & (POLLIN|POLLPRI))
{
if (fds[i].events & (POLLIN | POLLPRI)) {
ip = &ifds;
FD_SET(fds[i].fd, ip);
}
if(fds[i].events & POLLOUT)
{
if (fds[i].events & POLLOUT) {
op = &ofds;
FD_SET(fds[i].fd, op);
}
@@ -106,12 +100,9 @@ int win32_poll(struct pollfd *fds, unsigned int nfds, int timo)
}
// Set up the timeval structure for the timeout parameter
if(timo < 0)
{
if (timo < 0) {
toptr = 0;
}
else
{
} else {
toptr = &timeout;
timeout.tv_sec = timo / 1000;
timeout.tv_usec = (timo - timeout.tv_sec * 1000) * 1000;
@@ -129,22 +120,21 @@ int win32_poll(struct pollfd *fds, unsigned int nfds, int timo)
if (rc <= 0)
return rc;
if(rc > 0)
{
for (i = 0; i < nfds; ++i)
{
if (rc > 0) {
for (i = 0; i < nfds; ++i) {
int fd = fds[i].fd;
if(fds[i].events & (POLLIN|POLLPRI) && FD_ISSET(fd, &ifds))
if (fds[i].events & (POLLIN | POLLPRI) &&
FD_ISSET(fd, &ifds))
fds[i].revents |= POLLIN;
if (fds[i].events & POLLOUT && FD_ISSET(fd, &ofds))
fds[i].revents |= POLLOUT;
if(FD_ISSET(fd, &efds)) // Some error was detected ... should be some way to know.
if (FD_ISSET(fd,
&efds)) // Some error was detected ... should be some way to know.
fds[i].revents |= POLLHUP;
#ifdef DEBUG_POLL
printf("%d %d %d revent = %x\n",
FD_ISSET(fd, &ifds), FD_ISSET(fd, &ofds), FD_ISSET(fd, &efds),
fds[i].revents
);
printf("%d %d %d revent = %x\n", FD_ISSET(fd, &ifds),
FD_ISSET(fd, &ofds), FD_ISSET(fd, &efds),
fds[i].revents);
#endif
}
}
@@ -157,8 +147,7 @@ int win32_poll(struct pollfd *fds, unsigned int nfds, int timo)
#define DELTA_EPOCH_IN_MICROSECS 11644473600000000ULL
#endif
struct timezone
{
struct timezone {
int tz_minuteswest; /* minutes W of Greenwich */
int tz_dsttime; /* type of dst correction */
};
@@ -169,8 +158,7 @@ int win32_gettimeofday(struct timeval *tv, struct timezone *tz)
unsigned __int64 tmpres = 0;
static int tzflag;
if (NULL != tv)
{
if (NULL != tv) {
GetSystemTimeAsFileTime(&ft);
tmpres |= ft.dwHighDateTime;
@@ -184,10 +172,8 @@ int win32_gettimeofday(struct timeval *tv, struct timezone *tz)
tv->tv_usec = (long)(tmpres % 1000000UL);
}
if (NULL != tz)
{
if (!tzflag)
{
if (NULL != tz) {
if (!tzflag) {
_tzset();
tzflag++;
}