mirror of
https://github.com/Kitware/CMake.git
synced 2026-02-21 22:50:26 -06:00
Revise C++ coding style using clang-format
Run the `Utilities/Scripts/clang-format.bash` script to update all our C++ code to a new style defined by `.clang-format`. Use `clang-format` version 3.8. * If you reached this commit for a line in `git blame`, re-run the blame operation starting at the parent of this commit to see older history for the content. * See the parent commit for instructions to rebase a change across this style transition commit.
This commit is contained in:
@@ -18,16 +18,16 @@
|
||||
#include <stdio.h> // SEEK_SET
|
||||
#include <unistd.h>
|
||||
|
||||
cmFileLock::cmFileLock(): File(-1)
|
||||
cmFileLock::cmFileLock()
|
||||
: File(-1)
|
||||
{
|
||||
}
|
||||
|
||||
cmFileLockResult cmFileLock::Release()
|
||||
{
|
||||
if (this->Filename.empty())
|
||||
{
|
||||
if (this->Filename.empty()) {
|
||||
return cmFileLockResult::MakeOk();
|
||||
}
|
||||
}
|
||||
const int lockResult = this->LockFile(F_SETLK, F_UNLCK);
|
||||
|
||||
this->Filename = "";
|
||||
@@ -35,71 +35,56 @@ cmFileLockResult cmFileLock::Release()
|
||||
::close(this->File);
|
||||
this->File = -1;
|
||||
|
||||
if (lockResult == 0)
|
||||
{
|
||||
if (lockResult == 0) {
|
||||
return cmFileLockResult::MakeOk();
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
return cmFileLockResult::MakeSystem();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
cmFileLockResult cmFileLock::OpenFile()
|
||||
{
|
||||
this->File = ::open(this->Filename.c_str(), O_RDWR);
|
||||
if (this->File == -1)
|
||||
{
|
||||
if (this->File == -1) {
|
||||
return cmFileLockResult::MakeSystem();
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
return cmFileLockResult::MakeOk();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
cmFileLockResult cmFileLock::LockWithoutTimeout()
|
||||
{
|
||||
if (this->LockFile(F_SETLKW, F_WRLCK) == -1)
|
||||
{
|
||||
if (this->LockFile(F_SETLKW, F_WRLCK) == -1) {
|
||||
return cmFileLockResult::MakeSystem();
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
return cmFileLockResult::MakeOk();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
cmFileLockResult cmFileLock::LockWithTimeout(unsigned long seconds)
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
if (this->LockFile(F_SETLK, F_WRLCK) == -1)
|
||||
{
|
||||
if (errno != EACCES && errno != EAGAIN)
|
||||
{
|
||||
while (true) {
|
||||
if (this->LockFile(F_SETLK, F_WRLCK) == -1) {
|
||||
if (errno != EACCES && errno != EAGAIN) {
|
||||
return cmFileLockResult::MakeSystem();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
return cmFileLockResult::MakeOk();
|
||||
}
|
||||
if (seconds == 0)
|
||||
{
|
||||
}
|
||||
if (seconds == 0) {
|
||||
return cmFileLockResult::MakeTimeout();
|
||||
}
|
||||
}
|
||||
--seconds;
|
||||
cmSystemTools::Delay(1000);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int cmFileLock::LockFile(int cmd, int type)
|
||||
{
|
||||
struct ::flock lock;
|
||||
lock.l_start = 0;
|
||||
lock.l_len = 0; // lock all bytes
|
||||
lock.l_pid = 0; // unused (for F_GETLK only)
|
||||
lock.l_len = 0; // lock all bytes
|
||||
lock.l_pid = 0; // unused (for F_GETLK only)
|
||||
lock.l_type = static_cast<short>(type); // exclusive lock
|
||||
lock.l_whence = SEEK_SET;
|
||||
return ::fcntl(this->File, cmd, &lock);
|
||||
|
||||
Reference in New Issue
Block a user