Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/collision.h
Original file line number Diff line number Diff line change
Expand Up @@ -430,4 +430,4 @@ static inline bool Collision_instancesOverlapPrecise(Runner* runner, Instance* a
}

return false;
}
}
24 changes: 24 additions & 0 deletions src/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,27 @@
#define MAYBE_UNUSED
#endif
#endif

#if defined(__x86_64__) || defined(__i386__) || defined(_M_X64) || defined(_M_IX86)
#if defined(__GNUC__) && ((__GNUC__ < 4) || (__GNUC__ == 4 && __GNUC_MINOR__ < 4))
#define YIELD() __asm__ volatile("rep; nop" ::: "memory")
#else
#include <immintrin.h>
#define YIELD() _mm_pause()
#endif
#elif defined(_M_ARM64) || defined(_M_ARM)
#include <intrin.h>
#define YIELD() __yield()
#elif defined(__aarch64__) || (defined(__arm__) && defined(__ARM_ARCH) && (__ARM_ARCH >= 7))
#if defined(__GNUC__) && (__GNUC__ < 5)

@Un1q32 Un1q32 Jun 7, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clang appears to have this too, clang does define __GNUC__ but it pretends to be GCC 4.2.1

#define YIELD() __asm__ volatile("yield" ::: "memory")
#else
#include <arm_acle.h>
#define YIELD() __yield()
#endif
#elif defined(__riscv)
#define YIELD() __asm__ volatile("pause" ::: "memory")
#else
#define YIELD() ((void)0)
#endif

1 change: 1 addition & 0 deletions src/desktop/backends/glfw2.c
Original file line number Diff line number Diff line change
Expand Up @@ -267,5 +267,6 @@ void platformSleepUntil(double time) {

while (platformGetTime() < time) {
// Spin-wait for the remaining sub-millisecond
YIELD();
}
}
1 change: 1 addition & 0 deletions src/desktop/backends/glfw3.c
Original file line number Diff line number Diff line change
Expand Up @@ -428,5 +428,6 @@ void platformSleepUntil(double time) {
}
while (platformGetTime() < time) {
// Spin-wait for the remaining sub-millisecond
YIELD();
}
}
1 change: 1 addition & 0 deletions src/desktop/backends/sdl1.c
Original file line number Diff line number Diff line change
Expand Up @@ -258,5 +258,6 @@ void platformSleepUntil(double time) {

while (platformGetTime() < time) {
// Spin-wait for the remaining sub-millisecond
YIELD();
}
}
1 change: 1 addition & 0 deletions src/desktop/backends/sdl2.c
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,7 @@ void platformSleepUntil(double time) {

while (platformGetTime() < time) {
// Spin-wait for the remaining sub-millisecond
YIELD();
}
}

Expand Down
Loading