void qemu_event_set(QemuEvent *ev)
{
- if (atomic_mb_read(&ev->value) != EV_SET) {
+ /* qemu_event_set has release semantics, but because it *loads*
+ * ev->value we need a full memory barrier here.
+ */
+ smp_mb();
+ if (atomic_read(&ev->value) != EV_SET) {
if (atomic_xchg(&ev->value, EV_SET) == EV_BUSY) {
/* There were waiters, wake them up. */
futex_wake(ev, INT_MAX);
void qemu_event_reset(QemuEvent *ev)
{
- if (atomic_mb_read(&ev->value) == EV_SET) {
+ unsigned value;
+
+ value = atomic_read(&ev->value);
+ smp_mb_acquire();
+ if (value == EV_SET) {
/*
* If there was a concurrent reset (or even reset+wait),
* do nothing. Otherwise change EV_SET->EV_FREE.
{
unsigned value;
- value = atomic_mb_read(&ev->value);
+ value = atomic_read(&ev->value);
+ smp_mb_acquire();
if (value != EV_SET) {
if (value == EV_FREE) {
/*
void qemu_event_set(QemuEvent *ev)
{
- if (atomic_mb_read(&ev->value) != EV_SET) {
+ /* qemu_event_set has release semantics, but because it *loads*
+ * ev->value we need a full memory barrier here.
+ */
+ smp_mb();
+ if (atomic_read(&ev->value) != EV_SET) {
if (atomic_xchg(&ev->value, EV_SET) == EV_BUSY) {
/* There were waiters, wake them up. */
SetEvent(ev->event);
void qemu_event_reset(QemuEvent *ev)
{
- if (atomic_mb_read(&ev->value) == EV_SET) {
+ unsigned value;
+
+ value = atomic_read(&ev->value);
+ smp_mb_acquire();
+ if (value == EV_SET) {
/* If there was a concurrent reset (or even reset+wait),
* do nothing. Otherwise change EV_SET->EV_FREE.
*/
{
unsigned value;
- value = atomic_mb_read(&ev->value);
+ value = atomic_read(&ev->value);
+ smp_mb_acquire();
if (value != EV_SET) {
if (value == EV_FREE) {
/* qemu_event_set is not yet going to call SetEvent, but we are