Skip to content

Commit

Permalink
Remove more name space pollution from .inc files
Browse files Browse the repository at this point in the history
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@299222 91177308-0d34-0410-b5e6-96231b3b80d8
  • Loading branch information
kbeyls committed Mar 31, 2017
1 parent 40593e0 commit 1cbe5a4
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 20 deletions.
11 changes: 5 additions & 6 deletions lib/Support/Windows/Mutex.inc
Original file line number Diff line number Diff line change
Expand Up @@ -20,37 +20,36 @@
#include "llvm/Support/Mutex.h"

namespace llvm {
using namespace sys;

MutexImpl::MutexImpl(bool /*recursive*/)
sys::MutexImpl::MutexImpl(bool /*recursive*/)
{
data_ = new CRITICAL_SECTION;
InitializeCriticalSection((LPCRITICAL_SECTION)data_);
}

MutexImpl::~MutexImpl()
sys::MutexImpl::~MutexImpl()
{
DeleteCriticalSection((LPCRITICAL_SECTION)data_);
delete (LPCRITICAL_SECTION)data_;
data_ = 0;
}

bool
MutexImpl::acquire()
sys::MutexImpl::acquire()
{
EnterCriticalSection((LPCRITICAL_SECTION)data_);
return true;
}

bool
MutexImpl::release()
sys::MutexImpl::release()
{
LeaveCriticalSection((LPCRITICAL_SECTION)data_);
return true;
}

bool
MutexImpl::tryacquire()
sys::MutexImpl::tryacquire()
{
return TryEnterCriticalSection((LPCRITICAL_SECTION)data_);
}
Expand Down
1 change: 0 additions & 1 deletion lib/Support/Windows/Program.inc
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
//===----------------------------------------------------------------------===//

namespace llvm {
using namespace sys;

ProcessInfo::ProcessInfo() : ProcessHandle(0), Pid(0), ReturnCode(0) {}

Expand Down
13 changes: 6 additions & 7 deletions lib/Support/Windows/RWMutex.inc
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
#include "WindowsSupport.h"

namespace llvm {
using namespace sys;

// Windows has slim read-writer lock support on Vista and higher, so we
// will attempt to load the APIs. If they exist, we will use them, and
Expand Down Expand Up @@ -73,7 +72,7 @@ static bool loadSRW() {
return sHasSRW;
}

RWMutexImpl::RWMutexImpl() {
sys::RWMutexImpl::RWMutexImpl() {
if (loadSRW()) {
data_ = calloc(1, sizeof(SRWLOCK));
fpInitializeSRWLock(static_cast<PSRWLOCK>(data_));
Expand All @@ -83,14 +82,14 @@ RWMutexImpl::RWMutexImpl() {
}
}

RWMutexImpl::~RWMutexImpl() {
sys::RWMutexImpl::~RWMutexImpl() {
if (!sHasSRW)
DeleteCriticalSection(static_cast<LPCRITICAL_SECTION>(data_));
// Nothing to do in the case of slim reader/writers except free the memory.
free(data_);
}

bool RWMutexImpl::reader_acquire() {
bool sys::RWMutexImpl::reader_acquire() {
if (sHasSRW) {
fpAcquireSRWLockShared(static_cast<PSRWLOCK>(data_));
} else {
Expand All @@ -99,7 +98,7 @@ bool RWMutexImpl::reader_acquire() {
return true;
}

bool RWMutexImpl::reader_release() {
bool sys::RWMutexImpl::reader_release() {
if (sHasSRW) {
fpReleaseSRWLockShared(static_cast<PSRWLOCK>(data_));
} else {
Expand All @@ -108,7 +107,7 @@ bool RWMutexImpl::reader_release() {
return true;
}

bool RWMutexImpl::writer_acquire() {
bool sys::RWMutexImpl::writer_acquire() {
if (sHasSRW) {
fpAcquireSRWLockExclusive(static_cast<PSRWLOCK>(data_));
} else {
Expand All @@ -117,7 +116,7 @@ bool RWMutexImpl::writer_acquire() {
return true;
}

bool RWMutexImpl::writer_release() {
bool sys::RWMutexImpl::writer_release() {
if (sHasSRW) {
fpReleaseSRWLockExclusive(static_cast<PSRWLOCK>(data_));
} else {
Expand Down
11 changes: 5 additions & 6 deletions lib/Support/Windows/ThreadLocal.inc
Original file line number Diff line number Diff line change
Expand Up @@ -20,33 +20,32 @@
#include "llvm/Support/ThreadLocal.h"

namespace llvm {
using namespace sys;

ThreadLocalImpl::ThreadLocalImpl() : data() {
sys::ThreadLocalImpl::ThreadLocalImpl() : data() {
static_assert(sizeof(DWORD) <= sizeof(data), "size too big");
DWORD* tls = reinterpret_cast<DWORD*>(&data);
*tls = TlsAlloc();
assert(*tls != TLS_OUT_OF_INDEXES);
}

ThreadLocalImpl::~ThreadLocalImpl() {
sys::ThreadLocalImpl::~ThreadLocalImpl() {
DWORD* tls = reinterpret_cast<DWORD*>(&data);
TlsFree(*tls);
}

void *ThreadLocalImpl::getInstance() {
void *sys::ThreadLocalImpl::getInstance() {
DWORD* tls = reinterpret_cast<DWORD*>(&data);
return TlsGetValue(*tls);
}

void ThreadLocalImpl::setInstance(const void* d){
void sys::ThreadLocalImpl::setInstance(const void* d){
DWORD* tls = reinterpret_cast<DWORD*>(&data);
int errorcode = TlsSetValue(*tls, const_cast<void*>(d));
assert(errorcode != 0);
(void)errorcode;
}

void ThreadLocalImpl::removeInstance() {
void sys::ThreadLocalImpl::removeInstance() {
setInstance(0);
}

Expand Down

0 comments on commit 1cbe5a4

Please sign in to comment.