From owner-cvs-all@FreeBSD.ORG Tue Mar 28 20:01:05 2006 Return-Path: X-Original-To: cvs-all@freebsd.org Delivered-To: cvs-all@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 487DF16A400; Tue, 28 Mar 2006 20:01:05 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from server.baldwin.cx (66-23-211-162.clients.speedfactory.net [66.23.211.162]) by mx1.FreeBSD.org (Postfix) with ESMTP id 8D1C143D75; Tue, 28 Mar 2006 20:01:04 +0000 (GMT) (envelope-from jhb@freebsd.org) Received: from localhost (john@localhost [127.0.0.1]) by server.baldwin.cx (8.13.4/8.13.4) with ESMTP id k2SK0wJg072063; Tue, 28 Mar 2006 15:01:00 -0500 (EST) (envelope-from jhb@freebsd.org) From: John Baldwin To: "Dag-Erling =?iso-8859-1?q?Sm=F8rgrav?=" Date: Tue, 28 Mar 2006 15:01:05 -0500 User-Agent: KMail/1.9.1 References: <200603281434.k2SEYmaR031447@repoman.freebsd.org> <200603281358.26703.jhb@freebsd.org> <86acbawerh.fsf@xps.des.no> In-Reply-To: <86acbawerh.fsf@xps.des.no> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Message-Id: <200603281501.08699.jhb@freebsd.org> X-Virus-Scanned: ClamAV 0.87.1/1359/Tue Mar 28 06:49:08 2006 on server.baldwin.cx X-Virus-Status: Clean X-Spam-Status: No, score=-3.8 required=4.2 tests=ALL_TRUSTED,AWL,BAYES_00 autolearn=ham version=3.1.0 X-Spam-Checker-Version: SpamAssassin 3.1.0 (2005-09-13) on server.baldwin.cx Cc: cvs-src@freebsd.org, src-committers@freebsd.org, cvs-all@freebsd.org Subject: Re: cvs commit: src/sys/i386/include atomic.h X-BeenThere: cvs-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: CVS commit messages for the entire tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 28 Mar 2006 20:01:05 -0000 On Tuesday 28 March 2006 14:28, Dag-Erling Sm=F8rgrav wrote: > John Baldwin writes: > > On Tuesday 28 March 2006 13:05, Dag-Erling Sm=F8rgrav wrote: > > > John Baldwin writes: > > > > One reason for not having the casts, btw, is that you lose type > > > > checking. > > > Huh? Before my patch, any use of atomic_*_ptr with warnings turned > > > off would result in a slew of warnings because you'd be passing > > > pointers to a function which is declared to take u_int. The only way > > > to make this type safe is to use inline functions instead of the > > > macros I wrote. > > > > s/off/on/ I trust > > > > Not true. The tinderbox would attest to that. Please see code such as > > this: [...] >=20 > which uses uintptr_t, not actual pointers, to avoid warnings. In > effect, that code is broken. No, it's on _purpose_, because we do arithmetic on the value (setting flags, etc.) We happen to use curthread as our cookie value, but the cookie is an integer, not a pointer. > Apply the attached patch, see how far a buildkernel gets... Your patch could break the kernel, as it doesn't say that the value being modified is volatile (volatile void ** !=3D volatile uintptr_t *). I can't even get cdecl to tell me how to declare a pointer to a volatile void pointer. > I think the proper thing to do, to cover all your bases, would be to > define a MD atomic_*_intptr family which operated on uintptr_t, and > define an MI atomic_*_ptr family which operates on void * based on > that. *sigh* Where were you 6 months ago when I changed atomic_foo_ptr() to use uintptr_t rather than void *? (For very valid reasons you haven't bothered to research?) > > Even userland uses casts when it uses void * rather than uintptr_t for > > the underlying type. See src/lib/libpthread/sys/lock.c or > > src/lib/libthr/thr_umtx.h. >=20 > The latter only works because libthr is built with warnings disabled. > I just finished working on making it build at WARNS level 2; higher > levels will require a major overhaul, because the kernel interface it > uses is fundamentally broken. No, it needs to use the correct casts. We've been through this, the atomic(9) manpage covers it, etc. =2D-=20 John Baldwin <>< http://www.FreeBSD.org/~jhb/ "Power Users Use the Power to Serve" =3D http://www.FreeBSD.org