I’m looking for a Neutrino function which will do an atomic compare and
swap operation. The only atomic_* functions I find allow me to set/clear
bits, add, subtract, etc. I cannot find a compare and swap function.
That is something that would look like the following:

atomic_compare_and_swap(atomic_t oldValue, atomic_t newValue, atomic_t*
if (oldValue != *currentValue)
return 0;

*currentValue = newValue;
return 1;

Of course, a proper implementation would do all this atomically.

I know how to write this routine in assembly on any number of different
processors, but I’d love to just use a library routine provided by the
OS, thereby removing my processor portability exposure (and foisting it
on the OS where, IMHO, it belongs).

I could implement this easily using locks, but that would mean a) I’d
have to use a lock and b) I can’t use the technique within an interrupt
or signal handler.

Any thoughts?