[PATCH] [ASan] Make BlockingMutex really linker initialized.
David Blaikie
dblaikie at gmail.com
Tue Jan 27 15:47:05 PST 2015
On Tue, Jan 27, 2015 at 1:13 AM, Yury Gribov <tetra2005 at gmail.com> wrote:
> Updated based on review.
>
>
> REPOSITORY
> rL LLVM
>
> http://reviews.llvm.org/D7171
>
> Files:
> lib/sanitizer_common/sanitizer_linux.cc
> lib/sanitizer_common/sanitizer_mac.cc
> lib/sanitizer_common/sanitizer_mutex.h
>
> Index: lib/sanitizer_common/sanitizer_linux.cc
> ===================================================================
> --- lib/sanitizer_common/sanitizer_linux.cc
> +++ lib/sanitizer_common/sanitizer_linux.cc
> @@ -493,15 +493,12 @@
> MtxSleeping = 2
> };
>
> -BlockingMutex::BlockingMutex(LinkerInitialized) {
> - CHECK_EQ(owner_, 0);
> -}
> -
> BlockingMutex::BlockingMutex() {
> internal_memset(this, 0, sizeof(*this));
> }
>
> void BlockingMutex::Lock() {
> + CHECK_EQ(owner_, 0);
> atomic_uint32_t *m = reinterpret_cast<atomic_uint32_t
> *>(&opaque_storage_);
> if (atomic_exchange(m, MtxLocked, memory_order_acquire) == MtxUnlocked)
> return;
> Index: lib/sanitizer_common/sanitizer_mac.cc
> ===================================================================
> --- lib/sanitizer_common/sanitizer_mac.cc
> +++ lib/sanitizer_common/sanitizer_mac.cc
> @@ -217,10 +217,6 @@
> return sysconf(_SC_PAGESIZE);
> }
>
> -BlockingMutex::BlockingMutex(LinkerInitialized) {
> - // We assume that OS_SPINLOCK_INIT is zero
> -}
> -
> BlockingMutex::BlockingMutex() {
> internal_memset(this, 0, sizeof(*this));
> }
> Index: lib/sanitizer_common/sanitizer_mutex.h
> ===================================================================
> --- lib/sanitizer_common/sanitizer_mutex.h
> +++ lib/sanitizer_common/sanitizer_mutex.h
> @@ -73,7 +73,13 @@
>
> class BlockingMutex {
> public:
> +#if SANITIZER_WINDOWS
> + // Windows does not currently support LinkerInitialized
> explicit BlockingMutex(LinkerInitialized);
> +#else
> + explicit constexpr BlockingMutex(LinkerInitialized)
> + : opaque_storage_ {0, },
This is something I haven't seen before (though seems obvious enough) - any
idea if it's supported on the full compiler support matrix (except
windows?)?
> owner_(0) {}
+#endif
> BlockingMutex();
> void Lock();
> void Unlock();
>
> EMAIL PREFERENCES
> http://reviews.llvm.org/settings/panel/emailpreferences/
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150127/5c3d3769/attachment.html>
More information about the llvm-commits
mailing list