* fallback function names.
*/
typedef void *pvoid;
-typedef struct rcu_cb_item *prcu_cb_item;
# if defined(__GNUC__) && defined(__ATOMIC_ACQUIRE) && !defined(BROKEN_CLANG_ATOMICS) \
&& !defined(USE_ATOMIC_FALLBACKS)
return ret; \
}
IMPL_fallback_atomic_exchange_n(uint64_t)
-IMPL_fallback_atomic_exchange_n(prcu_cb_item)
# define ATOMIC_EXCHANGE_N(t, p, v, o) fallback_atomic_exchange_n_##t(p, v)
}
}
+/*
+ * Note: This call assumes its made under the protection of
+ * ossl_rcu_write_lock
+ */
int ossl_rcu_call(CRYPTO_RCU_LOCK *lock, rcu_cb_fn cb, void *data)
{
struct rcu_cb_item *new =
new->data = data;
new->fn = cb;
- /*
- * Use __ATOMIC_ACQ_REL here to indicate that any prior writes to this
- * list are visible to us prior to reading, and publish the new value
- * immediately
- */
- new->next = ATOMIC_EXCHANGE_N(prcu_cb_item, &lock->cb_items, new,
- __ATOMIC_ACQ_REL);
+
+ new->next = lock->cb_items;
+ lock->cb_items = new;
return 1;
}
struct rcu_cb_item *cb_items, *tmpcb;
/* before we do anything else, lets grab the cb list */
- cb_items = InterlockedExchangePointer((void * volatile *)&lock->cb_items, NULL);
+ ossl_crypto_mutex_lock(lock->write_lock);
+ cb_items = lock->cb_items;
+ lock->cb_items = NULL;
+ ossl_crypto_mutex_unlock(lock->write_lock);
qp = update_qp(lock, &curr_id);
}
+/*
+ * Note, must be called under the protection of ossl_rcu_write_lock
+ */
int ossl_rcu_call(CRYPTO_RCU_LOCK *lock, rcu_cb_fn cb, void *data)
{
struct rcu_cb_item *new;
new->data = data;
new->fn = cb;
- InterlockedExchangePointer((void * volatile *)&lock->cb_items, prev);
- new->next = prev;
+ new->next = lock->cb_items;
+ lock->cb_items = new;
+
return 1;
}