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.