aboutsummaryrefslogtreecommitdiffstats
path: root/util/system
diff options
context:
space:
mode:
authorRuslan Kovalev <ruslan.a.kovalev@gmail.com>2022-02-10 16:46:44 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:46:44 +0300
commit59e19371de37995fcb36beb16cd6ec030af960bc (patch)
treefa68e36093ebff8b805462e9e6d331fe9d348214 /util/system
parent89db6fe2fe2c32d2a832ddfeb04e8d078e301084 (diff)
downloadydb-59e19371de37995fcb36beb16cd6ec030af960bc.tar.gz
Restoring authorship annotation for Ruslan Kovalev <ruslan.a.kovalev@gmail.com>. Commit 1 of 2.
Diffstat (limited to 'util/system')
-rw-r--r--util/system/align.h2
-rw-r--r--util/system/atexit.h2
-rw-r--r--util/system/atomic.h2
-rw-r--r--util/system/atomic_gcc.h2
-rw-r--r--util/system/atomic_win.h2
-rw-r--r--util/system/backtrace.h2
-rw-r--r--util/system/byteorder.h2
-rw-r--r--util/system/compat.h2
-rw-r--r--util/system/condvar.h2
-rw-r--r--util/system/context.h2
-rw-r--r--util/system/context_i686.h2
-rw-r--r--util/system/context_x86.h2
-rw-r--r--util/system/context_x86_64.h2
-rw-r--r--util/system/daemon.h2
-rw-r--r--util/system/datetime.h2
-rw-r--r--util/system/defaults.h2
-rw-r--r--util/system/dynlib.h2
-rw-r--r--util/system/error.h2
-rw-r--r--util/system/event.h2
-rw-r--r--util/system/execpath.h2
-rw-r--r--util/system/fasttime.cpp382
-rw-r--r--util/system/fasttime.h12
-rw-r--r--util/system/file.cpp8
-rw-r--r--util/system/file.h2
-rw-r--r--util/system/filemap.cpp10
-rw-r--r--util/system/filemap.h2
-rw-r--r--util/system/flock.h2
-rw-r--r--util/system/fs.h2
-rw-r--r--util/system/fstat.cpp144
-rw-r--r--util/system/fstat.h26
-rw-r--r--util/system/guard.h2
-rw-r--r--util/system/hostname.h2
-rw-r--r--util/system/hp_timer.h4
-rw-r--r--util/system/info.h2
-rw-r--r--util/system/madvise.cpp62
-rw-r--r--util/system/madvise.h24
-rw-r--r--util/system/maxlen.h2
-rw-r--r--util/system/mem_info.cpp46
-rw-r--r--util/system/mem_info.h14
-rw-r--r--util/system/mem_info_ut.cpp28
-rw-r--r--util/system/mutex.h2
-rw-r--r--util/system/pipe.h2
-rw-r--r--util/system/platform.h2
-rw-r--r--util/system/progname.h2
-rw-r--r--util/system/rwlock.h2
-rw-r--r--util/system/sem.h2
-rw-r--r--util/system/sigset.h2
-rw-r--r--util/system/spin_wait.h2
-rw-r--r--util/system/spinlock.h2
-rw-r--r--util/system/sys_alloc.h2
-rw-r--r--util/system/tempfile.h2
-rw-r--r--util/system/thread.h2
-rw-r--r--util/system/tls.h2
-rw-r--r--util/system/type_name.h2
-rw-r--r--util/system/valgrind.h2
-rw-r--r--util/system/yassert.h2
-rw-r--r--util/system/yield.h2
57 files changed, 425 insertions, 425 deletions
diff --git a/util/system/align.h b/util/system/align.h
index ea0bbc5b46..5e9d07c50d 100644
--- a/util/system/align.h
+++ b/util/system/align.h
@@ -1,4 +1,4 @@
-#pragma once
+#pragma once
#include "yassert.h"
#include "defaults.h"
diff --git a/util/system/atexit.h b/util/system/atexit.h
index eb3188615c..430f3fc843 100644
--- a/util/system/atexit.h
+++ b/util/system/atexit.h
@@ -1,4 +1,4 @@
-#pragma once
+#pragma once
#include "defaults.h"
diff --git a/util/system/atomic.h b/util/system/atomic.h
index 80265babfd..968bc581a4 100644
--- a/util/system/atomic.h
+++ b/util/system/atomic.h
@@ -1,4 +1,4 @@
-#pragma once
+#pragma once
#include "defaults.h"
diff --git a/util/system/atomic_gcc.h b/util/system/atomic_gcc.h
index ed8dc2bdc5..ddc85a7234 100644
--- a/util/system/atomic_gcc.h
+++ b/util/system/atomic_gcc.h
@@ -1,4 +1,4 @@
-#pragma once
+#pragma once
#define ATOMIC_COMPILER_BARRIER() __asm__ __volatile__("" \
: \
diff --git a/util/system/atomic_win.h b/util/system/atomic_win.h
index 65c290e6cc..079e5ade11 100644
--- a/util/system/atomic_win.h
+++ b/util/system/atomic_win.h
@@ -1,4 +1,4 @@
-#pragma once
+#pragma once
#include <intrin.h>
diff --git a/util/system/backtrace.h b/util/system/backtrace.h
index 2fce7585c3..8b45980b59 100644
--- a/util/system/backtrace.h
+++ b/util/system/backtrace.h
@@ -1,4 +1,4 @@
-#pragma once
+#pragma once
#include <util/generic/fwd.h>
#include <util/system/defaults.h>
diff --git a/util/system/byteorder.h b/util/system/byteorder.h
index 94b9fea515..a723e66864 100644
--- a/util/system/byteorder.h
+++ b/util/system/byteorder.h
@@ -1,4 +1,4 @@
-#pragma once
+#pragma once
#include "defaults.h"
diff --git a/util/system/compat.h b/util/system/compat.h
index c53dbcca17..22dcdf224e 100644
--- a/util/system/compat.h
+++ b/util/system/compat.h
@@ -1,4 +1,4 @@
-#pragma once
+#pragma once
#include "defaults.h"
diff --git a/util/system/condvar.h b/util/system/condvar.h
index 569162717c..4f1a24bf20 100644
--- a/util/system/condvar.h
+++ b/util/system/condvar.h
@@ -1,4 +1,4 @@
-#pragma once
+#pragma once
#include "mutex.h"
diff --git a/util/system/context.h b/util/system/context.h
index d2a349bfc5..332e5757e5 100644
--- a/util/system/context.h
+++ b/util/system/context.h
@@ -1,4 +1,4 @@
-#pragma once
+#pragma once
#include "align.h"
#include "defaults.h"
diff --git a/util/system/context_i686.h b/util/system/context_i686.h
index 1abfd5dada..02e54c92db 100644
--- a/util/system/context_i686.h
+++ b/util/system/context_i686.h
@@ -1,4 +1,4 @@
-#pragma once
+#pragma once
#define MJB_BP 3
#define MJB_SP 4
diff --git a/util/system/context_x86.h b/util/system/context_x86.h
index 6ea066ff88..6532865da6 100644
--- a/util/system/context_x86.h
+++ b/util/system/context_x86.h
@@ -1,4 +1,4 @@
-#pragma once
+#pragma once
#if defined(_x86_64_)
#include "context_x86_64.h"
diff --git a/util/system/context_x86_64.h b/util/system/context_x86_64.h
index 94e4f37eb3..3b3b804357 100644
--- a/util/system/context_x86_64.h
+++ b/util/system/context_x86_64.h
@@ -1,4 +1,4 @@
-#pragma once
+#pragma once
#define MJB_RBP 1
#define MJB_RSP 6
diff --git a/util/system/daemon.h b/util/system/daemon.h
index b00793b9c9..d8f0b85c2e 100644
--- a/util/system/daemon.h
+++ b/util/system/daemon.h
@@ -1,4 +1,4 @@
-#pragma once
+#pragma once
namespace NDaemonMaker {
enum ECloseDescriptors {
diff --git a/util/system/datetime.h b/util/system/datetime.h
index aa009974e0..ef9799812e 100644
--- a/util/system/datetime.h
+++ b/util/system/datetime.h
@@ -1,4 +1,4 @@
-#pragma once
+#pragma once
#include "defaults.h"
#include "platform.h"
diff --git a/util/system/defaults.h b/util/system/defaults.h
index dcd7abea38..46865de3ef 100644
--- a/util/system/defaults.h
+++ b/util/system/defaults.h
@@ -1,4 +1,4 @@
-#pragma once
+#pragma once
#include "platform.h"
diff --git a/util/system/dynlib.h b/util/system/dynlib.h
index 66eaf4a5c1..256aad176d 100644
--- a/util/system/dynlib.h
+++ b/util/system/dynlib.h
@@ -1,4 +1,4 @@
-#pragma once
+#pragma once
#include "defaults.h"
diff --git a/util/system/error.h b/util/system/error.h
index 5f2d4cc547..1edded460a 100644
--- a/util/system/error.h
+++ b/util/system/error.h
@@ -1,4 +1,4 @@
-#pragma once
+#pragma once
#include "defaults.h"
diff --git a/util/system/event.h b/util/system/event.h
index cab2fc478a..833e8d5a70 100644
--- a/util/system/event.h
+++ b/util/system/event.h
@@ -1,4 +1,4 @@
-#pragma once
+#pragma once
#include <util/generic/ptr.h>
#include <util/datetime/base.h>
diff --git a/util/system/execpath.h b/util/system/execpath.h
index 4b914b8e85..fb42c9f11c 100644
--- a/util/system/execpath.h
+++ b/util/system/execpath.h
@@ -1,4 +1,4 @@
-#pragma once
+#pragma once
#include <util/generic/fwd.h>
diff --git a/util/system/fasttime.cpp b/util/system/fasttime.cpp
index 057a814f0a..3e2e9eebd1 100644
--- a/util/system/fasttime.cpp
+++ b/util/system/fasttime.cpp
@@ -1,21 +1,21 @@
#include "dynlib.h"
#include "fasttime.h"
-
-#include <util/generic/singleton.h>
-#include <util/generic/yexception.h>
+
+#include <util/generic/singleton.h>
+#include <util/generic/yexception.h>
#include <utility>
#include <util/thread/singleton.h>
-
+
#if defined(_win_) || defined(_arm32_) || defined(_cygwin_)
-ui64 InterpolatedMicroSeconds() {
- return MicroSeconds();
-}
-#else
-
+ui64 InterpolatedMicroSeconds() {
+ return MicroSeconds();
+}
+#else
+
#include <dlfcn.h>
#include <sys/time.h>
-
+
#if defined(_musl_)
#include <util/generic/hash.h>
#include <util/generic/vector.h>
@@ -24,219 +24,219 @@ ui64 InterpolatedMicroSeconds() {
#include <contrib/libs/linuxvdso/interface.h>
#endif
-namespace {
+namespace {
using TTime = ui64;
-
- struct TSymbols {
+
+ struct TSymbols {
using TFunc = int (*)(struct timeval*, struct timezone*);
-
- inline TSymbols()
+
+ inline TSymbols()
: Func(nullptr)
- {
+ {
// not DEFAULT, cause library/cpp/gettimeofday
Func = reinterpret_cast<TFunc>(dlsym(RTLD_NEXT, "gettimeofday"));
-
+
#if defined(_musl_)
- if (!Func) {
+ if (!Func) {
Func = reinterpret_cast<TFunc>(NVdso::Function("__vdso_gettimeofday", "LINUX_2.6"));
}
#endif
if (!Func) {
Func = reinterpret_cast<TFunc>(Libc()->Sym("gettimeofday"));
- }
- }
-
- inline TTime SystemTime() {
- timeval tv;
-
- Zero(tv);
-
+ }
+ }
+
+ inline TTime SystemTime() {
+ timeval tv;
+
+ Zero(tv);
+
Func(&tv, nullptr);
-
- return (((TTime)1000000) * (TTime)tv.tv_sec) + (TTime)tv.tv_usec;
- }
-
+
+ return (((TTime)1000000) * (TTime)tv.tv_sec) + (TTime)tv.tv_usec;
+ }
+
static inline THolder<TDynamicLibrary> OpenLibc() {
- const char* libs[] = {
+ const char* libs[] = {
"/lib/libc.so.8",
"/lib/libc.so.7",
"/lib/libc.so.6",
};
-
+
for (auto& lib : libs) {
- try {
+ try {
return MakeHolder<TDynamicLibrary>(lib);
- } catch (...) {
+ } catch (...) {
// ¯\_(ツ)_/¯
- }
- }
-
- ythrow yexception() << "can not load libc";
- }
-
- inline TDynamicLibrary* Libc() {
- if (!Lib) {
- Lib = OpenLibc();
- }
-
- return Lib.Get();
- }
-
+ }
+ }
+
+ ythrow yexception() << "can not load libc";
+ }
+
+ inline TDynamicLibrary* Libc() {
+ if (!Lib) {
+ Lib = OpenLibc();
+ }
+
+ return Lib.Get();
+ }
+
THolder<TDynamicLibrary> Lib;
- TFunc Func;
- };
-
- static inline TTime SystemTime() {
- return Singleton<TSymbols>()->SystemTime();
- }
-
- struct TInitialTimes {
- inline TInitialTimes()
- : ITime(TimeBase())
- , IProc(RdtscBase())
- {
- }
-
- static TTime RdtscBase() {
- return GetCycleCount() / (TTime)1000;
- }
-
- static TTime TimeBase() {
- return SystemTime();
- }
-
- inline TTime Rdtsc() {
- return RdtscBase() - IProc;
- }
-
- inline TTime Time() {
- return TimeBase() - ITime;
- }
-
- const TTime ITime;
- const TTime IProc;
- };
-
- template <size_t N, class A, class B>
- class TLinePredictor {
- public:
+ TFunc Func;
+ };
+
+ static inline TTime SystemTime() {
+ return Singleton<TSymbols>()->SystemTime();
+ }
+
+ struct TInitialTimes {
+ inline TInitialTimes()
+ : ITime(TimeBase())
+ , IProc(RdtscBase())
+ {
+ }
+
+ static TTime RdtscBase() {
+ return GetCycleCount() / (TTime)1000;
+ }
+
+ static TTime TimeBase() {
+ return SystemTime();
+ }
+
+ inline TTime Rdtsc() {
+ return RdtscBase() - IProc;
+ }
+
+ inline TTime Time() {
+ return TimeBase() - ITime;
+ }
+
+ const TTime ITime;
+ const TTime IProc;
+ };
+
+ template <size_t N, class A, class B>
+ class TLinePredictor {
+ public:
using TSample = std::pair<A, B>;
-
- inline TLinePredictor()
- : C_(0)
- , A_(0)
- , B_(0)
- {
- }
-
+
+ inline TLinePredictor()
+ : C_(0)
+ , A_(0)
+ , B_(0)
+ {
+ }
+
inline void Add(const A& a, const B& b) noexcept {
- Add(TSample(a, b));
- }
-
+ Add(TSample(a, b));
+ }
+
inline void Add(const TSample& s) noexcept {
- S_[(C_++) % N] = s;
+ S_[(C_++) % N] = s;
if (C_ > 1) {
ReCalc();
}
- }
-
+ }
+
inline B Predict(A a) const noexcept {
- return A_ + a * B_;
- }
-
+ return A_ + a * B_;
+ }
+
inline size_t Size() const noexcept {
- return C_;
- }
-
+ return C_;
+ }
+
inline bool Enough() const noexcept {
- return Size() >= N;
- }
-
+ return Size() >= N;
+ }
+
inline A LastX() const noexcept {
- return S_[(C_ - 1) % N].first;
- }
-
- private:
+ return S_[(C_ - 1) % N].first;
+ }
+
+ private:
inline void ReCalc() noexcept {
- const size_t n = Min(N, C_);
-
- double sx = 0;
- double sy = 0;
- double sxx = 0;
- double syy = 0;
- double sxy = 0;
-
- for (size_t i = 0; i < n; ++i) {
- const double x = S_[i].first;
- const double y = S_[i].second;
-
- sx += x;
- sy += y;
- sxx += x * x;
- syy += y * y;
- sxy += x * y;
- }
-
- B_ = (n * sxy - sx * sy) / (n * sxx - sx * sx);
+ const size_t n = Min(N, C_);
+
+ double sx = 0;
+ double sy = 0;
+ double sxx = 0;
+ double syy = 0;
+ double sxy = 0;
+
+ for (size_t i = 0; i < n; ++i) {
+ const double x = S_[i].first;
+ const double y = S_[i].second;
+
+ sx += x;
+ sy += y;
+ sxx += x * x;
+ syy += y * y;
+ sxy += x * y;
+ }
+
+ B_ = (n * sxy - sx * sy) / (n * sxx - sx * sx);
A_ = (sy - B_ * sx) / n;
- }
-
- private:
- size_t C_;
- TSample S_[N];
- double A_;
- double B_;
- };
-
- class TTimePredictor: public TInitialTimes {
- public:
- inline TTimePredictor()
- : Next_(1)
- {
- }
-
- inline TTime Get() {
- return GetBase() + ITime;
- }
-
- private:
- inline TTime GetBase() {
- const TTime x = Rdtsc();
-
- if (TimeToSync(x)) {
- const TTime y = Time();
-
- P_.Add(x, y);
-
- return y;
- }
-
- if (P_.Enough()) {
- return P_.Predict(x);
- }
-
- return Time();
- }
-
- inline bool TimeToSync(TTime x) {
- if (x > Next_) {
- Next_ = Min(x + x / 10, x + 1000000);
-
- return true;
- }
-
- return false;
- }
-
- private:
- TLinePredictor<16, TTime, TTime> P_;
- TTime Next_;
- };
-}
-
-ui64 InterpolatedMicroSeconds() {
+ }
+
+ private:
+ size_t C_;
+ TSample S_[N];
+ double A_;
+ double B_;
+ };
+
+ class TTimePredictor: public TInitialTimes {
+ public:
+ inline TTimePredictor()
+ : Next_(1)
+ {
+ }
+
+ inline TTime Get() {
+ return GetBase() + ITime;
+ }
+
+ private:
+ inline TTime GetBase() {
+ const TTime x = Rdtsc();
+
+ if (TimeToSync(x)) {
+ const TTime y = Time();
+
+ P_.Add(x, y);
+
+ return y;
+ }
+
+ if (P_.Enough()) {
+ return P_.Predict(x);
+ }
+
+ return Time();
+ }
+
+ inline bool TimeToSync(TTime x) {
+ if (x > Next_) {
+ Next_ = Min(x + x / 10, x + 1000000);
+
+ return true;
+ }
+
+ return false;
+ }
+
+ private:
+ TLinePredictor<16, TTime, TTime> P_;
+ TTime Next_;
+ };
+}
+
+ui64 InterpolatedMicroSeconds() {
return FastTlsSingleton<TTimePredictor>()->Get();
-}
-
-#endif
+}
+
+#endif
diff --git a/util/system/fasttime.h b/util/system/fasttime.h
index 544cb4bd19..1515185dd9 100644
--- a/util/system/fasttime.h
+++ b/util/system/fasttime.h
@@ -1,6 +1,6 @@
-#pragma once
-
-#include "datetime.h"
-
-/// Fast but possibly less accurate microseconds since epoch
-ui64 InterpolatedMicroSeconds();
+#pragma once
+
+#include "datetime.h"
+
+/// Fast but possibly less accurate microseconds since epoch
+ui64 InterpolatedMicroSeconds();
diff --git a/util/system/file.cpp b/util/system/file.cpp
index 4a261d020c..8b9779728c 100644
--- a/util/system/file.cpp
+++ b/util/system/file.cpp
@@ -1098,10 +1098,10 @@ TFile::TFile(FHANDLE fd)
}
TFile::TFile(FHANDLE fd, const TString& name)
- : Impl_(new TImpl(fd, name))
-{
-}
-
+ : Impl_(new TImpl(fd, name))
+{
+}
+
TFile::TFile(const TString& fName, EOpenMode oMode)
: Impl_(new TImpl(fName, oMode))
{
diff --git a/util/system/file.h b/util/system/file.h
index 9502e159b6..815805cd8c 100644
--- a/util/system/file.h
+++ b/util/system/file.h
@@ -1,4 +1,4 @@
-#pragma once
+#pragma once
#include "fhandle.h"
#include "flock.h"
diff --git a/util/system/filemap.cpp b/util/system/filemap.cpp
index 7454a4cb94..3f3536e383 100644
--- a/util/system/filemap.cpp
+++ b/util/system/filemap.cpp
@@ -1,5 +1,5 @@
#include "info.h"
-#include "madvise.h"
+#include "madvise.h"
#include "defaults.h"
#include "hi_lo.h"
@@ -288,14 +288,14 @@ public:
void SetSequential() {
#if defined(_unix_)
- if (!(Mode_ & oNotGreedy) && Length_) {
- MadviseSequentialAccess(PtrStart_, Length_);
- }
+ if (!(Mode_ & oNotGreedy) && Length_) {
+ MadviseSequentialAccess(PtrStart_, Length_);
+ }
#endif
}
void Evict(void* ptr, size_t len) {
- MadviseEvict(ptr, len);
+ MadviseEvict(ptr, len);
}
void Evict() {
diff --git a/util/system/filemap.h b/util/system/filemap.h
index 11be64bff4..1fa94de67c 100644
--- a/util/system/filemap.h
+++ b/util/system/filemap.h
@@ -1,4 +1,4 @@
-#pragma once
+#pragma once
#include "file.h"
#include "align.h"
diff --git a/util/system/flock.h b/util/system/flock.h
index 797b1970a1..e4a401acba 100644
--- a/util/system/flock.h
+++ b/util/system/flock.h
@@ -1,4 +1,4 @@
-#pragma once
+#pragma once
#include "error.h"
#include "defaults.h"
diff --git a/util/system/fs.h b/util/system/fs.h
index 237daf2d2d..ae3c7a75d7 100644
--- a/util/system/fs.h
+++ b/util/system/fs.h
@@ -1,4 +1,4 @@
-#pragma once
+#pragma once
#include <util/generic/flags.h>
#include <util/generic/string.h>
diff --git a/util/system/fstat.cpp b/util/system/fstat.cpp
index 81e98cbc6b..df402f0c04 100644
--- a/util/system/fstat.cpp
+++ b/util/system/fstat.cpp
@@ -2,26 +2,26 @@
#include "file.h"
#include <sys/stat.h>
-
+
#include <util/folder/path.h>
#include <cerrno>
-#if defined(_win_)
+#if defined(_win_)
#include "fs_win.h"
-
+
#ifdef _S_IFLNK
#undef _S_IFLNK
#endif
#define _S_IFLNK 0x80000000
-
+
ui32 GetFileMode(DWORD fileAttributes) {
ui32 mode = 0;
if (fileAttributes == 0xFFFFFFFF)
return mode;
- if (fileAttributes & FILE_ATTRIBUTE_DEVICE)
+ if (fileAttributes & FILE_ATTRIBUTE_DEVICE)
mode |= _S_IFCHR;
- if (fileAttributes & FILE_ATTRIBUTE_REPARSE_POINT)
+ if (fileAttributes & FILE_ATTRIBUTE_REPARSE_POINT)
mode |= _S_IFLNK; // todo: was undefined by the moment of writing this code
if (fileAttributes & FILE_ATTRIBUTE_DIRECTORY)
mode |= _S_IFDIR;
@@ -31,95 +31,95 @@ ui32 GetFileMode(DWORD fileAttributes) {
mode |= _S_IWRITE;
return mode;
}
-
+
#define S_ISDIR(st_mode) (st_mode & _S_IFDIR)
#define S_ISREG(st_mode) (st_mode & _S_IFREG)
#define S_ISLNK(st_mode) (st_mode & _S_IFLNK)
-
+
using TSystemFStat = BY_HANDLE_FILE_INFORMATION;
-
-#else
-
+
+#else
+
using TSystemFStat = struct stat;
-
+
#endif
-static void MakeStat(TFileStat& st, const TSystemFStat& fs) {
-#ifdef _unix_
- st.Mode = fs.st_mode;
- st.NLinks = fs.st_nlink;
- st.Uid = fs.st_uid;
- st.Gid = fs.st_gid;
- st.Size = fs.st_size;
+static void MakeStat(TFileStat& st, const TSystemFStat& fs) {
+#ifdef _unix_
+ st.Mode = fs.st_mode;
+ st.NLinks = fs.st_nlink;
+ st.Uid = fs.st_uid;
+ st.Gid = fs.st_gid;
+ st.Size = fs.st_size;
st.AllocationSize = fs.st_blocks * 512;
- st.ATime = fs.st_atime;
- st.MTime = fs.st_mtime;
- st.CTime = fs.st_ctime;
+ st.ATime = fs.st_atime;
+ st.MTime = fs.st_mtime;
+ st.CTime = fs.st_ctime;
st.INode = fs.st_ino;
-#else
+#else
timeval tv;
- FileTimeToTimeval(&fs.ftCreationTime, &tv);
+ FileTimeToTimeval(&fs.ftCreationTime, &tv);
st.CTime = tv.tv_sec;
- FileTimeToTimeval(&fs.ftLastAccessTime, &tv);
+ FileTimeToTimeval(&fs.ftLastAccessTime, &tv);
st.ATime = tv.tv_sec;
- FileTimeToTimeval(&fs.ftLastWriteTime, &tv);
+ FileTimeToTimeval(&fs.ftLastWriteTime, &tv);
st.MTime = tv.tv_sec;
- st.NLinks = fs.nNumberOfLinks;
- st.Mode = GetFileMode(fs.dwFileAttributes);
+ st.NLinks = fs.nNumberOfLinks;
+ st.Mode = GetFileMode(fs.dwFileAttributes);
st.Uid = 0;
st.Gid = 0;
- st.Size = ((ui64)fs.nFileSizeHigh << 32) | fs.nFileSizeLow;
+ st.Size = ((ui64)fs.nFileSizeHigh << 32) | fs.nFileSizeLow;
st.AllocationSize = st.Size; // FIXME
st.INode = ((ui64)fs.nFileIndexHigh << 32) | fs.nFileIndexLow;
#endif
-}
-
-static bool GetStatByHandle(TSystemFStat& fs, FHANDLE f) {
-#ifdef _win_
- return GetFileInformationByHandle(f, &fs);
-#else
- return !fstat(f, &fs);
-#endif
-}
-
+}
+
+static bool GetStatByHandle(TSystemFStat& fs, FHANDLE f) {
+#ifdef _win_
+ return GetFileInformationByHandle(f, &fs);
+#else
+ return !fstat(f, &fs);
+#endif
+}
+
static bool GetStatByName(TSystemFStat& fs, const char* fileName, bool nofollow) {
-#ifdef _win_
+#ifdef _win_
TFileHandle h = NFsPrivate::CreateFileWithUtf8Name(fileName, FILE_READ_ATTRIBUTES | FILE_READ_EA, FILE_SHARE_READ | FILE_SHARE_WRITE,
OPEN_EXISTING,
(nofollow ? FILE_FLAG_OPEN_REPARSE_POINT : 0) | FILE_FLAG_BACKUP_SEMANTICS, true);
if (!h.IsOpen()) {
return false;
}
- return GetStatByHandle(fs, h);
-#else
+ return GetStatByHandle(fs, h);
+#else
return !(nofollow ? lstat : stat)(fileName, &fs);
-#endif
-}
-
+#endif
+}
+
TFileStat::TFileStat() = default;
-
+
TFileStat::TFileStat(const TFile& f) {
- *this = TFileStat(f.GetHandle());
-}
-
+ *this = TFileStat(f.GetHandle());
+}
+
TFileStat::TFileStat(FHANDLE f) {
- TSystemFStat st;
- if (GetStatByHandle(st, f)) {
- MakeStat(*this, st);
- } else {
- *this = TFileStat();
- }
-}
-
+ TSystemFStat st;
+ if (GetStatByHandle(st, f)) {
+ MakeStat(*this, st);
+ } else {
+ *this = TFileStat();
+ }
+}
+
void TFileStat::MakeFromFileName(const char* fileName, bool nofollow) {
- TSystemFStat st;
+ TSystemFStat st;
if (GetStatByName(st, fileName, nofollow)) {
- MakeStat(*this, st);
- } else {
- *this = TFileStat();
- }
-}
-
+ MakeStat(*this, st);
+ } else {
+ *this = TFileStat();
+ }
+}
+
TFileStat::TFileStat(const TFsPath& fileName, bool nofollow) {
MakeFromFileName(fileName.GetPath().data(), nofollow);
}
@@ -137,16 +137,16 @@ bool TFileStat::IsNull() const noexcept {
}
bool TFileStat::IsFile() const noexcept {
- return S_ISREG(Mode);
-}
-
+ return S_ISREG(Mode);
+}
+
bool TFileStat::IsDir() const noexcept {
- return S_ISDIR(Mode);
-}
-
+ return S_ISDIR(Mode);
+}
+
bool TFileStat::IsSymlink() const noexcept {
- return S_ISLNK(Mode);
-}
+ return S_ISLNK(Mode);
+}
bool operator==(const TFileStat& l, const TFileStat& r) noexcept {
return l.Mode == r.Mode &&
diff --git a/util/system/fstat.h b/util/system/fstat.h
index 64e79e1b55..3c2c5d65c8 100644
--- a/util/system/fstat.h
+++ b/util/system/fstat.h
@@ -1,34 +1,34 @@
-#pragma once
-
+#pragma once
+
#include <util/generic/fwd.h>
#include <util/system/fhandle.h>
-
-class TFile;
+
+class TFile;
class TFsPath;
-
-struct TFileStat {
+
+struct TFileStat {
ui32 Mode = 0; /* protection */
ui32 Uid = 0; /* user ID of owner */
ui32 Gid = 0; /* group ID of owner */
-
+
ui64 NLinks = 0; /* number of hard links */
ui64 Size = 0; /* total size, in bytes */
ui64 INode = 0; /* inode number */
ui64 AllocationSize = 0; /* number of bytes allocated on the disk */
-
+
time_t ATime = 0; /* time of last access */
time_t MTime = 0; /* time of last modification */
time_t CTime = 0; /* time of last status change */
-
-public:
- TFileStat();
+
+public:
+ TFileStat();
bool IsNull() const noexcept;
bool IsFile() const noexcept;
bool IsDir() const noexcept;
bool IsSymlink() const noexcept;
-
+
explicit TFileStat(const TFile& f);
explicit TFileStat(FHANDLE f);
TFileStat(const TFsPath& fileName, bool nofollow = false);
@@ -40,7 +40,7 @@ public:
private:
void MakeFromFileName(const char* fileName, bool nofollow);
-};
+};
i64 GetFileLength(FHANDLE fd);
i64 GetFileLength(const char* name);
diff --git a/util/system/guard.h b/util/system/guard.h
index efc091d5f8..84c606980f 100644
--- a/util/system/guard.h
+++ b/util/system/guard.h
@@ -1,4 +1,4 @@
-#pragma once
+#pragma once
#include <util/generic/noncopyable.h>
diff --git a/util/system/hostname.h b/util/system/hostname.h
index 0839ee2b59..fe23900ca6 100644
--- a/util/system/hostname.h
+++ b/util/system/hostname.h
@@ -1,4 +1,4 @@
-#pragma once
+#pragma once
#include <util/generic/fwd.h>
diff --git a/util/system/hp_timer.h b/util/system/hp_timer.h
index 0a4c252ec2..5c57099bec 100644
--- a/util/system/hp_timer.h
+++ b/util/system/hp_timer.h
@@ -1,7 +1,7 @@
-#pragma once
+#pragma once
#include "defaults.h"
-
+
namespace NHPTimer {
using STime = i64;
// May delay for ~50ms to compute frequency
diff --git a/util/system/info.h b/util/system/info.h
index 73ebe48a9a..ea456ec661 100644
--- a/util/system/info.h
+++ b/util/system/info.h
@@ -1,4 +1,4 @@
-#pragma once
+#pragma once
#include "defaults.h"
diff --git a/util/system/madvise.cpp b/util/system/madvise.cpp
index 58c894e3ef..b4d2454146 100644
--- a/util/system/madvise.cpp
+++ b/util/system/madvise.cpp
@@ -1,16 +1,16 @@
-#include "madvise.h"
-#include "align.h"
-#include "info.h"
-
-#include <util/generic/yexception.h>
-
-#if defined(_win_)
+#include "madvise.h"
+#include "align.h"
+#include "info.h"
+
+#include <util/generic/yexception.h>
+
+#if defined(_win_)
#include <util/system/winint.h>
-#else
+#else
#include <sys/types.h>
#include <sys/mman.h>
-#endif
-
+#endif
+
#ifndef MADV_DONTDUMP /* This flag is defined in sys/mman.h since Linux 3.4, but currently old libc header is in use \
for capability with Ubuntu 12.04, so we need to define it here manually */
#define MADV_DONTDUMP 16 /* Explicity exclude from the core dump, overrides the coredump filter bits */
@@ -21,34 +21,34 @@
#define MADV_DODUMP 17 /* Undo the effect of an earlier MADV_DONTDUMP */
#endif
-namespace {
+namespace {
void Madvise(int flag, const void* cbegin, size_t size) {
- static const size_t pageSize = NSystemInfo::GetPageSize();
- void* begin = AlignDown(const_cast<void*>(cbegin), pageSize);
- size = AlignUp(size, pageSize);
-
-#if defined(_win_)
+ static const size_t pageSize = NSystemInfo::GetPageSize();
+ void* begin = AlignDown(const_cast<void*>(cbegin), pageSize);
+ size = AlignUp(size, pageSize);
+
+#if defined(_win_)
if (!VirtualFree((LPVOID)begin, size, flag)) {
TString err(LastSystemErrorText());
ythrow yexception() << "VirtualFree(" << begin << ", " << size << ", " << flag << ")"
<< " returned error: " << err;
- }
-#else
+ }
+#else
if (-1 == madvise(begin, size, flag)) {
TString err(LastSystemErrorText());
ythrow yexception() << "madvise(" << begin << ", " << size << ", " << flag << ")"
<< " returned error: " << err;
- }
-#endif
- }
-}
-
-void MadviseSequentialAccess(const void* begin, size_t size) {
+ }
+#endif
+ }
+}
+
+void MadviseSequentialAccess(const void* begin, size_t size) {
#if !defined(_win_)
Madvise(MADV_SEQUENTIAL, begin, size);
#endif
-}
-
+}
+
void MadviseSequentialAccess(TArrayRef<const char> data) {
MadviseSequentialAccess(data.data(), data.size());
}
@@ -57,12 +57,12 @@ void MadviseSequentialAccess(TArrayRef<const ui8> data) {
MadviseSequentialAccess(data.data(), data.size());
}
-void MadviseRandomAccess(const void* begin, size_t size) {
+void MadviseRandomAccess(const void* begin, size_t size) {
#if !defined(_win_)
Madvise(MADV_RANDOM, begin, size);
#endif
-}
-
+}
+
void MadviseRandomAccess(TArrayRef<const char> data) {
MadviseRandomAccess(data.data(), data.size());
}
@@ -71,7 +71,7 @@ void MadviseRandomAccess(TArrayRef<const ui8> data) {
MadviseRandomAccess(data.data(), data.size());
}
-void MadviseEvict(const void* begin, size_t size) {
+void MadviseEvict(const void* begin, size_t size) {
#if defined(_win_)
Madvise(MEM_DECOMMIT, begin, size);
#elif defined(_linux_) || defined(_cygwin_)
@@ -79,7 +79,7 @@ void MadviseEvict(const void* begin, size_t size) {
#else // freebsd, osx
Madvise(MADV_FREE, begin, size);
#endif
-}
+}
void MadviseEvict(TArrayRef<const char> data) {
MadviseEvict(data.data(), data.size());
diff --git a/util/system/madvise.h b/util/system/madvise.h
index 606733152e..37172703be 100644
--- a/util/system/madvise.h
+++ b/util/system/madvise.h
@@ -1,21 +1,21 @@
-#pragma once
-
-#include "defaults.h"
-
+#pragma once
+
+#include "defaults.h"
+
#include <util/generic/array_ref.h>
-/// see linux madvise(MADV_SEQUENTIAL)
-void MadviseSequentialAccess(const void* begin, size_t size);
+/// see linux madvise(MADV_SEQUENTIAL)
+void MadviseSequentialAccess(const void* begin, size_t size);
void MadviseSequentialAccess(TArrayRef<const char> data);
void MadviseSequentialAccess(TArrayRef<const ui8> data);
-
-/// see linux madvise(MADV_RANDOM)
-void MadviseRandomAccess(const void* begin, size_t size);
+
+/// see linux madvise(MADV_RANDOM)
+void MadviseRandomAccess(const void* begin, size_t size);
void MadviseRandomAccess(TArrayRef<const char> data);
void MadviseRandomAccess(TArrayRef<const ui8> data);
-
-/// see linux madvise(MADV_DONTNEED)
-void MadviseEvict(const void* begin, size_t size);
+
+/// see linux madvise(MADV_DONTNEED)
+void MadviseEvict(const void* begin, size_t size);
void MadviseEvict(TArrayRef<const char> data);
void MadviseEvict(TArrayRef<const ui8> data);
diff --git a/util/system/maxlen.h b/util/system/maxlen.h
index e1ff7f5008..15eab874c0 100644
--- a/util/system/maxlen.h
+++ b/util/system/maxlen.h
@@ -1,4 +1,4 @@
-#pragma once
+#pragma once
#include <cstdlib>
diff --git a/util/system/mem_info.cpp b/util/system/mem_info.cpp
index aa51ae3b16..42640022a5 100644
--- a/util/system/mem_info.cpp
+++ b/util/system/mem_info.cpp
@@ -1,15 +1,15 @@
-#include "mem_info.h"
-
-#include <util/generic/strbuf.h>
-#include <util/generic/utility.h>
-#include <util/generic/yexception.h>
-#include <util/stream/file.h>
-#include <util/string/cast.h>
+#include "mem_info.h"
+
+#include <util/generic/strbuf.h>
+#include <util/generic/utility.h>
+#include <util/generic/yexception.h>
+#include <util/stream/file.h>
+#include <util/string/cast.h>
#include <util/string/builder.h>
#include "error.h"
#include "info.h"
-
-#if defined(_unix_)
+
+#if defined(_unix_)
#include <errno.h>
#include <unistd.h>
#if defined(_freebsd_)
@@ -94,20 +94,20 @@ typedef enum _SYSTEM_INFORMATION_CLASS {
SystemProcessInformation = 5,
} SYSTEM_INFORMATION_CLASS;
-#else
-
-#endif
-
-namespace NMemInfo {
+#else
+
+#endif
+
+namespace NMemInfo {
TMemInfo GetMemInfo(pid_t pid) {
TMemInfo result;
-
-#if defined(_unix_)
-
+
+#if defined(_unix_)
+
#if defined(_linux_) || defined(_freebsd_) || defined(_cygwin_)
const ui32 pagesize = NSystemInfo::GetPageSize();
#endif
-
+
#if defined(_linux_) || defined(_cygwin_)
TString path;
if (!pid) {
@@ -129,17 +129,17 @@ namespace NMemInfo {
#elif defined(_freebsd_)
int mib[4] = {CTL_KERN, KERN_PROC, KERN_PROC_PID, pid};
size_t size = sizeof(struct kinfo_proc);
-
+
struct kinfo_proc proc;
Zero(proc);
-
+
errno = 0;
if (sysctl((int*)mib, 4, &proc, &size, nullptr, 0) == -1) {
int err = errno;
TString errtxt = LastSystemErrorText(err);
ythrow yexception() << "sysctl({CTL_KERN,KERN_PROC,KERN_PROC_PID,pid},4,proc,&size,NULL,0) returned -1, errno: " << err << " (" << errtxt << ")" << Endl;
}
-
+
result.VMS = proc.ki_size;
result.RSS = proc.ki_rssize * pagesize;
#elif defined(_darwin_) && !defined(_arm_) && !defined(__IOS__)
@@ -213,7 +213,7 @@ namespace NMemInfo {
result.VMS = process->VirtualSize;
result.RSS = process->WorkingSetSize;
-#endif
+#endif
return result;
}
-}
+}
diff --git a/util/system/mem_info.h b/util/system/mem_info.h
index f303d49197..b23dbb0d71 100644
--- a/util/system/mem_info.h
+++ b/util/system/mem_info.h
@@ -1,18 +1,18 @@
-#pragma once
-
+#pragma once
+
#include "compat.h"
-
-namespace NMemInfo {
+
+namespace NMemInfo {
struct TMemInfo {
ui64 RSS; // current RAM size of the process
ui64 VMS; // current VM size of the process
-
+
TMemInfo()
: RSS()
, VMS()
{
}
};
-
+
TMemInfo GetMemInfo(pid_t = 0);
-}
+}
diff --git a/util/system/mem_info_ut.cpp b/util/system/mem_info_ut.cpp
index a1100ba646..ade1c3367e 100644
--- a/util/system/mem_info_ut.cpp
+++ b/util/system/mem_info_ut.cpp
@@ -1,21 +1,21 @@
-#include "mem_info.h"
-
+#include "mem_info.h"
+
#include <library/cpp/testing/unittest/registar.h>
-
+
#include "info.h"
-
+
class TMemInfoTest: public NUnitTest::TTestBase {
UNIT_TEST_SUITE(TMemInfoTest)
- UNIT_TEST(TestMemInfo)
+ UNIT_TEST(TestMemInfo)
UNIT_TEST_SUITE_END();
- void TestMemInfo() {
- using namespace NMemInfo;
-
- TMemInfo stats = GetMemInfo();
-
+ void TestMemInfo() {
+ using namespace NMemInfo;
+
+ TMemInfo stats = GetMemInfo();
+
UNIT_ASSERT(stats.RSS >= NSystemInfo::GetPageSize());
UNIT_ASSERT(stats.VMS >= stats.RSS);
- }
-};
-
-UNIT_TEST_SUITE_REGISTRATION(TMemInfoTest)
+ }
+};
+
+UNIT_TEST_SUITE_REGISTRATION(TMemInfoTest)
diff --git a/util/system/mutex.h b/util/system/mutex.h
index 032630d134..6fac9a8f72 100644
--- a/util/system/mutex.h
+++ b/util/system/mutex.h
@@ -1,4 +1,4 @@
-#pragma once
+#pragma once
#include "guard.h"
#include "defaults.h"
diff --git a/util/system/pipe.h b/util/system/pipe.h
index 75d0360049..983d8a8b0d 100644
--- a/util/system/pipe.h
+++ b/util/system/pipe.h
@@ -1,4 +1,4 @@
-#pragma once
+#pragma once
#ifdef __GNUC__
#pragma GCC diagnostic push
diff --git a/util/system/platform.h b/util/system/platform.h
index 58f310ab34..9b65a9247d 100644
--- a/util/system/platform.h
+++ b/util/system/platform.h
@@ -1,4 +1,4 @@
-#pragma once
+#pragma once
// ya style breaks indentation in ifdef's and code becomes unreadable
// clang-format off
diff --git a/util/system/progname.h b/util/system/progname.h
index e5e2a0eee2..f28ffa28c3 100644
--- a/util/system/progname.h
+++ b/util/system/progname.h
@@ -1,4 +1,4 @@
-#pragma once
+#pragma once
#include <util/generic/fwd.h>
diff --git a/util/system/rwlock.h b/util/system/rwlock.h
index 0bb9b3fe1c..c10419a370 100644
--- a/util/system/rwlock.h
+++ b/util/system/rwlock.h
@@ -1,4 +1,4 @@
-#pragma once
+#pragma once
#include "guard.h"
#include "defaults.h"
diff --git a/util/system/sem.h b/util/system/sem.h
index 0c964ad6b6..c777d17d7e 100644
--- a/util/system/sem.h
+++ b/util/system/sem.h
@@ -1,4 +1,4 @@
-#pragma once
+#pragma once
#include "defaults.h"
diff --git a/util/system/sigset.h b/util/system/sigset.h
index 8dd02fd817..f0bd42ae2e 100644
--- a/util/system/sigset.h
+++ b/util/system/sigset.h
@@ -1,4 +1,4 @@
-#pragma once
+#pragma once
// Functions for manipulating signal sets
diff --git a/util/system/spin_wait.h b/util/system/spin_wait.h
index 91dd423e33..e97d0df35c 100644
--- a/util/system/spin_wait.h
+++ b/util/system/spin_wait.h
@@ -1,4 +1,4 @@
-#pragma once
+#pragma once
struct TSpinWait {
TSpinWait() noexcept;
diff --git a/util/system/spinlock.h b/util/system/spinlock.h
index af2630890a..04beefdfca 100644
--- a/util/system/spinlock.h
+++ b/util/system/spinlock.h
@@ -1,4 +1,4 @@
-#pragma once
+#pragma once
#include "atomic.h"
#include "spin_wait.h"
diff --git a/util/system/sys_alloc.h b/util/system/sys_alloc.h
index 4221a28f8c..29af4083e7 100644
--- a/util/system/sys_alloc.h
+++ b/util/system/sys_alloc.h
@@ -1,4 +1,4 @@
-#pragma once
+#pragma once
#include <util/system/compiler.h>
diff --git a/util/system/tempfile.h b/util/system/tempfile.h
index de249c129d..ccb01bf5b0 100644
--- a/util/system/tempfile.h
+++ b/util/system/tempfile.h
@@ -1,4 +1,4 @@
-#pragma once
+#pragma once
#include "fs.h"
#include "file.h"
diff --git a/util/system/thread.h b/util/system/thread.h
index a6e8abdb5b..7a0aa75cba 100644
--- a/util/system/thread.h
+++ b/util/system/thread.h
@@ -1,4 +1,4 @@
-#pragma once
+#pragma once
/// This code should not be used directly unless you really understand what you do.
/// If you need threads, use thread pool functionality in <util/thread/factory.h>
diff --git a/util/system/tls.h b/util/system/tls.h
index 3c4f56dbeb..358f9c8927 100644
--- a/util/system/tls.h
+++ b/util/system/tls.h
@@ -1,4 +1,4 @@
-#pragma once
+#pragma once
#include "defaults.h"
diff --git a/util/system/type_name.h b/util/system/type_name.h
index b6619aba3f..7fc72d0f4a 100644
--- a/util/system/type_name.h
+++ b/util/system/type_name.h
@@ -1,4 +1,4 @@
-#pragma once
+#pragma once
#include <util/generic/string.h>
#include <util/string/subst.h>
diff --git a/util/system/valgrind.h b/util/system/valgrind.h
index 2ec4ed927c..ef01227aae 100644
--- a/util/system/valgrind.h
+++ b/util/system/valgrind.h
@@ -1,4 +1,4 @@
-#pragma once
+#pragma once
#if defined(WITH_VALGRIND) && defined(HAVE_VALGRIND)
#include <valgrind/valgrind.h>
diff --git a/util/system/yassert.h b/util/system/yassert.h
index 529823440c..0dd4d8388e 100644
--- a/util/system/yassert.h
+++ b/util/system/yassert.h
@@ -1,4 +1,4 @@
-#pragma once
+#pragma once
#include "defaults.h"
#include "src_root.h"
diff --git a/util/system/yield.h b/util/system/yield.h
index 9965fb52b5..0ac6ba7d73 100644
--- a/util/system/yield.h
+++ b/util/system/yield.h
@@ -1,4 +1,4 @@
-#pragma once
+#pragma once
void SchedYield() noexcept;
void ThreadYield() noexcept;