From e32887d8dfb32dc7e9cc2f6313f4c86170c7f17c Mon Sep 17 00:00:00 2001 From: Andrei Alexandrescu Date: Fri, 22 May 2015 12:21:38 -0700 Subject: [PATCH] Workaround for https://issues.dlang.org/show_bug.cgi?id=14617 --- std/experimental/allocator/region.d | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/std/experimental/allocator/region.d b/std/experimental/allocator/region.d index 9017c1fcc..30aa189e6 100644 --- a/std/experimental/allocator/region.d +++ b/std/experimental/allocator/region.d @@ -498,6 +498,21 @@ version(Posix) struct SbrkRegion(uint minAlign = platformAlignment) import core.sys.posix.pthread; static shared pthread_mutex_t sbrkMutex = PTHREAD_MUTEX_INITIALIZER; + // workaround for https://issues.dlang.org/show_bug.cgi?id=14617 + version(OSX) + { + shared static this() + { + pthread_mutex_init(cast(pthread_mutex_t*) &sbrkMutex, null) == 0 + || assert(0); + } + shared static ~this() + { + pthread_mutex_destroy(cast(pthread_mutex_t*) &sbrkMutex) == 0 + || assert(0); + } + } + static assert(minAlign.isGoodStaticAlignment); static assert(size_t.sizeof == (void*).sizeof); private shared void* _brkInitial, _brkCurrent;