atomic_add_if_greater
int32 oldValue = atomic_add_if_greater(sem, 1, -1);
int32 oldValue = atomic_add_if_greater(sem, -1, 0);