[lldb][NFC] Fix all formatting errors in .cpp file headers
Summary:
A *.cpp file header in LLDB (and in LLDB) should like this:
```
//===-- TestUtilities.cpp -------------------------------------------------===//
```
However in LLDB most of our source files have arbitrary changes to this format and
these changes are spreading through LLDB as folks usually just use the existing
source files as templates for their new files (most notably the unnecessary
editor language indicator `-*- C++ -*-` is spreading and in every review
someone is pointing out that this is wrong, resulting in people pointing out that this
is done in the same way in other files).
This patch removes most of these inconsistencies including the editor language indicators,
all the different missing/additional '-' characters, files that center the file name, missing
trailing `===//` (mostly caused by clang-format breaking the line).
Reviewers: aprantl, espindola, jfb, shafik, JDevlieghere
Reviewed By: JDevlieghere
Subscribers: dexonsmith, wuzish, emaste, sdardis, nemanjai, kbarton, MaskRay, atanasyan, arphaman, jfb, abidh, jsji, JDevlieghere, usaxena95, lldb-commits
Tags: #lldb
Differential Revision: https://reviews.llvm.org/D73258
2020-01-24 15:23:27 +08:00
|
|
|
//===-- ProcessRunLock.cpp ------------------------------------------------===//
|
2016-11-26 13:23:44 +08:00
|
|
|
//
|
2019-01-19 16:50:56 +08:00
|
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
2016-11-26 13:23:44 +08:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2013-08-23 20:44:05 +08:00
|
|
|
#include "lldb/Host/ProcessRunLock.h"
|
2013-09-04 21:56:11 +08:00
|
|
|
#include "lldb/Host/windows/windows.h"
|
2013-08-23 20:44:05 +08:00
|
|
|
|
2015-05-15 06:50:19 +08:00
|
|
|
static PSRWLOCK GetLock(lldb::rwlock_t lock) {
|
|
|
|
return static_cast<PSRWLOCK>(lock);
|
|
|
|
}
|
2013-08-23 20:44:05 +08:00
|
|
|
|
2015-05-15 06:50:19 +08:00
|
|
|
static bool ReadLock(lldb::rwlock_t rwlock) {
|
|
|
|
::AcquireSRWLockShared(GetLock(rwlock));
|
|
|
|
return true;
|
|
|
|
}
|
2013-08-23 20:44:05 +08:00
|
|
|
|
2015-05-15 06:50:19 +08:00
|
|
|
static bool ReadUnlock(lldb::rwlock_t rwlock) {
|
|
|
|
::ReleaseSRWLockShared(GetLock(rwlock));
|
|
|
|
return true;
|
|
|
|
}
|
2013-08-23 20:44:05 +08:00
|
|
|
|
2015-05-15 06:50:19 +08:00
|
|
|
static bool WriteLock(lldb::rwlock_t rwlock) {
|
|
|
|
::AcquireSRWLockExclusive(GetLock(rwlock));
|
|
|
|
return true;
|
|
|
|
}
|
2013-08-23 20:44:05 +08:00
|
|
|
|
2015-05-15 06:50:19 +08:00
|
|
|
static bool WriteTryLock(lldb::rwlock_t rwlock) {
|
|
|
|
return !!::TryAcquireSRWLockExclusive(GetLock(rwlock));
|
|
|
|
}
|
2013-08-23 20:44:05 +08:00
|
|
|
|
2015-05-15 06:50:19 +08:00
|
|
|
static bool WriteUnlock(lldb::rwlock_t rwlock) {
|
|
|
|
::ReleaseSRWLockExclusive(GetLock(rwlock));
|
|
|
|
return true;
|
|
|
|
}
|
2013-08-23 20:44:05 +08:00
|
|
|
|
2015-05-15 06:50:19 +08:00
|
|
|
using namespace lldb_private;
|
2013-08-23 20:44:05 +08:00
|
|
|
|
2015-05-15 06:50:19 +08:00
|
|
|
ProcessRunLock::ProcessRunLock() : m_running(false) {
|
|
|
|
m_rwlock = new SRWLOCK;
|
|
|
|
InitializeSRWLock(GetLock(m_rwlock));
|
|
|
|
}
|
2013-08-23 20:44:05 +08:00
|
|
|
|
2016-10-06 01:07:34 +08:00
|
|
|
ProcessRunLock::~ProcessRunLock() { delete static_cast<SRWLOCK *>(m_rwlock); }
|
2013-08-23 20:44:05 +08:00
|
|
|
|
2015-05-15 06:50:19 +08:00
|
|
|
bool ProcessRunLock::ReadTryLock() {
|
|
|
|
::ReadLock(m_rwlock);
|
|
|
|
if (m_running == false)
|
|
|
|
return true;
|
|
|
|
::ReadUnlock(m_rwlock);
|
|
|
|
return false;
|
|
|
|
}
|
2013-08-23 20:44:05 +08:00
|
|
|
|
2015-05-15 06:50:19 +08:00
|
|
|
bool ProcessRunLock::ReadUnlock() { return ::ReadUnlock(m_rwlock); }
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2015-05-15 06:50:19 +08:00
|
|
|
bool ProcessRunLock::SetRunning() {
|
|
|
|
WriteLock(m_rwlock);
|
|
|
|
m_running = true;
|
|
|
|
WriteUnlock(m_rwlock);
|
|
|
|
return true;
|
|
|
|
}
|
2013-08-23 20:44:05 +08:00
|
|
|
|
2015-05-15 06:50:19 +08:00
|
|
|
bool ProcessRunLock::TrySetRunning() {
|
|
|
|
if (WriteTryLock(m_rwlock)) {
|
|
|
|
bool was_running = m_running;
|
|
|
|
m_running = true;
|
|
|
|
WriteUnlock(m_rwlock);
|
|
|
|
return !was_running;
|
2013-08-23 20:44:05 +08:00
|
|
|
}
|
2015-05-15 06:50:19 +08:00
|
|
|
return false;
|
2013-08-23 20:44:05 +08:00
|
|
|
}
|
|
|
|
|
2015-05-15 06:50:19 +08:00
|
|
|
bool ProcessRunLock::SetStopped() {
|
|
|
|
WriteLock(m_rwlock);
|
|
|
|
m_running = false;
|
|
|
|
WriteUnlock(m_rwlock);
|
|
|
|
return true;
|
|
|
|
}
|