Skip to content

Commit

Permalink
IO/io_blocking: clean up #if/#endif etc nesting and indentation
Browse files Browse the repository at this point in the history
  • Loading branch information
tonycoz committed Oct 25, 2023
1 parent bbc9522 commit 28256ee
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions dist/IO/IO.xs
Expand Up @@ -86,12 +86,12 @@ io_blocking(pTHX_ InputStream f, int block)
if (RETVAL >= 0) {
int mode = RETVAL;
int newmode = mode;
#ifdef O_NONBLOCK
# ifdef O_NONBLOCK
/* POSIX style */

# ifndef O_NDELAY
# define O_NDELAY O_NONBLOCK
# endif
# ifndef O_NDELAY
# define O_NDELAY O_NONBLOCK
# endif
/* Note: UNICOS and UNICOS/mk a F_GETFL returns an O_NDELAY
* after a successful F_SETFL of an O_NONBLOCK. */
RETVAL = RETVAL & (O_NONBLOCK | O_NDELAY) ? 0 : 1;
Expand All @@ -102,7 +102,7 @@ io_blocking(pTHX_ InputStream f, int block)
} else if (block > 0) {
newmode &= ~(O_NDELAY|O_NONBLOCK);
}
#else
# else
/* Not POSIX - better have O_NDELAY or we can't cope.
* for BSD-ish machines this is an acceptable alternative
* for SysV we can't tell "would block" from EOF but that is
Expand All @@ -115,16 +115,15 @@ io_blocking(pTHX_ InputStream f, int block)
} else if (block > 0) {
newmode &= ~O_NDELAY;
}
#endif
# endif
if (newmode != mode) {
const int ret = fcntl(fd, F_SETFL, newmode);
if (ret < 0)
RETVAL = ret;
}
}
return RETVAL;
#else
# ifdef WIN32
#elif defined(WIN32)
if (block >= 0) {
unsigned long flags = !block;
/* ioctl claims to take char* but really needs a u_long sized buffer */
Expand All @@ -139,9 +138,8 @@ io_blocking(pTHX_ InputStream f, int block)
}
/* TODO: Perhaps set $! to ENOTSUP? */
return -1;
# else
#else
return -1;
# endif
#endif
}

Expand Down

0 comments on commit 28256ee

Please sign in to comment.