Files
riscv-isa-sim/ci-tests/atomics.c
Alexander Romanov 7d43d38e4a fix: log store only if it actually happened
Since 92e4f02 moved logging logic into store_slow_path function it has
been logging stores even if actually_store parameter is false. Because
of that logging is broken for all atomic instructions. Function "amo" calls
store_slow_path with nullptr argument and actually_store equal to false
while callee uses reg_from_bytes independently from actually_store value
All of that causes dereferencing of nullptr. This commit logs memory
access only if it actually happened
2025-05-20 17:39:45 +03:00

21 lines
322 B
C

#include <stdio.h>
#include <stdatomic.h>
atomic_int acnt = 0;
atomic_int bcnt = 0;
int foo() {
for(int n = 0; n < 1000; ++n) {
++acnt;
if(acnt % 10 == 0)
++bcnt;
}
return acnt;
}
int main(void) {
int acnt = foo();
printf("First atomic counter is %u, second is %u\n", acnt, bcnt);
return 0;
}