summaryrefslogtreecommitdiff
path: root/android
diff options
context:
space:
mode:
authorChris Dickens <christopher.a.dickens@gmail.com>2020-08-12 16:06:38 -0700
committerChris Dickens <christopher.a.dickens@gmail.com>2020-08-12 16:06:38 -0700
commitd67eb5beaa44c17c09f089a522ff483f4978a978 (patch)
tree8a5dffe3e6779dc95fa1adb32a1dc6d7be69c7af /android
parentba6b8bcb7ea204e65a3deec3be81aacc9f4b6d5a (diff)
downloadlibusb-d67eb5beaa44c17c09f089a522ff483f4978a978.tar.gz
core: Introduce platform events abstraction
The way in which system handles or resources are represented differs greatly between Unix-like operating systems and Windows. Ever since Windows support was added to libusb, Windows been emulating principles of Unix-like operating systems such as file descriptors and poll(). This commit introduces an abstraction layer that completely removes the need to perform any emulation. Fundamentally there are three things that each platform provides to libusb: 1) A signallable event 2) A timer (not required, but useful) 3) A means to wait for event sources such as the above to be triggered The POSIX abstraction for Unix-like operating systems uses file descriptors as the "handles" to the underlying system resources. The signallable event is implemented using a pipe, the timer as a timerfd (where supported) and the poll() system call is used to wait for events. The Windows abstraction uses native HANDLEs as the "handles" to the underlying system resources. The signallable event is implemented using a manual-reset event, the timer as a manual-reset waitable timer, and the WaitForMultipleObjects() system call is used to wait for events. Closes #252 Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
Diffstat (limited to 'android')
-rw-r--r--android/config.h6
-rw-r--r--android/jni/libusb.mk2
2 files changed, 4 insertions, 4 deletions
diff --git a/android/config.h b/android/config.h
index 341c01f..4a4b995 100644
--- a/android/config.h
+++ b/android/config.h
@@ -26,6 +26,9 @@
/* Define to 1 to enable message logging. */
#define ENABLE_LOGGING 1
+/* Define to 1 if using the POSIX events abstraction. */
+#define EVENTS_POSIX 1
+
/* Define to 1 if you have the <asm/types.h> header file. */
#define HAVE_ASM_TYPES_H 1
@@ -41,9 +44,6 @@
/* Define to 1 if you have the <sys/time.h> header file. */
#define HAVE_SYS_TIME_H 1
-/* Define to 1 if using the POSIX poll() implementation. */
-#define POLL_POSIX 1
-
/* Define to 1 if using POSIX threads. */
#define THREADS_POSIX 1
diff --git a/android/jni/libusb.mk b/android/jni/libusb.mk
index 3308e79..656f903 100644
--- a/android/jni/libusb.mk
+++ b/android/jni/libusb.mk
@@ -35,7 +35,7 @@ LOCAL_SRC_FILES := \
$(LIBUSB_ROOT_REL)/libusb/sync.c \
$(LIBUSB_ROOT_REL)/libusb/strerror.c \
$(LIBUSB_ROOT_REL)/libusb/os/linux_usbfs.c \
- $(LIBUSB_ROOT_REL)/libusb/os/poll_posix.c \
+ $(LIBUSB_ROOT_REL)/libusb/os/events_posix.c \
$(LIBUSB_ROOT_REL)/libusb/os/threads_posix.c \
$(LIBUSB_ROOT_REL)/libusb/os/linux_netlink.c