/* Atomic compare-and-set primitive. 
The reading of the original value at <target>, the comparison, and the write of the new value (if it occurs) all happen atomically with respect to both interrupts and accesses of other processors to <target>. */
bool z_impl_atomic_cas(atomic_t *target, atomic_val_t old_value, atomic_val_t new_value)
/* Atomic compare-and-set primitive. 
The reading of the original value at <target>, the comparison, and the write of the new value (if it occurs) all happen atomically with respect to both interrupts and accesses of other processors to <target>. */
bool z_impl_atomic_cas(atomic_t *target, atomic_val_t old_value, atomic_val_t new_value)
{
	k_spinlock_key_t key;
	int ret = false;
	BUILD_ASSERT(!IS_ENABLED(CONFIG_SMP));
	key = k_spin_lock(&lock);
	if (*target == old_value) {
		*target = new_value;
		ret = true;
	}
	k_spin_unlock(&lock, key);
	return ret;
}