[llvm-commits] [llvm] r109686 - in /llvm/trunk: include/llvm/System/ThreadLocal.h lib/System/ThreadLocal.cpp lib/System/Unix/ThreadLocal.inc lib/System/Win32/ThreadLocal.inc

Owen Anderson resistor at mac.com
Wed Jul 28 15:49:44 PDT 2010


Author: resistor
Date: Wed Jul 28 17:49:43 2010
New Revision: 109686

URL: http://llvm.org/viewvc/llvm-project?rev=109686&view=rev
Log:
Add an erase() method to llvm::ThreadLocal.

Modified:
    llvm/trunk/include/llvm/System/ThreadLocal.h
    llvm/trunk/lib/System/ThreadLocal.cpp
    llvm/trunk/lib/System/Unix/ThreadLocal.inc
    llvm/trunk/lib/System/Win32/ThreadLocal.inc

Modified: llvm/trunk/include/llvm/System/ThreadLocal.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/System/ThreadLocal.h?rev=109686&r1=109685&r2=109686&view=diff
==============================================================================
--- llvm/trunk/include/llvm/System/ThreadLocal.h (original)
+++ llvm/trunk/include/llvm/System/ThreadLocal.h Wed Jul 28 17:49:43 2010
@@ -28,6 +28,7 @@
       virtual ~ThreadLocalImpl();
       void setInstance(const void* d);
       const void* getInstance();
+      void removeInstance();
     };
     
     /// ThreadLocal - A class used to abstract thread-local storage.  It holds,
@@ -43,6 +44,9 @@
       
       // set - Associates a pointer to an object with the current thread.
       void set(T* d) { setInstance(d); }
+      
+      // erase - Removes the pointer associated with the current thread.
+      void erase() { removeInstance(); }
     };
   }
 }

Modified: llvm/trunk/lib/System/ThreadLocal.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/System/ThreadLocal.cpp?rev=109686&r1=109685&r2=109686&view=diff
==============================================================================
--- llvm/trunk/lib/System/ThreadLocal.cpp (original)
+++ llvm/trunk/lib/System/ThreadLocal.cpp Wed Jul 28 17:49:43 2010
@@ -67,6 +67,10 @@
   return pthread_getspecific(*key);
 }
 
+void ThreadLocalImpl::removeInstance() {
+  setInstance(0);
+}
+
 }
 
 #elif defined(LLVM_ON_UNIX)

Modified: llvm/trunk/lib/System/Unix/ThreadLocal.inc
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/System/Unix/ThreadLocal.inc?rev=109686&r1=109685&r2=109686&view=diff
==============================================================================
--- llvm/trunk/lib/System/Unix/ThreadLocal.inc (original)
+++ llvm/trunk/lib/System/Unix/ThreadLocal.inc Wed Jul 28 17:49:43 2010
@@ -22,4 +22,5 @@
 ThreadLocalImpl::~ThreadLocalImpl() { }
 void ThreadLocalImpl::setInstance(const void* d) { data = const_cast<void*>(d);}
 const void* ThreadLocalImpl::getInstance() { return data; }
+void ThreadLocalImpl::removeInstance() { setInstance(0); }
 }

Modified: llvm/trunk/lib/System/Win32/ThreadLocal.inc
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/System/Win32/ThreadLocal.inc?rev=109686&r1=109685&r2=109686&view=diff
==============================================================================
--- llvm/trunk/lib/System/Win32/ThreadLocal.inc (original)
+++ llvm/trunk/lib/System/Win32/ThreadLocal.inc Wed Jul 28 17:49:43 2010
@@ -46,4 +46,8 @@
   assert(errorcode != 0);
 }
 
+void ThreadLocalImpl::removeInstance() {
+  setInstance(0);
+}
+
 }





More information about the llvm-commits mailing list