aboutsummaryrefslogtreecommitdiffstats
path: root/util/system
diff options
context:
space:
mode:
authorgulin <gulin@yandex-team.ru>2022-02-10 16:47:31 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:47:31 +0300
commitc807aae441c17fc7f577c35757a4b6e0bd909802 (patch)
treefc3268f43edbf6f854c0266cd05b91952484179b /util/system
parentd06e6190fa85c1fb4b011631503d53ea39942ff9 (diff)
downloadydb-c807aae441c17fc7f577c35757a4b6e0bd909802.tar.gz
Restoring authorship annotation for <gulin@yandex-team.ru>. Commit 1 of 2.
Diffstat (limited to 'util/system')
-rw-r--r--util/system/atomic_win.h2
-rw-r--r--util/system/filemap.cpp2
-rw-r--r--util/system/fs.cpp4
-rw-r--r--util/system/hostname.cpp2
-rw-r--r--util/system/hp_timer.cpp34
-rw-r--r--util/system/hp_timer.h4
-rw-r--r--util/system/shmat.cpp132
-rw-r--r--util/system/shmat.h16
-rw-r--r--util/system/thread.cpp14
-rw-r--r--util/system/yassert.h8
10 files changed, 109 insertions, 109 deletions
diff --git a/util/system/atomic_win.h b/util/system/atomic_win.h
index 65c290e6cc..3e9bd6244b 100644
--- a/util/system/atomic_win.h
+++ b/util/system/atomic_win.h
@@ -11,7 +11,7 @@
#pragma intrinsic(_InterlockedExchangeAdd)
#pragma intrinsic(_InterlockedExchange)
#pragma intrinsic(_InterlockedCompareExchange)
-
+
static inline intptr_t AtomicIncrement(TAtomic& a) {
return _InterlockedIncrement((volatile long*)&a);
}
diff --git a/util/system/filemap.cpp b/util/system/filemap.cpp
index 7454a4cb94..830a409077 100644
--- a/util/system/filemap.cpp
+++ b/util/system/filemap.cpp
@@ -76,7 +76,7 @@ TString TMemoryMapCommon::UnknownFileName() {
}
static inline i64 DownToGranularity(i64 offset) noexcept {
- return offset & ~((i64)(GRANULARITY - 1));
+ return offset & ~((i64)(GRANULARITY - 1));
}
#if defined(_unix_)
diff --git a/util/system/fs.cpp b/util/system/fs.cpp
index d2611a8ccc..42abc86a15 100644
--- a/util/system/fs.cpp
+++ b/util/system/fs.cpp
@@ -1,12 +1,12 @@
#include "fs.h"
#include "defaults.h"
-#if defined(_win_)
+#if defined(_win_)
#include "fs_win.h"
#else
#include <unistd.h>
#include <errno.h>
-#endif
+#endif
#include <util/generic/yexception.h>
#include <util/memory/tempbuf.h>
diff --git a/util/system/hostname.cpp b/util/system/hostname.cpp
index 386f646d6b..dd4d4414cd 100644
--- a/util/system/hostname.cpp
+++ b/util/system/hostname.cpp
@@ -27,7 +27,7 @@ namespace {
}
HostName = hostNameBuf.Data();
- }
+ }
TString HostName;
};
diff --git a/util/system/hp_timer.cpp b/util/system/hp_timer.cpp
index e4c3f21e6b..05ea5216bd 100644
--- a/util/system/hp_timer.cpp
+++ b/util/system/hp_timer.cpp
@@ -4,8 +4,8 @@
#include <util/generic/singleton.h>
#include <util/datetime/cputimer.h>
-using namespace NHPTimer;
-
+using namespace NHPTimer;
+
namespace {
struct TFreq {
inline TFreq()
@@ -13,12 +13,12 @@ namespace {
, Rate(1.0 / Freq)
, CyclesPerSecond(static_cast<ui64>(Rate))
{
- }
+ }
static inline const TFreq& Instance() {
return *SingletonWithPriority<TFreq, 1>();
- }
-
+ }
+
static double EstimateCPUClock() {
for (;;) {
ui64 startCycle = 0;
@@ -91,28 +91,28 @@ namespace {
const double Rate;
const ui64 CyclesPerSecond;
};
-}
-
+}
+
double NHPTimer::GetSeconds(const STime& a) noexcept {
return TFreq::Instance().GetSeconds(a);
-}
-
+}
+
double NHPTimer::GetClockRate() noexcept {
return TFreq::Instance().GetClockRate();
-}
-
+}
+
ui64 NHPTimer::GetCyclesPerSecond() noexcept {
return TFreq::Instance().GetCyclesPerSecond();
}
void NHPTimer::GetTime(STime* pTime) noexcept {
- *pTime = GetCycleCount();
-}
-
+ *pTime = GetCycleCount();
+}
+
double NHPTimer::GetTimePassed(STime* pTime) noexcept {
- STime old(*pTime);
+ STime old(*pTime);
*pTime = GetCycleCount();
- return GetSeconds(*pTime - old);
-}
+ return GetSeconds(*pTime - old);
+}
diff --git a/util/system/hp_timer.h b/util/system/hp_timer.h
index 0a4c252ec2..e482c413bd 100644
--- a/util/system/hp_timer.h
+++ b/util/system/hp_timer.h
@@ -1,5 +1,5 @@
#pragma once
-
+
#include "defaults.h"
namespace NHPTimer {
@@ -33,4 +33,4 @@ struct THPTimer {
private:
NHPTimer::STime Start;
-};
+};
diff --git a/util/system/shmat.cpp b/util/system/shmat.cpp
index 07ff0d6caa..a16108660f 100644
--- a/util/system/shmat.cpp
+++ b/util/system/shmat.cpp
@@ -1,4 +1,4 @@
-#include "shmat.h"
+#include "shmat.h"
#include <util/generic/guid.h>
@@ -37,8 +37,8 @@ extern "C" {
BOOL WINAPI UnmapViewOfFile(LPCVOID lpBaseAddress);
DWORD WINAPI GetLastError(void);
}
-#endif
-
+#endif
+
#if defined(_bionic_)
namespace {
#if !defined(__i386__)
@@ -95,117 +95,117 @@ TSharedMemory::TSharedMemory()
, Size(0)
{
}
-
+
#if defined(_win_)
static void FormatName(char* buf, const TGUID& id) {
- sprintf(buf, "Global\\shmat-%s", GetGuidAsString(id).c_str());
-}
-
+ sprintf(buf, "Global\\shmat-%s", GetGuidAsString(id).c_str());
+}
+
bool TSharedMemory::Open(const TGUID& id, int size) {
//Y_ASSERT(Data == 0);
- Id = id;
- Size = size;
-
- char name[100];
- FormatName(name, Id);
+ Id = id;
+ Size = size;
+
+ char name[100];
+ FormatName(name, Id);
Handle = OpenFileMappingA(FILE_MAP_ALL_ACCESS, FALSE, name);
if (Handle == 0) {
- return false;
+ return false;
}
-
+
Data = MapViewOfFile(Handle, FILE_MAP_ALL_ACCESS, 0, 0, size);
- if (Data == 0) {
+ if (Data == 0) {
//Y_ASSERT(0);
CloseHandle(Handle);
Handle = INVALID_OS_HANDLE;
- return false;
- }
-
- return true;
-}
+ return false;
+ }
+ return true;
+}
+
bool TSharedMemory::Create(int size) {
//Y_ASSERT(Data == 0);
- Size = size;
-
- CreateGuid(&Id);
-
- char name[100];
- FormatName(name, Id);
+ Size = size;
+
+ CreateGuid(&Id);
+
+ char name[100];
+ FormatName(name, Id);
Handle = CreateFileMappingA(INVALID_OS_HANDLE, nullptr, PAGE_READWRITE, 0, size, name);
if (Handle == 0) {
//Y_ASSERT(0);
- return false;
- }
-
+ return false;
+ }
+
Data = MapViewOfFile(Handle, FILE_MAP_ALL_ACCESS, 0, 0, size);
- if (Data == 0) {
+ if (Data == 0) {
//Y_ASSERT(0);
CloseHandle(Handle);
Handle = INVALID_OS_HANDLE;
- return false;
- }
-
- return true;
-}
+ return false;
+ }
+ return true;
+}
+
TSharedMemory::~TSharedMemory() {
if (Data) {
UnmapViewOfFile(Handle);
}
CloseHandle(Handle);
-}
-#else
+}
+#else
static key_t GetKey(const TGUID& id) {
i64 id64 = (ui64)(((ui64)id.dw[0] + (ui64)id.dw[2]) << 32) + (ui64)id.dw[1] + (ui64)id.dw[3];
- return id64;
-}
-
+ return id64;
+}
+
bool TSharedMemory::Open(const TGUID& id, int size) {
Y_VERIFY(id, "invalid shared memory guid: %s", GetGuidAsString(id).data());
//Y_ASSERT(Data == 0);
- Size = size;
-
- key_t k = GetKey(id);
+ Size = size;
+
+ key_t k = GetKey(id);
int shmId = shmget(k, Size, 0777); // do not fill Handle, since IPC_RMID should be called by owner
if (shmId < 0) {
- return false;
+ return false;
}
-
+
Data = shmat(shmId, nullptr, 0);
if (Data == nullptr) {
//Y_ASSERT(0);
- return false;
- }
-
- return true;
-}
+ return false;
+ }
+ return true;
+}
+
bool TSharedMemory::Create(int size) {
//Y_ASSERT(Data == 0);
- Size = size;
-
- CreateGuid(&Id);
-
- key_t k = GetKey(Id);
+ Size = size;
+
+ CreateGuid(&Id);
+
+ key_t k = GetKey(Id);
Handle = shmget(k, Size, IPC_CREAT | IPC_EXCL | 0777);
if (Handle < 0) {
//Y_ASSERT(0);
- return false;
- }
-
+ return false;
+ }
+
Data = shmat(Handle, nullptr, 0);
if (Data == (void*)-1) {
@@ -213,19 +213,19 @@ bool TSharedMemory::Create(int size) {
shmctl(Handle, IPC_RMID, nullptr);
Handle = -1;
- return false;
- }
-
- return true;
-}
+ return false;
+ }
+ return true;
+}
+
TSharedMemory::~TSharedMemory() {
if (Data) {
- shmdt(Data);
+ shmdt(Data);
}
if (Handle >= 0) {
shmctl(Handle, IPC_RMID, nullptr);
}
-}
-#endif
+}
+#endif
diff --git a/util/system/shmat.h b/util/system/shmat.h
index d9da3c151a..ab860e30ca 100644
--- a/util/system/shmat.h
+++ b/util/system/shmat.h
@@ -1,21 +1,21 @@
-#pragma once
-
+#pragma once
+
#include "fhandle.h"
#include <util/generic/ptr.h>
#include <util/generic/guid.h>
-
+
class TSharedMemory: public TThrRefBase {
- TGUID Id;
+ TGUID Id;
FHANDLE Handle;
void* Data;
- int Size;
+ int Size;
-public:
+public:
TSharedMemory();
~TSharedMemory() override;
- bool Create(int Size);
+ bool Create(int Size);
bool Open(const TGUID& id, int size);
const TGUID& GetId() {
@@ -29,4 +29,4 @@ public:
int GetSize() const {
return Size;
}
-};
+};
diff --git a/util/system/thread.cpp b/util/system/thread.cpp
index 6236746c2d..746c1eac30 100644
--- a/util/system/thread.cpp
+++ b/util/system/thread.cpp
@@ -203,15 +203,15 @@ namespace {
}
}
- {
+ {
TParams* holdP = P_.Release();
- int err = pthread_create(&H_, pattrs, ThreadProxy, holdP);
- if (err) {
+ int err = pthread_create(&H_, pattrs, ThreadProxy, holdP);
+ if (err) {
H_ = {};
- P_.Reset(holdP);
- PCHECK(err, "failed to create thread");
- }
- }
+ P_.Reset(holdP);
+ PCHECK(err, "failed to create thread");
+ }
+ }
}
private:
diff --git a/util/system/yassert.h b/util/system/yassert.h
index 529823440c..490ca4a7d9 100644
--- a/util/system/yassert.h
+++ b/util/system/yassert.h
@@ -52,7 +52,7 @@ inline bool YaIsDebuggerPresent() {
inline void YaDebugBreak() {
__debugbreak();
-}
+}
#undef Y_ASSERT
@@ -79,7 +79,7 @@ inline void YaDebugBreak() {
} \
} \
} while (false)
-#else
+#else
#define Y_ASSERT(a) \
do { \
if (false) { \
@@ -87,8 +87,8 @@ inline void YaDebugBreak() {
Y_UNUSED(__xxx); \
} \
} while (false)
-#endif
-
+#endif
+
namespace NPrivate {
/// method should not be used directly
[[noreturn]] void Panic(const TStaticBuf& file, int line, const char* function, const char* expr, const char* format, ...) noexcept Y_PRINTF_FORMAT(5, 6);