File indexing completed on 2026-09-04 09:23:11
0001
0002
0003
0004
0005
0006 #ifndef QYIELDCPU_H
0007 #define QYIELDCPU_H
0008
0009 #include <QtCore/qcompilerdetection.h>
0010 #include <QtCore/qprocessordetection.h>
0011 #include <QtCore/qtconfigmacros.h>
0012
0013 #if defined(Q_CC_MSVC_ONLY) && defined(Q_PROCESSOR_X86)
0014
0015
0016 # ifdef __cplusplus
0017 # include <atomic>
0018 extern "C"
0019 # endif
0020 void _mm_pause(void);
0021 #endif
0022
0023 QT_BEGIN_NAMESPACE
0024
0025 Q_ALWAYS_INLINE
0026 #ifdef Q_CC_GNU
0027 __attribute__((artificial))
0028 #endif
0029 void qYieldCpu(void) Q_DECL_NOEXCEPT;
0030
0031 void qYieldCpu(void)
0032 #ifdef __cplusplus
0033 noexcept
0034 #endif
0035 {
0036 #if __has_builtin(__builtin_arm_yield)
0037 __builtin_arm_yield();
0038 #elif __has_builtin(__yield)
0039 __yield();
0040 #elif defined(_YIELD_PROCESSOR) && defined(Q_CC_MSVC)
0041 _YIELD_PROCESSOR();
0042
0043 #elif __has_builtin(__builtin_ia32_pause)
0044 __builtin_ia32_pause();
0045 #elif defined(Q_PROCESSOR_X86) && defined(Q_CC_GNU)
0046
0047 __builtin_ia32_pause();
0048 #elif defined(Q_PROCESSOR_X86) && defined(Q_CC_MSVC)
0049 _mm_pause();
0050 #elif defined(Q_PROCESSOR_X86)
0051 __asm__("pause");
0052 #elif defined(Q_PROCESSOR_ARM) && Q_PROCESSOR_ARM >= 7 && defined(Q_CC_GNU)
0053 __asm__("yield");
0054
0055 #elif defined(Q_PROCESSOR_RISCV)
0056 __asm__(".word 0x0100000f");
0057
0058 #elif defined(_YIELD_PROCESSOR) && defined(Q_CC_GHS)
0059 _YIELD_PROCESSOR;
0060 #endif
0061 }
0062
0063 QT_END_NAMESPACE
0064
0065 #endif