17 #ifndef __TBB_machine_H 18 #error Do not #include this internal file directly; use public TBB headers instead. 22 #define __TBB_Yield() sched_yield() 26 #include <sys/syscall.h> 28 #if defined(SYS_futex) 31 #define __TBB_USE_FUTEX 1 33 #if defined(__has_include) 34 #define __TBB_has_include __has_include 36 #define __TBB_has_include(x) 0 43 #if defined(__linux__) || __TBB_has_include(<linux/futex.h>) 44 #include <linux/futex.h> 45 #elif defined(__OpenBSD__) || __TBB_has_include(<sys/futex.h>) 46 #include <sys/futex.h> 56 #if defined(FUTEX_WAIT_PRIVATE) 57 #define __TBB_FUTEX_WAIT FUTEX_WAIT_PRIVATE 58 #elif defined(FUTEX_WAIT) 59 #define __TBB_FUTEX_WAIT FUTEX_WAIT 61 #define __TBB_FUTEX_WAIT 0 64 #if defined(FUTEX_WAKE_PRIVATE) 65 #define __TBB_FUTEX_WAKE FUTEX_WAKE_PRIVATE 66 #elif defined(FUTEX_WAKE) 67 #define __TBB_FUTEX_WAKE FUTEX_WAKE 69 #define __TBB_FUTEX_WAKE 1 73 #error machine specific headers must be included after tbb_stddef.h 80 inline int futex_wait(
void *futex,
int comparand ) {
81 int r = syscall( SYS_futex,futex,__TBB_FUTEX_WAIT,comparand,NULL,NULL,0 );
84 __TBB_ASSERT( r==0||r==EWOULDBLOCK||(r==-1&&(e==EAGAIN||e==EINTR)),
"futex_wait failed." );
89 inline int futex_wakeup_one(
void *futex ) {
90 int r = ::syscall( SYS_futex,futex,__TBB_FUTEX_WAKE,1,NULL,NULL,0 );
91 __TBB_ASSERT( r==0||r==1,
"futex_wakeup_one: more than one thread woken up?" );
95 inline int futex_wakeup_all(
void *futex ) {
96 int r = ::syscall( SYS_futex,futex,__TBB_FUTEX_WAKE,INT_MAX,NULL,NULL,0 );
97 __TBB_ASSERT( r>=0,
"futex_wakeup_all: error in waking up threads" );
#define __TBB_ASSERT(predicate, comment)
No-op version of __TBB_ASSERT.