feature. See also
. The project being documented here (as the example) is the Zig library itself.
atomic.spinLoopHint
pub inline fn spinLoopHint() void
File
Code
pub inline fn spinLoopHint() void {
switch (builtin.target.cpu.arch) {
// pipelining/power resources
// https://software.intel.com/content/www/us/en/develop/articles/benefitting-power-and-performance-sleep-loops.html
.x86,
.x86_64,
=> asm volatile ("pause"),
// https://stackoverflow.com/a/7588941
.powerpc,
.powerpcle,
.powerpc64,
.powerpc64le,
=> asm volatile ("or 27, 27, 27"),
// on common aarch64 CPUs.
// https://bugs.java.com/bugdatabase/view_bug.do?bug_id=8258604
// https://bugs.mysql.com/bug.php?id=100664
.aarch64,
.aarch64_be,
=> asm volatile ("isb"),
// https://www.keil.com/support/man/docs/armasm/armasm_dom1361289926796.htm
.arm,
.armeb,
.thumb,
.thumbeb,
=> if (comptime builtin.cpu.hasAny(.arm, &.{ .has_v6k, .has_v6m })) {
asm volatile ("yield");
},
// opinionated here.
.hexagon,
=> asm volatile ("pause(#1)"),
.riscv32,
.riscv32be,
.riscv64,
.riscv64be,
=> if (comptime builtin.cpu.has(.riscv, .zihintpause)) {
asm volatile ("pause");
},
else => {},
}
}