Deleted Added
full compact
ThreadLocal.inc (218893) ThreadLocal.inc (239462)
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//===----------------------------------------------------------------------===//

--- 8 unchanged lines hidden (view full) ---

17//===----------------------------------------------------------------------===//
18
19#include "Windows.h"
20#include "llvm/Support/ThreadLocal.h"
21
22namespace llvm {
23using namespace sys;
24
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//===----------------------------------------------------------------------===//

--- 8 unchanged lines hidden (view full) ---

17//===----------------------------------------------------------------------===//
18
19#include "Windows.h"
20#include "llvm/Support/ThreadLocal.h"
21
22namespace llvm {
23using namespace sys;
24
25ThreadLocalImpl::ThreadLocalImpl() {
26 DWORD* tls = new DWORD;
25ThreadLocalImpl::ThreadLocalImpl() : data() {
26 typedef int SIZE_TOO_BIG[sizeof(DWORD) <= sizeof(data) ? 1 : -1];
27 DWORD* tls = reinterpret_cast<DWORD*>(&data);
27 *tls = TlsAlloc();
28 assert(*tls != TLS_OUT_OF_INDEXES);
28 *tls = TlsAlloc();
29 assert(*tls != TLS_OUT_OF_INDEXES);
29 data = tls;
30}
31
32ThreadLocalImpl::~ThreadLocalImpl() {
30}
31
32ThreadLocalImpl::~ThreadLocalImpl() {
33 DWORD* tls = static_cast<DWORD*>(data);
33 DWORD* tls = reinterpret_cast<DWORD*>(&data);
34 TlsFree(*tls);
34 TlsFree(*tls);
35 delete tls;
36}
37
38const void* ThreadLocalImpl::getInstance() {
35}
36
37const void* ThreadLocalImpl::getInstance() {
39 DWORD* tls = static_cast<DWORD*>(data);
38 DWORD* tls = reinterpret_cast<DWORD*>(&data);
40 return TlsGetValue(*tls);
41}
42
43void ThreadLocalImpl::setInstance(const void* d){
39 return TlsGetValue(*tls);
40}
41
42void ThreadLocalImpl::setInstance(const void* d){
44 DWORD* tls = static_cast<DWORD*>(data);
43 DWORD* tls = reinterpret_cast<DWORD*>(&data);
45 int errorcode = TlsSetValue(*tls, const_cast<void*>(d));
46 assert(errorcode != 0);
47 (void)errorcode;
48}
49
50void ThreadLocalImpl::removeInstance() {
51 setInstance(0);
52}
53
54}
44 int errorcode = TlsSetValue(*tls, const_cast<void*>(d));
45 assert(errorcode != 0);
46 (void)errorcode;
47}
48
49void ThreadLocalImpl::removeInstance() {
50 setInstance(0);
51}
52
53}