[PATCH v2 1/2] vkd3d: On apple, implement pthread_spinlock_t with os_unfair_lock.
Derek Lesho
dlesho at codeweavers.com
Thu Sep 12 10:24:59 CDT 2019
Signed-off-by: Derek Lesho <dlesho at codeweavers.com>
---
include/private/vkd3d_common.h | 36 ++++++++++++++++++++++++++++++++++
1 file changed, 36 insertions(+)
diff --git a/include/private/vkd3d_common.h b/include/private/vkd3d_common.h
index 1ac8a63..c6a0946 100644
--- a/include/private/vkd3d_common.h
+++ b/include/private/vkd3d_common.h
@@ -168,4 +168,40 @@ static inline void vkd3d_parse_version(const char *version, int *major, int *min
*minor = atoi(version);
}
+#ifdef __APPLE__
+#include <os/lock.h>
+
+typedef os_unfair_lock pthread_spinlock_t;
+
+inline int pthread_spin_init(pthread_spinlock_t *lock, int pshared)
+{
+ if (pshared != PTHREAD_PROCESS_PRIVATE) return E_INVALIDARG;
+ *lock = OS_UNFAIR_LOCK_INIT;
+ return 0;
+}
+
+inline int pthread_spin_lock(pthread_spinlock_t *lock)
+{
+ os_unfair_lock_lock(lock);
+ return 0;
+}
+
+inline int pthread_spin_trylock(pthread_spinlock_t *lock)
+{
+ if (!(os_unfair_lock_trylock(lock))) return EBUSY;
+ return 0;
+}
+
+inline int pthread_spin_unlock(pthread_spinlock_t *lock)
+{
+ os_unfair_lock_unlock(lock);
+ return 0;
+}
+
+inline int pthread_spin_destroy(pthread_spinlock_t *lock)
+{
+ return 0;
+}
+#endif
+
#endif /* __VKD3D_COMMON_H */
--
2.23.0
More information about the wine-devel
mailing list