On 16/05/13 21:47, Hans de Goede wrote:
Hi all,

With some help from Pete, Xiaofan as well as Nathan, I have been working on
integrating the libusb hp API work done by Nathan for 1.0.16 on top of libusbx.

We're planning to push these changes to libusbx master by the end of the week,
so please test and review before that, you can find the branch we intend
to push at https://github.com/jwrdegoede/libusbx/commits/darwin-integration";.

Esp. Windows CE and BSD testing is needed!


I've attached a handful of patches of changes needed to get WinCE building (I've not tried it on hardware yet). I suspect that people will have strong opinions on the first patch which creates poll_posix.c. Hopefully the other patches aren't as controversial.

Regards,

Toby
>From 5f8115fb45d46f2b2837ee4cb529a1bc9ff67f04 Mon Sep 17 00:00:00 2001
From: Toby Gray <toby.g...@realvnc.com>
Date: Mon, 20 May 2013 14:01:02 +0100
Subject: [PATCH 1/4] POSIX: Move setting of pipes to non-blocking into
 usbi_pipe.

---
 libusb/Makefile.am     |   12 ++++++++----
 libusb/io.c            |    6 ------
 libusb/os/poll_posix.c |   41 +++++++++++++++++++++++++++++++++++++++++
 libusb/os/poll_posix.h |    3 ++-
 4 files changed, 51 insertions(+), 11 deletions(-)
 create mode 100755 libusb/os/poll_posix.c

diff --git a/libusb/Makefile.am b/libusb/Makefile.am
index c5e3387..cd6db9c 100644
--- a/libusb/Makefile.am
+++ b/libusb/Makefile.am
@@ -2,6 +2,7 @@ all: libusb-1.0.la libusb-1.0.dll
 
 lib_LTLIBRARIES = libusb-1.0.la
 
+POSIX_POLL_SRC = os/poll_posix.c
 LINUX_USBFS_SRC = os/linux_usbfs.c
 DARWIN_USB_SRC = os/darwin_usb.c
 OPENBSD_USB_SRC = os/openbsd_usb.c
@@ -10,26 +11,29 @@ WINCE_USB_SRC = os/wince_usb.c os/wince_usb.h
 
 EXTRA_DIST = $(LINUX_USBFS_SRC) $(DARWIN_USB_SRC) $(OPENBSD_USB_SRC) \
 	$(WINDOWS_USB_SRC) $(WINCE_USB_SRC) \
+	$(POSIX_POLL_SRC) \
 	os/threads_posix.c os/threads_windows.c \
 	os/linux_udev.c os/linux_netlink.c
 
 if OS_LINUX
 
 if USE_UDEV
-OS_SRC = $(LINUX_USBFS_SRC) os/linux_udev.c
+OS_SRC = $(LINUX_USBFS_SRC) $(POSIX_POLL_SRC) \
+	os/linux_udev.c
 else
-OS_SRC = $(LINUX_USBFS_SRC) os/linux_netlink.c
+OS_SRC = $(LINUX_USBFS_SRC) $(POSIX_POLL_SRC) \
+	os/linux_netlink.c
 endif
 
 endif
 
 if OS_DARWIN
-OS_SRC = $(DARWIN_USB_SRC)
+OS_SRC = $(DARWIN_USB_SRC) $(POSIX_POLL_SRC)
 AM_CFLAGS_EXT = -no-cpp-precomp
 endif
 
 if OS_OPENBSD
-OS_SRC = $(OPENBSD_USB_SRC)
+OS_SRC = $(OPENBSD_USB_SRC) $(POSIX_POLL_SRC)
 endif
 
 if OS_WINDOWS
diff --git a/libusb/io.c b/libusb/io.c
index b8b31f7..b27e082 100644
--- a/libusb/io.c
+++ b/libusb/io.c
@@ -25,9 +25,6 @@
 #include <stdlib.h>
 #include <string.h>
 #include <time.h>
-#ifndef OS_WINDOWS
-#include <fcntl.h>
-#endif
 #ifdef HAVE_SIGNAL_H
 #include <signal.h>
 #endif
@@ -1082,9 +1079,6 @@ int usbi_io_init(struct libusb_context *ctx)
 		goto err;
 	}
 
-#ifndef OS_WINDOWS
-	fcntl(ctx->hotplug_pipe[1], F_SETFD, O_NONBLOCK);
-#endif
 	r = usbi_add_pollfd(ctx, ctx->hotplug_pipe[0], POLLIN);
 	if (r < 0)
 		goto err_close_hp_pipe;
