/* The standard atomic.h primitives don't quite do what we want here: We need an atomic add-and-return-previous-value (which could be done with atomic_add_return and a decrement) and an atomic set/zero-and-return-previous-value (which can't really be done with the atomic.h primitives). And since this is MIPS MT, we can assume that we have LL/SC.  */
static int atomic_postincrement(atomic_t *v)
/* The standard atomic.h primitives don't quite do what we want here: We need an atomic add-and-return-previous-value (which could be done with atomic_add_return and a decrement) and an atomic set/zero-and-return-previous-value (which can't really be done with the atomic.h primitives). And since this is MIPS MT, we can assume that we have LL/SC.  */
static int atomic_postincrement(atomic_t *v)
{
	unsigned long result;
	unsigned long temp;
	__asm__ __volatile__(
	"1:	ll	%0, %2					\n"
	"	addu	%1, %0, 1				\n"
	"	sc	%1, %2					\n"
	"	beqz	%1, 1b					\n"
	__WEAK_LLSC_MB
	: "=&r" (result), "=&r" (temp), "=m" (v->counter)
	: "m" (v->counter)
	: "memory");
	return result;
}