diff options
author | Bruce Evans <bde@FreeBSD.org> | 1995-07-25 21:28:47 +0000 |
---|---|---|
committer | Bruce Evans <bde@FreeBSD.org> | 1995-07-25 21:28:47 +0000 |
commit | 8089a0432e822e6ac9d177ba3dd0e62a171b620e (patch) | |
tree | cbf230d8b047b36d59fc858fd2428464ac1af46f | |
parent | 72f97bfa5bfd550ac22b662131b3fc5f5e690923 (diff) | |
download | src-8089a0432e822e6ac9d177ba3dd0e62a171b620e.tar.gz src-8089a0432e822e6ac9d177ba3dd0e62a171b620e.zip |
Fix bogus constraint "i" that only worked with -O. The cases where it
didn't work are somewhat bogusly optimized away before the constraint
is checked. We still expect constants passed to inline functions to
remain constant, but if the compiler ever decides that they aren't
constant then it will just generate slightly slower code instead of
an error.
Notes
Notes:
svn path=/head/; revision=9714
-rw-r--r-- | sys/amd64/include/cpufunc.h | 12 | ||||
-rw-r--r-- | sys/i386/include/cpufunc.h | 12 |
2 files changed, 18 insertions, 6 deletions
diff --git a/sys/amd64/include/cpufunc.h b/sys/amd64/include/cpufunc.h index 576ba23e26c8..117b59eb4739 100644 --- a/sys/amd64/include/cpufunc.h +++ b/sys/amd64/include/cpufunc.h @@ -30,7 +30,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: cpufunc.h,v 1.36 1995/05/14 22:25:11 davidg Exp $ + * $Id: cpufunc.h,v 1.37 1995/05/30 08:00:30 rgrimes Exp $ */ /* @@ -101,6 +101,12 @@ ffs(int mask) #else /* __GNUC >= 2 */ /* + * The following complications are to get around gcc not having a + * constraint letter for the range 0..255. We still put "d" in the + * constraint because "i" isn't a valid constraint when the port + * isn't constant. This only matters for -O0 because otherwise + * the non-working version gets optimized away. + * * Use an expression-statement instead of a conditional expression * because gcc-2.6.0 would promote the operands of the conditional * and produce poor code for "if ((inb(var) & const1) == const2)". @@ -122,14 +128,14 @@ inbc(u_int port) { u_char data; - __asm __volatile("inb %1,%0" : "=a" (data) : "i" (port)); + __asm __volatile("inb %1,%0" : "=a" (data) : "id" ((u_short)(port))); return (data); } static __inline void outbc(u_int port, u_char data) { - __asm __volatile("outb %0,%1" : : "a" (data), "i" (port)); + __asm __volatile("outb %0,%1" : : "a" (data), "id" ((u_short)(port))); } #endif /* __GNUC <= 2 */ diff --git a/sys/i386/include/cpufunc.h b/sys/i386/include/cpufunc.h index 576ba23e26c8..117b59eb4739 100644 --- a/sys/i386/include/cpufunc.h +++ b/sys/i386/include/cpufunc.h @@ -30,7 +30,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: cpufunc.h,v 1.36 1995/05/14 22:25:11 davidg Exp $ + * $Id: cpufunc.h,v 1.37 1995/05/30 08:00:30 rgrimes Exp $ */ /* @@ -101,6 +101,12 @@ ffs(int mask) #else /* __GNUC >= 2 */ /* + * The following complications are to get around gcc not having a + * constraint letter for the range 0..255. We still put "d" in the + * constraint because "i" isn't a valid constraint when the port + * isn't constant. This only matters for -O0 because otherwise + * the non-working version gets optimized away. + * * Use an expression-statement instead of a conditional expression * because gcc-2.6.0 would promote the operands of the conditional * and produce poor code for "if ((inb(var) & const1) == const2)". @@ -122,14 +128,14 @@ inbc(u_int port) { u_char data; - __asm __volatile("inb %1,%0" : "=a" (data) : "i" (port)); + __asm __volatile("inb %1,%0" : "=a" (data) : "id" ((u_short)(port))); return (data); } static __inline void outbc(u_int port, u_char data) { - __asm __volatile("outb %0,%1" : : "a" (data), "i" (port)); + __asm __volatile("outb %0,%1" : : "a" (data), "id" ((u_short)(port))); } #endif /* __GNUC <= 2 */ |