[PATCH] Provide kernel space items only if needed
Chris Johns
chrisj at rtems.org
Mon Mar 13 21:55:41 UTC 2023
Looks good
Thanks
Chris
On 13/3/2023 9:36 pm, Sebastian Huber wrote:
> The kernel space parts of standard system header files were protected
> against misuse by an preprocessor error directive. This approach does
> not work well with tools such as Doxygen. Provide the kernel space
> items only if the required defines are present.
> ---
> cpukit/include/machine/_kernel_in.h | 8 +++++---
> cpukit/include/machine/_kernel_in6.h | 8 +++++---
> cpukit/include/machine/_kernel_param.h | 8 +++++---
> cpukit/include/machine/_kernel_time.h | 8 +++++---
> cpukit/include/machine/_kernel_types.h | 8 +++++---
> cpukit/include/machine/_kernel_uio.h | 8 +++++---
> 6 files changed, 30 insertions(+), 18 deletions(-)
>
> diff --git a/cpukit/include/machine/_kernel_in.h b/cpukit/include/machine/_kernel_in.h
> index b33283353a..78492453cd 100644
> --- a/cpukit/include/machine/_kernel_in.h
> +++ b/cpukit/include/machine/_kernel_in.h
> @@ -39,9 +39,7 @@
> * (_KERNEL is defined before including <netinet/in.h>).
> */
>
> -#if !defined(_NETINET_IN_H_) || !defined(_KERNEL)
> -#error "must be included via <netinet/in.h> in kernel space"
> -#endif
> +#if defined(_NETINET_IN_H_) && defined(_KERNEL)
>
> struct ifnet; struct mbuf; /* forward declarations for Standard C */
> struct in_ifaddr;
> @@ -71,3 +69,7 @@ void in_ifdetach(struct ifnet *);
> #define satosin(sa) ((struct sockaddr_in *)(sa))
> #define sintosa(sin) ((struct sockaddr *)(sin))
> #define ifatoia(ifa) ((struct in_ifaddr *)(ifa))
> +
> +#else /* !_NETINET_IN_H_ || !_KERNEL */
> +#error "must be included via <netinet/in.h> in kernel space"
> +#endif /* _NETINET_IN_H_ && _KERNEL */
> diff --git a/cpukit/include/machine/_kernel_in6.h b/cpukit/include/machine/_kernel_in6.h
> index 7ec695bd6d..857b51548d 100644
> --- a/cpukit/include/machine/_kernel_in6.h
> +++ b/cpukit/include/machine/_kernel_in6.h
> @@ -38,9 +38,7 @@
> * (_KERNEL is defined before including <netinet6/in6.h>).
> */
>
> -#if !defined(_NETINET6_IN6_H_) || !defined(_KERNEL)
> -#error "must be included via <netinet6/in6.h> in kernel space"
> -#endif
> +#if defined(_NETINET6_IN6_H_) && defined(_KERNEL)
>
> /* XXX nonstandard */
> #define s6_addr8 __u6_addr.__u6_addr8
> @@ -187,3 +185,7 @@ extern void addrsel_policy_init(void);
> #define satosin6(sa) ((struct sockaddr_in6 *)(sa))
> #define sin6tosa(sin6) ((struct sockaddr *)(sin6))
> #define ifatoia6(ifa) ((struct in6_ifaddr *)(ifa))
> +
> +#else /* !_NETINET6_IN6_H_ || !_KERNEL */
> +#error "must be included via <netinet6/in6.h> in kernel space"
> +#endif /* _NETINET6_IN6_H_ && _KERNEL */
> diff --git a/cpukit/include/machine/_kernel_param.h b/cpukit/include/machine/_kernel_param.h
> index 5b381ccca5..1235d7b324 100644
> --- a/cpukit/include/machine/_kernel_param.h
> +++ b/cpukit/include/machine/_kernel_param.h
> @@ -37,9 +37,7 @@
> #include <sys/time.h>
> #include <sys/priority.h>
>
> -#if !defined(_SYS_PARAM_H_) || !defined(_KERNEL)
> -#error "must be included via <sys/param.h> in kernel space"
> -#endif
> +#if defined(_SYS_PARAM_H_) && defined(_KERNEL)
>
> #ifndef FALSE
> #define FALSE 0
> @@ -65,3 +63,7 @@ __END_DECLS
> #define ntohl(x) __ntohl(x)
> #define ntohs(x) __ntohs(x)
> #endif /* !_BYTEORDER_FUNC_DEFINED */
> +
> +#else /* !_SYS_PARAM_H_ || !_KERNEL */
> +#error "must be included via <sys/param.h> in kernel space"
> +#endif /* _SYS_PARAM_H_ && _KERNEL */
> diff --git a/cpukit/include/machine/_kernel_time.h b/cpukit/include/machine/_kernel_time.h
> index cfd223f0b6..c65355d006 100644
> --- a/cpukit/include/machine/_kernel_time.h
> +++ b/cpukit/include/machine/_kernel_time.h
> @@ -41,9 +41,7 @@
> * (_KERNEL is defined before including <sys/time.h>).
> */
>
> -#if !defined(_SYS_TIME_H_) || !defined(_KERNEL)
> -#error "must be included via <sys/time.h> in kernel space"
> -#endif
> +#if defined(_SYS_TIME_H_) && defined(_KERNEL)
>
> #include <machine/_timecounter.h>
>
> @@ -216,3 +214,7 @@ int tvtohz(struct timeval *tv);
> #define TIMESEL(sbt, sbt2) \
> (((sbt2) >= sbt_timethreshold) ? \
> ((*(sbt) = getsbinuptime()), 1) : ((*(sbt) = sbinuptime()), 0))
> +
> +#else /* !_SYS_TIME_H_ || !_KERNEL */
> +#error "must be included via <sys/time.h> in kernel space"
> +#endif /* _SYS_TIME_H_ && _KERNEL */
> diff --git a/cpukit/include/machine/_kernel_types.h b/cpukit/include/machine/_kernel_types.h
> index 98f0366b64..7f70964e2d 100644
> --- a/cpukit/include/machine/_kernel_types.h
> +++ b/cpukit/include/machine/_kernel_types.h
> @@ -32,9 +32,7 @@
> * POSSIBILITY OF SUCH DAMAGE.
> */
>
> -#if !defined(_SYS_TYPES_H) || !defined(_KERNEL)
> -#error "must be included via <sys/types.h> in kernel space"
> -#endif
> +#if defined(_SYS_TYPES_H) && defined(_KERNEL)
>
> #include <stdbool.h>
>
> @@ -42,3 +40,7 @@ typedef int boolean_t;
> typedef struct device *device_t;
> typedef char vm_memattr_t;
> typedef struct vm_page *vm_page_t;
> +
> +#else /* !_SYS_TYPES_H || !_KERNEL */
> +#error "must be included via <sys/types.h> in kernel space"
> +#endif /* _SYS_TYPES_H && _KERNEL */
> diff --git a/cpukit/include/machine/_kernel_uio.h b/cpukit/include/machine/_kernel_uio.h
> index 59929cb03c..c9454e97ca 100644
> --- a/cpukit/include/machine/_kernel_uio.h
> +++ b/cpukit/include/machine/_kernel_uio.h
> @@ -39,9 +39,7 @@
> * kernel space (_KERNEL is defined before including <sys/uio.h>).
> */
>
> -#if !defined(_SYS_UIO_H_) || !defined(_KERNEL)
> -#error "must be included via <sys/uio.h> in kernel space"
> -#endif
> +#if defined(_SYS_UIO_H_) && defined(_KERNEL)
>
> struct uio {
> struct iovec *uio_iov; /* scatter/gather list */
> @@ -88,3 +86,7 @@ int uiomove_fromphys(struct vm_page *ma[], vm_offset_t offset, int n,
> struct uio *uio);
> int uiomove_nofault(void *cp, int n, struct uio *uio);
> int uiomove_object(struct vm_object *obj, off_t obj_size, struct uio *uio);
> +
> +#else /* !_SYS_UIO_H_ || !_KERNEL */
> +#error "must be included via <sys/uio.h> in kernel space"
> +#endif /* _SYS_UIO_H_ && _KERNEL */
More information about the devel
mailing list