summaryrefslogtreecommitdiffstats
path: root/libusb-1.0/libusb/os/threads_windows.h
diff options
context:
space:
mode:
authorBenjamin Dobell <benjamin.dobell+github@glassechidna.com.au>2010-12-04 14:25:04 +0100
committerBenjamin Dobell <benjamin.dobell+github@glassechidna.com.au>2010-12-04 14:25:04 +0100
commit46f2c1134d276944fb74584a61d90cc363aee7eb (patch)
tree6fa14b7ef509a3fb84305dec013dd24bcae6c17d /libusb-1.0/libusb/os/threads_windows.h
parentAddresses: (diff)
downloadHeimdall-46f2c1134d276944fb74584a61d90cc363aee7eb.tar
Heimdall-46f2c1134d276944fb74584a61d90cc363aee7eb.tar.gz
Heimdall-46f2c1134d276944fb74584a61d90cc363aee7eb.tar.bz2
Heimdall-46f2c1134d276944fb74584a61d90cc363aee7eb.tar.lz
Heimdall-46f2c1134d276944fb74584a61d90cc363aee7eb.tar.xz
Heimdall-46f2c1134d276944fb74584a61d90cc363aee7eb.tar.zst
Heimdall-46f2c1134d276944fb74584a61d90cc363aee7eb.zip
Diffstat (limited to '')
-rw-r--r--libusb-1.0/libusb/os/threads_windows.h84
1 files changed, 84 insertions, 0 deletions
diff --git a/libusb-1.0/libusb/os/threads_windows.h b/libusb-1.0/libusb/os/threads_windows.h
new file mode 100644
index 0000000..2cd1867
--- /dev/null
+++ b/libusb-1.0/libusb/os/threads_windows.h
@@ -0,0 +1,84 @@
+/*
+ * libusb synchronization on Microsoft Windows
+ *
+ * Copyright (C) 2010 Michael Plante <michael.plante@gmail.com>
+ *
+ * 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
+ */
+
+#ifndef __LIBUSB_THREADS_WINDOWS_H__
+#define __LIBUSB_THREADS_WINDOWS_H__
+
+#define usbi_mutex_static_t volatile LONG
+#define USBI_MUTEX_INITIALIZER 0
+
+#define usbi_mutex_t HANDLE
+
+struct usbi_cond_perthread {
+ struct list_head list;
+ DWORD tid;
+ HANDLE event;
+};
+struct usbi_cond_t_ {
+ // Every time a thread touches the CV, it winds up in one of these lists.
+ // It stays there until the CV is destroyed, even if the thread
+ // terminates.
+ struct list_head waiters;
+ struct list_head not_waiting;
+};
+typedef struct usbi_cond_t_ usbi_cond_t;
+
+// We *were* getting timespec from pthread.h:
+#if (!defined(HAVE_STRUCT_TIMESPEC) && !defined(_TIMESPEC_DEFINED))
+#define HAVE_STRUCT_TIMESPEC 1
+#define _TIMESPEC_DEFINED 1
+struct timespec {
+ long tv_sec;
+ long tv_nsec;
+};
+#endif /* HAVE_STRUCT_TIMESPEC | _TIMESPEC_DEFINED */
+
+// We *were* getting ETIMEDOUT from pthread.h:
+#ifndef ETIMEDOUT
+# define ETIMEDOUT 10060 /* This is the value in winsock.h. */
+#endif
+
+#define usbi_mutexattr_t void
+#define usbi_condattr_t void
+
+
+int usbi_mutex_static_lock(usbi_mutex_static_t *mutex);
+int usbi_mutex_static_unlock(usbi_mutex_static_t *mutex);
+
+
+int usbi_mutex_init(usbi_mutex_t *mutex,
+ const usbi_mutexattr_t *attr);
+int usbi_mutex_lock(usbi_mutex_t *mutex);
+int usbi_mutex_unlock(usbi_mutex_t *mutex);
+int usbi_mutex_trylock(usbi_mutex_t *mutex);
+int usbi_mutex_destroy(usbi_mutex_t *mutex);
+
+int usbi_cond_init(usbi_cond_t *cond,
+ const usbi_condattr_t *attr);
+int usbi_cond_destroy(usbi_cond_t *cond);
+int usbi_cond_wait(usbi_cond_t *cond, usbi_mutex_t *mutex);
+int usbi_cond_timedwait(usbi_cond_t *cond,
+ usbi_mutex_t *mutex,
+ const struct timespec *abstime);
+int usbi_cond_broadcast(usbi_cond_t *cond);
+int usbi_cond_signal(usbi_cond_t *cond);
+
+#endif /* __LIBUSB_THREADS_WINDOWS_H__ */
+