diff options
author | heretic <heretic@yandex-team.ru> | 2022-02-10 16:45:43 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:45:43 +0300 |
commit | 397cbe258b9e064f49c4ca575279f02f39fef76e (patch) | |
tree | a0b0eb3cca6a14e4e8ea715393637672fa651284 /contrib/restricted/abseil-cpp-tstring/y_absl/base/internal/sysinfo.cc | |
parent | 43f5a35593ebc9f6bcea619bb170394ea7ae468e (diff) | |
download | ydb-397cbe258b9e064f49c4ca575279f02f39fef76e.tar.gz |
Restoring authorship annotation for <heretic@yandex-team.ru>. Commit 1 of 2.
Diffstat (limited to 'contrib/restricted/abseil-cpp-tstring/y_absl/base/internal/sysinfo.cc')
-rw-r--r-- | contrib/restricted/abseil-cpp-tstring/y_absl/base/internal/sysinfo.cc | 56 |
1 files changed, 28 insertions, 28 deletions
diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/base/internal/sysinfo.cc b/contrib/restricted/abseil-cpp-tstring/y_absl/base/internal/sysinfo.cc index 9eb0cf3f8c..ab4bcee26c 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/base/internal/sysinfo.cc +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/base/internal/sysinfo.cc @@ -39,7 +39,7 @@ #endif #include <string.h> - + #include <cassert> #include <cstdint> #include <cstdio> @@ -51,11 +51,11 @@ #include <vector> #include "y_absl/base/call_once.h" -#include "y_absl/base/config.h" +#include "y_absl/base/config.h" #include "y_absl/base/internal/raw_logging.h" #include "y_absl/base/internal/spinlock.h" #include "y_absl/base/internal/unscaledcycleclock.h" -#include "y_absl/base/thread_annotations.h" +#include "y_absl/base/thread_annotations.h" namespace y_absl { ABSL_NAMESPACE_BEGIN @@ -144,12 +144,12 @@ static int GetNumCPUs() { #if defined(_WIN32) static double GetNominalCPUFrequency() { -#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP) && \ - !WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) - // UWP apps don't have access to the registry and currently don't provide an - // API informing about CPU nominal frequency. - return 1.0; -#else +#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP) && \ + !WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) + // UWP apps don't have access to the registry and currently don't provide an + // API informing about CPU nominal frequency. + return 1.0; +#else #pragma comment(lib, "advapi32.lib") // For Reg* functions. HKEY key; // Use the Reg* functions rather than the SH functions because shlwapi.dll @@ -169,7 +169,7 @@ static double GetNominalCPUFrequency() { } } return 1.0; -#endif // WINAPI_PARTITION_APP && !WINAPI_PARTITION_DESKTOP +#endif // WINAPI_PARTITION_APP && !WINAPI_PARTITION_DESKTOP } #elif defined(CTL_HW) && defined(HW_CPU_FREQ) @@ -415,16 +415,16 @@ pid_t GetTID() { #else // Fallback implementation of GetTID using pthread_getspecific. -ABSL_CONST_INIT static once_flag tid_once; -ABSL_CONST_INIT static pthread_key_t tid_key; -ABSL_CONST_INIT static y_absl::base_internal::SpinLock tid_lock( - y_absl::kConstInit, base_internal::SCHEDULE_KERNEL_ONLY); +ABSL_CONST_INIT static once_flag tid_once; +ABSL_CONST_INIT static pthread_key_t tid_key; +ABSL_CONST_INIT static y_absl::base_internal::SpinLock tid_lock( + y_absl::kConstInit, base_internal::SCHEDULE_KERNEL_ONLY); // We set a bit per thread in this array to indicate that an ID is in // use. ID 0 is unused because it is the default value returned by // pthread_getspecific(). -ABSL_CONST_INIT static std::vector<uint32_t> *tid_array - ABSL_GUARDED_BY(tid_lock) = nullptr; +ABSL_CONST_INIT static std::vector<uint32_t> *tid_array + ABSL_GUARDED_BY(tid_lock) = nullptr; static constexpr int kBitsPerWord = 32; // tid_array is uint32_t. // Returns the TID to tid_array. @@ -491,18 +491,18 @@ pid_t GetTID() { #endif -// GetCachedTID() caches the thread ID in thread-local storage (which is a -// userspace construct) to avoid unnecessary system calls. Without this caching, -// it can take roughly 98ns, while it takes roughly 1ns with this caching. -pid_t GetCachedTID() { -#ifdef ABSL_HAVE_THREAD_LOCAL - static thread_local pid_t thread_id = GetTID(); - return thread_id; -#else - return GetTID(); -#endif // ABSL_HAVE_THREAD_LOCAL -} - +// GetCachedTID() caches the thread ID in thread-local storage (which is a +// userspace construct) to avoid unnecessary system calls. Without this caching, +// it can take roughly 98ns, while it takes roughly 1ns with this caching. +pid_t GetCachedTID() { +#ifdef ABSL_HAVE_THREAD_LOCAL + static thread_local pid_t thread_id = GetTID(); + return thread_id; +#else + return GetTID(); +#endif // ABSL_HAVE_THREAD_LOCAL +} + } // namespace base_internal ABSL_NAMESPACE_END } // namespace y_absl |