From 7cc4a02c7ff7bafd798b185beb7b0c2986b9f32f Mon Sep 17 00:00:00 2001 From: zhaoyao73 Date: Fri, 28 Jul 2023 03:44:45 -0400 Subject: [PATCH] fix arch_try_cmpxchg macro declaration (#307) fix arch_try_cmpxchg in atomic_cmpxchg Co-authored-by: Yao Zhao --- kernel/src/arch/x86_64/include/asm/cmpxchg.h | 6 +++--- kernel/src/common/atomic.h | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/kernel/src/arch/x86_64/include/asm/cmpxchg.h b/kernel/src/arch/x86_64/include/asm/cmpxchg.h index c890a135..6b7a5f5d 100644 --- a/kernel/src/arch/x86_64/include/asm/cmpxchg.h +++ b/kernel/src/arch/x86_64/include/asm/cmpxchg.h @@ -77,7 +77,7 @@ extern void __cmpxchg_wrong_size(void) __compiletime_error("Bad argument size fo likely(is_success); \ }) -#define arch_try_cmpxchg(ptr, old_ptr, new_ptr) \ - __raw_try_cmpxchg((ptr), (old_ptr), (new_ptr), sizeof(*ptr)) +#define arch_try_cmpxchg(ptr, old_ptr, new) \ + __raw_try_cmpxchg((ptr), (old_ptr), (new), sizeof(*ptr)) -bool __try_cmpxchg_q(uint64_t *ptr, uint64_t *old_ptr, uint64_t *new_ptr); \ No newline at end of file +bool __try_cmpxchg_q(uint64_t *ptr, uint64_t *old_ptr, uint64_t *new_ptr); diff --git a/kernel/src/common/atomic.h b/kernel/src/common/atomic.h index d9fc2ef6..77b4d3ac 100644 --- a/kernel/src/common/atomic.h +++ b/kernel/src/common/atomic.h @@ -102,6 +102,6 @@ inline void atomic_clear_mask(atomic_t *ato, long mask) // cmpxchgq 比较并交换 inline long atomic_cmpxchg(atomic_t *ato, long oldval, long newval) { - bool success = arch_try_cmpxchg(&ato->value, &oldval, &newval); + bool success = arch_try_cmpxchg(&ato->value, &oldval, newval); return success ? oldval : newval; -} \ No newline at end of file +}