[llvm-commits] [llvm] r118463 - /llvm/trunk/lib/System/DynamicLibrary.cpp
Chris Lattner
clattner at apple.com
Mon Nov 8 22:07:28 PST 2010
On Nov 8, 2010, at 4:36 PM, Owen Anderson wrote:
> Author: resistor
> Date: Mon Nov 8 18:36:06 2010
> New Revision: 118463
>
> URL: http://llvm.org/viewvc/llvm-project?rev=118463&view=rev
> Log:
> Fix PR8441, a thread unsafe static variable in our dynamic library loading facilities.
Hi Owen,
Does SmartMutex<true> cause a static constructor?
-Chris
>
> Modified:
> llvm/trunk/lib/System/DynamicLibrary.cpp
>
> Modified: llvm/trunk/lib/System/DynamicLibrary.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/System/DynamicLibrary.cpp?rev=118463&r1=118462&r2=118463&view=diff
> ==============================================================================
> --- llvm/trunk/lib/System/DynamicLibrary.cpp (original)
> +++ llvm/trunk/lib/System/DynamicLibrary.cpp Mon Nov 8 18:36:06 2010
> @@ -15,6 +15,7 @@
> //===----------------------------------------------------------------------===//
>
> #include "llvm/System/DynamicLibrary.h"
> +#include "llvm/System/Mutex.h"
> #include "llvm/Config/config.h"
> #include <cstdio>
> #include <cstring>
> @@ -60,6 +61,7 @@
> //=== independent code.
> //===----------------------------------------------------------------------===//
>
> +static SmartMutex<true> HandlesMutex;
> static std::vector<void *> *OpenedHandles = 0;
>
>
> @@ -76,6 +78,7 @@
> if (Filename == NULL)
> H = RTLD_DEFAULT;
> #endif
> + SmartScopedLock<true> Lock(HandlesMutex);
> if (OpenedHandles == 0)
> OpenedHandles = new std::vector<void *>();
> OpenedHandles->push_back(H);
> @@ -110,6 +113,7 @@
>
> #if HAVE_DLFCN_H
> // Now search the libraries.
> + SmartScopedLock<true> Lock(HandlesMutex);
> if (OpenedHandles) {
> for (std::vector<void *>::iterator I = OpenedHandles->begin(),
> E = OpenedHandles->end(); I != E; ++I) {
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
More information about the llvm-commits
mailing list