From owner-freebsd-threads@FreeBSD.ORG Tue Sep 11 14:12:08 2012 Return-Path: Delivered-To: freebsd-threads@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id DF1661065673 for ; Tue, 11 Sep 2012 14:12:08 +0000 (UTC) (envelope-from tijl@coosemans.org) Received: from mailrelay006.isp.belgacom.be (mailrelay006.isp.belgacom.be [195.238.6.172]) by mx1.freebsd.org (Postfix) with ESMTP id 6A0218FC23 for ; Tue, 11 Sep 2012 14:12:07 +0000 (UTC) X-Belgacom-Dynamic: yes X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AgEFAN9FT1BbsVPi/2dsb2JhbABFuA6DQYEIgiABAQUnLyIBEAsOCgkWDwkDAgECASceBg0BBwEBiBC8AYsQhiYDjmWBIJV1gmg Received: from 226.83-177-91.adsl-dyn.isp.belgacom.be (HELO kalimero.tijl.coosemans.org) ([91.177.83.226]) by relay.skynet.be with ESMTP; 11 Sep 2012 16:10:59 +0200 Received: from kalimero.tijl.coosemans.org (kalimero.tijl.coosemans.org [127.0.0.1]) by kalimero.tijl.coosemans.org (8.14.5/8.14.5) with ESMTP id q8BEAwNU003019; Tue, 11 Sep 2012 16:10:59 +0200 (CEST) (envelope-from tijl@coosemans.org) Message-ID: <504F466C.4060802@coosemans.org> Date: Tue, 11 Sep 2012 16:10:52 +0200 From: Tijl Coosemans User-Agent: Mozilla/5.0 (X11; FreeBSD i386; rv:14.0) Gecko/20120804 Thunderbird/14.0 MIME-Version: 1.0 To: Konstantin Belousov References: <504E3473.6010107@coosemans.org> <20120911134314.GK37286@deviant.kiev.zoral.com.ua> In-Reply-To: <20120911134314.GK37286@deviant.kiev.zoral.com.ua> X-Enigmail-Version: 1.4.2 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="------------enigCB9EA2EE7742D7CA4CCC9E9A" Cc: freebsd-threads@freebsd.org Subject: Re: review stdatomic.h fixes X-BeenThere: freebsd-threads@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Threading on FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 11 Sep 2012 14:12:09 -0000 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--