Skip to content

Commit 3d369dc

Browse files
committed
fix annotate order in atomic load/store
1 parent c9c71b6 commit 3d369dc

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

src/utils/utils_posix_concurrency.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,23 +73,23 @@ int utils_write_unlock(utils_rwlock_t *rwlock) {
7373
}
7474

7575
void utils_atomic_load_acquire_u64(uint64_t *ptr, uint64_t *out) {
76-
utils_annotate_acquire(ptr);
7776
__atomic_load(ptr, out, memory_order_acquire);
77+
utils_annotate_acquire(ptr);
7878
}
7979

8080
void utils_atomic_load_acquire_ptr(void **ptr, void **out) {
81-
utils_annotate_acquire((void *)ptr);
8281
*out = (void *)__atomic_load_n((uintptr_t *)ptr, memory_order_acquire);
82+
utils_annotate_acquire((void *)ptr);
8383
}
8484

8585
void utils_atomic_store_release_u64(uint64_t *ptr, uint64_t *val) {
86-
__atomic_store(ptr, val, memory_order_release);
8786
utils_annotate_release(ptr);
87+
__atomic_store(ptr, val, memory_order_release);
8888
}
8989

9090
void utils_atomic_store_release_ptr(void **ptr, void *val) {
91-
__atomic_store_n((uintptr_t *)ptr, (uintptr_t)val, memory_order_release);
9291
utils_annotate_release(ptr);
92+
__atomic_store_n((uintptr_t *)ptr, (uintptr_t)val, memory_order_release);
9393
}
9494

9595
uint64_t utils_atomic_increment_u64(uint64_t *val) {

src/utils/utils_windows_concurrency.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,29 +72,29 @@ void utils_atomic_load_acquire_u64(uint64_t *ptr, uint64_t *out) {
7272
// NOTE: Windows cl complains about direct accessing 'ptr' which is next
7373
// accessed using Interlocked* functions (warning 28112 - disabled)
7474
ASSERT_IS_ALIGNED((uintptr_t)ptr, 8);
75-
utils_annotate_acquire(ptr);
7675
LONG64 ret = InterlockedCompareExchange64((LONG64 volatile *)ptr, 0, 0);
76+
utils_annotate_acquire(ptr);
7777
*out = *(uint64_t *)&ret;
7878
}
7979

8080
void utils_atomic_load_acquire_ptr(void **ptr, void **out) {
8181
ASSERT_IS_ALIGNED((uintptr_t)ptr, 8);
82-
utils_annotate_acquire((void *)ptr);
8382
uintptr_t ret = (uintptr_t)InterlockedCompareExchangePointer(ptr, 0, 0);
83+
utils_annotate_acquire((void *)ptr);
8484
*(uintptr_t *)out = ret;
8585
}
8686

8787
void utils_atomic_store_release_u64(uint64_t *ptr, uint64_t *val) {
8888
ASSERT_IS_ALIGNED((uintptr_t)ptr, 8);
8989
ASSERT_IS_ALIGNED((uintptr_t)val, 8);
90-
InterlockedExchange64((LONG64 volatile *)ptr, *(LONG64 *)val);
9190
utils_annotate_release(ptr);
91+
InterlockedExchange64((LONG64 volatile *)ptr, *(LONG64 *)val);
9292
}
9393

9494
void utils_atomic_store_release_ptr(void **ptr, void *val) {
9595
ASSERT_IS_ALIGNED((uintptr_t)ptr, 8);
96-
InterlockedExchangePointer(ptr, val);
9796
utils_annotate_release(ptr);
97+
InterlockedExchangePointer(ptr, val);
9898
}
9999

100100
uint64_t utils_atomic_increment_u64(uint64_t *ptr) {

0 commit comments

Comments
 (0)