summaryrefslogtreecommitdiffstats
path: root/library/cpp/yt/system
diff options
context:
space:
mode:
authorbabenko <[email protected]>2026-06-15 11:13:32 +0300
committerbabenko <[email protected]>2026-06-15 11:32:51 +0300
commit12be02b42fc24cf7bd990d56da8cf8908a35db2d (patch)
tree801270254f6351c6fe2b30e81f19df5cd4a1578e /library/cpp/yt/system
parent03c4def7658a9ce2bcf05bd4e9feee83d89d3fe6 (diff)
Make library/cpp/yt/rseq a Linux-only dependency of library/cpp/yt/system
Make library/cpp/yt/rseq a Linux-only dependency of library/cpp/yt/system commit_hash:7d6f5e738658447529440425b55b2891f6664d81
Diffstat (limited to 'library/cpp/yt/system')
-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
3 files changed, 16 insertions, 16 deletions
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(