<div dir="ltr">I'm OK with this.</div><div class="gmail_extra"><br><div class="gmail_quote">On Sun, Jan 29, 2017 at 10:18 AM, Dimitry Andric <span dir="ltr"><<a href="mailto:dimitry@andric.com" target="_blank">dimitry@andric.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">I'd like to merge this to the release_40 branch.  Eric, you OK with that?<br>
<span class="HOEnZb"><font color="#888888"><br>
-Dimitry<br>
</font></span><div class="HOEnZb"><div class="h5"><br>
> On 26 Jan 2017, at 19:37, Dimitry Andric via cfe-commits <<a href="mailto:cfe-commits@lists.llvm.org">cfe-commits@lists.llvm.org</a>> wrote:<br>
><br>
> Author: dim<br>
> Date: Thu Jan 26 12:37:18 2017<br>
> New Revision: 293197<br>
><br>
> URL: <a href="http://llvm.org/viewvc/llvm-project?rev=293197&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project?rev=293197&view=rev</a><br>
> Log:<br>
> Disable thread safety analysis for some functions in __thread_support<br>
><br>
> Many thread-related libc++ test cases fail on FreeBSD, due to the<br>
> following -Werror warnings:<br>
><br>
>    In file included from test/std/thread/thread.<wbr>threads/thread.thread.this/<wbr>sleep_until.pass.cpp:17:<br>
>    In file included from include/thread:97:<br>
>    In file included from include/__mutex_base:17:<br>
>    include/__threading_support:<wbr>222:1: error: mutex '__m' is still held at the end of function [-Werror,-Wthread-safety-<wbr>analysis]<br>
>    }<br>
>    ^<br>
>    include/__threading_support:<wbr>221:10: note: mutex acquired here<br>
>      return pthread_mutex_lock(__m);<br>
>             ^<br>
>    include/__threading_support:<wbr>231:10: error: releasing mutex '__m' that was not held [-Werror,-Wthread-safety-<wbr>analysis]<br>
>      return pthread_mutex_unlock(__m);<br>
>             ^<br>
>    include/__threading_support:<wbr>242:1: error: mutex '__m' is still held at the end of function [-Werror,-Wthread-safety-<wbr>analysis]<br>
>    }<br>
>    ^<br>
>    include/__threading_support:<wbr>241:10: note: mutex acquired here<br>
>      return pthread_mutex_lock(__m);<br>
>             ^<br>
>    include/__threading_support:<wbr>251:10: error: releasing mutex '__m' that was not held [-Werror,-Wthread-safety-<wbr>analysis]<br>
>      return pthread_mutex_unlock(__m);<br>
>             ^<br>
>    include/__threading_support:<wbr>272:10: error: calling function 'pthread_cond_wait' requires holding mutex '__m' exclusively [-Werror,-Wthread-safety-<wbr>analysis]<br>
>      return pthread_cond_wait(__cv, __m);<br>
>             ^<br>
>    include/__threading_support:<wbr>278:10: error: calling function 'pthread_cond_timedwait' requires holding mutex '__m' exclusively [-Werror,-Wthread-safety-<wbr>analysis]<br>
>      return pthread_cond_timedwait(__cv, __m, __ts);<br>
>             ^<br>
>    6 errors generated.<br>
><br>
> This is because on FreeBSD, the pthread functions have lock annotations.<br>
> Since the functions in __thread_support are internal to libc++ only, add<br>
> no_thread_safety_analysis attributes to suppress these warnings.<br>
><br>
> Reviewers: mclow.lists, EricWF, delesley, aaron.ballman<br>
> Reviewed By: aaron.ballman<br>
> Subscribers: ed, aaron.ballman, joerg, emaste, cfe-commits<br>
> Differential Revision: <a href="https://reviews.llvm.org/D28520" rel="noreferrer" target="_blank">https://reviews.llvm.org/<wbr>D28520</a><br>
><br>
> Modified:<br>
>    libcxx/trunk/include/__<wbr>threading_support<br>
><br>
> Modified: libcxx/trunk/include/__<wbr>threading_support<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__threading_support?rev=293197&r1=293196&r2=293197&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/libcxx/trunk/include/_<wbr>_threading_support?rev=293197&<wbr>r1=293196&r2=293197&view=diff</a><br>
> ==============================<wbr>==============================<wbr>==================<br>
> --- libcxx/trunk/include/__<wbr>threading_support (original)<br>
> +++ libcxx/trunk/include/__<wbr>threading_support Thu Jan 26 12:37:18 2017<br>
> @@ -40,6 +40,12 @@<br>
> #define _LIBCPP_THREAD_ABI_VISIBILITY inline _LIBCPP_INLINE_VISIBILITY<br>
> #endif<br>
><br>
> +#if defined(__FreeBSD__) && defined(__clang__) && __has_attribute(no_thread_<wbr>safety_analysis)<br>
> +#define _LIBCPP_NO_THREAD_SAFETY_<wbr>ANALYSIS __attribute__((no_thread_<wbr>safety_analysis))<br>
> +#else<br>
> +#define _LIBCPP_NO_THREAD_SAFETY_<wbr>ANALYSIS<br>
> +#endif<br>
> +<br>
> _LIBCPP_BEGIN_NAMESPACE_STD<br>
><br>
> #if defined(_LIBCPP_HAS_THREAD_<wbr>API_PTHREAD)<br>
> @@ -102,25 +108,25 @@ typedef DWORD __libcpp_tls_key;<br>
> _LIBCPP_THREAD_ABI_VISIBILITY<br>
> int __libcpp_recursive_mutex_init(<wbr>__libcpp_recursive_mutex_t *__m);<br>
><br>
> -_LIBCPP_THREAD_ABI_VISIBILITY<br>
> +_LIBCPP_THREAD_ABI_VISIBILITY _LIBCPP_NO_THREAD_SAFETY_<wbr>ANALYSIS<br>
> int __libcpp_recursive_mutex_lock(<wbr>__libcpp_recursive_mutex_t *__m);<br>
><br>
> -_LIBCPP_THREAD_ABI_VISIBILITY<br>
> +_LIBCPP_THREAD_ABI_VISIBILITY _LIBCPP_NO_THREAD_SAFETY_<wbr>ANALYSIS<br>
> bool __libcpp_recursive_mutex_<wbr>trylock(__libcpp_recursive_<wbr>mutex_t *__m);<br>
><br>
> -_LIBCPP_THREAD_ABI_VISIBILITY<br>
> +_LIBCPP_THREAD_ABI_VISIBILITY _LIBCPP_NO_THREAD_SAFETY_<wbr>ANALYSIS<br>
> int __libcpp_recursive_mutex_<wbr>unlock(__libcpp_recursive_<wbr>mutex_t *__m);<br>
><br>
> _LIBCPP_THREAD_ABI_VISIBILITY<br>
> int __libcpp_recursive_mutex_<wbr>destroy(__libcpp_recursive_<wbr>mutex_t *__m);<br>
><br>
> -_LIBCPP_THREAD_ABI_VISIBILITY<br>
> +_LIBCPP_THREAD_ABI_VISIBILITY _LIBCPP_NO_THREAD_SAFETY_<wbr>ANALYSIS<br>
> int __libcpp_mutex_lock(__libcpp_<wbr>mutex_t *__m);<br>
><br>
> -_LIBCPP_THREAD_ABI_VISIBILITY<br>
> +_LIBCPP_THREAD_ABI_VISIBILITY _LIBCPP_NO_THREAD_SAFETY_<wbr>ANALYSIS<br>
> bool __libcpp_mutex_trylock(__<wbr>libcpp_mutex_t *__m);<br>
><br>
> -_LIBCPP_THREAD_ABI_VISIBILITY<br>
> +_LIBCPP_THREAD_ABI_VISIBILITY _LIBCPP_NO_THREAD_SAFETY_<wbr>ANALYSIS<br>
> int __libcpp_mutex_unlock(__<wbr>libcpp_mutex_t *__m);<br>
><br>
> _LIBCPP_THREAD_ABI_VISIBILITY<br>
> @@ -133,10 +139,10 @@ int __libcpp_condvar_signal(__<wbr>libcpp_con<br>
> _LIBCPP_THREAD_ABI_VISIBILITY<br>
> int __libcpp_condvar_broadcast(__<wbr>libcpp_condvar_t* __cv);<br>
><br>
> -_LIBCPP_THREAD_ABI_VISIBILITY<br>
> +_LIBCPP_THREAD_ABI_VISIBILITY _LIBCPP_NO_THREAD_SAFETY_<wbr>ANALYSIS<br>
> int __libcpp_condvar_wait(__<wbr>libcpp_condvar_t* __cv, __libcpp_mutex_t* __m);<br>
><br>
> -_LIBCPP_THREAD_ABI_VISIBILITY<br>
> +_LIBCPP_THREAD_ABI_VISIBILITY _LIBCPP_NO_THREAD_SAFETY_<wbr>ANALYSIS<br>
> int __libcpp_condvar_timedwait(__<wbr>libcpp_condvar_t *__cv, __libcpp_mutex_t *__m,<br>
>                                timespec *__ts);<br>
><br>
><br>
><br>
> ______________________________<wbr>_________________<br>
> cfe-commits mailing list<br>
> <a href="mailto:cfe-commits@lists.llvm.org">cfe-commits@lists.llvm.org</a><br>
> <a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/cfe-commits</a><br>
<br>
</div></div></blockquote></div><br></div>