svn commit: r203774 - head/lib/libusb
Wojciech A. Koszek
wkoszek at FreeBSD.org
Thu Feb 11 08:30:43 UTC 2010
Author: wkoszek
Date: Thu Feb 11 08:30:43 2010
New Revision: 203774
URL: http://svn.freebsd.org/changeset/base/203774
Log:
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@
Modified:
head/lib/libusb/libusb10.c
Modified: head/lib/libusb/libusb10.c
==============================================================================
--- head/lib/libusb/libusb10.c Thu Feb 11 08:24:35 2010 (r203773)
+++ head/lib/libusb/libusb10.c Thu Feb 11 08:30:43 2010 (r203774)
@@ -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);
More information about the svn-src-all
mailing list