LLVM
10.0.0
lib
Support
Windows
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
18
#include "
llvm/Support/Windows/WindowsSupport.h
"
19
#include "
llvm/Support/ThreadLocal.h
"
20
21
namespace
llvm
{
22
23
sys::ThreadLocalImpl::ThreadLocalImpl
() : data() {
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
30
sys::ThreadLocalImpl::~ThreadLocalImpl
() {
31
DWORD
* tls =
reinterpret_cast<
DWORD
*
>
(&data);
32
TlsFree(*tls);
33
}
34
35
void
*
sys::ThreadLocalImpl::getInstance
() {
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
47
void
sys::ThreadLocalImpl::removeInstance
() {
48
setInstance(0);
49
}
50
51
}
llvm::sys::ThreadLocalImpl::getInstance
void * getInstance()
llvm::sys::ThreadLocalImpl::removeInstance
void removeInstance()
llvm
This class represents lattice values for constants.
Definition:
AllocatorList.h:23
WindowsSupport.h
llvm::sys::ThreadLocalImpl::~ThreadLocalImpl
virtual ~ThreadLocalImpl()
llvm::sys::ThreadLocalImpl::ThreadLocalImpl
ThreadLocalImpl()
ThreadLocal.h
llvm::AMDGPU::SDWA::DWORD
Definition:
SIDefines.h:420
llvm::sys::ThreadLocalImpl::setInstance
void setInstance(const void *d)
assert
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
Generated on Tue Mar 24 2020 13:11:15 for LLVM by
1.8.13