LLVM
3.7.0
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
work
release_test
rc4
llvm.src
lib
Support
Windows
Windows/ThreadLocal.inc
Go to the documentation of this file.
1
//= llvm/Support/Win32/ThreadLocal.inc - Win32 Thread Local Data -*- C++ -*-===//
2
//
3
// The LLVM Compiler Infrastructure
4
//
5
// This file is distributed under the University of Illinois Open Source
6
// License. See LICENSE.TXT for details.
7
//
8
//===----------------------------------------------------------------------===//
9
//
10
// This file implements the Win32 specific (non-pthread) ThreadLocal class.
11
//
12
//===----------------------------------------------------------------------===//
13
14
//===----------------------------------------------------------------------===//
15
//=== WARNING: Implementation here must contain only generic Win32 code that
16
//=== is guaranteed to work on *all* Win32 variants.
17
//===----------------------------------------------------------------------===//
18
19
#include "
WindowsSupport.h
"
20
#include "
llvm/Support/ThreadLocal.h
"
21
22
namespace
llvm {
23
using namespace
sys;
24
25
ThreadLocalImpl::ThreadLocalImpl
() : data() {
26
static_assert(
sizeof
(DWORD) <=
sizeof
(
data
),
"size too big"
);
27
DWORD* tls =
reinterpret_cast<
DWORD*
>
(&
data
);
28
*tls = TlsAlloc();
29
assert(*tls != TLS_OUT_OF_INDEXES);
30
}
31
32
ThreadLocalImpl::~ThreadLocalImpl
() {
33
DWORD* tls =
reinterpret_cast<
DWORD*
>
(&
data
);
34
TlsFree(*tls);
35
}
36
37
void
*
ThreadLocalImpl::getInstance
() {
38
DWORD* tls =
reinterpret_cast<
DWORD*
>
(&
data
);
39
return
TlsGetValue(*tls);
40
}
41
42
void
ThreadLocalImpl::setInstance
(
const
void
* d){
43
DWORD* tls =
reinterpret_cast<
DWORD*
>
(&
data
);
44
int
errorcode = TlsSetValue(*tls, const_cast<void*>(d));
45
assert(errorcode != 0);
46
(void)errorcode;
47
}
48
49
void
ThreadLocalImpl::removeInstance
() {
50
setInstance
(0);
51
}
52
53
}
llvm::sys::ThreadLocalImpl::getInstance
void * getInstance()
llvm::sys::ThreadLocalImpl::removeInstance
void removeInstance()
WindowsSupport.h
llvm::sys::ThreadLocalImpl::data
char data[sizeof(ThreadLocalDataTy)]
Definition:
ThreadLocal.h:32
llvm::sys::ThreadLocalImpl::~ThreadLocalImpl
virtual ~ThreadLocalImpl()
llvm::sys::ThreadLocalImpl::ThreadLocalImpl
ThreadLocalImpl()
ThreadLocal.h
llvm::sys::ThreadLocalImpl::setInstance
void setInstance(const void *d)
Generated on Mon Aug 31 2015 11:11:00 for LLVM by
1.8.6