21 #ifndef __TBB_machine_H 22 #error Do not #include this internal file directly; use public TBB headers instead. 26 #define __TBB_Yield() sched_yield() 30 #include <sys/syscall.h> 32 #if defined(SYS_futex) 35 #define __TBB_USE_FUTEX 1 37 #if defined(__has_include) 38 #define __TBB_has_include __has_include 40 #define __TBB_has_include(x) 0 47 #if defined(__linux__) || __TBB_has_include(<linux/futex.h>) 48 #include <linux/futex.h> 49 #elif defined(__OpenBSD__) || __TBB_has_include(<sys/futex.h>) 50 #include <sys/futex.h> 60 #if defined(FUTEX_WAIT_PRIVATE) 61 #define __TBB_FUTEX_WAIT FUTEX_WAIT_PRIVATE 62 #elif defined(FUTEX_WAIT) 63 #define __TBB_FUTEX_WAIT FUTEX_WAIT 65 #define __TBB_FUTEX_WAIT 0 68 #if defined(FUTEX_WAKE_PRIVATE) 69 #define __TBB_FUTEX_WAKE FUTEX_WAKE_PRIVATE 70 #elif defined(FUTEX_WAKE) 71 #define __TBB_FUTEX_WAKE FUTEX_WAKE 73 #define __TBB_FUTEX_WAKE 1 77 #error machine specific headers must be included after tbb_stddef.h 84 inline int futex_wait(
void *futex,
int comparand ) {
85 int r = syscall( SYS_futex,futex,__TBB_FUTEX_WAIT,comparand,NULL,NULL,0 );
88 __TBB_ASSERT( r==0||r==EWOULDBLOCK||(r==-1&&(e==EAGAIN||e==EINTR)),
"futex_wait failed." );
93 inline int futex_wakeup_one(
void *futex ) {
94 int r = ::syscall( SYS_futex,futex,__TBB_FUTEX_WAKE,1,NULL,NULL,0 );
95 __TBB_ASSERT( r==0||r==1,
"futex_wakeup_one: more than one thread woken up?" );
99 inline int futex_wakeup_all(
void *futex ) {
100 int r = ::syscall( SYS_futex,futex,__TBB_FUTEX_WAKE,INT_MAX,NULL,NULL,0 );
101 __TBB_ASSERT( r>=0,
"futex_wakeup_all: error in waking up threads" );
#define __TBB_ASSERT(predicate, comment)
No-op version of __TBB_ASSERT.