From: Denis Mukhin <dmukhin@ford.com>
Move xc_bitops.h to common tools location to be shared between
the toolstack and unit test code.
Adjust the guard in xen-tools/bitops.h
Correct the #include directives and comments referring to the old
xc_bitops.h in the toolstack code.
Signed-off-by: Denis Mukhin <dmukhin@ford.com>
---
Changes since v15:
- n/a
---
.../ctrl/xc_bitops.h => include/xen-tools/bitops.h} | 6 +++---
tools/libs/ctrl/xc_misc.c | 13 +++++++------
tools/libs/guest/xg_dom_elfloader.c | 3 ++-
tools/libs/guest/xg_dom_hvmloader.c | 3 ++-
tools/libs/guest/xg_private.h | 2 +-
tools/libs/guest/xg_sr_common.h | 3 +--
6 files changed, 16 insertions(+), 14 deletions(-)
rename tools/{libs/ctrl/xc_bitops.h => include/xen-tools/bitops.h} (95%)
diff --git a/tools/libs/ctrl/xc_bitops.h b/tools/include/xen-tools/bitops.h
similarity index 95%
rename from tools/libs/ctrl/xc_bitops.h
rename to tools/include/xen-tools/bitops.h
index 4a776dc3a57f..681482f6759f 100644
--- a/tools/libs/ctrl/xc_bitops.h
+++ b/tools/include/xen-tools/bitops.h
@@ -1,5 +1,5 @@
-#ifndef XC_BITOPS_H
-#define XC_BITOPS_H 1
+#ifndef __XEN_TOOLS_BITOPS_H__
+#define __XEN_TOOLS_BITOPS_H__
/* bitmap operations for single threaded access */
@@ -81,4 +81,4 @@ static inline void bitmap_or(void *_dst, const void *_other,
dst[i] |= other[i];
}
-#endif /* XC_BITOPS_H */
+#endif /* __XEN_TOOLS_BITOPS_H__ */
diff --git a/tools/libs/ctrl/xc_misc.c b/tools/libs/ctrl/xc_misc.c
index 33e87bac2868..10ddf85667a9 100644
--- a/tools/libs/ctrl/xc_misc.c
+++ b/tools/libs/ctrl/xc_misc.c
@@ -17,8 +17,8 @@
* License along with this library; If not, see <http://www.gnu.org/licenses/>.
*/
-#include "xc_bitops.h"
#include "xc_private.h"
+#include <xen-tools/bitops.h>
#include <xen/hvm/hvm_op.h>
int xc_get_max_cpus(xc_interface *xch)
@@ -94,11 +94,12 @@ xc_cpumap_t xc_cpumap_alloc(xc_interface *xch)
}
/*
- * xc_bitops.h has macros that do this as well - however they assume that
- * the bitmask is word aligned but xc_cpumap_t is only guaranteed to be
- * byte aligned and so we need byte versions for architectures which do
- * not support misaligned accesses (which is basically everyone
- * but x86, although even on x86 it can be inefficient).
+ * <xen-tools/bitops.h> has macros that do this as well - however they
+ * assume that the bitmask is word aligned but xc_cpumap_t is only
+ * guaranteed to be byte aligned and so we need byte versions for
+ * architectures which do not support misaligned accesses (which is
+ * basically everyone but x86, although even on x86 it can be
+ * inefficient).
*
* NOTE: The xc_bitops macros now use byte alignment.
* TODO: Clean up the users of this interface.
diff --git a/tools/libs/guest/xg_dom_elfloader.c b/tools/libs/guest/xg_dom_elfloader.c
index f17930d98bf7..8531e90f8e21 100644
--- a/tools/libs/guest/xg_dom_elfloader.c
+++ b/tools/libs/guest/xg_dom_elfloader.c
@@ -25,8 +25,9 @@
#include <stdarg.h>
#include <inttypes.h>
+#include <xen-tools/bitops.h>
+
#include "xg_private.h"
-#include "xc_bitops.h"
#define XEN_VER "xen-3.0"
diff --git a/tools/libs/guest/xg_dom_hvmloader.c b/tools/libs/guest/xg_dom_hvmloader.c
index 39e1e5f579a7..0f569c20c522 100644
--- a/tools/libs/guest/xg_dom_hvmloader.c
+++ b/tools/libs/guest/xg_dom_hvmloader.c
@@ -24,8 +24,9 @@
#include <inttypes.h>
#include <assert.h>
+#include <xen-tools/bitops.h>
+
#include "xg_private.h"
-#include "xc_bitops.h"
/* ------------------------------------------------------------------------ */
/* parse elf binary */
diff --git a/tools/libs/guest/xg_private.h b/tools/libs/guest/xg_private.h
index d73947094f2e..285229cf82a3 100644
--- a/tools/libs/guest/xg_private.h
+++ b/tools/libs/guest/xg_private.h
@@ -28,9 +28,9 @@
#include <sys/stat.h>
#include "xc_private.h"
-#include "xc_bitops.h"
#include "xenguest.h"
+#include <xen-tools/bitops.h>
#include <xen/memory.h>
#include <xen/elfnote.h>
#include <xen/libelf/libelf.h>
diff --git a/tools/libs/guest/xg_sr_common.h b/tools/libs/guest/xg_sr_common.h
index 2f058ee3a6ff..2e583f2eac72 100644
--- a/tools/libs/guest/xg_sr_common.h
+++ b/tools/libs/guest/xg_sr_common.h
@@ -2,11 +2,10 @@
#define __COMMON__H
#include <stdbool.h>
+#include <xen-tools/bitops.h>
#include "xg_private.h"
#include "xg_save_restore.h"
-#include "xc_bitops.h"
-
#include "xg_sr_stream_format.h"
/* String representation of Domain Header types. */
--
2.34.1
On Tue, Aug 12, 2025 at 10:30:45PM +0000, dmkhn@proton.me wrote:
> diff --git a/tools/libs/guest/xg_dom_elfloader.c b/tools/libs/guest/xg_dom_elfloader.c
> index f17930d98bf7..8531e90f8e21 100644
> --- a/tools/libs/guest/xg_dom_elfloader.c
> +++ b/tools/libs/guest/xg_dom_elfloader.c
> @@ -25,8 +25,9 @@
> #include <stdarg.h>
> #include <inttypes.h>
>
> +#include <xen-tools/bitops.h>
It doesn't looks like xg_dom_elfloader.c is using anything from
bitops.h. The last use of it was probably removed in ed04ca95981f
("libelf: rewrite symtab/strtab loading")
> +
> #include "xg_private.h"
> -#include "xc_bitops.h"
>
> #define XEN_VER "xen-3.0"
>
> diff --git a/tools/libs/guest/xg_dom_hvmloader.c b/tools/libs/guest/xg_dom_hvmloader.c
> index 39e1e5f579a7..0f569c20c522 100644
> --- a/tools/libs/guest/xg_dom_hvmloader.c
> +++ b/tools/libs/guest/xg_dom_hvmloader.c
> @@ -24,8 +24,9 @@
> #include <inttypes.h>
> #include <assert.h>
>
> +#include <xen-tools/bitops.h>
> +
I think there's two reason to remove this include:
- it doesn't looks like xg_dom_hvmloader.c is using any macro from it.
- bitops.h is already included by xg_private.h.
> #include "xg_private.h"
> -#include "xc_bitops.h"
>
> /* ------------------------------------------------------------------------ */
> /* parse elf binary */
> diff --git a/tools/libs/guest/xg_sr_common.h b/tools/libs/guest/xg_sr_common.h
> index 2f058ee3a6ff..2e583f2eac72 100644
> --- a/tools/libs/guest/xg_sr_common.h
> +++ b/tools/libs/guest/xg_sr_common.h
> @@ -2,11 +2,10 @@
> #define __COMMON__H
>
> #include <stdbool.h>
> +#include <xen-tools/bitops.h>
It's already included in xg_private.h, so this feels unnecessary.
>
> #include "xg_private.h"
> #include "xg_save_restore.h"
> -#include "xc_bitops.h"
> -
If the extraneous includes could be removed, that would be nice. In
anycase:
Acked-by: Anthony PERARD <anthony.perard@vates.tech>
Thanks,
--
Anthony PERARD
On Mon, Aug 25, 2025 at 11:30:20AM +0200, Anthony PERARD wrote:
> On Tue, Aug 12, 2025 at 10:30:45PM +0000, dmkhn@proton.me wrote:
> > diff --git a/tools/libs/guest/xg_dom_elfloader.c b/tools/libs/guest/xg_dom_elfloader.c
> > index f17930d98bf7..8531e90f8e21 100644
> > --- a/tools/libs/guest/xg_dom_elfloader.c
> > +++ b/tools/libs/guest/xg_dom_elfloader.c
> > @@ -25,8 +25,9 @@
> > #include <stdarg.h>
> > #include <inttypes.h>
> >
> > +#include <xen-tools/bitops.h>
>
> It doesn't looks like xg_dom_elfloader.c is using anything from
> bitops.h. The last use of it was probably removed in ed04ca95981f
> ("libelf: rewrite symtab/strtab loading")
Ack.
>
> > +
> > #include "xg_private.h"
> > -#include "xc_bitops.h"
> >
> > #define XEN_VER "xen-3.0"
> >
> > diff --git a/tools/libs/guest/xg_dom_hvmloader.c b/tools/libs/guest/xg_dom_hvmloader.c
> > index 39e1e5f579a7..0f569c20c522 100644
> > --- a/tools/libs/guest/xg_dom_hvmloader.c
> > +++ b/tools/libs/guest/xg_dom_hvmloader.c
> > @@ -24,8 +24,9 @@
> > #include <inttypes.h>
> > #include <assert.h>
> >
> > +#include <xen-tools/bitops.h>
> > +
>
> I think there's two reason to remove this include:
> - it doesn't looks like xg_dom_hvmloader.c is using any macro from it.
> - bitops.h is already included by xg_private.h.
Will remove.
>
>
> > #include "xg_private.h"
> > -#include "xc_bitops.h"
> >
> > /* ------------------------------------------------------------------------ */
> > /* parse elf binary */
> > diff --git a/tools/libs/guest/xg_sr_common.h b/tools/libs/guest/xg_sr_common.h
> > index 2f058ee3a6ff..2e583f2eac72 100644
> > --- a/tools/libs/guest/xg_sr_common.h
> > +++ b/tools/libs/guest/xg_sr_common.h
> > @@ -2,11 +2,10 @@
> > #define __COMMON__H
> >
> > #include <stdbool.h>
> > +#include <xen-tools/bitops.h>
>
> It's already included in xg_private.h, so this feels unnecessary.
Ack.
> >
> > #include "xg_private.h"
> > #include "xg_save_restore.h"
> > -#include "xc_bitops.h"
> > -
>
>
> If the extraneous includes could be removed, that would be nice. In
> anycase:
> Acked-by: Anthony PERARD <anthony.perard@vates.tech>
Thanks
>
> Thanks,
>
> --
> Anthony PERARD
>
© 2016 - 2025 Red Hat, Inc.