[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [Xen-devel] [PATCH v6 03/10] public: xen.h: add definitions for UUID handling
>>> On 03.10.17 at 14:15, <julien.grall@xxxxxxx> wrote: > On 21/09/17 20:59, Volodymyr Babchuk wrote: >> --- a/xen/include/public/xen.h >> +++ b/xen/include/public/xen.h >> @@ -930,6 +930,33 @@ __DEFINE_XEN_GUEST_HANDLE(uint16, uint16_t); >> __DEFINE_XEN_GUEST_HANDLE(uint32, uint32_t); >> __DEFINE_XEN_GUEST_HANDLE(uint64, uint64_t); >> >> +typedef struct >> +{ >> + uint8_t a[16]; >> +} xen_uuid_t; >> + >> +#if defined(__GNUC__) && !defined(__STRICT_ANSI__) >> + >> +#define XEN_DEFINE_UUID(a, b, c, d, e1, e2, e3, e4, e5, e6) \ >> + (xen_uuid_t){{((a) >> 24) & 0xFF, ((a) >> 16) & 0xFF, \ >> + ((a) >> 8) & 0xFF, ((a) >> 0) & 0xFF, \ >> + ((b) >> 8) & 0xFF, ((b) >> 0) & 0xFF, \ >> + ((c) >> 8) & 0xFF, ((c) >> 0) & 0xFF, \ >> + ((d) >> 8) & 0xFF, ((d) >> 0) & 0xFF, \ >> + e1, e2, e3, e4, e5, e6}} >> + >> +#else >> + >> +#define XEN_DEFINE_UUID(a, b, c, d, e1, e2, e3, e4, e5, e6) \ >> + {{((a) >> 24) & 0xFF, ((a) >> 16) & 0xFF, \ >> + ((a) >> 8) & 0xFF, ((a) >> 0) & 0xFF, \ >> + ((b) >> 8) & 0xFF, ((b) >> 0) & 0xFF, \ >> + ((c) >> 8) & 0xFF, ((c) >> 0) & 0xFF, \ >> + ((d) >> 8) & 0xFF, ((d) >> 0) & 0xFF, \ >> + e1, e2, e3, e4, e5, e6}} > > The only difference between the two macros is the former is having the > cast whilst the latter not. > > How about factorizing the code, i.e: > > #define __XEN_DEFINE_UUID(a, b, c, d, e1, e2, e3, e4, e5, e6) > {{ ... }} > > #if defined(....) > > #define XEN_DEFINE_UUID(a, b, c, d, e1, e2, e3, e4, e5, e6) \ > (xen_uuid_t)__XEN_DEFINE_UUID(a, b, c, d, ...) > > #else > > #define XEN_DEFINE_UUID(....) __XEN_DEFINE_UUID(...) > > Any opinons? I think this would render things more readable. But the helper macro must not use a reserved name (i.e. neither two leading underscores nor a single one followed by an upper case X is acceptable). I'd recommend a trailing underscore here. Jan _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxx https://lists.xen.org/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |