Skip to content

Commit 481cfe3

Browse files
committed
Platform independent yielding
1 parent 30680d5 commit 481cfe3

File tree

1 file changed

+11
-0
lines changed
  • Framework/Foundation/3rdparty/x9

1 file changed

+11
-0
lines changed

Framework/Foundation/3rdparty/x9/x9.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,12 @@
3535
#include "x9.h"
3636

3737
#include <assert.h> /* assert */
38+
#if defined(__x86_64__) || defined(__i386__)
3839
#include <immintrin.h> /* _mm_pause */
40+
#elif defined(__aarch64__)
41+
#else
42+
#error Not supported architecture
43+
#endif
3944
#include <stdarg.h> /* va_* */
4045
#include <stdatomic.h> /* atomic_* */
4146
#include <stdbool.h> /* bool */
@@ -361,7 +366,13 @@ void x9_read_from_inbox_spin(x9_inbox* const inbox,
361366
register x9_msg_header* const header = x9_header_ptr(inbox, idx);
362367

363368
for (;;) {
369+
#if defined(__x86_64__) || defined(__i386__)
364370
_mm_pause();
371+
#elif defined(__aarch64__)
372+
__asm__ __volatile__ ("yield");
373+
#else
374+
#error Not supported architecture
375+
#endif
365376
if (atomic_load_explicit(&header->slot_has_data, __ATOMIC_RELAXED)) {
366377
if (atomic_load_explicit(&header->msg_written, __ATOMIC_ACQUIRE)) {
367378
memcpy(outparam, (char*)header + sizeof(x9_msg_header), msg_sz);

0 commit comments

Comments
 (0)