On Thu, Sep 04, 2014 at 08:42:44AM -0700, Jarno Rajahalme wrote: > Small nits below, otherwise looks good to me (even though I?m not versed in > MSVC), > > Signed-off-by: Jarno Rajahalme <jrajaha...@nicira.com> > > On Sep 3, 2014, at 1:08 PM, Gurucharan Shetty <shet...@nicira.com> wrote: > > > > +/* 64 bit writes are atomic on i586 if 64 bit aligned. */ > > +#define atomic_store64(DST, SRC, ORDER) > > \ > > + if (((size_t) (DST) & (sizeof *(DST) - 1)) == 0) { > > \ > > + if (ORDER == memory_order_seq_cst) { > > \ > > + InterlockedExchange64((int64_t volatile *) (DST), > > \ > > + (int64_t) (SRC)); > > \ > > + } else { > > \ > > + *(DST) = (SRC); > > \ > > + } > > \ > > + } else { > > \ > > + abort(); > > \ > > + } > > + > > How about this instead: > > /* 64 bit writes are atomic on i586 if 64 bit aligned. */ > #define atomic_store64(DST, SRC, ORDER) \ > if (((size_t) (DST) & (sizeof *(DST) - 1)) \ > || ORDER == memory_order_seq_cst) { \ > InterlockedExchange64((int64_t volatile *) (DST), \ > (int64_t) (SRC)); \ > } else { \ > *(DST) = (SRC); \ > } \ > > However, you should probably keep the version in your patch if you > know that the alignment check can be computed at compile-time and/or > there is some documentation that MSVC will not align 64-bit units on > at 4-byte alignment.
http://msdn.microsoft.com/en-us/library/ee959491.aspx says that MSVC cannot align 64-bit types on 64-bit boundaries, at least on the stack: Data types that are larger than 4 bytes are not automatically aligned on the stack when you use the x86 compiler to compile an application. Because the architecture for the x86 compiler is a 4 byte aligned stack, anything larger than 4 bytes, for example, a 64-bit integer, cannot be automatically aligned to an 8-byte address. _______________________________________________ dev mailing list dev@openvswitch.org http://openvswitch.org/mailman/listinfo/dev