X-Git-Url: https://git.saurik.com/apple/security.git/blobdiff_plain/bac41a7b9a0a9254fa30f8bb6e6038ab71a483e2..ce0ac947b4708d0bc1c7e6789b3e1f3bfc80d6e9:/cdsa/cdsa_utilities/globalizer.cpp?ds=sidebyside diff --git a/cdsa/cdsa_utilities/globalizer.cpp b/cdsa/cdsa_utilities/globalizer.cpp index 0f7fa629..03051e60 100644 --- a/cdsa/cdsa_utilities/globalizer.cpp +++ b/cdsa/cdsa_utilities/globalizer.cpp @@ -28,17 +28,15 @@ // // @@@ Assumption: {bool,T*} atomic unless PTHREAD_STRICT // -#ifdef __MWERKS__ -#define _CPP_GLOBALIZER -#endif #include +#include #include // // The Error class thrown if Nexus operations fail // -GlobalNexus::Error::~Error() +GlobalNexus::Error::~Error() throw() { } @@ -70,8 +68,8 @@ GlobalNexus::Error::~Error() // WARNING: // This code makes the following non-portable assumptions: // (a) NULL == 0 (binary representation of NULL pointer is zero value) -// Pointers acquired from new have at least their LSB zero (are at -// (b) least two-byte aligned). +// (b) Pointers acquired from new have at least their LSB zero (are at +// least two-byte aligned). // It seems like it's been a while since anyone made a machine/runtime that // violated either of those. But you have been warned. // @@ -98,16 +96,17 @@ AtomicWord ModuleNexusCommon::create(void *(*make)()) void *singleton = make(); pointer = AtomicWord(singleton); // we need a write barrier here, but the mutex->unlock below provides it for free - debug("nexus", "ModuleNexus %p constructed object 0x%x", this, pointer); } catch (...) { - debug("nexus", "ModuleNexus %p construction failed", this); + secdebug("nexus", "ModuleNexus %p construction failed", this); mutex->unlock(); - sync--; - //@@@ set up for retry here? + if (--sync == 0) { + delete mutex; + pointer = 0; + } throw; } } else { - mutex = reinterpret_cast(pointer & ~0x1); + mutex = reinterpret_cast(initialPointer & ~0x1); mutex->lock(); // we'll wait here } mutex->unlock();