xen/bitmap: Drop unused headers
PATCH 1/1 xen/bitmap: Drop unused headers
Nothing in bitmap.h uses lib.h. Reduce to just macros.h and string.h. Drop types.h while at it, as it comes in through bitops.h
cpumask.h and nodemask.h only include kernel.h to get container_of(). Move it into macros.h where it belongs.
No functional change.
---
CC: Anthony PERARD <[email protected]>
CC: Michal Orzel <[email protected]>
CC: Jan Beulich <[email protected]>
CC: Julien Grall <[email protected]>
CC: Roger Pau Monné <[email protected]>
CC: Stefano Stabellini <[email protected]>
https://gitlab.com/xen-project/hardware/xen-staging/-/pipelines/1810741296
v2:
* Rebase by a year.
* Move container_of() too.
--- xen/include/xen/bitmap.h | 4 ++-- xen/include/xen/cpumask.h | 1 - xen/include/xen/kernel.h | 12 ------------ xen/include/xen/macros.h | 13 +++++++++++++ xen/include/xen/nodemask.h | 1 - 5 files changed, 15 insertions(+), 16 deletions(-)
xen/include/xen/bitmap.h +2 -2
@@ -3,9 +3,9 @@#ifndef __ASSEMBLY__ -#include <xen/lib.h> -#include <xen/types.h> #include <xen/bitops.h> +#include <xen/macros.h> +#include <xen/string.h> /* * bitmaps provide bit arrays that consume one or more unsigned
xen/include/xen/cpumask.h +0 -1
@@ -57,7 +57,6 @@#include <xen/bitmap.h> #include <xen/bug.h> -#include <xen/kernel.h> #include <xen/random.h> typedef struct cpumask{ DECLARE_BITMAP(bits, NR_CPUS); } cpumask_t;
xen/include/xen/kernel.h +0 -12
@@ -8,18 +8,6 @@#include <xen/macros.h> #include <xen/types.h> -/** -* container_of - cast a member of a structure out to the containing structure -* -* @ptr: the pointer to the member. -* @type: the type of the container struct this is embedded in. -* @member: the name of the member within the struct. -* -*/ -#define container_of (ptr, type, member) ({ \ - typeof_field(type, member) *__mptr = (ptr); \ - (type *)( (char *)__mptr - offsetof(type,member) );}) -/** * __struct_group() - Create a mirrored named and anonyomous struct *
xen/include/xen/macros.h +13 -0
@@ -102,6 +102,19 @@*/ #define sizeof_field (type, member) sizeof(((type *)NULL)->member) +/** +* container_of - cast a member of a structure out to the containing structure +* +* @ptr: the pointer to the member. +* @type: the type of the container struct this is embedded in. +* @member: the name of the member within the struct. +*/ +#define container_of (ptr, type, member) \ + ({ \ + typeof_field(type, member) *__mptr = (ptr); \ + (type *)((void *)__mptr - offsetof(type, member)); \ + }) +/* Cast an arbitrary integer to a pointer. */ #define _p (x) ((void *)(unsigned long)(x))
xen/include/xen/nodemask.h +0 -1
@@ -53,7 +53,6 @@* for_each_online_node(node) for-loop node over node_online_map */ -#include <xen/kernel.h> #include <xen/bitmap.h> #include <xen/numa.h>
Signature · 1 line
2.39.5
Hi Andrew,
Quoted 5 lines · Andrew Cooper
Nothing in
bitmap.huseslib.h. Reduce to justmacros.handstring.h. Droptypes.hwhile at it, as it comes in throughbitops.h
cpumask.handnodemask.honly includekernel.hto getcontainer_of(). Move it intomacros.hwhere it belongs.
The wording implies that container_of() will be moved as-is (barring coding style). However...
[...]
xen/include/xen/kernel.h line 22
Quoted 12 lines
xen/include/xen/kernel.h +0
-12-/** -* container_of - cast a member of a structure out to the containing structure -* -* @ptr: the pointer to the member. -* @type: the type of the container struct this is embedded in. -* @member: the name of the member within the struct. -* -*/ -#define container_of (ptr, type, member) ({ \ - typeof_field(type, member) *__mptr = (ptr); \ - (type *)( (char *)__mptr - offsetof(type,member) );}) -
I see the cast was switch from "char *" to ...
Quoted 12 lines
/**
*__struct_group()- Create a mirrored named and anonyomous struct *xen/include/xen/macros.h +1
-0@@ -102,6 +102,19 @@*/ #define sizeof_field (type, member) sizeof(((type *)NULL)->member) +/**
xen/include/xen/macros.h line 115
Quoted 10 lines
xen/include/xen/macros.h +10
-0+* container_of - cast a member of a structure out to the containing structure +* +* @ptr: the pointer to the member. +* @type: the type of the container struct this is embedded in. +* @member: the name of the member within the struct. +*/ +#define container_of (ptr, type, member) \ + ({ \ + typeof_field(type, member) *__mptr = (ptr); \ + (type *)((void *)__mptr - offsetof(type, member)); \
... "void *". AFAICT, this is doesn't change anything. However, I think it is worth mentioning in the commit message to show this was intended.
With that:
Cheers,
Signature · 1 line
Julien Grall
Quoted 9 lines · Andrew Cooper
Nothing in
bitmap.huseslib.h. Reduce to justmacros.handstring.h. Droptypes.hwhile at it, as it comes in throughbitops.h
cpumask.handnodemask.honly includekernel.hto getcontainer_of(). Move it intomacros.hwhere it belongs.No functional change.
Signed-off-by Andrew Cooper <[email protected]>
Thanks, Roger.