Skip to content

Commit e8da260

Browse files
committed
use pthread_yield if bus yielding is unavailable
If a platform does not support bus yielding, yield the threads' cpu timeslice early.
1 parent 8240eff commit e8da260

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/utils.h

+3-1
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,9 @@ static inline void *xrealloc(void *ptr, size_t size)
7777
|| defined(__ARM_ARCH_7S__) || defined(__aarch64__)
7878
#define brubeck_cpu_relax() __asm__ volatile("yield\n": : :"memory")
7979
#else
80-
#define brubeck_cpu_relax() break
80+
/* Many OSes support it, but some require odd macros to get the declaration */
81+
int pthread_yield(void);
82+
#define brubeck_cpu_relax() pthread_yield ()
8183
#endif
8284

8385
void initproctitle (int argc, char **argv);

0 commit comments

Comments
 (0)