Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 11 Sep 2012 16:10:52 +0200
From:      Tijl Coosemans <tijl@coosemans.org>
To:        Konstantin Belousov <kostikbel@gmail.com>
Cc:        freebsd-threads@freebsd.org
Subject:   Re: review stdatomic.h fixes
Message-ID:  <504F466C.4060802@coosemans.org>
In-Reply-To: <20120911134314.GK37286@deviant.kiev.zoral.com.ua>
References:  <504E3473.6010107@coosemans.org> <20120911134314.GK37286@deviant.kiev.zoral.com.ua>

next in thread | previous in thread | raw e-mail | index | archive | help
This is an OpenPGP/MIME signed message (RFC 2440 and 3156)
--------------enigCB9EA2EE7742D7CA4CCC9E9A
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

On 11-09-2012 15:43, Konstantin Belousov wrote:
> 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 somebo=
dy could
>> review.
>>
>>> Index: stdatomic.h
>>> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
>>> --- 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 =3D (value) }
>>> -#define	atomic_init(obj, value) do {					\
>>> -	(obj)->__val =3D (value);						\
>>> -} while (0)
>>> +#define	atomic_init(obj, value)		((void)((obj)->__val =3D (value)))
>>
>> atomic_init() is defined as a (generic) function returning void, so ma=
ke 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 i=
t
> is done for gcc case.

It's not an ordinary function but a generic function. The arguments can h=
ave
different types. The standard defines it as

void atomic_init( volatile A *obj, C value );

Where A can be any atomic type and C the corresponding non-atomic type.


--------------enigCB9EA2EE7742D7CA4CCC9E9A
Content-Type: application/pgp-signature; name="signature.asc"
Content-Description: OpenPGP digital signature
Content-Disposition: attachment; filename="signature.asc"

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.19 (FreeBSD)

iF4EAREIAAYFAlBPRnIACgkQfoCS2CCgtivRmwD+Iak+/vk2GqQyOE16gJlMMwmU
EsFBGGcAcN6dyeDYHVIA+wR7Hy8V3iYLY0QjdSySHrrMHYdexau9aSogRu+sNAyv
=tI/2
-----END PGP SIGNATURE-----

--------------enigCB9EA2EE7742D7CA4CCC9E9A--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?504F466C.4060802>