From owner-freebsd-hackers Thu Nov 22 0:47:32 2001 Delivered-To: freebsd-hackers@freebsd.org Received: from mail.viasoft.com.cn (unknown [61.153.1.177]) by hub.freebsd.org (Postfix) with ESMTP id 7C32437B418; Thu, 22 Nov 2001 00:47:27 -0800 (PST) Received: from davidwnt (davidwnt.viasoft.com.cn [192.168.1.239]) by mail.viasoft.com.cn (8.9.3/8.9.3) with SMTP id QAA23336; Thu, 22 Nov 2001 16:54:26 +0800 Message-ID: <005201c17331$c603bcd0$ef01a8c0@davidwnt> From: "David Xu" To: "John Baldwin" Cc: References: Subject: Re: add some constraints in cpufunc.h Date: Thu, 22 Nov 2001 16:43:34 +0800 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 5.00.2919.6700 X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2919.6700 Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG According to GCC manual of inline assembler instruction, it says if = your instruction changes condition code register(on X86, it's cpu flag register, and a = simple addl=20 instruction can affect it), you'd put cc there, I have reviewed some = source header files of bus management, they all have cc constraint, but others not, = and some=20 lines lost __volatile__ keyword, GCC can feel free to optimize them = and re-order=20 or delete these lines when it thinks this is a right decision, this = could be dangerous when high optimizing option is turned on. -- David Xu ----- Original Message -----=20 From: "John Baldwin" To: "David Xu" Cc: Sent: Thursday, November 22, 2001 3:38 AM Subject: RE: add some constraints in cpufunc.h >=20 > On 21-Nov-01 David Xu wrote: > > 4.4-stable, file sys/i386/include/cpufunc.h,=20 > >=20 > > --- cpufunc.h.orig Wed Nov 21 13:35:36 2001 > > +++ cpufunc.h Wed Nov 21 15:00:12 2001 > > @@ -72,7 +72,7 @@ > > { > > u_int result; > > =20 > > - __asm __volatile("bsfl %0,%0" : "=3Dr" (result) : "0" = (mask)); > > + __asm __volatile("bsfl %0,%0" : "=3Dr" (result) : "0" (mask) = : "cc"); > > return (result); > > } > > =20 > > @@ -81,7 +81,7 @@ > > { > > u_int result; > > =20 > > - __asm __volatile("bsrl %0,%0" : "=3Dr" (result) : "0" = (mask)); > > + __asm __volatile("bsrl %0,%0" : "=3Dr" (result) : "0" (mask) = : "cc"); > > return (result); > > } > > =20 > > @@ -305,7 +305,7 @@ > > u_int result; > > =20 > > __asm __volatile("xorl %0,%0; xchgl %1,%0" > > - : "=3D&r" (result) : "m" (*addr)); > > + : "=3D&r" (result) : "m" (*addr) : "cc"); > > return (result); > > } > >=20 >=20 > Have you had actual bugs as a result of "cc" not being in the = constraints? >=20 > If so, there's a _lot_ more places that need this. All the atomic = ops, for > example. >=20 > --=20 >=20 > John Baldwin <>< http://www.FreeBSD.org/~jhb/ > "Power Users Use the Power to Serve!" - http://www.FreeBSD.org/ To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message