LLVM  10.0.0
ThreadLocal.inc
Go to the documentation of this file.
1 //= llvm/Support/Win32/ThreadLocal.inc - Win32 Thread Local Data -*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // This file implements the Win32 specific (non-pthread) ThreadLocal class.
10 //
11 //===----------------------------------------------------------------------===//
12 
13 //===----------------------------------------------------------------------===//
14 //=== WARNING: Implementation here must contain only generic Win32 code that
15 //=== is guaranteed to work on *all* Win32 variants.
16 //===----------------------------------------------------------------------===//
17 
20 
21 namespace llvm {
22 
24  static_assert(sizeof(DWORD) <= sizeof(data), "size too big");
25  DWORD* tls = reinterpret_cast<DWORD*>(&data);
26  *tls = TlsAlloc();
27  assert(*tls != TLS_OUT_OF_INDEXES);
28 }
29 
31  DWORD* tls = reinterpret_cast<DWORD*>(&data);
32  TlsFree(*tls);
33 }
34 
36  DWORD* tls = reinterpret_cast<DWORD*>(&data);
37  return TlsGetValue(*tls);
38 }
39 
40 void sys::ThreadLocalImpl::setInstance(const void* d){
41  DWORD* tls = reinterpret_cast<DWORD*>(&data);
42  int errorcode = TlsSetValue(*tls, const_cast<void*>(d));
43  assert(errorcode != 0);
44  (void)errorcode;
45 }
46 
48  setInstance(0);
49 }
50 
51 }
This class represents lattice values for constants.
Definition: AllocatorList.h:23
void setInstance(const void *d)
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())