Skip to content
Open
Show file tree
Hide file tree
Changes from 6 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;
}
}
27 changes: 27 additions & 0 deletions src/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,30 @@
#define MAYBE_UNUSED
#endif
#endif

#ifdef __GNUC__
#if defined(__x86_64__) || defined(__i386__) || defined(_M_X64) || defined(_M_IX86)
#if defined(__GNUC__) && ((__GNUC__ < 4) || (__GNUC__ == 4 && __GNUC_MINOR__ < 4))
Comment thread
cobaltgit marked this conversation as resolved.
Outdated
#define YIELD() __asm__ volatile("rep; nop" ::: "memory")
#else
#include <immintrin.h>
#define YIELD() _mm_pause()
#endif
#elif defined(_M_ARM64) || defined(_M_ARM)
Comment thread
cobaltgit marked this conversation as resolved.
#include <intrin.h>
#define YIELD() __yield()
#elif defined(__aarch64__) || (defined(__arm__) && defined(__ARM_ARCH) && (__ARM_ARCH >= 7))
#if defined(__GNUC__) && (__GNUC__ < 5)
#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
#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