diff options
author | Koushik Dutta <koushd@gmail.com> | 2013-08-14 09:36:11 -0700 |
---|---|---|
committer | Koushik Dutta <koushd@gmail.com> | 2013-08-14 10:23:30 -0700 |
commit | 591d9768c61fe4f50fb5b4919df07ec37d9db891 (patch) | |
tree | c662e1d676af2eec0372b618df10baecad6b8bca | |
parent | 368d613a17a3d768a7f434b886a8299f13711f8d (diff) | |
download | android_external_libusbx-591d9768c61fe4f50fb5b4919df07ec37d9db891.tar.gz android_external_libusbx-591d9768c61fe4f50fb5b4919df07ec37d9db891.tar.bz2 android_external_libusbx-591d9768c61fe4f50fb5b4919df07ec37d9db891.zip |
Fixes for libusbx on AOSP.
-rw-r--r-- | config.h | 152 | ||||
-rw-r--r-- | libusb/Android.mk | 55 | ||||
-rw-r--r-- | libusb/os/darwin_usb.c | 15 |
3 files changed, 221 insertions, 1 deletions
diff --git a/config.h b/config.h new file mode 100644 index 0000000..4985a57 --- /dev/null +++ b/config.h @@ -0,0 +1,152 @@ +/* config.h. Generated from config.h.in by configure. */ +/* config.h.in. Generated from configure.ac by autoheader. */ + +/* Default visibility */ +#define DEFAULT_VISIBILITY __attribute__((visibility("default"))) + +/* Start with debug message logging enabled */ +/* #undef ENABLE_DEBUG_LOGGING */ + +/* Message logging */ +#define ENABLE_LOGGING 1 + +/* Define to 1 if you have the <asm/types.h> header file. */ +/* #undef HAVE_ASM_TYPES_H */ + +/* Define to 1 if you have the <dlfcn.h> header file. */ +#define HAVE_DLFCN_H 1 + +/* Define to 1 if you have the `gettimeofday' function. */ +#define HAVE_GETTIMEOFDAY 1 + +/* Define to 1 if you have the <inttypes.h> header file. */ +#define HAVE_INTTYPES_H 1 + +/* Define to 1 if you have the `udev' library (-ludev). */ +/* #undef HAVE_LIBUDEV */ + +/* Define to 1 if you have the <libudev.h> header file. */ +/* #undef HAVE_LIBUDEV_H */ + +/* Define to 1 if you have the <linux/filter.h> header file. */ +/* #undef HAVE_LINUX_FILTER_H */ + +/* Define to 1 if you have the <linux/netlink.h> header file. */ +/* #undef HAVE_LINUX_NETLINK_H */ + +/* Define to 1 if you have the <memory.h> header file. */ +#define HAVE_MEMORY_H 1 + +/* Define to 1 if you have the <poll.h> header file. */ +#define HAVE_POLL_H 1 + +/* Define to 1 if you have the <signal.h> header file. */ +#define HAVE_SIGNAL_H 1 + +/* Define to 1 if you have the <stdint.h> header file. */ +#define HAVE_STDINT_H 1 + +/* Define to 1 if you have the <stdlib.h> header file. */ +#define HAVE_STDLIB_H 1 + +/* Define to 1 if you have the <strings.h> header file. */ +#define HAVE_STRINGS_H 1 + +/* Define to 1 if you have the <string.h> header file. */ +#define HAVE_STRING_H 1 + +/* Define to 1 if the system has the type `struct timespec'. */ +#define HAVE_STRUCT_TIMESPEC 1 + +/* syslog() function available */ +#define HAVE_SYSLOG_FUNC 1 + +/* Define to 1 if you have the <syslog.h> header file. */ +#define HAVE_SYSLOG_H 1 + +/* Define to 1 if you have the <sys/socket.h> header file. */ +/* #undef HAVE_SYS_SOCKET_H */ + +/* Define to 1 if you have the <sys/stat.h> header file. */ +#define HAVE_SYS_STAT_H 1 + +/* Define to 1 if you have the <sys/time.h> header file. */ +#define HAVE_SYS_TIME_H 1 + +/* Define to 1 if you have the <sys/types.h> header file. */ +#define HAVE_SYS_TYPES_H 1 + +/* Define to 1 if you have the <unistd.h> header file. */ +#define HAVE_UNISTD_H 1 + +/* Define to the sub-directory in which libtool stores uninstalled libraries. + */ +#define LT_OBJDIR ".libs/" + +/* Define to 1 if your C compiler doesn't accept -c and -o together. */ +/* #undef NO_MINUS_C_MINUS_O */ + +#if defined(__APPLE__) +#define OS_DARWIN +#define THREADS_POSIX +#elif defined(__linux__) +#define OS_LINUX +#define THREADS_POSIX +#endif + +/* Linux backend */ +/* #undef OS_LINUX */ + +/* OpenBSD/NetBSD backend */ +/* #undef OS_OPENBSD */ + +/* Windows backend */ +/* #undef OS_WINDOWS */ + +/* Name of package */ +#define PACKAGE "libusbx" + +/* Define to the address where bug reports for this package should be sent. */ +#define PACKAGE_BUGREPORT "libusbx-devel@lists.sourceforge.net" + +/* Define to the full name of this package. */ +#define PACKAGE_NAME "libusbx" + +/* Define to the full name and version of this package. */ +#define PACKAGE_STRING "libusbx 1.0.16" + +/* Define to the one symbol short name of this package. */ +#define PACKAGE_TARNAME "libusbx" + +/* Define to the home page for this package. */ +#define PACKAGE_URL "http://libusbx.org" + +/* Define to the version of this package. */ +#define PACKAGE_VERSION "1.0.16" + +/* type of second poll() argument */ +#define POLL_NFDS_TYPE nfds_t + +/* Define to 1 if you have the ANSI C header files. */ +#define STDC_HEADERS 1 + +/* timerfd headers available */ +/* #undef USBI_TIMERFD_AVAILABLE */ + +/* Enable output to system log */ +/* #undef USE_SYSTEM_LOGGING_FACILITY */ + +/* Use udev for device enumeration/hotplug */ +/* #undef USE_UDEV */ + +/* Version number of package */ +#define VERSION "1.0.16" + +/* Use GNU extensions */ +#define _GNU_SOURCE 1 + +/* Define to `__inline__' or `__inline' if that's what the C compiler + calls it, or to nothing if 'inline' is not supported under any name. */ +#ifndef __cplusplus +/* #undef inline */ +#endif diff --git a/libusb/Android.mk b/libusb/Android.mk new file mode 100644 index 0000000..f3e0425 --- /dev/null +++ b/libusb/Android.mk @@ -0,0 +1,55 @@ +LOCAL_PATH:= $(call my-dir) + +include $(CLEAR_VARS) + +LOCAL_SRC_FILES:= \ + core.c \ + descriptor.c \ + io.c \ + sync.c \ + os/linux_usbfs.c \ + os/threads_posix.c \ + os/poll_posix.c \ + hotplug.c + +LOCAL_C_INCLUDES += \ + external/libusbx/ \ + external/libusbx/libusb/ \ + external/libusbx/libusb/os + +LOCAL_CFLAGS := -D_SHARED_LIBRARY_ +LOCAL_MODULE_TAGS:= optional +LOCAL_MODULE:= libusbx +include $(BUILD_STATIC_LIBRARY) + +include $(CLEAR_VARS) + +LOCAL_SRC_FILES:= \ + core.c \ + descriptor.c \ + io.c \ + sync.c \ + hotplug.c + +LOCAL_C_INCLUDES += \ + external/libusbx/ \ + external/libusbx/libusb/ \ + external/libusbx/libusb/os + +ifeq ($(HOST_OS),linux) + LOCAL_SRC_FILES += os/linux_usbfs.c os/threads_posix.c os/poll_posix.c +endif + +ifeq ($(HOST_OS),darwin) + LOCAL_SRC_FILES += os/darwin_usb.c os/threads_posix.c os/poll_posix.c +endif + +ifeq ($(HOST_OS),windows) + LOCAL_SRC_FILES += os/windows_usbfs.c +endif + + +LOCAL_CFLAGS := -D_SHARED_LIBRARY_ +LOCAL_MODULE_TAGS:= optional +LOCAL_MODULE:= libusbx +include $(BUILD_HOST_STATIC_LIBRARY) diff --git a/libusb/os/darwin_usb.c b/libusb/os/darwin_usb.c index b0ee5b2..f8e94e2 100644 --- a/libusb/os/darwin_usb.c +++ b/libusb/os/darwin_usb.c @@ -40,6 +40,8 @@ #include <objc/objc-auto.h> #endif +#include <inttypes.h> + #include "darwin_usb.h" /* async event thread */ @@ -307,6 +309,9 @@ static void darwin_clear_iterator (io_iterator_t iter) { IOObjectRelease (device); } +#include <dlfcn.h> +void (*registerThreadWithCollector_fn)(void) = NULL; + static void *darwin_event_thread_main (void *arg0) { IOReturn kresult; struct libusb_context *ctx = (struct libusb_context *)arg0; @@ -321,7 +326,15 @@ static void *darwin_event_thread_main (void *arg0) { This is required because, unlike NSThreads, pthreads are not automatically registered. Although we don't use Objective-C, we use CoreFoundation, which does. */ - objc_registerThreadWithCollector(); + if (!registerThreadWithCollector_fn) { + registerThreadWithCollector_fn = (void(*)(void)) dlsym(RTLD_NEXT, "objc_registerThreadWithCollector"); + if (registerThreadWithCollector_fn) { + (*registerThreadWithCollector_fn)(); + } + else { + // fail? + } + } #endif /* hotplug (device arrival/removal) sources */ |