All pastes #730964 Raw Edit

Stuff

public text v1 · immutable
·published 2007-10-09 17:53 UTC
rendered paste body
int cmpxchg(int oldval, int newval, lock_t * l)
{
	int result;
	asm volatile("lock; cmpxchgl %2, %0" :
			"+m" (*l), "=a" (result) :
 			"r"(newval), "1"(oldval) :
 			"cc");
	return result;
}

int test_and_set(lock_t * l, int newval)
{
	return cmpxchg(l->status, newval, &l->status);
}