[PATCH] D19415: [libcxx][rfc] Externalized threading support
Asiri Rathnayake via cfe-commits
cfe-commits at lists.llvm.org
Fri Apr 29 05:00:30 PDT 2016
rmaprath updated this revision to Diff 55573.
rmaprath added a comment.
Minor re-spin on http://reviews.llvm.org/D19412.
http://reviews.llvm.org/D19415
Files:
include/__threading_support
Index: include/__threading_support
===================================================================
--- include/__threading_support
+++ include/__threading_support
@@ -192,7 +192,77 @@
pthread_setspecific(__key, __p);
}
-#else // !_LIBCPP_THREAD_API_PTHREAD
+#elif defined(_LIBCPP_THREAD_API_EXTERNAL)
+
+// Mutex
+#if !defined(_LIBCPP_MUTEX_INITIALIZER)
+ #error "_LIBCPP_MUTEX_INITIALIZER must be defined."
+#endif
+struct __libcpp_mutex_external;
+typedef __libcpp_mutex_external* __libcpp_mutex_t;
+
+int __libcpp_recursive_mutex_init(__libcpp_mutex_t* __m);
+
+int __libcpp_mutex_lock(__libcpp_mutex_t* __m);
+
+int __libcpp_mutex_trylock(__libcpp_mutex_t* __m);
+
+int __libcpp_mutex_unlock(__libcpp_mutex_t* __m);
+
+int __libcpp_mutex_destroy(__libcpp_mutex_t* __m);
+
+// Condition variable
+#if !defined(_LIBCPP_CONDVAR_INITIALIZER)
+ #error "_LIBCPP_CONDVAR_INITIALIZER must be defined."
+#endif
+struct __libcpp_condvar_external;
+typedef __libcpp_condvar_external* __libcpp_condvar_t;
+
+int __libcpp_condvar_signal(__libcpp_condvar_t* __cv);
+
+int __libcpp_condvar_broadcast(__libcpp_condvar_t* __cv);
+
+int __libcpp_condvar_wait(__libcpp_condvar_t* __cv, __libcpp_mutex_t* __m);
+
+int __libcpp_condvar_timedwait(__libcpp_condvar_t* __cv, __libcpp_mutex_t* __m, timespec* __ts);
+
+int __libcpp_condvar_destroy(__libcpp_condvar_t* __cv);
+
+// Thread id
+typedef unsigned long __libcpp_thread_id;
+
+// Returns non-zero if the thread ids are equal, otherwise 0
+int __libcpp_thread_id_equal(__libcpp_thread_id t1, __libcpp_thread_id t2);
+
+// Returns non-zero if t1 < t2, otherwise 0
+int __libcpp_thread_id_less(__libcpp_thread_id t1, __libcpp_thread_id t2);
+
+// Thread
+struct __libcpp_thread_external;
+typedef __libcpp_thread_external* __libcpp_thread_t;
+
+int __libcpp_thread_create(__libcpp_thread_t* __t, void* (*__f)(void*), void* __arg);
+
+__libcpp_thread_id __libcpp_thread_get_current_id();
+
+__libcpp_thread_id __libcpp_thread_get_id(const __libcpp_thread_t* __t);
+
+int __libcpp_thread_join(__libcpp_thread_t* __t);
+
+int __libcpp_thread_detach(__libcpp_thread_t* __t);
+
+void __libcpp_thread_yield();
+
+// Thread local storage
+typedef unsigned long __libcpp_tl_key;
+
+int __libcpp_tl_create(__libcpp_tl_key* __key, void (*__at_exit) (void*));
+
+void* __libcpp_tl_get(__libcpp_tl_key __key);
+
+void __libcpp_tl_set(__libcpp_tl_key __key, void* __p);
+
+#else
#error "No thread API selected."
#endif
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D19415.55573.patch
Type: text/x-patch
Size: 2462 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20160429/56d9707c/attachment.bin>
More information about the cfe-commits
mailing list