aboutsummaryrefslogtreecommitdiff
path: root/riscv/insns/sc_d.h
diff options
context:
space:
mode:
Diffstat (limited to 'riscv/insns/sc_d.h')
-rw-r--r--riscv/insns/sc_d.h11
1 files changed, 4 insertions, 7 deletions
diff --git a/riscv/insns/sc_d.h b/riscv/insns/sc_d.h
index aeeabd3..f44d873 100644
--- a/riscv/insns/sc_d.h
+++ b/riscv/insns/sc_d.h
@@ -1,11 +1,8 @@
require_extension('A');
require_rv64;
-if (MMU.check_load_reservation(RS1))
-{
- MMU.store_uint64(RS1, RS2);
- WRITE_RD(0);
-}
-else
- WRITE_RD(1);
+bool have_reservation = MMU.check_load_reservation(RS1);
+MMU.amo_uint64(RS1, [&](uint64_t lhs) { return have_reservation ? RS2 : lhs; });
MMU.yield_load_reservation();
+
+WRITE_RD(!have_reservation);