core: Correct the conditionals for {cloexec,nonblock}_ioctl
These functions are declared with one set of conditionals in the
header, and defined with another set of conditionals in the c file.
This commit makes all decisions regarding `uv__{nonblock,cloexec}_ioctl`
depend on a boolean macro instead.
There's one function that expects `uv__nonblock_ioctl` to be defined,
so that bit of the function is also conditionally compiled.
PR-URL: https://github.com/libuv/libuv/pull/3163
Reviewed-By: Jameson Nash <vtjnash@gmail.com>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
This commit is contained in:
parent
b201c1a0f0
commit
6b0051d14d
@ -584,7 +584,7 @@ int uv__close(int fd) {
|
||||
return uv__close_nocheckstdio(fd);
|
||||
}
|
||||
|
||||
|
||||
#if UV__NONBLOCK_IS_IOCTL
|
||||
int uv__nonblock_ioctl(int fd, int set) {
|
||||
int r;
|
||||
|
||||
@ -599,7 +599,6 @@ int uv__nonblock_ioctl(int fd, int set) {
|
||||
}
|
||||
|
||||
|
||||
#if !defined(__CYGWIN__) && !defined(__MSYS__) && !defined(__HAIKU__)
|
||||
int uv__cloexec_ioctl(int fd, int set) {
|
||||
int r;
|
||||
|
||||
|
||||
@ -176,9 +176,11 @@ struct uv__stream_queued_fds_s {
|
||||
defined(__NetBSD__)
|
||||
#define uv__cloexec uv__cloexec_ioctl
|
||||
#define uv__nonblock uv__nonblock_ioctl
|
||||
#define UV__NONBLOCK_IS_IOCTL 1
|
||||
#else
|
||||
#define uv__cloexec uv__cloexec_fcntl
|
||||
#define uv__nonblock uv__nonblock_fcntl
|
||||
#define UV__NONBLOCK_IS_IOCTL 0
|
||||
#endif
|
||||
|
||||
/* On Linux, uv__nonblock_fcntl() and uv__nonblock_ioctl() do not commute
|
||||
|
||||
@ -79,9 +79,10 @@ int uv_poll_init(uv_loop_t* loop, uv_poll_t* handle, int fd) {
|
||||
* Workaround for e.g. kqueue fds not supporting ioctls.
|
||||
*/
|
||||
err = uv__nonblock(fd, 1);
|
||||
#if UV__NONBLOCK_IS_IOCTL
|
||||
if (err == UV_ENOTTY)
|
||||
if (uv__nonblock == uv__nonblock_ioctl)
|
||||
err = uv__nonblock_fcntl(fd, 1);
|
||||
err = uv__nonblock_fcntl(fd, 1);
|
||||
#endif
|
||||
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user