aboutsummaryrefslogtreecommitdiffstats
path: root/util
diff options
context:
space:
mode:
authorsomov <somov@yandex-team.ru>2022-02-10 16:45:47 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:45:47 +0300
commita5950576e397b1909261050b8c7da16db58f10b1 (patch)
tree7ba7677f6a4c3e19e2cefab34d16df2c8963b4d4 /util
parent81eddc8c0b55990194e112b02d127b87d54164a9 (diff)
downloadydb-a5950576e397b1909261050b8c7da16db58f10b1.tar.gz
Restoring authorship annotation for <somov@yandex-team.ru>. Commit 1 of 2.
Diffstat (limited to 'util')
-rw-r--r--util/charset/unidata.h2
-rw-r--r--util/datetime/base_ut.cpp4
-rw-r--r--util/datetime/systime.cpp2
-rw-r--r--util/digest/multi_ut.cpp4
-rw-r--r--util/digest/sequence_ut.cpp6
-rw-r--r--util/folder/dirut.cpp26
-rw-r--r--util/folder/filelist.cpp2
-rw-r--r--util/folder/tempdir.cpp22
-rw-r--r--util/folder/tempdir.h6
-rw-r--r--util/generic/cast.h4
-rw-r--r--util/generic/hash.h2
-rw-r--r--util/generic/hash_primes.h2
-rw-r--r--util/generic/hide_ptr.cpp10
-rw-r--r--util/generic/hide_ptr.h6
-rw-r--r--util/generic/maybe.h160
-rw-r--r--util/generic/ptr.h2
-rw-r--r--util/generic/strbase.h2
-rw-r--r--util/generic/string.h26
-rw-r--r--util/generic/string_ut.cpp8
-rw-r--r--util/generic/typetraits.h12
-rw-r--r--util/generic/typetraits_ut.cpp2
-rw-r--r--util/generic/vector_ut.cpp80
-rw-r--r--util/generic/ymath.h2
-rw-r--r--util/memory/segpool_alloc.h2
-rw-r--r--util/network/socket.cpp236
-rw-r--r--util/network/socket.h4
-rw-r--r--util/network/socket_ut.cpp150
-rw-r--r--util/stream/zlib.cpp10
-rw-r--r--util/stream/zlib.h4
-rw-r--r--util/string/cast.cpp6
-rw-r--r--util/system/compat.cpp18
-rw-r--r--util/system/compat.h10
-rw-r--r--util/system/compiler.h20
-rw-r--r--util/system/context.h4
-rw-r--r--util/system/defaults.h10
-rw-r--r--util/system/file_ut.cpp4
-rw-r--r--util/system/filemap.h12
-rw-r--r--util/system/mktemp.cpp10
-rw-r--r--util/system/platform.h32
-rw-r--r--util/system/sanitizers.cpp14
-rw-r--r--util/system/sanitizers.h4
-rw-r--r--util/system/shmat.cpp36
-rw-r--r--util/system/thread.cpp24
-rw-r--r--util/system/tls.h6
-rw-r--r--util/system/winint.h4
-rw-r--r--util/system/yassert.h24
46 files changed, 518 insertions, 518 deletions
diff --git a/util/charset/unidata.h b/util/charset/unidata.h
index 400d314186..1be76c56f3 100644
--- a/util/charset/unidata.h
+++ b/util/charset/unidata.h
@@ -301,7 +301,7 @@ inline wchar32 ToTitle(wchar32 ch) {
inline int ToDigit(wchar32 ch) {
ui32 i = NUnicode::NPrivate::CharInfo(ch);
- return (i & IS_DIGIT) ? static_cast<int>(i >> SVAL_OFFSET) : -1;
+ return (i & IS_DIGIT) ? static_cast<int>(i >> SVAL_OFFSET) : -1;
}
// BIDI properties
diff --git a/util/datetime/base_ut.cpp b/util/datetime/base_ut.cpp
index afc3f802eb..4a41884b98 100644
--- a/util/datetime/base_ut.cpp
+++ b/util/datetime/base_ut.cpp
@@ -2,8 +2,8 @@
#include <library/cpp/testing/unittest/registar.h>
-#include <util/generic/utility.h>
-#include <util/generic/ylimits.h>
+#include <util/generic/utility.h>
+#include <util/generic/ylimits.h>
#include <util/generic/ymath.h>
#include <util/string/cast.h>
#include <util/stream/output.h>
diff --git a/util/datetime/systime.cpp b/util/datetime/systime.cpp
index 6ee7e8fc6e..a17b50f510 100644
--- a/util/datetime/systime.cpp
+++ b/util/datetime/systime.cpp
@@ -90,7 +90,7 @@ struct tm* GmTimeR(const time_t* timer, struct tm* tmbuf) {
{31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31},
{31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}};
- i64 time = static_cast<i64>(*timer);
+ i64 time = static_cast<i64>(*timer);
ui64 dayclock, dayno;
int year = EPOCH_YR;
diff --git a/util/digest/multi_ut.cpp b/util/digest/multi_ut.cpp
index dff64ff0cc..bb6ea14bb5 100644
--- a/util/digest/multi_ut.cpp
+++ b/util/digest/multi_ut.cpp
@@ -14,11 +14,11 @@ class TMultiHashTest: public TTestBase {
private:
inline void TestStrInt() {
- UNIT_ASSERT_EQUAL(MultiHash(TString("1234567"), static_cast<int>(123)), static_cast<size_t>(ULL(17038203285960021630)));
+ UNIT_ASSERT_EQUAL(MultiHash(TString("1234567"), static_cast<int>(123)), static_cast<size_t>(ULL(17038203285960021630)));
}
inline void TestIntStr() {
- UNIT_ASSERT_EQUAL(MultiHash(static_cast<int>(123), TString("1234567")), static_cast<size_t>(ULL(9973288649881090712)));
+ UNIT_ASSERT_EQUAL(MultiHash(static_cast<int>(123), TString("1234567")), static_cast<size_t>(ULL(9973288649881090712)));
}
inline void TestSimpleCollision() {
diff --git a/util/digest/sequence_ut.cpp b/util/digest/sequence_ut.cpp
index 87d6102ee5..b12f72df9c 100644
--- a/util/digest/sequence_ut.cpp
+++ b/util/digest/sequence_ut.cpp
@@ -15,12 +15,12 @@ class TRangeHashTest: public TTestBase {
private:
inline void TestStrokaInt() {
- const size_t canonicalHash = static_cast<size_t>(ULL(12727184940294366172));
+ const size_t canonicalHash = static_cast<size_t>(ULL(12727184940294366172));
UNIT_ASSERT_EQUAL(canonicalHash, TRangeHash<>()(TString("12345")));
}
inline void TestIntVector() {
- const size_t canonicalHash = static_cast<size_t>(ULL(1351128487744230578));
+ const size_t canonicalHash = static_cast<size_t>(ULL(1351128487744230578));
TVector<int> testVec = {1, 2, 4, 3};
UNIT_ASSERT_EQUAL(canonicalHash, TRangeHash<>()(testVec));
}
@@ -52,7 +52,7 @@ class TSequenceHashTest: public TTestBase {
private:
inline void TestSimpleBuffer() {
int arr[] = {1, 2, 3};
- const size_t canonicalHash = static_cast<size_t>(ULL(3903918011533391876));
+ const size_t canonicalHash = static_cast<size_t>(ULL(3903918011533391876));
TContiguousHash<TSimpleRangeHash> hasher;
UNIT_ASSERT_EQUAL(canonicalHash, hasher(TArrayRef<int>(arr, arr + 3)));
}
diff --git a/util/folder/dirut.cpp b/util/folder/dirut.cpp
index ffc9b09f96..690c980c8b 100644
--- a/util/folder/dirut.cpp
+++ b/util/folder/dirut.cpp
@@ -425,17 +425,17 @@ TString RealLocation(const TString& path) {
int MakeTempDir(char path[/*FILENAME_MAX*/], const char* prefix) {
int ret;
-
+
TString sysTmp;
-
+
#ifdef _win32_
- if (!prefix || *prefix == '/') {
+ if (!prefix || *prefix == '/') {
#else
- if (!prefix) {
+ if (!prefix) {
#endif
- sysTmp = GetSystemTempDir();
+ sysTmp = GetSystemTempDir();
prefix = sysTmp.data();
- }
+ }
if ((ret = ResolvePath(prefix, nullptr, path, 1)) != 0)
return ret;
@@ -507,19 +507,19 @@ const char* GetFileNameComponent(const char* f) {
TString GetSystemTempDir() {
#ifdef _win_
- char buffer[1024];
- DWORD size = GetTempPath(1024, buffer);
- if (!size) {
- ythrow TSystemError() << "failed to get system temporary directory";
- }
+ char buffer[1024];
+ DWORD size = GetTempPath(1024, buffer);
+ if (!size) {
+ ythrow TSystemError() << "failed to get system temporary directory";
+ }
return TString(buffer, size);
#else
const char* var = "TMPDIR";
const char* def = "/tmp";
const char* r = getenv(var);
const char* result = r ? r : def;
- return result[0] == '/' ? result : ResolveDir(result);
-#endif
+ return result[0] == '/' ? result : ResolveDir(result);
+#endif
}
TString ResolveDir(const char* path) {
diff --git a/util/folder/filelist.cpp b/util/folder/filelist.cpp
index b21fcdbf20..5345317556 100644
--- a/util/folder/filelist.cpp
+++ b/util/folder/filelist.cpp
@@ -33,7 +33,7 @@ void TFileEntitiesList::Fill(const TString& dirname, TStringBuf prefix, TStringB
if (((Mask & EM_FILES) && file->fts_info == FTS_F) || ((Mask & EM_DIRS) && file->fts_info == FTS_D) || ((Mask & EM_SLINKS) && file->fts_info == FTS_SL)) {
++FileNamesSize;
FileNames.Append(filename.data(), filename.size() + 1);
- }
+ }
}
Restart();
diff --git a/util/folder/tempdir.cpp b/util/folder/tempdir.cpp
index 6fdf8f753c..e72b2a4fb0 100644
--- a/util/folder/tempdir.cpp
+++ b/util/folder/tempdir.cpp
@@ -1,7 +1,7 @@
#include "tempdir.h"
-
+
#include "dirut.h"
-
+
#include <util/system/fs.h>
#include <util/system/maxlen.h>
@@ -12,7 +12,7 @@ TTempDir::TTempDir()
TTempDir::TTempDir(const char* prefix, TCreationToken)
: TempDir()
- , Remove(true)
+ , Remove(true)
{
char tempDir[MAX_PATH];
if (MakeTempDir(tempDir, prefix) != 0) {
@@ -23,7 +23,7 @@ TTempDir::TTempDir(const char* prefix, TCreationToken)
TTempDir::TTempDir(const TString& tempDir)
: TempDir(tempDir)
- , Remove(true)
+ , Remove(true)
{
NFs::Remove(TempDir);
MakeDirIfNotExist(TempDir.c_str());
@@ -33,12 +33,12 @@ TTempDir TTempDir::NewTempDir(const TString& root) {
return {root.c_str(), TCreationToken{}};
}
-void TTempDir::DoNotRemove() {
- Remove = false;
-}
-
+void TTempDir::DoNotRemove() {
+ Remove = false;
+}
+
TTempDir::~TTempDir() {
- if (Remove) {
- RemoveDirWithContents(TempDir);
- }
+ if (Remove) {
+ RemoveDirWithContents(TempDir);
+ }
}
diff --git a/util/folder/tempdir.h b/util/folder/tempdir.h
index ff458f83b9..8fed58245d 100644
--- a/util/folder/tempdir.h
+++ b/util/folder/tempdir.h
@@ -29,8 +29,8 @@ public:
return TempDir;
}
- void DoNotRemove();
-
+ void DoNotRemove();
+
private:
struct TCreationToken {};
@@ -39,5 +39,5 @@ private:
TTempDir(const char* prefix, TCreationToken);
TFsPath TempDir;
- bool Remove;
+ bool Remove;
};
diff --git a/util/generic/cast.h b/util/generic/cast.h
index 0d4a41f385..6d273a9e43 100644
--- a/util/generic/cast.h
+++ b/util/generic/cast.h
@@ -124,7 +124,7 @@ inline std::enable_if_t<!::NPrivate::TSafelyConvertible<TSmall, TLarge>::Result,
}
}
- TSmallInt smallInt = TSmallInt(largeInt);
+ TSmallInt smallInt = TSmallInt(largeInt);
if (std::is_signed<TSmallInt>::value && std::is_unsigned<TLargeInt>::value) {
if (IsNegative(smallInt)) {
@@ -134,7 +134,7 @@ inline std::enable_if_t<!::NPrivate::TSafelyConvertible<TSmall, TLarge>::Result,
}
}
- if (TLargeInt(smallInt) != largeInt) {
+ if (TLargeInt(smallInt) != largeInt) {
ythrow TBadCastException() << "Conversion '" << TypeName<TLarge>() << '{' << TLargeInt(largeInt) << "}' to '"
<< TypeName<TSmallInt>() << "', loss of data";
}
diff --git a/util/generic/hash.h b/util/generic/hash.h
index e46db21fa9..0a396f9b9e 100644
--- a/util/generic/hash.h
+++ b/util/generic/hash.h
@@ -494,7 +494,7 @@ private:
/* This method is templated to postpone instantiation of key extraction functor. */
template <class ValueL>
- auto get_key(const ValueL& value) const -> decltype(ExtractKey()(value)) {
+ auto get_key(const ValueL& value) const -> decltype(ExtractKey()(value)) {
return this->_get_key_extract()(value);
}
diff --git a/util/generic/hash_primes.h b/util/generic/hash_primes.h
index 4dc2da0b8f..15ffc3e484 100644
--- a/util/generic/hash_primes.h
+++ b/util/generic/hash_primes.h
@@ -24,7 +24,7 @@ namespace NPrivate {
/// @see https://gmplib.org/~tege/divcnst-pldi94.pdf
template <typename TDivisor, typename TDividend, typename MulUnsignedUpper>
class TReciprocalDivisor {
- static_assert(sizeof(TDivisor) <= sizeof(TDividend), "TDivisor and TDividend should have the same size");
+ static_assert(sizeof(TDivisor) <= sizeof(TDividend), "TDivisor and TDividend should have the same size");
public:
constexpr TReciprocalDivisor() noexcept = default;
diff --git a/util/generic/hide_ptr.cpp b/util/generic/hide_ptr.cpp
index 74eac028aa..58837b6d90 100644
--- a/util/generic/hide_ptr.cpp
+++ b/util/generic/hide_ptr.cpp
@@ -1,5 +1,5 @@
-#include "hide_ptr.h"
-
-void* HidePointerOrigin(void* ptr) {
- return ptr;
-}
+#include "hide_ptr.h"
+
+void* HidePointerOrigin(void* ptr) {
+ return ptr;
+}
diff --git a/util/generic/hide_ptr.h b/util/generic/hide_ptr.h
index c734894bd7..ea415c46aa 100644
--- a/util/generic/hide_ptr.h
+++ b/util/generic/hide_ptr.h
@@ -1,3 +1,3 @@
-#pragma once
-
-void* HidePointerOrigin(void*);
+#pragma once
+
+void* HidePointerOrigin(void*);
diff --git a/util/generic/maybe.h b/util/generic/maybe.h
index 34d21aebcd..f250a893f9 100644
--- a/util/generic/maybe.h
+++ b/util/generic/maybe.h
@@ -50,107 +50,107 @@ private:
"Instantiation of TMaybe with non-destructible type is ill-formed");
template <class U>
- struct TConstructibleFromMaybeSomehow {
- public:
- static constexpr bool value = std::is_constructible<T, TMaybe<U, Policy>&>::value ||
- std::is_constructible<T, const TMaybe<U, Policy>&>::value ||
- std::is_constructible<T, TMaybe<U, Policy>&&>::value ||
- std::is_constructible<T, const TMaybe<U, Policy>&&>::value ||
- std::is_convertible<TMaybe<U, Policy>&, T>::value ||
- std::is_convertible<const TMaybe<U, Policy>&, T>::value ||
- std::is_convertible<TMaybe<U, Policy>&&, T>::value ||
- std::is_convertible<const TMaybe<U, Policy>&&, T>::value;
- };
+ struct TConstructibleFromMaybeSomehow {
+ public:
+ static constexpr bool value = std::is_constructible<T, TMaybe<U, Policy>&>::value ||
+ std::is_constructible<T, const TMaybe<U, Policy>&>::value ||
+ std::is_constructible<T, TMaybe<U, Policy>&&>::value ||
+ std::is_constructible<T, const TMaybe<U, Policy>&&>::value ||
+ std::is_convertible<TMaybe<U, Policy>&, T>::value ||
+ std::is_convertible<const TMaybe<U, Policy>&, T>::value ||
+ std::is_convertible<TMaybe<U, Policy>&&, T>::value ||
+ std::is_convertible<const TMaybe<U, Policy>&&, T>::value;
+ };
template <class U>
- struct TAssignableFromMaybeSomehow {
- public:
- static constexpr bool value = TConstructibleFromMaybeSomehow<U>::value ||
- std::is_assignable<T&, TMaybe<U, Policy>&>::value ||
- std::is_assignable<T&, const TMaybe<U, Policy>&>::value ||
- std::is_assignable<T&, TMaybe<U, Policy>&&>::value ||
- std::is_assignable<T&, const TMaybe<U, Policy>&&>::value;
- };
+ struct TAssignableFromMaybeSomehow {
+ public:
+ static constexpr bool value = TConstructibleFromMaybeSomehow<U>::value ||
+ std::is_assignable<T&, TMaybe<U, Policy>&>::value ||
+ std::is_assignable<T&, const TMaybe<U, Policy>&>::value ||
+ std::is_assignable<T&, TMaybe<U, Policy>&&>::value ||
+ std::is_assignable<T&, const TMaybe<U, Policy>&&>::value;
+ };
template <class U>
- struct TImplicitCopyCtor {
- public:
- static constexpr bool value = std::is_constructible<T, const U&>::value &&
- std::is_convertible<const U&, T>::value &&
- !TConstructibleFromMaybeSomehow<U>::value;
- };
+ struct TImplicitCopyCtor {
+ public:
+ static constexpr bool value = std::is_constructible<T, const U&>::value &&
+ std::is_convertible<const U&, T>::value &&
+ !TConstructibleFromMaybeSomehow<U>::value;
+ };
template <class U>
- struct TExplicitCopyCtor {
- public:
- static constexpr bool value = std::is_constructible<T, const U&>::value &&
- !std::is_convertible<const U&, T>::value &&
- !TConstructibleFromMaybeSomehow<U>::value;
- };
+ struct TExplicitCopyCtor {
+ public:
+ static constexpr bool value = std::is_constructible<T, const U&>::value &&
+ !std::is_convertible<const U&, T>::value &&
+ !TConstructibleFromMaybeSomehow<U>::value;
+ };
template <class U>
- struct TImplicitMoveCtor {
- public:
- static constexpr bool value = std::is_constructible<T, U&&>::value &&
- std::is_convertible<U&&, T>::value &&
- !TConstructibleFromMaybeSomehow<U>::value;
- };
+ struct TImplicitMoveCtor {
+ public:
+ static constexpr bool value = std::is_constructible<T, U&&>::value &&
+ std::is_convertible<U&&, T>::value &&
+ !TConstructibleFromMaybeSomehow<U>::value;
+ };
template <class U>
- struct TExplicitMoveCtor {
- public:
- static constexpr bool value = std::is_constructible<T, U&&>::value &&
- !std::is_convertible<U&&, T>::value &&
- !TConstructibleFromMaybeSomehow<U>::value;
- };
+ struct TExplicitMoveCtor {
+ public:
+ static constexpr bool value = std::is_constructible<T, U&&>::value &&
+ !std::is_convertible<U&&, T>::value &&
+ !TConstructibleFromMaybeSomehow<U>::value;
+ };
template <class U>
- struct TCopyAssignable {
- public:
- static constexpr bool value = std::is_constructible<T, const U&>::value &&
- std::is_assignable<T&, const U&>::value &&
- !TAssignableFromMaybeSomehow<U>::value;
- };
+ struct TCopyAssignable {
+ public:
+ static constexpr bool value = std::is_constructible<T, const U&>::value &&
+ std::is_assignable<T&, const U&>::value &&
+ !TAssignableFromMaybeSomehow<U>::value;
+ };
template <class U>
- struct TMoveAssignable {
- public:
+ struct TMoveAssignable {
+ public:
static constexpr bool value = std::is_constructible<T, U&&>::value &&
std::is_assignable<T&, U&&>::value &&
!TAssignableFromMaybeSomehow<U>::value;
- };
+ };
- template <class U>
- struct TImplicitAnyCtor {
- public:
- using UDec = std::decay_t<U>;
-
- static constexpr bool value = std::is_constructible<T, U>::value &&
- std::is_convertible<U, T>::value &&
- !std::is_same<UDec, TInPlace>::value &&
- !std::is_same<UDec, TMaybe>::value;
- };
+ template <class U>
+ struct TImplicitAnyCtor {
+ public:
+ using UDec = std::decay_t<U>;
- template <class U>
- struct TExplicitAnyCtor {
- public:
- using UDec = std::decay_t<U>;
- static constexpr bool value = std::is_constructible<T, U>::value &&
- !std::is_convertible<U, T>::value &&
- !std::is_same<UDec, TInPlace>::value &&
- !std::is_same<UDec, TMaybe>::value;
- };
+ static constexpr bool value = std::is_constructible<T, U>::value &&
+ std::is_convertible<U, T>::value &&
+ !std::is_same<UDec, TInPlace>::value &&
+ !std::is_same<UDec, TMaybe>::value;
+ };
template <class U>
- struct TAssignableFromAny {
- public:
- using UDec = std::decay_t<U>;
- static constexpr bool value = !std::is_same<UDec, TMaybe>::value &&
- std::is_constructible<T, U>::value &&
- std::is_assignable<T&, U>::value &&
- (!std::is_scalar<T>::value || !std::is_same<UDec, T>::value);
- };
-
+ struct TExplicitAnyCtor {
+ public:
+ using UDec = std::decay_t<U>;
+ static constexpr bool value = std::is_constructible<T, U>::value &&
+ !std::is_convertible<U, T>::value &&
+ !std::is_same<UDec, TInPlace>::value &&
+ !std::is_same<UDec, TMaybe>::value;
+ };
+
+ template <class U>
+ struct TAssignableFromAny {
+ public:
+ using UDec = std::decay_t<U>;
+ static constexpr bool value = !std::is_same<UDec, TMaybe>::value &&
+ std::is_constructible<T, U>::value &&
+ std::is_assignable<T&, U>::value &&
+ (!std::is_scalar<T>::value || !std::is_same<UDec, T>::value);
+ };
+
using TBase = TMaybeBase<T>;
public:
diff --git a/util/generic/ptr.h b/util/generic/ptr.h
index 19db0e3ec5..27b72cafdd 100644
--- a/util/generic/ptr.h
+++ b/util/generic/ptr.h
@@ -303,7 +303,7 @@ public:
DoSwap(T_, r.T_);
}
- inline T* Get() const noexcept {
+ inline T* Get() const noexcept {
return T_;
}
diff --git a/util/generic/strbase.h b/util/generic/strbase.h
index ab39fc7537..846db66785 100644
--- a/util/generic/strbase.h
+++ b/util/generic/strbase.h
@@ -523,7 +523,7 @@ public:
inline size_t find_first_not_of(const TStringView set, size_t pos) const noexcept {
return AsStringView().find_first_not_of(set.data(), pos, set.size());
}
-
+
inline size_t find_last_of(TCharType c, size_t pos = npos) const noexcept {
return find_last_of(&c, pos, 1);
}
diff --git a/util/generic/string.h b/util/generic/string.h
index 8cd8aa6917..ae2f213dbd 100644
--- a/util/generic/string.h
+++ b/util/generic/string.h
@@ -119,13 +119,13 @@ public:
}
TChar* operator&() {
- return S_.begin() + Pos_;
- }
-
+ return S_.begin() + Pos_;
+ }
+
const TChar* operator&() const {
- return S_.cbegin() + Pos_;
- }
-
+ return S_.cbegin() + Pos_;
+ }
+
TBasicCharRef& operator=(TChar c) {
Y_ASSERT(Pos_ < S_.size() || (Pos_ == S_.size() && !c));
@@ -1215,15 +1215,15 @@ TBasicString<TCharType> to_title(const TBasicString<TCharType, TTraits>& s) {
return ret;
}
-namespace std {
+namespace std {
template <>
- struct hash<TString> {
- using argument_type = TString;
- using result_type = size_t;
- inline result_type operator()(argument_type const& s) const noexcept {
+ struct hash<TString> {
+ using argument_type = TString;
+ using result_type = size_t;
+ inline result_type operator()(argument_type const& s) const noexcept {
return NHashPrivate::ComputeStringHash(s.data(), s.size());
- }
- };
+ }
+ };
}
#undef Y_NOEXCEPT
diff --git a/util/generic/string_ut.cpp b/util/generic/string_ut.cpp
index ac82e9091d..7e255c687a 100644
--- a/util/generic/string_ut.cpp
+++ b/util/generic/string_ut.cpp
@@ -584,16 +584,16 @@ protected:
void find_last_of() {
// 21.3.6.4
TStringType s(Data_.one_two_three_one_two_three());
-
+
UNIT_ASSERT(s.find_last_of(Data_.abcde()) == 26);
UNIT_ASSERT(s.find_last_of(TStringType(Data_.abcde())) == 26);
-
+
TStringType test(Data_.aba());
-
+
UNIT_ASSERT(test.find_last_of(Data_.a(), 2, 1) == 2);
UNIT_ASSERT(test.find_last_of(Data_.a(), 1, 1) == 0);
UNIT_ASSERT(test.find_last_of(Data_.a(), 0, 1) == 0);
-
+
UNIT_ASSERT(test.find_last_of(*Data_.a(), 2) == 2);
UNIT_ASSERT(test.find_last_of(*Data_.a(), 1) == 0);
UNIT_ASSERT(test.find_last_of(*Data_.a(), 0) == 0);
diff --git a/util/generic/typetraits.h b/util/generic/typetraits.h
index d165bd1a06..bd67c874c8 100644
--- a/util/generic/typetraits.h
+++ b/util/generic/typetraits.h
@@ -48,8 +48,8 @@ namespace NPrivate {
}
}
-#if _LIBCPP_STD_VER >= 17 && !defined(_MSC_VER)
-// Disable std::conjunction for MSVC by analogy with std::disjunction.
+#if _LIBCPP_STD_VER >= 17 && !defined(_MSC_VER)
+// Disable std::conjunction for MSVC by analogy with std::disjunction.
template <class... Bs>
using TConjunction = std::conjunction<Bs...>;
#else
@@ -57,10 +57,10 @@ template <class... Bs>
struct TConjunction: ::TBoolConstant<::NPrivate::ConjunctionImpl<Bs...>()> {};
#endif
-#if _LIBCPP_STD_VER >= 17 && !defined(_MSC_VER)
-// Disable std::disjunction for MSVC.
-// It reduces build time (500 -> 20 seconds) and memory consumption (20 GB -> less than 1 GB)
-// for some files (notably search/dssm_boosting/dssm_boosting_calcer.cpp).
+#if _LIBCPP_STD_VER >= 17 && !defined(_MSC_VER)
+// Disable std::disjunction for MSVC.
+// It reduces build time (500 -> 20 seconds) and memory consumption (20 GB -> less than 1 GB)
+// for some files (notably search/dssm_boosting/dssm_boosting_calcer.cpp).
template <class... Bs>
using TDisjunction = std::disjunction<Bs...>;
#else
diff --git a/util/generic/typetraits_ut.cpp b/util/generic/typetraits_ut.cpp
index e7571c75ec..f021f9e0b0 100644
--- a/util/generic/typetraits_ut.cpp
+++ b/util/generic/typetraits_ut.cpp
@@ -60,7 +60,7 @@ namespace {
class TNonStdLayoutClass2 {
public:
virtual void Func() {
- }
+ }
};
class TNonStdLayoutClass3: public TNonStdLayoutClass2 {
diff --git a/util/generic/vector_ut.cpp b/util/generic/vector_ut.cpp
index 0f6b4037a0..359bbcceb2 100644
--- a/util/generic/vector_ut.cpp
+++ b/util/generic/vector_ut.cpp
@@ -27,7 +27,7 @@ class TYVectorTest: public TTestBase {
UNIT_TEST(TestShrink)
//UNIT_TEST(TestEbo)
UNIT_TEST(TestFillInConstructor)
- UNIT_TEST(TestYResize)
+ UNIT_TEST(TestYResize)
UNIT_TEST(TestCrop)
UNIT_TEST(TestInitializeList)
UNIT_TEST_SUITE_END();
@@ -470,45 +470,45 @@ private:
}
}
}
-
- struct TPod {
- int x;
+
+ struct TPod {
+ int x;
operator int() {
return x;
}
- };
-
- struct TNonPod {
- int x;
- TNonPod() {
- x = 0;
- }
+ };
+
+ struct TNonPod {
+ int x;
+ TNonPod() {
+ x = 0;
+ }
operator int() {
return x;
}
- };
-
+ };
+
template <typename T>
class TDebugAlloc: public std::allocator<T> {
- public:
- using TBase = std::allocator<T>;
-
+ public:
+ using TBase = std::allocator<T>;
+
T* allocate(typename TBase::size_type n) {
auto p = TBase::allocate(n);
- for (size_t i = 0; i < n; ++i) {
- memset(p + i, 0xab, sizeof(T));
- }
- return p;
- }
-
+ for (size_t i = 0; i < n; ++i) {
+ memset(p + i, 0xab, sizeof(T));
+ }
+ return p;
+ }
+
template <class TOther>
- struct rebind {
+ struct rebind {
using other = TDebugAlloc<TOther>;
- };
- };
-
+ };
+ };
+
template <typename T>
void TestYResize() {
#ifdef _YNDX_LIBCXX_ENABLE_VECTOR_POD_RESIZE_UNINITIALIZED
@@ -518,23 +518,23 @@ private:
#endif
TVector<T, TDebugAlloc<T>> v;
-
- v.reserve(5);
+
+ v.reserve(5);
auto firstBegin = v.begin();
-
+
v.yresize(5); // No realloc, no initialization if allowed
- UNIT_ASSERT(firstBegin == v.begin());
- for (int i = 0; i < 5; ++i) {
+ UNIT_ASSERT(firstBegin == v.begin());
+ for (int i = 0; i < 5; ++i) {
UNIT_ASSERT_VALUES_EQUAL(bool(v[i]), ALLOW_UNINITIALIZED);
- }
-
+ }
+
v.yresize(20); // Realloc, still no initialization
- UNIT_ASSERT(firstBegin != v.begin());
- for (int i = 0; i < 20; ++i) {
+ UNIT_ASSERT(firstBegin != v.begin());
+ for (int i = 0; i < 20; ++i) {
UNIT_ASSERT_VALUES_EQUAL(bool(v[i]), ALLOW_UNINITIALIZED);
- }
- }
-
+ }
+ }
+
struct TNoDefaultConstructor {
TNoDefaultConstructor() = delete;
explicit TNoDefaultConstructor(int val)
@@ -558,11 +558,11 @@ private:
UNIT_ASSERT(vec[0].Val == 42);
}
- void TestYResize() {
+ void TestYResize() {
TestYResize<int>();
TestYResize<TPod>();
TestYResize<TNonPod>();
- }
+ }
void CheckInitializeList(const TVector<int>& v) {
for (size_t i = 0; i < v.size(); ++i) {
diff --git a/util/generic/ymath.h b/util/generic/ymath.h
index 9ff9ae2abe..745d1c03a9 100644
--- a/util/generic/ymath.h
+++ b/util/generic/ymath.h
@@ -84,7 +84,7 @@ static inline bool IsNan(double f) {
#if defined(_win_)
return _isnan(f) != 0;
#else
- return std::isnan(f);
+ return std::isnan(f);
#endif
}
diff --git a/util/memory/segpool_alloc.h b/util/memory/segpool_alloc.h
index 1a83b7a543..0723629921 100644
--- a/util/memory/segpool_alloc.h
+++ b/util/memory/segpool_alloc.h
@@ -84,7 +84,7 @@ struct segpool_alloc {
}
~segpool_alloc() {
//assert(pool_count == pool_free_count && malloc_count == malloc_free_count); <- uncomment when swap() problem is solved
- //printf("in ~segpool_alloc: size = %u, pool_count = %" PRId64 ", malloc_count = %" PRId64 ", pool_free_count = %" PRId64 ", malloc_free_count = %" PRId64 "\n",
+ //printf("in ~segpool_alloc: size = %u, pool_count = %" PRId64 ", malloc_count = %" PRId64 ", pool_free_count = %" PRId64 ", malloc_free_count = %" PRId64 "\n",
// sizeof(_Tp), pool_count, malloc_count, pool_free_count, malloc_free_count);
//fflush(stdout);
}
diff --git a/util/network/socket.cpp b/util/network/socket.cpp
index 4f6e804346..c8e500eb05 100644
--- a/util/network/socket.cpp
+++ b/util/network/socket.cpp
@@ -74,101 +74,101 @@ const char* inet_ntop(int af, const void* src, char* dst, socklen_t size) {
}
return dst;
}
-
-struct evpair {
- int event;
- int winevent;
-};
-
-static const evpair evpairs_to_win[] = {
+
+struct evpair {
+ int event;
+ int winevent;
+};
+
+static const evpair evpairs_to_win[] = {
{POLLIN, FD_READ | FD_CLOSE | FD_ACCEPT},
{POLLRDNORM, FD_READ | FD_CLOSE | FD_ACCEPT},
- {POLLRDBAND, -1},
- {POLLPRI, -1},
- {POLLOUT, FD_WRITE | FD_CLOSE},
- {POLLWRNORM, FD_WRITE | FD_CLOSE},
- {POLLWRBAND, -1},
- {POLLERR, 0},
- {POLLHUP, 0},
+ {POLLRDBAND, -1},
+ {POLLPRI, -1},
+ {POLLOUT, FD_WRITE | FD_CLOSE},
+ {POLLWRNORM, FD_WRITE | FD_CLOSE},
+ {POLLWRBAND, -1},
+ {POLLERR, 0},
+ {POLLHUP, 0},
{POLLNVAL, 0}};
-
-static const size_t nevpairs_to_win = sizeof(evpairs_to_win) / sizeof(evpairs_to_win[0]);
-
-static const evpair evpairs_to_unix[] = {
+
+static const size_t nevpairs_to_win = sizeof(evpairs_to_win) / sizeof(evpairs_to_win[0]);
+
+static const evpair evpairs_to_unix[] = {
{FD_ACCEPT, POLLIN | POLLRDNORM},
- {FD_READ, POLLIN | POLLRDNORM},
- {FD_WRITE, POLLOUT | POLLWRNORM},
- {FD_CLOSE, POLLHUP},
-};
-
-static const size_t nevpairs_to_unix = sizeof(evpairs_to_unix) / sizeof(evpairs_to_unix[0]);
-
+ {FD_READ, POLLIN | POLLRDNORM},
+ {FD_WRITE, POLLOUT | POLLWRNORM},
+ {FD_CLOSE, POLLHUP},
+};
+
+static const size_t nevpairs_to_unix = sizeof(evpairs_to_unix) / sizeof(evpairs_to_unix[0]);
+
static int convert_events(int events, const evpair* evpairs, size_t nevpairs, bool ignoreUnknown) noexcept {
- int result = 0;
- for (size_t i = 0; i < nevpairs; ++i) {
- int event = evpairs[i].event;
- if (events & event) {
- events ^= event;
- long winEvent = evpairs[i].winevent;
- if (winEvent == -1)
- return -1;
- if (winEvent == 0)
- continue;
- result |= winEvent;
- }
- }
+ int result = 0;
+ for (size_t i = 0; i < nevpairs; ++i) {
+ int event = evpairs[i].event;
+ if (events & event) {
+ events ^= event;
+ long winEvent = evpairs[i].winevent;
+ if (winEvent == -1)
+ return -1;
+ if (winEvent == 0)
+ continue;
+ result |= winEvent;
+ }
+ }
if (events != 0 && !ignoreUnknown)
- return -1;
- return result;
-}
-
-class TWSAEventHolder {
-private:
- HANDLE Event;
-
-public:
+ return -1;
+ return result;
+}
+
+class TWSAEventHolder {
+private:
+ HANDLE Event;
+
+public:
inline TWSAEventHolder(HANDLE event) noexcept
: Event(event)
{
- }
-
+ }
+
inline ~TWSAEventHolder() {
- WSACloseEvent(Event);
- }
-
+ WSACloseEvent(Event);
+ }
+
inline HANDLE Get() noexcept {
- return Event;
- }
-};
-
+ return Event;
+ }
+};
+
int poll(struct pollfd fds[], nfds_t nfds, int timeout) noexcept {
- HANDLE rawEvent = WSACreateEvent();
- if (rawEvent == WSA_INVALID_EVENT) {
- errno = EIO;
- return -1;
- }
-
- TWSAEventHolder event(rawEvent);
-
+ HANDLE rawEvent = WSACreateEvent();
+ if (rawEvent == WSA_INVALID_EVENT) {
+ errno = EIO;
+ return -1;
+ }
+
+ TWSAEventHolder event(rawEvent);
+
int checked_sockets = 0;
- for (pollfd* fd = fds; fd < fds + nfds; ++fd) {
- int win_events = convert_events(fd->events, evpairs_to_win, nevpairs_to_win, false);
- if (win_events == -1) {
- errno = EINVAL;
- return -1;
- }
- fd->revents = 0;
- if (WSAEventSelect(fd->fd, event.Get(), win_events)) {
- int error = WSAGetLastError();
+ for (pollfd* fd = fds; fd < fds + nfds; ++fd) {
+ int win_events = convert_events(fd->events, evpairs_to_win, nevpairs_to_win, false);
+ if (win_events == -1) {
+ errno = EINVAL;
+ return -1;
+ }
+ fd->revents = 0;
+ if (WSAEventSelect(fd->fd, event.Get(), win_events)) {
+ int error = WSAGetLastError();
if (error == WSAEINVAL || error == WSAENOTSOCK) {
- fd->revents = POLLNVAL;
+ fd->revents = POLLNVAL;
++checked_sockets;
} else {
- errno = EIO;
- return -1;
- }
- }
+ errno = EIO;
+ return -1;
+ }
+ }
fd_set readfds;
fd_set writefds;
struct timeval timeout = {0, 0};
@@ -190,54 +190,54 @@ int poll(struct pollfd fds[], nfds_t nfds, int timeout) noexcept {
}
++checked_sockets;
}
- }
-
+ }
+
if (checked_sockets > 0) {
// returns without wait since we already have sockets in desired conditions
return checked_sockets;
}
- HANDLE events[] = {event.Get()};
- DWORD wait_result = WSAWaitForMultipleEvents(1, events, TRUE, timeout, FALSE);
- if (wait_result == WSA_WAIT_TIMEOUT)
- return 0;
+ HANDLE events[] = {event.Get()};
+ DWORD wait_result = WSAWaitForMultipleEvents(1, events, TRUE, timeout, FALSE);
+ if (wait_result == WSA_WAIT_TIMEOUT)
+ return 0;
else if (wait_result == WSA_WAIT_EVENT_0) {
- for (pollfd* fd = fds; fd < fds + nfds; ++fd) {
- if (fd->revents == POLLNVAL)
- continue;
- WSANETWORKEVENTS network_events;
- if (WSAEnumNetworkEvents(fd->fd, event.Get(), &network_events)) {
- errno = EIO;
- return -1;
- }
- fd->revents = 0;
- for (int i = 0; i < FD_MAX_EVENTS; ++i) {
+ for (pollfd* fd = fds; fd < fds + nfds; ++fd) {
+ if (fd->revents == POLLNVAL)
+ continue;
+ WSANETWORKEVENTS network_events;
+ if (WSAEnumNetworkEvents(fd->fd, event.Get(), &network_events)) {
+ errno = EIO;
+ return -1;
+ }
+ fd->revents = 0;
+ for (int i = 0; i < FD_MAX_EVENTS; ++i) {
if ((network_events.lNetworkEvents & (1 << i)) != 0 && network_events.iErrorCode[i]) {
- fd->revents = POLLERR;
- break;
- }
- }
- if (fd->revents == POLLERR)
- continue;
- if (network_events.lNetworkEvents) {
- fd->revents = static_cast<short>(convert_events(network_events.lNetworkEvents, evpairs_to_unix, nevpairs_to_unix, true));
- if (fd->revents & POLLHUP) {
- fd->revents &= POLLHUP | POLLIN | POLLRDNORM;
- }
- }
- }
- int chanded_sockets = 0;
- for (pollfd* fd = fds; fd < fds + nfds; ++fd)
- if (fd->revents != 0)
- ++chanded_sockets;
- return chanded_sockets;
- } else {
- errno = EIO;
- return -1;
- }
-}
+ fd->revents = POLLERR;
+ break;
+ }
+ }
+ if (fd->revents == POLLERR)
+ continue;
+ if (network_events.lNetworkEvents) {
+ fd->revents = static_cast<short>(convert_events(network_events.lNetworkEvents, evpairs_to_unix, nevpairs_to_unix, true));
+ if (fd->revents & POLLHUP) {
+ fd->revents &= POLLHUP | POLLIN | POLLRDNORM;
+ }
+ }
+ }
+ int chanded_sockets = 0;
+ for (pollfd* fd = fds; fd < fds + nfds; ++fd)
+ if (fd->revents != 0)
+ ++chanded_sockets;
+ return chanded_sockets;
+ } else {
+ errno = EIO;
+ return -1;
+ }
+}
#endif
-
+
#endif
bool GetRemoteAddr(SOCKET Socket, char* str, socklen_t size) {
diff --git a/util/network/socket.h b/util/network/socket.h
index 40c8648b40..76f46c542a 100644
--- a/util/network/socket.h
+++ b/util/network/socket.h
@@ -29,7 +29,7 @@ struct pollfd {
short events;
short revents;
};
-
+
#define POLLIN (1 << 0)
#define POLLRDNORM (1 << 1)
#define POLLRDBAND (1 << 2)
@@ -40,7 +40,7 @@ struct pollfd {
#define POLLERR (1 << 7)
#define POLLHUP (1 << 8)
#define POLLNVAL (1 << 9)
-
+
const char* inet_ntop(int af, const void* src, char* dst, socklen_t size);
int poll(struct pollfd fds[], nfds_t nfds, int timeout) noexcept;
#else
diff --git a/util/network/socket_ut.cpp b/util/network/socket_ut.cpp
index 6b20e11f70..f27a7a32dd 100644
--- a/util/network/socket_ut.cpp
+++ b/util/network/socket_ut.cpp
@@ -52,7 +52,7 @@ void TSockTest::TestSock() {
UNIT_ASSERT(!si.ReadLine().empty());
}
-
+
void TSockTest::TestTimeout() {
static const int timeout = 1000;
i64 startTime = millisec();
@@ -230,112 +230,112 @@ private:
SOCKET StartServerSocket(ui16 port, int backlog);
SOCKET StartClientSocket(ui32 ip, ui16 port);
SOCKET AcceptConnection(SOCKET serverSocket);
-};
-
+};
+
UNIT_TEST_SUITE_REGISTRATION(TPollTest);
-
-sockaddr_in TPollTest::GetAddress(ui32 ip, ui16 port) {
- struct sockaddr_in addr;
- memset(&addr, 0, sizeof(addr));
- addr.sin_family = AF_INET;
- addr.sin_port = htons(port);
- addr.sin_addr.s_addr = htonl(ip);
- return addr;
-}
-
-SOCKET TPollTest::CreateSocket() {
- SOCKET s = socket(AF_INET, SOCK_STREAM, 0);
+
+sockaddr_in TPollTest::GetAddress(ui32 ip, ui16 port) {
+ struct sockaddr_in addr;
+ memset(&addr, 0, sizeof(addr));
+ addr.sin_family = AF_INET;
+ addr.sin_port = htons(port);
+ addr.sin_addr.s_addr = htonl(ip);
+ return addr;
+}
+
+SOCKET TPollTest::CreateSocket() {
+ SOCKET s = socket(AF_INET, SOCK_STREAM, 0);
if (s == INVALID_SOCKET) {
ythrow yexception() << "Can not create socket (" << LastSystemErrorText() << ")";
}
- return s;
-}
-
-SOCKET TPollTest::StartServerSocket(ui16 port, int backlog) {
- TSocketHolder s(CreateSocket());
- sockaddr_in addr = GetAddress(ntohl(INADDR_ANY), port);
+ return s;
+}
+
+SOCKET TPollTest::StartServerSocket(ui16 port, int backlog) {
+ TSocketHolder s(CreateSocket());
+ sockaddr_in addr = GetAddress(ntohl(INADDR_ANY), port);
if (bind(s, (sockaddr*)&addr, sizeof(addr)) == SOCKET_ERROR) {
ythrow yexception() << "Can not bind server socket (" << LastSystemErrorText() << ")";
}
if (listen(s, backlog) == SOCKET_ERROR) {
ythrow yexception() << "Can not listen on server socket (" << LastSystemErrorText() << ")";
}
- return s.Release();
-}
-
-SOCKET TPollTest::StartClientSocket(ui32 ip, ui16 port) {
- TSocketHolder s(CreateSocket());
- sockaddr_in addr = GetAddress(ip, port);
+ return s.Release();
+}
+
+SOCKET TPollTest::StartClientSocket(ui32 ip, ui16 port) {
+ TSocketHolder s(CreateSocket());
+ sockaddr_in addr = GetAddress(ip, port);
if (connect(s, (sockaddr*)&addr, sizeof(addr)) == SOCKET_ERROR) {
ythrow yexception() << "Can not connect client socket (" << LastSystemErrorText() << ")";
}
- return s.Release();
-}
-
-SOCKET TPollTest::AcceptConnection(SOCKET serverSocket) {
+ return s.Release();
+}
+
+SOCKET TPollTest::AcceptConnection(SOCKET serverSocket) {
SOCKET connectedSocket = accept(serverSocket, nullptr, nullptr);
if (connectedSocket == INVALID_SOCKET) {
ythrow yexception() << "Can not accept connection on server socket (" << LastSystemErrorText() << ")";
}
- return connectedSocket;
-}
-
-void TPollTest::TestPollInOut() {
-#ifdef _win_
- const size_t socketCount = 1000;
-
- ui16 port = static_cast<ui16>(1300 + rand() % 97);
- TSocketHolder serverSocket = StartServerSocket(port, socketCount);
-
- ui32 localIp = ntohl(inet_addr("127.0.0.1"));
-
+ return connectedSocket;
+}
+
+void TPollTest::TestPollInOut() {
+#ifdef _win_
+ const size_t socketCount = 1000;
+
+ ui16 port = static_cast<ui16>(1300 + rand() % 97);
+ TSocketHolder serverSocket = StartServerSocket(port, socketCount);
+
+ ui32 localIp = ntohl(inet_addr("127.0.0.1"));
+
TVector<TSimpleSharedPtr<TSocketHolder>> clientSockets;
TVector<TSimpleSharedPtr<TSocketHolder>> connectedSockets;
TVector<pollfd> fds;
-
- for (size_t i = 0; i < socketCount; ++i) {
+
+ for (size_t i = 0; i < socketCount; ++i) {
TSimpleSharedPtr<TSocketHolder> clientSocket(new TSocketHolder(StartClientSocket(localIp, port)));
- clientSockets.push_back(clientSocket);
-
- if (i % 5 == 0 || i % 5 == 2) {
- char buffer = 'c';
- if (send(*clientSocket, &buffer, 1, 0) == -1)
+ clientSockets.push_back(clientSocket);
+
+ if (i % 5 == 0 || i % 5 == 2) {
+ char buffer = 'c';
+ if (send(*clientSocket, &buffer, 1, 0) == -1)
ythrow yexception() << "Can not send (" << LastSystemErrorText() << ")";
- }
-
+ }
+
TSimpleSharedPtr<TSocketHolder> connectedSocket(new TSocketHolder(AcceptConnection(serverSocket)));
- connectedSockets.push_back(connectedSocket);
-
- if (i % 5 == 2 || i % 5 == 3) {
- closesocket(*clientSocket);
- shutdown(*clientSocket, SD_BOTH);
- }
- }
-
+ connectedSockets.push_back(connectedSocket);
+
+ if (i % 5 == 2 || i % 5 == 3) {
+ closesocket(*clientSocket);
+ shutdown(*clientSocket, SD_BOTH);
+ }
+ }
+
int expectedCount = 0;
for (size_t i = 0; i < connectedSockets.size(); ++i) {
- pollfd fd = {(i % 5 == 4) ? INVALID_SOCKET : static_cast<SOCKET>(*connectedSockets[i]), POLLIN | POLLOUT, 0};
- fds.push_back(fd);
+ pollfd fd = {(i % 5 == 4) ? INVALID_SOCKET : static_cast<SOCKET>(*connectedSockets[i]), POLLIN | POLLOUT, 0};
+ fds.push_back(fd);
if (i % 5 != 4)
++expectedCount;
- }
-
- int polledCount = poll(&fds[0], fds.size(), INFTIM);
+ }
+
+ int polledCount = poll(&fds[0], fds.size(), INFTIM);
UNIT_ASSERT_EQUAL(expectedCount, polledCount);
-
- for (size_t i = 0; i < connectedSockets.size(); ++i) {
+
+ for (size_t i = 0; i < connectedSockets.size(); ++i) {
short revents = fds[i].revents;
- if (i % 5 == 0) {
+ if (i % 5 == 0) {
UNIT_ASSERT_EQUAL(static_cast<short>(POLLRDNORM | POLLWRNORM), revents);
- } else if (i % 5 == 1) {
+ } else if (i % 5 == 1) {
UNIT_ASSERT_EQUAL(static_cast<short>(POLLOUT | POLLWRNORM), revents);
- } else if (i % 5 == 2) {
+ } else if (i % 5 == 2) {
UNIT_ASSERT_EQUAL(static_cast<short>(POLLHUP | POLLRDNORM | POLLWRNORM), revents);
- } else if (i % 5 == 3) {
+ } else if (i % 5 == 3) {
UNIT_ASSERT_EQUAL(static_cast<short>(POLLHUP | POLLWRNORM), revents);
- } else if (i % 5 == 4) {
+ } else if (i % 5 == 4) {
UNIT_ASSERT_EQUAL(static_cast<short>(POLLNVAL), revents);
- }
- }
-#endif
+ }
+ }
+#endif
}
diff --git a/util/stream/zlib.cpp b/util/stream/zlib.cpp
index 60f4e9439f..196d155b99 100644
--- a/util/stream/zlib.cpp
+++ b/util/stream/zlib.cpp
@@ -188,15 +188,15 @@ namespace {
}
class TZLibCompress::TImpl: public TAdditionalStorage<TImpl>, private TZLibCommon {
- static inline ZLib::StreamType Type(ZLib::StreamType type) {
+ static inline ZLib::StreamType Type(ZLib::StreamType type) {
if (type == ZLib::Auto) {
return ZLib::ZLib;
}
- if (type >= ZLib::Invalid) {
- ythrow TZLibError() << "invalid compression type: " << static_cast<unsigned long>(type);
- }
-
+ if (type >= ZLib::Invalid) {
+ ythrow TZLibError() << "invalid compression type: " << static_cast<unsigned long>(type);
+ }
+
return type;
}
diff --git a/util/stream/zlib.h b/util/stream/zlib.h
index e7de7c81b7..2d55bd4999 100644
--- a/util/stream/zlib.h
+++ b/util/stream/zlib.h
@@ -28,8 +28,8 @@ namespace ZLib {
Auto = 0, /**< Auto detect format. Can be used for decompression only. */
ZLib = 1,
GZip = 2,
- Raw = 3,
- Invalid = 4
+ Raw = 3,
+ Invalid = 4
};
enum {
diff --git a/util/string/cast.cpp b/util/string/cast.cpp
index aa1e65a8e9..2823ad0e58 100644
--- a/util/string/cast.cpp
+++ b/util/string/cast.cpp
@@ -516,11 +516,11 @@ bool FromStringImpl<bool>(const char* data, size_t len) {
return result;
}
-template <>
+template <>
TString FromStringImpl<TString>(const char* data, size_t len) {
return TString(data, len);
-}
-
+}
+
template <>
TStringBuf FromStringImpl<TStringBuf>(const char* data, size_t len) {
return TStringBuf(data, len);
diff --git a/util/system/compat.cpp b/util/system/compat.cpp
index 18fbfa296a..f1ea393ea7 100644
--- a/util/system/compat.cpp
+++ b/util/system/compat.cpp
@@ -23,15 +23,15 @@ const char* getprogname() {
#endif
#ifdef _win_
-
-void sleep(i64 len) {
- Sleep((unsigned long)len * 1000);
-}
-
-void usleep(i64 len) {
- Sleep((unsigned long)len / 1000);
-}
-
+
+void sleep(i64 len) {
+ Sleep((unsigned long)len * 1000);
+}
+
+void usleep(i64 len) {
+ Sleep((unsigned long)len / 1000);
+}
+
#include <fcntl.h>
int ftruncate(int fd, i64 length) {
return _chsize_s(fd, length);
diff --git a/util/system/compat.h b/util/system/compat.h
index c53dbcca17..ef91de58ae 100644
--- a/util/system/compat.h
+++ b/util/system/compat.h
@@ -62,14 +62,14 @@ extern "C" {
#endif
#ifdef _win_
-
+
#ifdef sleep // may be defined by perl
#undef sleep
#endif
-
-void sleep(i64 len);
-void usleep(i64 len);
-
+
+void sleep(i64 len);
+void usleep(i64 len);
+
#endif
#ifdef _win_
diff --git a/util/system/compiler.h b/util/system/compiler.h
index b373edcc46..f473deab05 100644
--- a/util/system/compiler.h
+++ b/util/system/compiler.h
@@ -307,26 +307,26 @@ _YandexAbort();
#if defined(_MSC_VER)
#define __PRETTY_FUNCTION__ __FUNCSIG__
#endif
-
-#if defined(__GNUC__)
+
+#if defined(__GNUC__)
#define Y_WEAK __attribute__((weak))
-#else
+#else
#define Y_WEAK
-#endif
+#endif
-#if defined(__CUDACC_VER_MAJOR__)
+#if defined(__CUDACC_VER_MAJOR__)
#define Y_CUDA_AT_LEAST(x, y) (__CUDACC_VER_MAJOR__ > x || (__CUDACC_VER_MAJOR__ == x && __CUDACC_VER_MINOR__ >= y))
-#else
+#else
#define Y_CUDA_AT_LEAST(x, y) 0
#endif
-// NVidia CUDA C++ Compiler did not know about noexcept keyword until version 9.0
-#if !Y_CUDA_AT_LEAST(9, 0)
+// NVidia CUDA C++ Compiler did not know about noexcept keyword until version 9.0
+#if !Y_CUDA_AT_LEAST(9, 0)
#if defined(__CUDACC__) && !defined(noexcept)
#define noexcept throw()
#endif
-#endif
-
+#endif
+
#if defined(__GNUC__)
#define Y_COLD __attribute__((cold))
#define Y_LEAF __attribute__((leaf))
diff --git a/util/system/context.h b/util/system/context.h
index d2a349bfc5..8bb2adaa32 100644
--- a/util/system/context.h
+++ b/util/system/context.h
@@ -11,7 +11,7 @@
#define STACK_ALIGN (8 * PLATFORM_DATA_ALIGN)
-#if defined(_x86_64_) || defined(_i386_) || defined(_arm_) || defined(_ppc64_)
+#if defined(_x86_64_) || defined(_i386_) || defined(_arm_) || defined(_ppc64_)
#define STACK_GROW_DOWN 1
#else
#error todo
@@ -26,7 +26,7 @@
#define USE_UCONTEXT_CONT
#elif defined(_win_)
#define USE_FIBER_CONT
-#elif (defined(_i386_) || defined(_x86_64_) || defined(_arm64_)) && !defined(_k1om_)
+#elif (defined(_i386_) || defined(_x86_64_) || defined(_arm64_)) && !defined(_k1om_)
#define USE_JUMP_CONT
#else
#define USE_UCONTEXT_CONT
diff --git a/util/system/defaults.h b/util/system/defaults.h
index dcd7abea38..e889b71fce 100644
--- a/util/system/defaults.h
+++ b/util/system/defaults.h
@@ -19,16 +19,16 @@
#include <sys/param.h>
#endif
-#if defined(BSD) || defined(_android_)
-
+#if defined(BSD) || defined(_android_)
+
#if defined(BSD)
#include <machine/endian.h>
#endif
-
+
#if defined(_android_)
#include <endian.h>
#endif
-
+
#if (BYTE_ORDER == LITTLE_ENDIAN)
#define _little_endian_
#elif (BYTE_ORDER == BIG_ENDIAN)
@@ -36,7 +36,7 @@
#else
#error unknown endian not supported
#endif
-
+
#elif (defined(_sun_) && !defined(__i386__)) || defined(_hpux_) || defined(WHATEVER_THAT_HAS_BIG_ENDIAN)
#define _big_endian_
#else
diff --git a/util/system/file_ut.cpp b/util/system/file_ut.cpp
index 941e6a50f3..df987972b7 100644
--- a/util/system/file_ut.cpp
+++ b/util/system/file_ut.cpp
@@ -194,8 +194,8 @@ void TFileTest::TestRW() {
UNIT_ASSERT(!f1.IsOpen());
UNIT_ASSERT(!f2.IsOpen());
UNIT_ASSERT(unlink("f1.txt") == 0);
-}
-
+}
+
#ifdef _unix_
#include <locale.h>
#endif
diff --git a/util/system/filemap.h b/util/system/filemap.h
index 11be64bff4..e28a37da4c 100644
--- a/util/system/filemap.h
+++ b/util/system/filemap.h
@@ -265,11 +265,11 @@ public:
}
const T* Begin() const noexcept {
return Ptr_;
- }
+ }
/// for STL compatibility only, End() usage is recommended
const T* end() const noexcept {
return End_;
- }
+ }
const T* End() const noexcept {
return End_;
}
@@ -367,11 +367,11 @@ public:
return ((T*)Ptr())[pos];
}
T* begin() {
- return (T*)Ptr();
- }
+ return (T*)Ptr();
+ }
T* end() {
- return (T*)((char*)Ptr() + MappedSize());
- }
+ return (T*)((char*)Ptr() + MappedSize());
+ }
size_t size() const {
return MappedSize() / sizeof(T);
}
diff --git a/util/system/mktemp.cpp b/util/system/mktemp.cpp
index 505b7b4a4b..ab993d5f43 100644
--- a/util/system/mktemp.cpp
+++ b/util/system/mktemp.cpp
@@ -1,7 +1,7 @@
#include "tempfile.h"
-#include <util/folder/dirut.h>
-#include <util/generic/yexception.h>
+#include <util/folder/dirut.h>
+#include <util/generic/yexception.h>
#include <util/stream/file.h>
#include <cerrno>
@@ -21,11 +21,11 @@ TString MakeTempName(const char* wrkDir, const char* prefix, const char* extensi
#ifndef _win32_
TString filePath;
- if (wrkDir && *wrkDir) {
+ if (wrkDir && *wrkDir) {
filePath += wrkDir;
- } else {
+ } else {
filePath += GetSystemTempDir();
- }
+ }
if (filePath.back() != '/') {
filePath += '/';
diff --git a/util/system/platform.h b/util/system/platform.h
index 58f310ab34..26010d8569 100644
--- a/util/system/platform.h
+++ b/util/system/platform.h
@@ -69,7 +69,7 @@
#define _win_
#endif
-#if defined(__arm__) || defined(__ARM__) || defined(__ARM_NEON) || defined(__aarch64__) || defined(_M_ARM)
+#if defined(__arm__) || defined(__ARM__) || defined(__ARM_NEON) || defined(__aarch64__) || defined(_M_ARM)
#if defined(__arm64) || defined(__arm64__) || defined(__aarch64__)
#define _arm64_
#else
@@ -99,15 +99,15 @@
#define _ia64_
#endif
-#if defined(__powerpc__)
+#if defined(__powerpc__)
#define _ppc_
-#endif
-
-#if defined(__powerpc64__)
+#endif
+
+#if defined(__powerpc64__)
#define _ppc64_
-#endif
-
-#if !defined(sparc) && !defined(__sparc) && !defined(__hpux__) && !defined(__alpha__) && !defined(_ia64_) && !defined(_x86_64_) && !defined(_arm_) && !defined(_i386_) && !defined(_ppc_) && !defined(_ppc64_)
+#endif
+
+#if !defined(sparc) && !defined(__sparc) && !defined(__hpux__) && !defined(__alpha__) && !defined(_ia64_) && !defined(_x86_64_) && !defined(_arm_) && !defined(_i386_) && !defined(_ppc_) && !defined(_ppc64_)
#error "platform not defined, please, define one"
#endif
@@ -115,11 +115,11 @@
#define _x86_
#endif
-#if defined(__MIC__)
+#if defined(__MIC__)
#define _mic_
#define _k1om_
-#endif
-
+#endif
+
// stdio or MessageBox
#if defined(__CONSOLE__) || defined(_CONSOLE)
#define _console_
@@ -183,7 +183,7 @@
#endif
// 16, 32 or 64
-#if defined(__sparc_v9__) || defined(_x86_64_) || defined(_ia64_) || defined(_arm64_) || defined(_ppc64_)
+#if defined(__sparc_v9__) || defined(_x86_64_) || defined(_ia64_) || defined(_arm64_) || defined(_ppc64_)
#define _64_
#else
#define _32_
@@ -214,11 +214,11 @@
#endif
#define SIZEOF_CHAR 1
-#define SIZEOF_UNSIGNED_CHAR 1
+#define SIZEOF_UNSIGNED_CHAR 1
#define SIZEOF_SHORT 2
-#define SIZEOF_UNSIGNED_SHORT 2
+#define SIZEOF_UNSIGNED_SHORT 2
#define SIZEOF_INT 4
-#define SIZEOF_UNSIGNED_INT 4
+#define SIZEOF_UNSIGNED_INT 4
#if defined(_32_)
#define SIZEOF_LONG 4
@@ -238,7 +238,7 @@
#endif
#define SIZEOF_LONG_LONG 8
-#define SIZEOF_UNSIGNED_LONG_LONG 8
+#define SIZEOF_UNSIGNED_LONG_LONG 8
#undef SIZEOF_SIZE_T // in case we include <Python.h> which defines it, too
#define SIZEOF_SIZE_T SIZEOF_PTR
diff --git a/util/system/sanitizers.cpp b/util/system/sanitizers.cpp
index bb799a9e2e..744ec6ce87 100644
--- a/util/system/sanitizers.cpp
+++ b/util/system/sanitizers.cpp
@@ -114,15 +114,15 @@ void TFiberContext::BeforeSwitch(TFiberContext* old) noexcept {
void TFiberContext::AfterSwitch() noexcept {
#if defined(_asan_enabled_)
- __sanitizer_finish_switch_fiber(Token_, nullptr, nullptr);
-#endif
-}
-
-void TFiberContext::AfterStart() noexcept {
-#if defined(_asan_enabled_)
- __sanitizer_finish_switch_fiber(nullptr, nullptr, nullptr);
+ __sanitizer_finish_switch_fiber(Token_, nullptr, nullptr);
#endif
}
+
+void TFiberContext::AfterStart() noexcept {
+#if defined(_asan_enabled_)
+ __sanitizer_finish_switch_fiber(nullptr, nullptr, nullptr);
+#endif
+}
#if defined(_tsan_enabled_)
extern "C" {
diff --git a/util/system/sanitizers.h b/util/system/sanitizers.h
index 965e5c751e..94f7fff6ee 100644
--- a/util/system/sanitizers.h
+++ b/util/system/sanitizers.h
@@ -28,8 +28,8 @@ namespace NSan {
void BeforeSwitch(TFiberContext* old) noexcept;
void AfterSwitch() noexcept;
- static void AfterStart() noexcept;
-
+ static void AfterStart() noexcept;
+
private:
void* Token_;
const void* Stack_;
diff --git a/util/system/shmat.cpp b/util/system/shmat.cpp
index 07ff0d6caa..65fbf3a6da 100644
--- a/util/system/shmat.cpp
+++ b/util/system/shmat.cpp
@@ -61,30 +61,30 @@ namespace {
static int shmdt(const void* addr) {
return syscall(__NR_shmdt, addr);
}
-
+
#else
#define IPCOP_shmat 21
#define IPCOP_shmdt 22
#define IPCOP_shmget 23
#define IPCOP_shmctl 24
-
- static int shmget(key_t key, size_t size, int flag) {
- return syscall(__NR_ipc, IPCOP_shmget, key, size, flag, 0);
- }
-
- static void* shmat(int id, const void* addr, int flag) {
- void* retval;
- long res = syscall(__NR_ipc, IPCOP_shmat, id, flag, (long)&retval, addr);
+
+ static int shmget(key_t key, size_t size, int flag) {
+ return syscall(__NR_ipc, IPCOP_shmget, key, size, flag, 0);
+ }
+
+ static void* shmat(int id, const void* addr, int flag) {
+ void* retval;
+ long res = syscall(__NR_ipc, IPCOP_shmat, id, flag, (long)&retval, addr);
return (res >= 0) ? retval : (void*)-1;
- }
-
- static int shmctl(int id, int cmd, void* buf) {
- return syscall(__NR_ipc, IPCOP_shmctl, id, cmd | IPC_64, 0, buf);
- }
-
- static int shmdt(const void* addr) {
- return syscall(__NR_ipc, IPCOP_shmdt, 0, 0, 0, addr);
- }
+ }
+
+ static int shmctl(int id, int cmd, void* buf) {
+ return syscall(__NR_ipc, IPCOP_shmctl, id, cmd | IPC_64, 0, buf);
+ }
+
+ static int shmdt(const void* addr) {
+ return syscall(__NR_ipc, IPCOP_shmdt, 0, 0, 0, addr);
+ }
#endif
}
#endif
diff --git a/util/system/thread.cpp b/util/system/thread.cpp
index 6236746c2d..f10d79113f 100644
--- a/util/system/thread.cpp
+++ b/util/system/thread.cpp
@@ -530,27 +530,27 @@ TCurrentThreadLimits::TCurrentThreadLimits() noexcept
StackBegin = pthread_get_stackaddr_np(pthread_self());
StackLength = pthread_get_stacksize_np(pthread_self());
#elif defined(_MSC_VER)
-
+
#if _WIN32_WINNT >= _WIN32_WINNT_WIN8
ULONG_PTR b = 0;
ULONG_PTR e = 0;
- GetCurrentThreadStackLimits(&b, &e);
+ GetCurrentThreadStackLimits(&b, &e);
StackBegin = (const void*)b;
StackLength = e - b;
-
+
#else
- // Copied from https://github.com/llvm-mirror/compiler-rt/blob/release_40/lib/sanitizer_common/sanitizer_win.cc#L91
- void* place_on_stack = alloca(16);
- MEMORY_BASIC_INFORMATION memory_info;
- Y_VERIFY(VirtualQuery(place_on_stack, &memory_info, sizeof(memory_info)));
-
- StackBegin = memory_info.AllocationBase;
- StackLength = static_cast<const char*>(memory_info.BaseAddress) + memory_info.RegionSize - static_cast<const char*>(StackBegin);
-
+ // Copied from https://github.com/llvm-mirror/compiler-rt/blob/release_40/lib/sanitizer_common/sanitizer_win.cc#L91
+ void* place_on_stack = alloca(16);
+ MEMORY_BASIC_INFORMATION memory_info;
+ Y_VERIFY(VirtualQuery(place_on_stack, &memory_info, sizeof(memory_info)));
+
+ StackBegin = memory_info.AllocationBase;
+ StackLength = static_cast<const char*>(memory_info.BaseAddress) + memory_info.RegionSize - static_cast<const char*>(StackBegin);
+
#endif
-
+
#else
#error port me
#endif
diff --git a/util/system/tls.h b/util/system/tls.h
index 3c4f56dbeb..542cdf31e8 100644
--- a/util/system/tls.h
+++ b/util/system/tls.h
@@ -15,10 +15,10 @@
#define Y_DISABLE_THRKEY_OPTIMIZATION
#endif
-#if defined(__GNUC__) && defined(__ANDROID__) && defined(__i686__) // https://st.yandex-team.ru/DEVTOOLS-3352
+#if defined(__GNUC__) && defined(__ANDROID__) && defined(__i686__) // https://st.yandex-team.ru/DEVTOOLS-3352
#define Y_DISABLE_THRKEY_OPTIMIZATION
-#endif
-
+#endif
+
/**
@def Y_THREAD(TType)
diff --git a/util/system/winint.h b/util/system/winint.h
index ebeaefb3d2..b9be6d0bdf 100644
--- a/util/system/winint.h
+++ b/util/system/winint.h
@@ -7,11 +7,11 @@
#ifndef WIN32_LEAN_AND_MEAN
#define WIN32_LEAN_AND_MEAN
#endif
-
+
#ifndef NOMINMAX
#define NOMINMAX
#endif
-
+
#include <windows.h>
#undef GetFreeSpace
diff --git a/util/system/yassert.h b/util/system/yassert.h
index 529823440c..bdd0f7b150 100644
--- a/util/system/yassert.h
+++ b/util/system/yassert.h
@@ -22,10 +22,10 @@
#include <cassert>
#endif
-#if !defined(_MSC_VER)
- #if defined(__has_builtin) && __has_builtin(__debugbreak)
+#if !defined(_MSC_VER)
+ #if defined(__has_builtin) && __has_builtin(__debugbreak)
// Do nothing, use __debugbreak builtin
- #else
+ #else
inline void __debugbreak() {
#if defined(__x86_64__) || defined(__i386__)
__asm__ volatile("int $3\n");
@@ -33,27 +33,27 @@ inline void __debugbreak() {
assert(0);
#endif
}
- #endif
-
+ #endif
+
inline bool YaIsDebuggerPresent() {
return false;
}
#else
// __debugbreak is intrinsic in MSVC
-
+
extern "C" {
__declspec(dllimport) int __stdcall IsDebuggerPresent();
}
-
+
inline bool YaIsDebuggerPresent() {
return IsDebuggerPresent() != 0;
}
-#endif
-
-inline void YaDebugBreak() {
- __debugbreak();
+#endif
+
+inline void YaDebugBreak() {
+ __debugbreak();
}
-
+
#undef Y_ASSERT
#if !defined(NDEBUG) && !defined(__GCCXML__)