From 2d648c1da0a95b54c877a4aac6835181b1c069e5 Mon Sep 17 00:00:00 2001 From: Aleric Inglewood Date: Sat, 14 May 2011 23:43:19 +0200 Subject: [PATCH] Workaround for windows compiler bug. Visual C++ compiler doesn't like to take a pointer to a variable in the argument list of that variable when it is being declared. --- indra/llcommon/aithreadsafe.h | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/indra/llcommon/aithreadsafe.h b/indra/llcommon/aithreadsafe.h index 810aa8c2f..486b3b24f 100644 --- a/indra/llcommon/aithreadsafe.h +++ b/indra/llcommon/aithreadsafe.h @@ -51,6 +51,14 @@ template struct AIReadAccess; template struct AIWriteAccess; template struct AIAccess; +#if LL_WINDOWS +template class AIThreadSafeBits; +template +struct AIThreadSafeWindowsHack { + AIThreadSafeWindowsHack(AIThreadSafeBits& var, T* object); +}; +#endif + template class AIThreadSafeBits { @@ -73,6 +81,9 @@ public: void* memory() const { return const_cast(&mMemory[0]); } protected: +#if LL_WINDOWS + template friend struct AIThreadSafeWindowsHack; +#endif // Accessors. T const* ptr() const { return reinterpret_cast(mMemory); } T* ptr() { return reinterpret_cast(mMemory); } @@ -168,7 +179,12 @@ protected: public: // Only for use by AITHREADSAFE, see below. - AIThreadSafe(T* object) { llassert(object == AIThreadSafeBits::ptr()); } + AIThreadSafe(T* object) + { +#if !LL_WINDOWS + llassert(object == AIThreadSafeBits::ptr()); +#endif + } }; /** @@ -191,7 +207,18 @@ public: * Note: This macro does not allow to allocate such object on the heap. * If that is needed, have a look at AIThreadSafeDC. */ +#if LL_WINDOWS +template +AIThreadSafeWindowsHack::AIThreadSafeWindowsHack(AIThreadSafeBits& var, T* object) +{ + llassert(object == var.ptr()); +} +#define AITHREADSAFE(type, var, paramlist) \ + AIThreadSafe var(NULL); \ + AIThreadSafeWindowsHack dummy_##var(var, new (var.memory()) type paramlist) +#else #define AITHREADSAFE(type, var, paramlist) AIThreadSafe var(new (var.memory()) type paramlist) +#endif /** * @brief A wrapper class for objects that need to be accessed by more than one thread.