atomic: Fix the atomic_load_ptr() *SAN interceptor

The interceptor didn't handle a pointer of type "foo * const *" and in
that case we'd get compiler errors 1) an invalid cast to volatile
uintptr_t, and 2) an assignment to a variable of type "foo * const"
(__retptr).

Reported by:	mjg
MFC after:	1 week
This commit is contained in:
Mark Johnston 2023-02-09 09:54:52 -05:00
parent 6332ef8941
commit 08b0c98006

View File

@ -267,17 +267,11 @@ ATOMIC_SAN_THREAD_FENCE(SAN_INTERCEPTOR_PREFIX);
#define atomic_fcmpset_acq_ptr ATOMIC_SAN(fcmpset_acq_ptr)
#define atomic_fcmpset_rel_ptr ATOMIC_SAN(fcmpset_rel_ptr)
#define atomic_fetchadd_ptr ATOMIC_SAN(fetchadd_ptr)
#define atomic_load_ptr(x) ({ \
__typeof(*x) __retptr; \
__retptr = (void *)ATOMIC_SAN(load_ptr)((volatile uintptr_t *)(x)); \
__retptr; \
})
#define atomic_load_ptr(x) \
((void *)ATOMIC_SAN(load_ptr)(__DECONST(volatile uintptr_t *, (x))))
#define atomic_load_acq_ptr ATOMIC_SAN(load_acq_ptr)
#define atomic_load_consume_ptr(x) ({ \
__typeof(*x) __retptr; \
__retptr = (void *)atomic_load_acq_ptr((volatile uintptr_t *)(x));\
__retptr; \
})
#define atomic_load_consume_ptr(x) \
((void *)atomic_load_acq_ptr((volatile uintptr_t *)(x)))
#define atomic_readandclear_ptr ATOMIC_SAN(readandclear_ptr)
#define atomic_set_ptr ATOMIC_SAN(set_ptr)
#define atomic_set_acq_ptr ATOMIC_SAN(set_acq_ptr)