Skip to content

Commit 08b3922

Browse files
committed
Fix: Require inline Asm for HW-specific YIELDs
1 parent b19dc4c commit 08b3922

File tree

1 file changed

+9
-15
lines changed

1 file changed

+9
-15
lines changed

include/fork_union.hpp

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1519,6 +1519,7 @@ inline capabilities_t cpu_capabilities() noexcept {
15191519
// Check for basic PAUSE instruction support (always available on x86-64)
15201520
caps = static_cast<capabilities_t>(caps | capability_x86_pause_k);
15211521

1522+
#if defined(__GNUC__) || defined(__clang__) // We use inline assembly - unavailable in MSVC
15221523
// CPUID to check for WAITPKG support (TPAUSE instruction)
15231524
std::uint32_t eax, ebx, ecx, edx;
15241525

@@ -1528,6 +1529,7 @@ inline capabilities_t cpu_capabilities() noexcept {
15281529

15291530
// WAITPKG is bit 5 in ECX
15301531
if (ecx & (1u << 5)) caps = static_cast<capabilities_t>(caps | capability_x86_tpause_k);
1532+
#endif
15311533

15321534
#elif _FU_DETECT_ARCH_ARM64
15331535

@@ -1540,7 +1542,7 @@ inline capabilities_t cpu_capabilities() noexcept {
15401542
size_t size = sizeof(wfet_support);
15411543
if (sysctlbyname("hw.optional.arm.FEAT_WFxT", &wfet_support, &size, NULL, 0) == 0 && wfet_support)
15421544
caps = static_cast<capabilities_t>(caps | capability_arm64_wfet_k);
1543-
#else
1545+
#elif defined(__GNUC__) || defined(__clang__) // We use inline assembly - unavailable in MSVC
15441546
// On non-Apple ARM systems, try to read the system register
15451547
// Note: This may fail on some systems where userspace access is restricted
15461548
std::uint64_t id_aa64isar2_el0 = 0;
@@ -3592,27 +3594,19 @@ struct logging_colors_t {
35923594

35933595
explicit logging_colors_t(bool use_colors) noexcept : use_colors_(use_colors) {}
35943596

3595-
#if FU_ENABLE_NUMA
3596-
explicit logging_colors_t(int file_descriptor = STDOUT_FILENO) noexcept {
3597-
if (!::isatty(file_descriptor)) return;
3598-
3599-
char const *term = std::getenv("TERM");
3600-
if (!term) return;
3601-
3602-
use_colors_ = std::strstr(term, "color") != nullptr || std::strstr(term, "xterm") != nullptr ||
3603-
std::strstr(term, "screen") != nullptr || std::strcmp(term, "linux") == 0;
3604-
}
3605-
#else
36063597
explicit logging_colors_t() noexcept {
3598+
#if defined(_WIN32)
3599+
if (!::isatty(_fileno(stdout))) return;
3600+
#endif
3601+
#if defined(__unix__) || defined(__APPLE__)
3602+
if (!::isatty(STDOUT_FILENO)) return;
3603+
#endif
36073604
char const *term = std::getenv("TERM");
36083605
if (!term) return;
3609-
36103606
use_colors_ = std::strstr(term, "color") != nullptr || std::strstr(term, "xterm") != nullptr ||
36113607
std::strstr(term, "screen") != nullptr || std::strcmp(term, "linux") == 0;
36123608
}
36133609

3614-
#endif
3615-
36163610
/* ANSI style codes */
36173611
char const *reset() { return use_colors_ ? "\033[0m" : ""; }
36183612
char const *bold() { return use_colors_ ? "\033[1m" : ""; }

0 commit comments

Comments
 (0)