git: d0cbb1930e82 - main - atomics: atomic_load_consume_ptr(): Accept pointers to const

From: Olivier Certner <olce_at_FreeBSD.org>
Date: Mon, 20 Jan 2025 15:50:44 UTC
The branch main has been updated by olce:

URL: https://cgit.FreeBSD.org/src/commit/?id=d0cbb1930e82a53b07b1091402ff14cdfe7a4898

commit d0cbb1930e82a53b07b1091402ff14cdfe7a4898
Author:     Olivier Certner <olce@FreeBSD.org>
AuthorDate: 2025-01-20 13:53:35 +0000
Commit:     Olivier Certner <olce@FreeBSD.org>
CommitDate: 2025-01-20 15:49:52 +0000

    atomics: atomic_load_consume_ptr(): Accept pointers to const
    
    Now that all directly-implemented loads (with acquire semantics or not)
    accept pointers to const, ensure that atomic_load_consume_ptr(), built
    on atomic_load_acq_ptr(), does so too, in the common atomics header as
    well as *SAN interceptors.
    
    Reviewed by:    kib
    Fixes:          5e9a82e898d5 ("atomics: Constify loads")
    MFC after:      4 days
    Sponsored by:   The FreeBSD Foundation
    Differential Revision:  https://reviews.freebsd.org/D48497
---
 sys/sys/atomic_common.h | 2 +-
 sys/sys/atomic_san.h    | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/sys/sys/atomic_common.h b/sys/sys/atomic_common.h
index e03cd93c2d4a..e802b2a99630 100644
--- a/sys/sys/atomic_common.h
+++ b/sys/sys/atomic_common.h
@@ -133,7 +133,7 @@
  * openly resorting to the stronger acquire fence, to be sorted out.
  */
 #define	atomic_load_consume_ptr(p)	\
-    ((__typeof(*p)) atomic_load_acq_ptr((uintptr_t *)p))
+    ((__typeof(*p)) atomic_load_acq_ptr((const volatile uintptr_t *)p))
 
 #define	atomic_interrupt_fence()	__compiler_membar()
 
diff --git a/sys/sys/atomic_san.h b/sys/sys/atomic_san.h
index 93a9bfcbf593..06c6c98ec8a8 100644
--- a/sys/sys/atomic_san.h
+++ b/sys/sys/atomic_san.h
@@ -270,7 +270,7 @@ ATOMIC_SAN_THREAD_FENCE(SAN_INTERCEPTOR_PREFIX);
 	    __DECONST(volatile uintptr_t *, (x))))
 #define	atomic_load_acq_ptr		ATOMIC_SAN(load_acq_ptr)
 #define	atomic_load_consume_ptr(x)					\
-	((__typeof(*x))atomic_load_acq_ptr((volatile uintptr_t *)(x)))
+	((__typeof(*x))atomic_load_acq_ptr((const 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)