michael@0: // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. michael@0: // Use of this source code is governed by a BSD-style license that can be michael@0: // found in the LICENSE file. michael@0: michael@0: #include "base/thread_local.h" michael@0: michael@0: #include michael@0: michael@0: #include "base/logging.h" michael@0: michael@0: namespace base { michael@0: michael@0: // static michael@0: void ThreadLocalPlatform::AllocateSlot(SlotType& slot) { michael@0: slot = TlsAlloc(); michael@0: CHECK(slot != TLS_OUT_OF_INDEXES); michael@0: } michael@0: michael@0: // static michael@0: void ThreadLocalPlatform::FreeSlot(SlotType& slot) { michael@0: if (!TlsFree(slot)) { michael@0: NOTREACHED() << "Failed to deallocate tls slot with TlsFree()."; michael@0: } michael@0: } michael@0: michael@0: // static michael@0: void* ThreadLocalPlatform::GetValueFromSlot(SlotType& slot) { michael@0: return TlsGetValue(slot); michael@0: } michael@0: michael@0: // static michael@0: void ThreadLocalPlatform::SetValueInSlot(SlotType& slot, void* value) { michael@0: if (!TlsSetValue(slot, value)) { michael@0: CHECK(false) << "Failed to TlsSetValue()."; michael@0: } michael@0: } michael@0: michael@0: } // namespace base