diff --git a/libusb/os/poll_posix.c b/libusb/os/poll_posix.c
new file mode 100755
index 0000000..bd1c538
--- /dev/null
+++ b/libusb/os/poll_posix.c
@@ -0,0 +1,41 @@
+/*
+ * poll_posix: poll compatibility wrapper for POSIX systems
+ * Copyright © 2013 RealVNC Ltd.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ */
+
+#include <unistd.h>
+#include <fcntl.h>
+#include <errno.h>
+#include <stdlib.h>
+
+#include "libusbi.h"
+
+int usbi_pipe(int pipefd[2])
+{
+	int ret = pipe(pipefd);
+	if (ret != 0) {
+		return ret;
+	}
+	ret = fcntl(pipefd[1], F_SETFD, O_NONBLOCK);
+	if (ret != 0) {
+		usbi_dbg("Failed to set non-blocking on new pipe: %d", errno);
+		usbi_close(pipefd[0]);
+		usbi_close(pipefd[1]);
+	}
+	return ret;
+}
diff --git a/libusb/os/poll_posix.h b/libusb/os/poll_posix.h
index 0e5e7f5..5b4b2c9 100644
--- a/libusb/os/poll_posix.h
+++ b/libusb/os/poll_posix.h
@@ -4,7 +4,8 @@
 #define usbi_write write
 #define usbi_read read
 #define usbi_close close
-#define usbi_pipe pipe
 #define usbi_poll poll
 
+int usbi_pipe(int pipefd[2]);
+
 #endif /* LIBUSB_POLL_POSIX_H */
-- 
1.7.9.5

>From 8b6c5e73e485cc859ebc99136fed802a6b5ebaa3 Mon Sep 17 00:00:00 2001
From: Toby Gray <toby.g...@realvnc.com>
Date: Mon, 20 May 2013 15:44:34 +0100
Subject: [PATCH 2/4] Hotplug: Make use of HAVE_SYS_TYPES_H define.

---
 libusb/hotplug.c |    2 ++
 1 file changed, 2 insertions(+)

diff --git a/libusb/hotplug.c b/libusb/hotplug.c
index a58608f..77ccb31 100644
--- a/libusb/hotplug.c
+++ b/libusb/hotplug.c
@@ -25,7 +25,9 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+#ifdef HAVE_SYS_TYPES_H
 #include <sys/types.h>
+#endif
 #include <assert.h>
 
 #include "libusbi.h"
-- 
1.7.9.5

>From 6df8883b052edd83c11ecacc0c1c8243d5134726 Mon Sep 17 00:00:00 2001
From: Toby Gray <toby.g...@realvnc.com>
Date: Mon, 20 May 2013 15:45:04 +0100
Subject: [PATCH 3/4] Windows: Add new symbol for libusb_get_port_numbers to
 def file.

---
 libusb/libusb-1.0.def |    2 ++
 1 file changed, 2 insertions(+)

diff --git a/libusb/libusb-1.0.def b/libusb/libusb-1.0.def
index 1c25eae..0343116 100644
--- a/libusb/libusb-1.0.def
+++ b/libusb/libusb-1.0.def
@@ -128,3 +128,5 @@ EXPORTS
   libusb_unref_device@4 = libusb_unref_device
   libusb_wait_for_event
   libusb_wait_for_event@8 = libusb_wait_for_event
+  libusb_get_port_numbers
+  libusb_get_port_numbers@12 = libusb_get_port_numbers
-- 
1.7.9.5

>From b4b2791e9a8bb1eb292025aa074ee5d90848c80e Mon Sep 17 00:00:00 2001
From: Toby Gray <toby.g...@realvnc.com>
Date: Mon, 20 May 2013 15:45:59 +0100
Subject: [PATCH 4/4] WinCE: Add hotplug.c to projects.

---
 msvc/libusb_dll_wince.vcproj    |    4 ++++
 msvc/libusb_static_wince.vcproj |    4 ++++
 2 files changed, 8 insertions(+)

diff --git a/msvc/libusb_dll_wince.vcproj b/msvc/libusb_dll_wince.vcproj
index 96b1f04..4238a4d 100644
--- a/msvc/libusb_dll_wince.vcproj
+++ b/msvc/libusb_dll_wince.vcproj
@@ -1145,6 +1145,10 @@
 				>
 			</File>
 			<File
+				RelativePath="..\libusb\hotplug.c"
+				>
+			</File>
+			<File
 				RelativePath="..\libusb\io.c"
 				>
 			</File>
diff --git a/msvc/libusb_static_wince.vcproj b/msvc/libusb_static_wince.vcproj
index 33825da..54fd48d 100644
--- a/msvc/libusb_static_wince.vcproj
+++ b/msvc/libusb_static_wince.vcproj
@@ -1087,6 +1087,10 @@
 				>
 			</File>
 			<File
+				RelativePath="..\libusb\hotplug.c"
+				>
+			</File>
+			<File
 				RelativePath="..\libusb\io.c"
 				>
 			</File>
-- 
1.7.9.5

------------------------------------------------------------------------------
AlienVault Unified Security Management (USM) platform delivers complete
security visibility with the essential security capabilities. Easily and
efficiently configure, manage, and operate all of your security controls
from a single console and one unified framework. Download a free trial.
http://p.sf.net/sfu/alienvault_d2d
_______________________________________________
libusbx-devel mailing list
libusbx-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/libusbx-devel

Reply via email to