From d14c38ceb8aa10bd94913d0456ec0f726693379b Mon Sep 17 00:00:00 2001 From: Mark Johnston Date: Tue, 5 Nov 2024 14:31:50 +0000 Subject: [PATCH] sys: Avoid relying on pollution from refcount.h Fix up headers which previously assumed that refcount.h includes systm.h, and make them more self-contained. Then, replace the systm.h include in refcount with kassert.h. Reviewed by: imp, kib MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D47450 --- sys/powerpc/include/counter.h | 2 ++ sys/sys/_lock.h | 4 ++-- sys/sys/_mutex.h | 6 ++++-- sys/sys/_rmlock.h | 10 ++++++++-- sys/sys/_rwlock.h | 6 ++++-- sys/sys/_sx.h | 5 ++++- sys/sys/file.h | 7 +++++-- sys/sys/ktls.h | 3 +++ sys/sys/refcount.h | 7 ++++--- sys/sys/sglist.h | 1 + tools/build/test-includes/badfiles.inc | 1 - 11 files changed, 37 insertions(+), 15 deletions(-) diff --git a/sys/powerpc/include/counter.h b/sys/powerpc/include/counter.h index 68e292cde7f6..90e6400ad562 100644 --- a/sys/powerpc/include/counter.h +++ b/sys/powerpc/include/counter.h @@ -100,6 +100,8 @@ counter_u64_add(counter_u64_t c, int64_t inc) #else /* !64bit */ +#include + #define counter_enter() critical_enter() #define counter_exit() critical_exit() diff --git a/sys/sys/_lock.h b/sys/sys/_lock.h index ef167b9ab5ec..7057463fbde2 100644 --- a/sys/sys/_lock.h +++ b/sys/sys/_lock.h @@ -33,8 +33,8 @@ struct lock_object { const char *lo_name; /* Individual lock name. */ - u_int lo_flags; - u_int lo_data; /* General class specific data. */ + unsigned int lo_flags; + unsigned int lo_data; /* General class specific data. */ struct witness *lo_witness; /* Data for witness. */ }; diff --git a/sys/sys/_mutex.h b/sys/sys/_mutex.h index 0fcd5a2c2809..7241f9f1d31c 100644 --- a/sys/sys/_mutex.h +++ b/sys/sys/_mutex.h @@ -31,6 +31,8 @@ #ifndef _SYS__MUTEX_H_ #define _SYS__MUTEX_H_ +#include +#include #include /* @@ -44,7 +46,7 @@ */ struct mtx { struct lock_object lock_object; /* Common lock properties. */ - volatile uintptr_t mtx_lock; /* Owner and flags. */ + volatile __uintptr_t mtx_lock; /* Owner and flags. */ }; /* @@ -58,7 +60,7 @@ struct mtx { */ struct mtx_padalign { struct lock_object lock_object; /* Common lock properties. */ - volatile uintptr_t mtx_lock; /* Owner and flags. */ + volatile __uintptr_t mtx_lock; /* Owner and flags. */ } __aligned(CACHE_LINE_SIZE); #endif /* !_SYS__MUTEX_H_ */ diff --git a/sys/sys/_rmlock.h b/sys/sys/_rmlock.h index 38375b623a65..9c8893efe19c 100644 --- a/sys/sys/_rmlock.h +++ b/sys/sys/_rmlock.h @@ -32,6 +32,14 @@ #ifndef _SYS__RMLOCK_H_ #define _SYS__RMLOCK_H_ +#include +#include +#include +#include +#include + +struct thread; + /* * Mostly reader/occasional writer lock. */ @@ -66,8 +74,6 @@ struct rm_priotracker { LIST_ENTRY(rm_priotracker) rmp_qentry; }; -#include - struct rmslock_pcpu; struct rmslock { diff --git a/sys/sys/_rwlock.h b/sys/sys/_rwlock.h index d360cfe2a4e9..8c15771cb172 100644 --- a/sys/sys/_rwlock.h +++ b/sys/sys/_rwlock.h @@ -28,6 +28,8 @@ #ifndef _SYS__RWLOCK_H_ #define _SYS__RWLOCK_H_ +#include +#include #include /* @@ -41,7 +43,7 @@ */ struct rwlock { struct lock_object lock_object; - volatile uintptr_t rw_lock; + volatile __uintptr_t rw_lock; }; /* @@ -55,7 +57,7 @@ struct rwlock { */ struct rwlock_padalign { struct lock_object lock_object; - volatile uintptr_t rw_lock; + volatile __uintptr_t rw_lock; } __aligned(CACHE_LINE_SIZE); #endif /* !_SYS__RWLOCK_H_ */ diff --git a/sys/sys/_sx.h b/sys/sys/_sx.h index f70462c9a008..c6fd485620c6 100644 --- a/sys/sys/_sx.h +++ b/sys/sys/_sx.h @@ -31,12 +31,15 @@ #ifndef _SYS__SX_H_ #define _SYS__SX_H_ +#include +#include + /* * Shared/exclusive lock main structure definition. */ struct sx { struct lock_object lock_object; - volatile uintptr_t sx_lock; + volatile __uintptr_t sx_lock; }; #endif /* !_SYS__SX_H_ */ diff --git a/sys/sys/file.h b/sys/sys/file.h index 820ad1015573..a2dc02e523d8 100644 --- a/sys/sys/file.h +++ b/sys/sys/file.h @@ -37,13 +37,16 @@ #include #include #else -#include -#include +#include #include #include +#include +#include +#include #include struct filedesc; +struct proc; struct stat; struct thread; struct uio; diff --git a/sys/sys/ktls.h b/sys/sys/ktls.h index 9b3433f4b1fd..0e52d643fe3b 100644 --- a/sys/sys/ktls.h +++ b/sys/sys/ktls.h @@ -28,8 +28,11 @@ #define _SYS_KTLS_H_ #ifdef _KERNEL +#include #include #include + +#include #endif struct tls_record_layer { diff --git a/sys/sys/refcount.h b/sys/sys/refcount.h index 44588fe3c812..ae0ec44fd7a6 100644 --- a/sys/sys/refcount.h +++ b/sys/sys/refcount.h @@ -28,13 +28,14 @@ #ifndef __SYS_REFCOUNT_H__ #define __SYS_REFCOUNT_H__ -#include - -#include +#include +#include #if !defined(_KERNEL) && !defined(_STANDALONE) #include #endif +#include + #define REFCOUNT_SATURATED(val) (((val) & (1U << 31)) != 0) #define REFCOUNT_SATURATION_VALUE (3U << 30) diff --git a/sys/sys/sglist.h b/sys/sys/sglist.h index 96f3c1cd5ffb..3bbada573772 100644 --- a/sys/sys/sglist.h +++ b/sys/sys/sglist.h @@ -55,6 +55,7 @@ struct sglist { struct bio; struct mbuf; +struct thread; struct uio; static __inline void diff --git a/tools/build/test-includes/badfiles.inc b/tools/build/test-includes/badfiles.inc index eb0cd05cb39f..1d648819cd8c 100644 --- a/tools/build/test-includes/badfiles.inc +++ b/tools/build/test-includes/badfiles.inc @@ -100,7 +100,6 @@ BADHDRS= \ sys/prng.h \ sys/qmath.h \ sys/racct.h \ - sys/refcount.h \ sys/resourcevar.h \ sys/rman.h \ sys/rmlock.h \