summaryrefslogtreecommitdiff
path: root/util.c
diff options
context:
space:
mode:
authorJarkko Hietaniemi <jhi@iki.fi>2015-11-05 18:52:20 -0500
committerJarkko Hietaniemi <jhi@iki.fi>2015-11-23 06:55:12 -0500
commit3baee7ccba467a3ddc1cb6bfb1a4cabd40cd7424 (patch)
treecd997ea09534ba203a372e75ccfcdde402a439da /util.c
parent04106f2e5c6e8162bd22fd9c7505096116e483cd (diff)
downloadperl-3baee7ccba467a3ddc1cb6bfb1a4cabd40cd7424.tar.gz
clang thread safety annotations
http://clang.llvm.org/docs/ThreadSafetyAnalysis.html Static (compile-time) annotations for declaring the multithreaded behavior of functions, variables, and capabilities (like mutexes). Available since about clang 3.5. ./Configure -des -Dusedevel -Dusethreads -Dcc=clang -Accflags='-Wthread-safety' clang -Wthread-safety then checks the validity of the annotations.
Diffstat (limited to 'util.c')
-rw-r--r--util.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/util.c b/util.c
index ab468fec5f..4d66fe5bd0 100644
--- a/util.c
+++ b/util.c
@@ -6577,6 +6577,28 @@ Perl_dump_c_backtrace(pTHX_ PerlIO* fp, int depth, int skip)
#endif /* #ifdef USE_C_BACKTRACE */
+#ifdef PERL_TSA_ACTIVE
+
+/* pthread_mutex_t and perl_mutex are typedef equivalent
+ * so casting the pointers is fine. */
+
+int perl_tsa_mutex_lock(perl_mutex* mutex)
+{
+ return pthread_mutex_lock((pthread_mutex_t *) mutex);
+}
+
+int perl_tsa_mutex_unlock(perl_mutex* mutex)
+{
+ return pthread_mutex_unlock((pthread_mutex_t *) mutex);
+}
+
+int perl_tsa_mutex_destroy(perl_mutex* mutex)
+{
+ return pthread_mutex_destroy((pthread_mutex_t *) mutex);
+}
+
+#endif
+
/*
* ex: set ts=8 sts=4 sw=4 et:
*/