//
// @@@ Assumption: {bool,T*} atomic unless PTHREAD_STRICT
//
-#ifdef __MWERKS__
-#define _CPP_GLOBALIZER
-#endif
#include <Security/globalizer.h>
+#include <Security/debugging.h>
#include <cstdlib>
//
// The Error class thrown if Nexus operations fail
//
-GlobalNexus::Error::~Error()
+GlobalNexus::Error::~Error() throw()
{
}
// 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.
//
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<Mutex *>(pointer & ~0x1);
+ mutex = reinterpret_cast<Mutex *>(initialPointer & ~0x1);
mutex->lock(); // we'll wait here
}
mutex->unlock();