void spin_mutex::scoped_lock::internal_acquire( spin_mutex& m ) { __TBB_ASSERT( !my_mutex, "already holding a lock on a spin_mutex" ); ITT_NOTIFY(sync_prepare, &m); my_unlock_value = __TBB_LockByte(m.flag); my_mutex = &m; ITT_NOTIFY(sync_acquired, &m); }
static void TestTinyLock() { if( Verbose ) printf("testing __TBB_LockByte\n"); unsigned char flags[16]; for( int i=0; i<16; ++i ) flags[i] = i; #if __GNUC__==4&&__GNUC_MINOR__==3&&__GNUC_PATCHLEVEL__==0 __TBB_store_with_release( flags[8], 0 ); #else flags[8] = 0; #endif __TBB_LockByte(flags[8]); for( int i=0; i<16; ++i ) ASSERT( flags[i]==(i==8?1:i), NULL ); }