dim created this revision.
dim added reviewers: EricWF, mclow.lists.
dim added subscribers: cfe-commits, emaste, joerg.
Many thread-related libc++ test cases fail on FreeBSD, due to the following
-Werror warnings:
In file included from
/share/dim/src/llvm/trunk/projects/libcxx/test/std/thread/thread.threads/thread.thread.this/sleep_until.pass.cpp:17:
In file included from
/share/dim/src/llvm/trunk/projects/libcxx/include/thread:97:
In file included from
/share/dim/src/llvm/trunk/projects/libcxx/include/__mutex_base:17:
/share/dim/src/llvm/trunk/projects/libcxx/include/__threading_support:222:1:
error: mutex '__m' is still held at the end of function
[-Werror,-Wthread-safety-analysis]
}
^
/share/dim/src/llvm/trunk/projects/libcxx/include/__threading_support:221:10:
note: mutex acquired here
return pthread_mutex_lock(__m);
^
/share/dim/src/llvm/trunk/projects/libcxx/include/__threading_support:231:10:
error: releasing mutex '__m' that was not held
[-Werror,-Wthread-safety-analysis]
return pthread_mutex_unlock(__m);
^
/share/dim/src/llvm/trunk/projects/libcxx/include/__threading_support:242:1:
error: mutex '__m' is still held at the end of function
[-Werror,-Wthread-safety-analysis]
}
^
/share/dim/src/llvm/trunk/projects/libcxx/include/__threading_support:241:10:
note: mutex acquired here
return pthread_mutex_lock(__m);
^
/share/dim/src/llvm/trunk/projects/libcxx/include/__threading_support:251:10:
error: releasing mutex '__m' that was not held
[-Werror,-Wthread-safety-analysis]
return pthread_mutex_unlock(__m);
^
/share/dim/src/llvm/trunk/projects/libcxx/include/__threading_support:272:10:
error: calling function 'pthread_cond_wait' requires holding mutex '__m'
exclusively [-Werror,-Wthread-safety-analysis]
return pthread_cond_wait(__cv, __m);
^
/share/dim/src/llvm/trunk/projects/libcxx/include/__threading_support:278:10:
error: calling function 'pthread_cond_timedwait' requires holding mutex '__m'
exclusively [-Werror,-Wthread-safety-analysis]
return pthread_cond_timedwait(__cv, __m, __ts);
^
6 errors generated.
Obviously, these warnings are false, since the functions are exactly doing what
they are supposed to do.
Therefore, add pragmas to ignored -Wthread-safety-analysis warnings. These
could also be set for the whole block of thread-related functions, but in this
version I have added them per function.
I also considered doing this with macros, as Joerg suggested, but macros that
expand to multi-line pragma statements are rather unwieldy, and don't make it
much nicer, in my opinion. Suggestions welcome, of course.
https://reviews.llvm.org/D28520
Files:
include/__threading_support
Index: include/__threading_support
===================================================================
--- include/__threading_support
+++ include/__threading_support
@@ -216,40 +216,68 @@
return 0;
}
+#ifdef __clang__
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wthread-safety-analysis"
+#endif
int __libcpp_recursive_mutex_lock(__libcpp_recursive_mutex_t *__m)
{
return pthread_mutex_lock(__m);
}
+#ifdef __clang__
+#pragma clang diagnostic pop
+#endif
int __libcpp_recursive_mutex_trylock(__libcpp_recursive_mutex_t *__m)
{
return pthread_mutex_trylock(__m);
}
+#ifdef __clang__
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wthread-safety-analysis"
+#endif
int __libcpp_recursive_mutex_unlock(__libcpp_mutex_t *__m)
{
return pthread_mutex_unlock(__m);
}
+#ifdef __clang__
+#pragma clang diagnostic pop
+#endif
int __libcpp_recursive_mutex_destroy(__libcpp_recursive_mutex_t *__m)
{
return pthread_mutex_destroy(__m);
}
+#ifdef __clang__
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wthread-safety-analysis"
+#endif
int __libcpp_mutex_lock(__libcpp_mutex_t *__m)
{
return pthread_mutex_lock(__m);
}
+#ifdef __clang__
+#pragma clang diagnostic pop
+#endif
int __libcpp_mutex_trylock(__libcpp_mutex_t *__m)
{
return pthread_mutex_trylock(__m);
}
+#ifdef __clang__
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wthread-safety-analysis"
+#endif
int __libcpp_mutex_unlock(__libcpp_mutex_t *__m)
{
return pthread_mutex_unlock(__m);
}
+#ifdef __clang__
+#pragma clang diagnostic pop
+#endif
int __libcpp_mutex_destroy(__libcpp_mutex_t *__m)
{
@@ -267,16 +295,30 @@
return pthread_cond_broadcast(__cv);
}
+#ifdef __clang__
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wthread-safety-analysis"
+#endif
int __libcpp_condvar_wait(__libcpp_condvar_t *__cv, __libcpp_mutex_t *__m)
{
return pthread_cond_wait(__cv, __m);
}
+#ifdef __clang__
+#pragma clang diagnostic pop
+#endif
+#ifdef __clang__
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wthread-safety-analysis"
+#endif
int __libcpp_condvar_timedwait(__libcpp_condvar_t *__cv, __libcpp_mutex_t *__m,
timespec *__ts)
{
return pthread_cond_timedwait(__cv, __m, __ts);
}
+#ifdef __clang__
+#pragma clang diagnostic pop
+#endif
int __libcpp_condvar_destroy(__libcpp_condvar_t *__cv)
{
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits