review stdatomic.h fixes

Konstantin Belousov kostikbel at gmail.com
Tue Sep 11 13:43:20 UTC 2012


On Mon, Sep 10, 2012 at 08:41:55PM +0200, Tijl Coosemans wrote:
> Hi,
> 
> Below is a patch+descriptions for stdatomic.h that I was hoping somebody could
> review.
> 
> > Index: stdatomic.h
> > ===================================================================
> > --- stdatomic.h	(revision 240316)
> > +++ stdatomic.h	(working copy)
> > @@ -54,9 +54,7 @@
> >  #define	atomic_init(obj, value)		__c11_atomic_init(obj, value)
> >  #else
> >  #define	ATOMIC_VAR_INIT(value)		{ .__val = (value) }
> > -#define	atomic_init(obj, value) do {					\
> > -	(obj)->__val = (value);						\
> > -} while (0)
> > +#define	atomic_init(obj, value)		((void)((obj)->__val = (value)))
> 
> atomic_init() is defined as a (generic) function returning void, so make this
> a void expression instead of using do-while.
Why not define it as static inline function for real ? For some symbols,
e.g.atomic_is_lock_free(), you would need both function and macro, as it
is done for gcc case.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 196 bytes
Desc: not available
Url : http://lists.freebsd.org/pipermail/freebsd-threads/attachments/20120911/8594ca9f/attachment.pgp


More information about the freebsd-threads mailing list