[PATCH] D28520: Disable -Wthread-safety-analysis for some functions in __thread_support

Dimitry Andric via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Jan 10 12:00:59 PST 2017


dim updated this revision to Diff 83843.
dim added a comment.

- Move `_LIBCPP_THREAD_SAFETY_ANNOTATION` macro definition to `__config`.
- Add `_LIBCPP_THREAD_SAFETY_ANNOTATION(no_thread_safety_analysis)` macros to `__threading_support` function declarations which require them.

Note that I was not able to figure out how to make the other thread safety annotation attributes, such as `try_acquire_capability()`, match to the function signatures, as these use `int` instead of `bool`, for example.


https://reviews.llvm.org/D28520

Files:
  include/__config
  include/__mutex_base
  include/__threading_support


Index: include/__threading_support
===================================================================
--- include/__threading_support
+++ include/__threading_support
@@ -98,25 +98,25 @@
 _LIBCPP_THREAD_ABI_VISIBILITY
 int __libcpp_recursive_mutex_init(__libcpp_recursive_mutex_t *__m);
 
-_LIBCPP_THREAD_ABI_VISIBILITY
+_LIBCPP_THREAD_ABI_VISIBILITY _LIBCPP_THREAD_SAFETY_ANNOTATION(no_thread_safety_analysis)
 int __libcpp_recursive_mutex_lock(__libcpp_recursive_mutex_t *__m);
 
-_LIBCPP_THREAD_ABI_VISIBILITY
+_LIBCPP_THREAD_ABI_VISIBILITY _LIBCPP_THREAD_SAFETY_ANNOTATION(no_thread_safety_analysis)
 int __libcpp_recursive_mutex_trylock(__libcpp_recursive_mutex_t *__m);
 
-_LIBCPP_THREAD_ABI_VISIBILITY
+_LIBCPP_THREAD_ABI_VISIBILITY _LIBCPP_THREAD_SAFETY_ANNOTATION(no_thread_safety_analysis)
 int __libcpp_recursive_mutex_unlock(__libcpp_recursive_mutex_t *__m);
 
 _LIBCPP_THREAD_ABI_VISIBILITY
 int __libcpp_recursive_mutex_destroy(__libcpp_recursive_mutex_t *__m);
 
-_LIBCPP_THREAD_ABI_VISIBILITY
+_LIBCPP_THREAD_ABI_VISIBILITY _LIBCPP_THREAD_SAFETY_ANNOTATION(no_thread_safety_analysis)
 int __libcpp_mutex_lock(__libcpp_mutex_t *__m);
 
 _LIBCPP_THREAD_ABI_VISIBILITY
 int __libcpp_mutex_trylock(__libcpp_mutex_t *__m);
 
-_LIBCPP_THREAD_ABI_VISIBILITY
+_LIBCPP_THREAD_ABI_VISIBILITY _LIBCPP_THREAD_SAFETY_ANNOTATION(no_thread_safety_analysis)
 int __libcpp_mutex_unlock(__libcpp_mutex_t *__m);
 
 _LIBCPP_THREAD_ABI_VISIBILITY
@@ -129,10 +129,10 @@
 _LIBCPP_THREAD_ABI_VISIBILITY
 int __libcpp_condvar_broadcast(__libcpp_condvar_t* __cv);
 
-_LIBCPP_THREAD_ABI_VISIBILITY
+_LIBCPP_THREAD_ABI_VISIBILITY _LIBCPP_THREAD_SAFETY_ANNOTATION(no_thread_safety_analysis)
 int __libcpp_condvar_wait(__libcpp_condvar_t* __cv, __libcpp_mutex_t* __m);
 
-_LIBCPP_THREAD_ABI_VISIBILITY
+_LIBCPP_THREAD_ABI_VISIBILITY _LIBCPP_THREAD_SAFETY_ANNOTATION(no_thread_safety_analysis)
 int __libcpp_condvar_timedwait(__libcpp_condvar_t *__cv, __libcpp_mutex_t *__m,
                                timespec *__ts);
 
Index: include/__mutex_base
===================================================================
--- include/__mutex_base
+++ include/__mutex_base
@@ -24,14 +24,6 @@
 
 #ifndef _LIBCPP_HAS_NO_THREADS
 
-#ifndef _LIBCPP_THREAD_SAFETY_ANNOTATION
-#  ifdef _LIBCPP_HAS_THREAD_SAFETY_ANNOTATIONS
-#    define _LIBCPP_THREAD_SAFETY_ANNOTATION(x) __attribute__((x))
-#  else
-#    define _LIBCPP_THREAD_SAFETY_ANNOTATION(x)
-#  endif
-#endif  // _LIBCPP_THREAD_SAFETY_ANNOTATION
-
 class _LIBCPP_TYPE_VIS _LIBCPP_THREAD_SAFETY_ANNOTATION(capability("mutex")) mutex
 {
 #ifndef _LIBCPP_HAS_NO_CONSTEXPR
Index: include/__config
===================================================================
--- include/__config
+++ include/__config
@@ -981,6 +981,16 @@
 #define _LIBCPP_HAS_THREAD_SAFETY_ANNOTATIONS
 #endif
 
+#if !defined(_LIBCPP_HAS_NO_THREADS)
+# if !defined(_LIBCPP_THREAD_SAFETY_ANNOTATION)
+#  if defined(_LIBCPP_HAS_THREAD_SAFETY_ANNOTATIONS)
+#   define _LIBCPP_THREAD_SAFETY_ANNOTATION(x) __attribute__((x))
+#  else
+#   define _LIBCPP_THREAD_SAFETY_ANNOTATION(x)
+#  endif
+# endif
+#endif
+
 #if __has_attribute(require_constant_initialization)
 #define _LIBCPP_SAFE_STATIC __attribute__((__require_constant_initialization__))
 #else


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D28520.83843.patch
Type: text/x-patch
Size: 3255 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20170110/680aebb0/attachment-0001.bin>


More information about the cfe-commits mailing list