LinuxKPI: fix WRITE_ONCE(), remove ACCESS_ONCE()

Fix a gcc warning: "to be safe all intermediate pointers in cast from
'...' to '...' must be 'const' qualified [-Wcast-qual]".
Doing what is essentially a __DECONST() adding the uintptr_t gets
rid of the massive amount of warnings we get in LinuxKPI and lets
us see the actual problems a lot better.
This is a follow-up to 74e908b3c6 which
fixed READ_ONCE().
ACCESS_ONCE() seems to be an obsolete KPI these days in Linux and
FreeBSD does not use it either directly so we can entirely remove
it now.

Sponsored by:	The FreeBSD Foundation
Suggested by:	jhb
Reviewed by:	hselasky
MFC after:	10 days
Differential Revision: https://reviews.freebsd.org/D40084
This commit is contained in:
Bjoern A. Zeeb 2023-05-13 15:17:47 +00:00
parent 805d759338
commit 046d8d89ed

View File

@ -88,11 +88,9 @@
#define ___PASTE(a,b) a##b
#define __PASTE(a,b) ___PASTE(a,b)
#define ACCESS_ONCE(x) (*(volatile __typeof(x) *)&(x))
#define WRITE_ONCE(x,v) do { \
barrier(); \
ACCESS_ONCE(x) = (v); \
(*(volatile __typeof(x) *)(uintptr_t)&(x)) = (v); \
barrier(); \
} while (0)