>>> On 03.07.18 at 22:55, <andrew.coop...@citrix.com> wrote:
> From: Roger Pau Monné <roger....@citrix.com>
> 
> Move x86_cpuid_lookup_deep_deps() into the shared library, removing the
> individual copies from the hypervisor and libxc respectively.
> 
> Signed-off-by: Roger Pau Monné <roger....@citrix.com>
> Signed-off-by: Andrew Cooper <andrew.coop...@citrix.com>
> ---
> CC: Jan Beulich <jbeul...@suse.com>
> CC: Wei Liu <wei.l...@citrix.com>
> CC: Roger Pau Monné <roger....@citrix.com>
> CC: Sergey Dyasli <sergey.dya...@citrix.com>
> CC: Ian Jackson <ian.jack...@eu.citrix.com>
> ---
>  tools/libxc/Makefile               |  5 +++++
>  tools/libxc/include/xenctrl.h      |  1 -
>  tools/libxc/xc_cpuid_x86.c         | 29 +------------------------
>  xen/arch/x86/cpu/common.c          |  2 +-
>  xen/arch/x86/cpuid.c               | 32 +--------------------------
>  xen/common/Makefile                |  1 +
>  xen/common/libx86/Makefile         |  1 +
>  xen/common/libx86/cpuid.c          | 44 
> ++++++++++++++++++++++++++++++++++++++
>  xen/common/libx86/libx86-private.h | 42 ++++++++++++++++++++++++++++++++++++

I'm pretty opposed to redundancies in names like this - why can't
this simply be private.h - its placement in the tree makes clear
whose private header this is.

> --- /dev/null
> +++ b/xen/common/libx86/libx86-private.h
> @@ -0,0 +1,42 @@
> +#ifndef XEN_LIBX86_PRIVATE_H
> +#define XEN_LIBX86_PRIVATE_H
> +
> +#ifdef __XEN__
> +
> +#include <xen/bitops.h>
> +#include <xen/kernel.h>
> +#include <xen/lib.h>
> +#include <xen/types.h>
> +
> +#else
> +
> +#include <inttypes.h>
> +#include <stdbool.h>
> +#include <stddef.h>
> +
> +#include <xen-tools/libs.h>
> +
> +#define MAX(x, y) ((x) > (y) ? (x) : (y))
> +
> +#define ARRAY_SIZE(x) (sizeof x / sizeof *x)
> +
> +static inline bool test_bit(unsigned int bit, const void *vaddr)
> +{
> +    const char *addr = vaddr;
> +
> +    return addr[bit / 8] & (1u << (bit % 8));
> +}
> +
> +#endif /* __XEN__ */
> +
> +#endif /* XEN_LIBX86_PRIVATE_H */

Did you consider making this x86-independent but still shared?
None of the above is x86-specific. libelf could then possibly use
this too, for exampled.

Also I think we pretty consistently use sizeof(x), not sizeof x, so
I'd like to ask that ARRAY_SIZE() be adjusted accordingly.

Jan


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

Reply via email to