diff options
author | wkoszek <wkoszek@FreeBSD.org> | 2010-02-11 08:30:43 +0000 |
---|---|---|
committer | wkoszek <wkoszek@FreeBSD.org> | 2010-02-11 08:30:43 +0000 |
commit | 431460b437aee657d6f44ce980c70bd7f1135075 (patch) | |
tree | 8e87cd441e0dab2e3c97c19bb589f4d9c39a78d6 /lib/libusb/libusb10.c | |
parent | 1ca3f3128bcb61c6225b71950f265df5e3287379 (diff) | |
download | FreeBSD-src-431460b437aee657d6f44ce980c70bd7f1135075.zip FreeBSD-src-431460b437aee657d6f44ce980c70bd7f1135075.tar.gz |
Use more standard way for setting nonblocking flag for a filedescriptor.
This makes libusb porting a bit easier.
There shouldn't by any negative change in behaviour after this commit.
Remove redundant headers.
Reviewed by: hps@
Diffstat (limited to 'lib/libusb/libusb10.c')
-rw-r--r-- | lib/libusb/libusb10.c | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/lib/libusb/libusb10.c b/lib/libusb/libusb10.c index 25520d2..7e9e885 100644 --- a/lib/libusb/libusb10.c +++ b/lib/libusb/libusb10.c @@ -25,17 +25,16 @@ * SUCH DAMAGE. */ +#include <assert.h> #include <stdlib.h> #include <unistd.h> #include <stdio.h> #include <poll.h> #include <pthread.h> -#include <time.h> #include <errno.h> #include <sys/ioctl.h> -#include <sys/filio.h> +#include <sys/fcntl.h> #include <sys/queue.h> -#include <sys/endian.h> #include "libusb20.h" #include "libusb20_desc.h" @@ -73,6 +72,7 @@ libusb_init(libusb_context **context) { struct libusb_context *ctx; char *debug; + int flag; int ret; ctx = malloc(sizeof(*ctx)); @@ -103,10 +103,12 @@ libusb_init(libusb_context **context) return (LIBUSB_ERROR_OTHER); } /* set non-blocking mode on the control pipe to avoid deadlock */ - ret = 1; - ioctl(ctx->ctrl_pipe[0], FIONBIO, &ret); - ret = 1; - ioctl(ctx->ctrl_pipe[1], FIONBIO, &ret); + flag = 1; + ret = fcntl(ctx->ctrl_pipe[0], O_NONBLOCK, &flag); + assert(ret != -1 && "Couldn't set O_NONBLOCK for ctx->ctrl_pipe[0]"); + flag = 1; + ret = fcntl(ctx->ctrl_pipe[1], O_NONBLOCK, &flag); + assert(ret != -1 && "Couldn't set O_NONBLOCK for ctx->ctrl_pipe[1]"); libusb10_add_pollfd(ctx, &ctx->ctx_poll, NULL, ctx->ctrl_pipe[0], POLLIN); |