[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Xen-devel] [PATCH v6 02/18] Add cmpxchg16b support for x86-64




> -----Original Message-----
> From: Jan Beulich [mailto:JBeulich@xxxxxxxx]
> Sent: Monday, September 07, 2015 6:37 PM
> To: Wu, Feng
> Cc: Andrew Cooper; xen-devel@xxxxxxxxxxxxx; Keir Fraser
> Subject: RE: [PATCH v6 02/18] Add cmpxchg16b support for x86-64
> 
> >>> On 06.09.15 at 08:32, <feng.wu@xxxxxxxxx> wrote:
> >> From: Wu, Feng
> >> Sent: Sunday, September 06, 2015 2:07 PM
> >> If that is the case, what about the changes below?
> >>
> >> #define cmpxchg16b(ptr,o,n)
> >> \
> >>     ASSERT((unsigned long)ptr & 0xF == 0);
> >> \
> >>     ASSERT(sizeof(*o) == sizeof(__uint128_t))
> >> \
> >>     ASSERT(sizeof(*n) == sizeof(__uint128_t))
> >> \
> >>     __cmpxchg16b((ptr), (void *)(o), (void *)(n))
> >
> > Seems there is a build error with this change, we cannot
> > add stuff before __cmpxchg() since it needs return some
> > value to the caller. Any suggestion here?
> 
> You of course first need to make this proper C (missing semicolons)
> and convert it to a construct that is just a single statement (if
> necessary using gcc's compound expression extension).

Thanks for your suggestion. How about this?

#define cmpxchg16b(ptr,o,n)                                            \
    ( ({ ASSERT(((unsigned long)ptr & 0xF) == 0); }),                  \
      BUILD_BUG_ON(sizeof(*o) != sizeof(__uint128_t)),                 \
      BUILD_BUG_ON(sizeof(*n) != sizeof(__uint128_t)),                 \
      __cmpxchg16b((ptr), (__uint128_t *)(o), (__uint128_t *)(n)) )

Thanks,
Feng

> 
> Jan


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.