summaryrefslogtreecommitdiffstats
path: root/library/cpp
diff options
context:
space:
mode:
Diffstat (limited to 'library/cpp')
-rw-r--r--library/cpp/yt/rseq/ya.make4
-rw-r--r--library/cpp/yt/system/cpu_id-inl.h2
-rw-r--r--library/cpp/yt/system/cpu_id.cpp23
-rw-r--r--library/cpp/yt/system/ya.make7
4 files changed, 20 insertions, 16 deletions
diff --git a/library/cpp/yt/rseq/ya.make b/library/cpp/yt/rseq/ya.make
index cb233c52fbb..f0f55e17f49 100644
--- a/library/cpp/yt/rseq/ya.make
+++ b/library/cpp/yt/rseq/ya.make
@@ -2,6 +2,10 @@ LIBRARY()
INCLUDE(${ARCADIA_ROOT}/library/cpp/yt/ya_cpp.make.inc)
+IF (NOT OS_LINUX)
+ MESSAGE(FATAL_ERROR "library/cpp/yt/rseq is Linux-only")
+ENDIF()
+
SRCS(
rseq.cpp
)
diff --git a/library/cpp/yt/system/cpu_id-inl.h b/library/cpp/yt/system/cpu_id-inl.h
index af3ed0d7ab4..e336ba5a2ce 100644
--- a/library/cpp/yt/system/cpu_id-inl.h
+++ b/library/cpp/yt/system/cpu_id-inl.h
@@ -5,7 +5,9 @@
#endif
#undef CPU_ID_INL_H_
+#ifdef __linux__
#include <library/cpp/yt/rseq/rseq.h>
+#endif
#include <util/system/compiler.h>
diff --git a/library/cpp/yt/system/cpu_id.cpp b/library/cpp/yt/system/cpu_id.cpp
index d4cccc21ee1..9f6e46c9fc9 100644
--- a/library/cpp/yt/system/cpu_id.cpp
+++ b/library/cpp/yt/system/cpu_id.cpp
@@ -1,10 +1,10 @@
#include "cpu_id.h"
-#include <library/cpp/yt/rseq/rseq.h>
-
#include <library/cpp/yt/misc/tls.h>
-#if defined(__linux__)
+#ifdef __linux__
+#include <library/cpp/yt/rseq/rseq.h>
+
#include <sched.h>
#endif
@@ -12,33 +12,26 @@ namespace NYT::NDetail {
////////////////////////////////////////////////////////////////////////////////
-#ifdef YT_RSEQ_AVAILABLE
+#ifdef __linux__
YT_PREVENT_TLS_CACHING int GetCurrentCpuIdSlow()
{
+#ifdef YT_RSEQ_AVAILABLE
if (NRseq::EnsureCurrentThreadRegistered()) {
auto cpuId = NRseq::ReadField<int>(NRseq::CpuIdFieldOffset);
if (cpuId >= 0) {
return cpuId;
}
}
-
- auto cpuId = ::sched_getcpu();
- return cpuId >= 0 ? cpuId : 0;
-}
-
-#elif defined(__linux__)
-
-// Linux without a known fast path (e.g. an unsupported arch): use sched_getcpu.
-int GetCurrentCpuIdSlow()
-{
+#endif
+ // No rseq fast path (unsupported arch, or thread not registered): sched_getcpu.
auto cpuId = ::sched_getcpu();
return cpuId >= 0 ? cpuId : 0;
}
#else
-// No rseq and no sched_getcpu (darwin / windows): sharding degenerates to one shard.
+// No sched_getcpu (darwin / windows): sharding degenerates to one shard.
int GetCurrentCpuIdSlow()
{
return 0;
diff --git a/library/cpp/yt/system/ya.make b/library/cpp/yt/system/ya.make
index 772cbaba788..aca2f0dcdf6 100644
--- a/library/cpp/yt/system/ya.make
+++ b/library/cpp/yt/system/ya.make
@@ -15,9 +15,14 @@ PEERDIR(
library/cpp/yt/cpu_clock
library/cpp/yt/exception
library/cpp/yt/misc
- library/cpp/yt/rseq
)
+IF (OS_LINUX)
+ PEERDIR(
+ library/cpp/yt/rseq
+ )
+ENDIF()
+
END()
RECURSE(