+#ifdef HAVE_WIN32_THREAD
+
+class TlsSlot
+{
+public:
+ TlsSlot()
+ {
+ m_slot = ::TlsAlloc();
+ }
+
+ ~TlsSlot()
+ {
+ ::TlsFree(m_slot);
+ }
+
+ operator DWORD() const { return m_slot; }
+
+private:
+ DWORD m_slot;
+
+ DECLARE_NO_COPY_CLASS(TlsSlot)
+};
+
+BENCHMARK_FUNC(Win32TLS)
+{
+ static TlsSlot s_slot;
+
+ for ( int n = 0; n < NUM_ITER; n++ )
+ {
+ if ( n % 2 )
+ ::TlsSetValue(s_slot, 0);
+ else
+ ::TlsSetValue(s_slot, &n);
+ }
+
+ return !::TlsGetValue(s_slot);
+}
+
+#endif // HAVE_WIN32_THREAD
+