On 04/07/18 09:42, Jan Beulich wrote:
>
>> --- /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.

In response to several questions across the series, all of the common
macros now live in <xen-tools/libs.h> alongside the already-common
BUILD_BUG_ON() implementation.

~Andrew

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

Reply via email to