157
157
#define _FU_UNLIKELY (x ) (x)
158
158
#endif
159
159
160
+ #if defined(__GNUC__) || defined(__clang__)
161
+ #define _FU_WITH_ASM_YIELDS 1
162
+ #else
163
+ #define _FU_WITH_ASM_YIELDS 0
164
+ #endif
165
+
160
166
/* Detect target CPU architecture.
161
167
* We'll only use it when compiling Inline Assembly code on GCC or Clang.
162
168
*/
@@ -1411,7 +1417,7 @@ concept is_unsafe_pool = //
1411
1417
1412
1418
#pragma region - Hardware Friendly Yield
1413
1419
1414
- #if defined(__GNUC__) || defined(__clang__) // We need inline assembly support
1420
+ #if _FU_WITH_ASM_YIELDS // We need inline assembly support
1415
1421
1416
1422
#if _FU_DETECT_ARCH_ARM64
1417
1423
@@ -1425,6 +1431,12 @@ struct arm64_yield_t {
1425
1431
* Places the core into light sleep mode, waiting for an event to wake it up,
1426
1432
* or the timeout to expire.
1427
1433
*/
1434
+ #pragma GCC push_options
1435
+ #pragma GCC target("+wfxt")
1436
+ #if defined(__clang__)
1437
+ #pragma clang attribute push(__attribute__((target("+wfxt"))), apply_to = function)
1438
+ #endif
1439
+
1428
1440
struct arm64_wfet_t {
1429
1441
inline void operator ()() const noexcept {
1430
1442
std::uint64_t cntfrq_el0, cntvct_el0;
@@ -1440,6 +1452,11 @@ struct arm64_wfet_t {
1440
1452
}
1441
1453
};
1442
1454
1455
+ #pragma GCC pop_options
1456
+ #if defined(__clang__)
1457
+ #pragma clang attribute pop
1458
+ #endif
1459
+
1443
1460
#endif // _FU_DETECT_ARCH_ARM64
1444
1461
1445
1462
#if _FU_DETECT_ARCH_X86_64
@@ -1519,7 +1536,7 @@ inline capabilities_t cpu_capabilities() noexcept {
1519
1536
// Check for basic PAUSE instruction support (always available on x86-64)
1520
1537
caps = static_cast <capabilities_t >(caps | capability_x86_pause_k);
1521
1538
1522
- #if defined(__GNUC__) || defined(__clang__) // We use inline assembly - unavailable in MSVC
1539
+ #if _FU_WITH_ASM_YIELDS // We use inline assembly - unavailable in MSVC
1523
1540
// CPUID to check for WAITPKG support (TPAUSE instruction)
1524
1541
std::uint32_t eax, ebx, ecx, edx;
1525
1542
@@ -1542,7 +1559,7 @@ inline capabilities_t cpu_capabilities() noexcept {
1542
1559
size_t size = sizeof (wfet_support);
1543
1560
if (sysctlbyname (" hw.optional.arm.FEAT_WFxT" , &wfet_support, &size, NULL , 0 ) == 0 && wfet_support)
1544
1561
caps = static_cast <capabilities_t >(caps | capability_arm64_wfet_k);
1545
- #elif defined(__GNUC__) || defined(__clang__) // We use inline assembly - unavailable in MSVC
1562
+ #elif _FU_WITH_ASM_YIELDS // We use inline assembly - unavailable in MSVC
1546
1563
// On non-Apple ARM systems, try to read the system register
1547
1564
// Note: This may fail on some systems where userspace access is restricted
1548
1565
std::uint64_t id_aa64isar2_el0 = 0 ;
0 commit comments