From owner-svn-src-all@FreeBSD.ORG Thu Feb 11 08:30:43 2010 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 78E45106566C; Thu, 11 Feb 2010 08:30:43 +0000 (UTC) (envelope-from wkoszek@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 674F08FC0C; Thu, 11 Feb 2010 08:30:43 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o1B8UhYq019948; Thu, 11 Feb 2010 08:30:43 GMT (envelope-from wkoszek@svn.freebsd.org) Received: (from wkoszek@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o1B8UhIL019946; Thu, 11 Feb 2010 08:30:43 GMT (envelope-from wkoszek@svn.freebsd.org) Message-Id: <201002110830.o1B8UhIL019946@svn.freebsd.org> From: "Wojciech A. Koszek" Date: Thu, 11 Feb 2010 08:30:43 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r203774 - head/lib/libusb X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 11 Feb 2010 08:30:43 -0000 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 #include #include #include #include #include -#include #include #include -#include +#include #include -#include #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);