summaryrefslogtreecommitdiff
path: root/thread.h
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 /thread.h
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 'thread.h')
-rw-r--r--thread.h12
1 files changed, 10 insertions, 2 deletions
diff --git a/thread.h b/thread.h
index 1fb1cc6131..9958a5bffb 100644
--- a/thread.h
+++ b/thread.h
@@ -208,10 +208,18 @@
} STMT_END
# endif
+# ifdef PERL_TSA_ACTIVE
+# define perl_pthread_mutex_lock(m) perl_tsa_mutex_lock(m)
+# define perl_pthread_mutex_unlock(m) perl_tsa_mutex_unlock(m)
+# else
+# define perl_pthread_mutex_lock(m) pthread_mutex_lock(m)
+# define perl_pthread_mutex_unlock(m) pthread_mutex_unlock(m)
+# endif
+
# define MUTEX_LOCK(m) \
STMT_START { \
int _eC_; \
- if ((_eC_ = pthread_mutex_lock((m)))) \
+ if ((_eC_ = perl_pthread_mutex_lock((m)))) \
Perl_croak_nocontext("panic: MUTEX_LOCK (%d) [%s:%d]", \
_eC_, __FILE__, __LINE__); \
} STMT_END
@@ -219,7 +227,7 @@
# define MUTEX_UNLOCK(m) \
STMT_START { \
int _eC_; \
- if ((_eC_ = pthread_mutex_unlock((m)))) \
+ if ((_eC_ = perl_pthread_mutex_unlock((m)))) \
Perl_croak_nocontext("panic: MUTEX_UNLOCK (%d) [%s:%d]", \
_eC_, __FILE__, __LINE__); \
} STMT_END