security/sandbox/chromium/base/threading/thread_local_win.cc

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/security/sandbox/chromium/base/threading/thread_local_win.cc	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,42 @@
     1.4 +// Copyright (c) 2010 The Chromium Authors. All rights reserved.
     1.5 +// Use of this source code is governed by a BSD-style license that can be
     1.6 +// found in the LICENSE file.
     1.7 +
     1.8 +#include "base/threading/thread_local.h"
     1.9 +
    1.10 +#include <windows.h>
    1.11 +
    1.12 +#include "base/logging.h"
    1.13 +
    1.14 +namespace base {
    1.15 +
    1.16 +namespace internal {
    1.17 +
    1.18 +// static
    1.19 +void ThreadLocalPlatform::AllocateSlot(SlotType& slot) {
    1.20 +  slot = TlsAlloc();
    1.21 +  CHECK_NE(slot, TLS_OUT_OF_INDEXES);
    1.22 +}
    1.23 +
    1.24 +// static
    1.25 +void ThreadLocalPlatform::FreeSlot(SlotType& slot) {
    1.26 +  if (!TlsFree(slot)) {
    1.27 +    NOTREACHED() << "Failed to deallocate tls slot with TlsFree().";
    1.28 +  }
    1.29 +}
    1.30 +
    1.31 +// static
    1.32 +void* ThreadLocalPlatform::GetValueFromSlot(SlotType& slot) {
    1.33 +  return TlsGetValue(slot);
    1.34 +}
    1.35 +
    1.36 +// static
    1.37 +void ThreadLocalPlatform::SetValueInSlot(SlotType& slot, void* value) {
    1.38 +  if (!TlsSetValue(slot, value)) {
    1.39 +    LOG(FATAL) << "Failed to TlsSetValue().";
    1.40 +  }
    1.41 +}
    1.42 +
    1.43 +}  // namespace internal
    1.44 +
    1.45 +}  // namespace base

mercurial