summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSean McBride <sean@rogue-research.com>2017-12-29 13:23:00 -0500
committerChris Dickens <christopher.a.dickens@gmail.com>2018-01-08 10:28:16 -0800
commit860657126edbb362f0e6961f16510780dfd206f4 (patch)
treee60dc6bf9e87ae1005781b1dbf73ce9ba01572ea
parent0f59214f1253a36f27c3acbcd9601d026d4741b1 (diff)
downloadlibusb-860657126edbb362f0e6961f16510780dfd206f4.tar.gz
darwin: Replaced low-level mach API with pthread API
Found this because clang was warning that the return value was being converted from unsigned to signed. The need for a mach API surprised me, and I found this alternative formulation in a Chromium bug: https://groups.google.com/forum/#!topic/native-client-reviews/z---hlHbQNc which describes: "mach_thread_self() needs to be balanced by mach_port_deallocate(), which is two system calls. pthread_mach_thread_np(pthread_self()) is two libc function calls and no system calls, because pthread caches the Mach port." Fixed the conversion warning too, with a cast. Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
-rw-r--r--libusb/os/threads_posix.c5
-rw-r--r--libusb/version_nano.h2
2 files changed, 3 insertions, 4 deletions
diff --git a/libusb/os/threads_posix.c b/libusb/os/threads_posix.c
index ce14445..16a7578 100644
--- a/libusb/os/threads_posix.c
+++ b/libusb/os/threads_posix.c
@@ -29,7 +29,7 @@
# include <unistd.h>
# include <sys/syscall.h>
#elif defined(__APPLE__)
-# include <mach/mach.h>
+# include <pthread.h>
#elif defined(__CYGWIN__)
# include <windows.h>
#endif
@@ -69,8 +69,7 @@ int usbi_get_tid(void)
real thread support. For 5.1 and earlier, -1 is returned. */
ret = syscall(SYS_getthrid);
#elif defined(__APPLE__)
- ret = mach_thread_self();
- mach_port_deallocate(mach_task_self(), ret);
+ ret = (int)pthread_mach_thread_np(pthread_self());
#elif defined(__CYGWIN__)
ret = GetCurrentThreadId();
#else
diff --git a/libusb/version_nano.h b/libusb/version_nano.h
index ae1c8d3..92e7b53 100644
--- a/libusb/version_nano.h
+++ b/libusb/version_nano.h
@@ -1 +1 @@
-#define LIBUSB_NANO 11280
+#define LIBUSB_NANO 11281