On 23.05.2022 12:07, Roger Pau Monné wrote: > On Mon, May 23, 2022 at 05:52:17AM -0400, Lin Liu wrote: >> diff --git a/xen/include/xen/compiler.h b/xen/include/xen/compiler.h >> index 933aec09a9..ae029afa14 100644 >> --- a/xen/include/xen/compiler.h >> +++ b/xen/include/xen/compiler.h >> @@ -185,4 +185,28 @@ >> # define CLANG_DISABLE_WARN_GCC_COMPAT_END >> #endif >> >> +#ifndef __has_builtin >> +/* >> + * Backwards compatibility for GCC < 10. >> + * All supported versions of Clang support __has_builtin >> + * */ >> +#define __has_builtin(x) GCC_has ## x >> + >> +#define GCC_has__builtin_bswap16 (CONFIG_GCC_VERSION >= 40800) >> +#define GCC_has__builtin_bswap32 (CONFIG_GCC_VERSION >= 40400) >> +#define GCC_has__builtin_bswap64 (CONFIG_GCC_VERSION >= 40400) >> +#endif >> + >> +#ifndef __ORDER_LITTLE_ENDIAN__ >> +# define __ORDER_LITTLE_ENDIAN__ 1234 >> +#endif >> + >> +#ifndef __ORDER_BIG_ENDIAN__ >> +# define __ORDER_BIG_ENDIAN__ 4321 >> +#endif >> + >> +/* Indirect macros required for expanded argument pasting. */ >> +#define PASTE_(a, b) a ## b >> +#define PASTE(a, b) PASTE_(a, b) > > I think it would be better if byteswap.h included lib.h, rather than > moving the PASTE define into compiler.h.
+1 > Likewise the __ORDER_{BIG,LITTLE}_ENDIAN__ defines would be better > placed in byteswap.h itself if possible IMO, since it's not strictly > related to the compiler. These need to live in per-arch headers, i.e. asm/byteorder.h. Jan