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: int error = pthread_key_create(&slot, NULL); michael@0: CHECK(error == 0); michael@0: } michael@0: michael@0: // static michael@0: void ThreadLocalPlatform::FreeSlot(SlotType& slot) { michael@0: int error = pthread_key_delete(slot); michael@0: DCHECK(error == 0); michael@0: } michael@0: michael@0: // static michael@0: void* ThreadLocalPlatform::GetValueFromSlot(SlotType& slot) { michael@0: return pthread_getspecific(slot); michael@0: } michael@0: michael@0: // static michael@0: void ThreadLocalPlatform::SetValueInSlot(SlotType& slot, void* value) { michael@0: int error = pthread_setspecific(slot, value); michael@0: CHECK(error == 0); michael@0: } michael@0: michael@0: } // namespace base