Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 22 Nov 2001 16:43:34 +0800
From:      "David Xu" <davidx@viasoft.com.cn>
To:        "John Baldwin" <jhb@FreeBSD.org>
Cc:        <freebsd-hackers@FreeBSD.org>
Subject:   Re: add some constraints in cpufunc.h
Message-ID:  <005201c17331$c603bcd0$ef01a8c0@davidwnt>
References:  <XFMail.011121113835.jhb@FreeBSD.org>

next in thread | previous in thread | raw e-mail | index | archive | help
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" <jhb@FreeBSD.org>
To: "David Xu" <davidx@viasoft.com.cn>
Cc: <freebsd-hackers@FreeBSD.org>
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 <jhb@FreeBSD.org>  <><  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




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?005201c17331$c603bcd0$ef01a8c0>