Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1351)

Unified Diff: third_party/libusb/src/libusb/os/threads_posix.c

Issue 19490008: Recommit: Update libusb 1.0.9 to libusbx 1.0.16 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/libusb/src/libusb/os/threads_posix.c
diff --git a/third_party/libusb/src/libusb/os/threads_posix.c b/third_party/libusb/src/libusb/os/threads_posix.c
index 60c57cf81e63e92d1f5c252bdb18040d4e08140b..46f6db76f4fda3b3d54a6bcec85f952984393a98 100644
--- a/third_party/libusb/src/libusb/os/threads_posix.c
+++ b/third_party/libusb/src/libusb/os/threads_posix.c
@@ -1,8 +1,8 @@
/*
- * libusb synchronization using POSIX Threads
+ * libusbx synchronization using POSIX Threads
*
- * Copyright (C) 2011 Vitali Lovich <vlovich@aliph.com>
- * Copyright (C) 2011 Peter Stuge <peter@stuge.se>
+ * Copyright © 2011 Vitali Lovich <vlovich@aliph.com>
+ * Copyright © 2011 Peter Stuge <peter@stuge.se>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -19,14 +19,14 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#ifdef _XOPEN_SOURCE
-# if _XOPEN_SOURCE < 500
-# undef _XOPEN_SOURCE
-# define _XOPEN_SOURCE 500
-# endif
-#else
-#define _XOPEN_SOURCE 500
-#endif /* _XOPEN_SOURCE */
+#if defined(__linux__) || defined(__OpenBSD__)
+# include <unistd.h>
+# include <sys/syscall.h>
+#elif defined(__APPLE__)
+# include <mach/mach.h>
+#elif defined(__CYGWIN__)
+# include <windows.h>
+#endif
#include "threads_posix.h"
@@ -41,6 +41,7 @@ int usbi_mutex_init_recursive(pthread_mutex_t *mutex, pthread_mutexattr_t *attr)
return err;
}
+ /* mutexattr_settype requires _GNU_SOURCE or _XOPEN_SOURCE >= 500 on Linux */
err = pthread_mutexattr_settype(attr, PTHREAD_MUTEX_RECURSIVE);
if (err != 0)
goto finish;
@@ -53,3 +54,22 @@ finish:
return err;
}
+
+int usbi_get_tid(void)
+{
+ int ret = -1;
+#if defined(__linux__)
+ ret = syscall(SYS_gettid);
+#elif defined(__OpenBSD__)
+ /* The following only works with OpenBSD > 5.1 as it requires
+ 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);
+#elif defined(__CYGWIN__)
+ ret = GetCurrentThreadId();
+#endif
+/* TODO: NetBSD thread ID support */
+ return ret;
+}
« no previous file with comments | « third_party/libusb/src/libusb/os/threads_posix.h ('k') | third_party/libusb/src/libusb/os/threads_windows.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698