From owner-freebsd-threads@FreeBSD.ORG Mon Sep 10 11:10:17 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 A22BB10656D0 for ; Mon, 10 Sep 2012 11:10:17 +0000 (UTC) (envelope-from owner-bugmaster@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by mx1.freebsd.org (Postfix) with ESMTP id 736208FC1A for ; Mon, 10 Sep 2012 11:10:17 +0000 (UTC) Received: from freefall.freebsd.org (localhost [127.0.0.1]) by freefall.freebsd.org (8.14.5/8.14.5) with ESMTP id q8ABAHlc073283 for ; Mon, 10 Sep 2012 11:10:17 GMT (envelope-from owner-bugmaster@FreeBSD.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.5/8.14.5/Submit) id q8ABAFJD072929 for freebsd-threads@FreeBSD.org; Mon, 10 Sep 2012 11:10:15 GMT (envelope-from owner-bugmaster@FreeBSD.org) Date: Mon, 10 Sep 2012 11:10:15 GMT Message-Id: <201209101110.q8ABAFJD072929@freefall.freebsd.org> X-Authentication-Warning: freefall.freebsd.org: gnats set sender to owner-bugmaster@FreeBSD.org using -f From: FreeBSD bugmaster To: freebsd-threads@FreeBSD.org Cc: Subject: Current problem reports assigned to freebsd-threads@FreeBSD.org 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: Mon, 10 Sep 2012 11:10:17 -0000 Note: to view an individual PR, use: http://www.freebsd.org/cgi/query-pr.cgi?pr=(number). The following is a listing of current problems submitted by FreeBSD users. These represent problem reports covering all versions including experimental development code and obsolete releases. S Tracker Resp. Description -------------------------------------------------------------------------------- o threa/168417 threads pthread_getcpuclockid() does not work to specification o threa/165173 threads [build] clang buildworld breaks libthr o threa/163512 threads libc defaults to single threaded o threa/160708 threads possible security problem with RLIMIT_VMEM o threa/150959 threads [libc] Stub pthread_once in libc should call _libc_onc o threa/148515 threads Memory / syslog strangeness in FreeBSD 8.x ( possible o threa/141721 threads rtprio(1): (id|rt)prio priority resets when new thread o threa/135673 threads databases/mysql50-server - MySQL query lock-ups on 7.2 o threa/128922 threads threads hang with xorg running o threa/122923 threads 'nice' does not prevent background process from steali o threa/121336 threads lang/neko threading ok on UP, broken on SMP (FreeBSD 7 o threa/116668 threads can no longer use jdk15 with libthr on -stable SMP o threa/115211 threads pthread_atfork misbehaves in initial thread o threa/110636 threads [request] gdb(1): using gdb with multi thread applicat o threa/110306 threads apache 2.0 segmentation violation when calling gethost o threa/103975 threads Implicit loading/unloading of libpthread.so may crash o threa/101323 threads [patch] fork(2) in threaded programs broken. o threa/80992 threads abort() sometimes not caught by gdb depending on threa o threa/79683 threads svctcp_create() fails if multiple threads call at the s threa/76694 threads fork cause hang in dup()/close() function in child (-l s threa/30464 threads [patch] pthread mutex attributes -- pshared 21 problems total. From owner-freebsd-threads@FreeBSD.ORG Mon Sep 10 18:43:13 2012 Return-Path: Delivered-To: freebsd-threads@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 1F6A7106566C for ; Mon, 10 Sep 2012 18:43:13 +0000 (UTC) (envelope-from tijl@coosemans.org) Received: from mailrelay004.isp.belgacom.be (mailrelay004.isp.belgacom.be [195.238.6.170]) by mx1.freebsd.org (Postfix) with ESMTP id 2F6028FC19 for ; Mon, 10 Sep 2012 18:43:11 +0000 (UTC) X-Belgacom-Dynamic: yes X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AicFAA0zTlBbsUTc/2dsb2JhbABFuAeDO4EIgiABAQQoLyIGNxYYAwIBAgEnMQgBAYgGCpoqoS+RSQOOZYEglXWCaA Received: from 220.68-177-91.adsl-dyn.isp.belgacom.be (HELO kalimero.tijl.coosemans.org) ([91.177.68.220]) by relay.skynet.be with ESMTP; 10 Sep 2012 20:42:01 +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 q8AIg0gT025112 for ; Mon, 10 Sep 2012 20:42:00 +0200 (CEST) (envelope-from tijl@coosemans.org) Message-ID: <504E3473.6010107@coosemans.org> Date: Mon, 10 Sep 2012 20:41:55 +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: freebsd-threads@freebsd.org X-Enigmail-Version: 1.4.2 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="------------enig83B97E350A1AAB484E25EDE0" Subject: 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: Mon, 10 Sep 2012 18:43:13 -0000 This is an OpenPGP/MIME signed message (RFC 2440 and 3156) --------------enig83B97E350A1AAB484E25EDE0 Content-Type: multipart/mixed; boundary="------------060506060407090809070302" This is a multi-part message in MIME format. --------------060506060407090809070302 Content-Type: text/plain; charset=ISO-8859-15 Content-Transfer-Encoding: quoted-printable Hi, Below is a patch+descriptions for stdatomic.h that I was hoping somebody = 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 make = this a void expression instead of using do-while. > #endif > =20 > /* > @@ -111,8 +109,9 @@ > #define atomic_thread_fence(order) __atomic_thread_fence(order) > #define atomic_signal_fence(order) __atomic_signal_fence(order) > #else > -#define atomic_thread_fence(order) __sync_synchronize() > -#define atomic_signal_fence(order) __asm volatile ("" : : : "memory") > +#define atomic_thread_fence(order) ((void)(order), __sync_synchronize(= )) > +#define atomic_signal_fence(order) \ > + __extension__ ({ (void)(order); __asm volatile ("" ::: "memory"); (vo= id)0; }) These are defined as ordinary functions returning void so turn these into= void expressions and evaluate the argument. Because these are ordinary functions they should also be added to libc, but that's not part of this patch. > #endif > =20 > /* > @@ -121,13 +120,13 @@ > =20 > #if defined(__CLANG_ATOMICS) > #define atomic_is_lock_free(obj) \ > - __c11_atomic_is_lock_free(sizeof(obj)) > + ((void)(obj), __c11_atomic_is_lock_free(sizeof(*(obj)))) Evaluate the argument and add a * because obj is the address of an atomic= variable. > #elif defined(__GNUC_ATOMICS) > #define atomic_is_lock_free(obj) \ > - __atomic_is_lock_free(sizeof((obj)->__val)) > + __atomic_is_lock_free(sizeof((obj)->__val), &(obj)->val) Add a second argument following GCC documentation. > #else > #define atomic_is_lock_free(obj) \ > - (sizeof((obj)->__val) <=3D sizeof(void *)) > + ((void)(obj), sizeof((obj)->__val) <=3D sizeof(void *)) Evaluate the argument. > #endif > =20 > /* > @@ -234,13 +233,17 @@ > __atomic_store_n(&(object)->__val, desired, order) > #else > #define atomic_compare_exchange_strong_explicit(object, expected, \ > - desired, success, failure) ({ \ > + desired, success, failure) __extension__ ({ \ > __typeof__((object)->__val) __v; \ > + __typeof__(expected) __e; \ > _Bool __r; \ > + __e =3D (expected); \ > + (void)(success); \ > + (void)(failure); \ > __v =3D __sync_val_compare_and_swap(&(object)->__val, \ > - *(expected), desired); \ > - __r =3D *(expected) =3D=3D __v; \ > - *(expected) =3D __v; \ > + *__e, desired); \ > + __r =3D (*__e =3D=3D __v); \ > + *__e =3D __v; \ > __r; \ > }) Evaluate "success" and "failure" and evaluate "expected" only once. > =20 > @@ -251,18 +254,20 @@ > #if __has_builtin(__sync_swap) > /* Clang provides a full-barrier atomic exchange - use it if available= =2E */ > #define atomic_exchange_explicit(object, desired, order) \ > - __sync_swap(&(object)->__val, desired) > + ((void)(order), __sync_swap(&(object)->__val, desired)) Evaluate argument. > #else > /* > * __sync_lock_test_and_set() is only an acquire barrier in theory (al= though in > - * practice it is usually a full barrier) so we need an explicit barri= er after > + * practice it is usually a full barrier) so we need an explicit barri= er before It's missing a release barrier so I think the extra barrier has to be put= before not after. A store with a release barrier for instance guarantees that all previous loads and stores are satisfied before doing the store. That should give the implementation below acquire-release semantics but I'm not sure it's sequentially consistent. > * it. > */ > -#define atomic_exchange_explicit(object, desired, order) ({ \ > - __typeof__((object)->__val) __v; \ > - __v =3D __sync_lock_test_and_set(&(object)->__val, desired); \ > +#define atomic_exchange_explicit(object, desired, order) \ > +__extension__ ({ \ > + __typeof__(object) __o =3D (object); \ > + __typeof__(desired) __d =3D (desired); \ > + (void)(order); \ > __sync_synchronize(); \ > - __v; \ > + __sync_lock_test_and_set(&(__o)->__val, __d); \ > }) The standard doesn't define what a generic function is, but I assume that= like an ordinary function it has a sequence point between the evaluation of the arguments and the function body. So evaluate all arguments before the barrier. Also, __sync_lock_test_and_set doesn't perform an exchange on all architectures so I think this macro should only be defined for architectures where it's guaranteed to work and undefined otherwise. > #endif > #define atomic_fetch_add_explicit(object, operand, order) \ > @@ -277,11 +282,14 @@ > __sync_fetch_and_xor(&(object)->__val, operand) > #define atomic_load_explicit(object, order) \ > __sync_fetch_and_add(&(object)->__val, 0) > -#define atomic_store_explicit(object, desired, order) do { \ > +#define atomic_store_explicit(object, desired, order) __extension__ ({= \ > + __typeof__(object) __o =3D (object); \ > + __typeof__(desired) __d =3D (desired); \ > + (void)(order); \ > __sync_synchronize(); \ > - (object)->__val =3D (desired); \ > + __o->__val =3D __d; \ > __sync_synchronize(); \ > -} while (0) > +}) > #endif > =20 > /* Evaluate all arguments before the barrier and turn this into a void expression. The assignment isn't guaranteed to be atomic (e.g. 64 bit values on 32 bit architectures). So as with the exchange operation I think this macro should only be defined if it's guaranteed to work in all cases. Atomics are hard enough to get right that we shouldn't have implementations that can fail sporadically. In my opinion if a programmer wants to use c11 atomics he should use a c11 compiler, so there's nothing wrong with leaving some operations undefined for older compilers. The implementation of the atomic_flag type and functions needs some work too. The type is currently defined as atomic_bool, but it should be a plain structure type. The difference is that atomic_bool can be used in expressions and atomic_flag cannot. --------------060506060407090809070302 Content-Type: text/plain; charset=ISO-8859-15; name="stdatomic.h.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="stdatomic.h.patch" 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))) #endif =20 /* @@ -111,8 +109,9 @@ #define atomic_thread_fence(order) __atomic_thread_fence(order) #define atomic_signal_fence(order) __atomic_signal_fence(order) #else -#define atomic_thread_fence(order) __sync_synchronize() -#define atomic_signal_fence(order) __asm volatile ("" : : : "memory") +#define atomic_thread_fence(order) ((void)(order), __sync_synchronize())= +#define atomic_signal_fence(order) \ + __extension__ ({ (void)(order); __asm volatile ("" ::: "memory"); (void= )0; }) #endif =20 /* @@ -121,13 +120,13 @@ =20 #if defined(__CLANG_ATOMICS) #define atomic_is_lock_free(obj) \ - __c11_atomic_is_lock_free(sizeof(obj)) + ((void)(obj), __c11_atomic_is_lock_free(sizeof(*(obj)))) #elif defined(__GNUC_ATOMICS) #define atomic_is_lock_free(obj) \ - __atomic_is_lock_free(sizeof((obj)->__val)) + __atomic_is_lock_free(sizeof((obj)->__val), &(obj)->val) #else #define atomic_is_lock_free(obj) \ - (sizeof((obj)->__val) <=3D sizeof(void *)) + ((void)(obj), sizeof((obj)->__val) <=3D sizeof(void *)) #endif =20 /* @@ -234,13 +233,17 @@ __atomic_store_n(&(object)->__val, desired, order) #else #define atomic_compare_exchange_strong_explicit(object, expected, \ - desired, success, failure) ({ \ + desired, success, failure) __extension__ ({ \ __typeof__((object)->__val) __v; \ + __typeof__(expected) __e; \ _Bool __r; \ + __e =3D (expected); \ + (void)(success); \ + (void)(failure); \ __v =3D __sync_val_compare_and_swap(&(object)->__val, \ - *(expected), desired); \ - __r =3D *(expected) =3D=3D __v; \ - *(expected) =3D __v; \ + *__e, desired); \ + __r =3D (*__e =3D=3D __v); \ + *__e =3D __v; \ __r; \ }) =20 @@ -251,18 +254,20 @@ #if __has_builtin(__sync_swap) /* Clang provides a full-barrier atomic exchange - use it if available. = */ #define atomic_exchange_explicit(object, desired, order) \ - __sync_swap(&(object)->__val, desired) + ((void)(order), __sync_swap(&(object)->__val, desired)) #else /* * __sync_lock_test_and_set() is only an acquire barrier in theory (alth= ough in - * practice it is usually a full barrier) so we need an explicit barrier= after + * practice it is usually a full barrier) so we need an explicit barrier= before * it. */ -#define atomic_exchange_explicit(object, desired, order) ({ \ - __typeof__((object)->__val) __v; \ - __v =3D __sync_lock_test_and_set(&(object)->__val, desired); \ +#define atomic_exchange_explicit(object, desired, order) \ +__extension__ ({ \ + __typeof__(object) __o =3D (object); \ + __typeof__(desired) __d =3D (desired); \ + (void)(order); \ __sync_synchronize(); \ - __v; \ + __sync_lock_test_and_set(&(__o)->__val, __d); \ }) #endif #define atomic_fetch_add_explicit(object, operand, order) \ @@ -277,11 +282,14 @@ __sync_fetch_and_xor(&(object)->__val, operand) #define atomic_load_explicit(object, order) \ __sync_fetch_and_add(&(object)->__val, 0) -#define atomic_store_explicit(object, desired, order) do { \ +#define atomic_store_explicit(object, desired, order) __extension__ ({ \= + __typeof__(object) __o =3D (object); \ + __typeof__(desired) __d =3D (desired); \ + (void)(order); \ __sync_synchronize(); \ - (object)->__val =3D (desired); \ + __o->__val =3D __d; \ __sync_synchronize(); \ -} while (0) +}) #endif =20 /* --------------060506060407090809070302-- --------------enig83B97E350A1AAB484E25EDE0 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) iF4EAREIAAYFAlBONHgACgkQfoCS2CCgtitnoAD/UCPkEEiwf5oGO9042MXEIy3s lfQbpzuCwyyvTXJRUWMA/jm2qIo81f+Rb94ALoJsgHRk/KqSAb3fcpbVC8VbbPWG =4Yq1 -----END PGP SIGNATURE----- --------------enig83B97E350A1AAB484E25EDE0-- From owner-freebsd-threads@FreeBSD.ORG Tue Sep 11 13:43:20 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 AFA5E106566B for ; Tue, 11 Sep 2012 13:43:20 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from mail.zoral.com.ua (mx0.zoral.com.ua [91.193.166.200]) by mx1.freebsd.org (Postfix) with ESMTP id EA26F8FC0A for ; Tue, 11 Sep 2012 13:43:19 +0000 (UTC) Received: from skuns.kiev.zoral.com.ua (localhost [127.0.0.1]) by mail.zoral.com.ua (8.14.2/8.14.2) with ESMTP id q8BDhQIG058317; Tue, 11 Sep 2012 16:43:26 +0300 (EEST) (envelope-from kostikbel@gmail.com) Received: from deviant.kiev.zoral.com.ua (kostik@localhost [127.0.0.1]) by deviant.kiev.zoral.com.ua (8.14.5/8.14.5) with ESMTP id q8BDhEsg004447; Tue, 11 Sep 2012 16:43:14 +0300 (EEST) (envelope-from kostikbel@gmail.com) Received: (from kostik@localhost) by deviant.kiev.zoral.com.ua (8.14.5/8.14.5/Submit) id q8BDhEU7004446; Tue, 11 Sep 2012 16:43:14 +0300 (EEST) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: deviant.kiev.zoral.com.ua: kostik set sender to kostikbel@gmail.com using -f Date: Tue, 11 Sep 2012 16:43:14 +0300 From: Konstantin Belousov To: Tijl Coosemans Message-ID: <20120911134314.GK37286@deviant.kiev.zoral.com.ua> References: <504E3473.6010107@coosemans.org> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="VSVNCtZB1QZ8vhj+" Content-Disposition: inline In-Reply-To: <504E3473.6010107@coosemans.org> User-Agent: Mutt/1.5.21 (2010-09-15) X-Virus-Scanned: clamav-milter 0.95.2 at skuns.kiev.zoral.com.ua X-Virus-Status: Clean X-Spam-Status: No, score=-4.0 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00 autolearn=ham version=3.2.5 X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on skuns.kiev.zoral.com.ua 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 13:43:20 -0000 --VSVNCtZB1QZ8vhj+ Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Mon, Sep 10, 2012 at 08:41:55PM +0200, Tijl Coosemans wrote: > Hi, >=20 > Below is a patch+descriptions for stdatomic.h that I was hoping somebody = could > review. >=20 > > 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))) >=20 > 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. --VSVNCtZB1QZ8vhj+ Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.12 (FreeBSD) iEYEARECAAYFAlBPP/IACgkQC3+MBN1Mb4i4wwCgyJlE/0GkRGdhNXaEfu1JJK+O lfUAn048+EY+ZpZ8PUNilCh+vtf2ScL/ =Ve7l -----END PGP SIGNATURE----- --VSVNCtZB1QZ8vhj+-- 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--