On Thu, 7 Dec 2000 [EMAIL PROTECTED] wrote:
> I'm not a constraints expert either, but I noticed that when I try to
> build a kernel WITHOUT any optimization, I get a failure in
>
> /usr/src/sys/i386/atomic.h .
>
> # make atomic.o
> cc -c -O0 -pipe -Wall -Wredundant-decls -Wnested-externs
> ...
> /usr/src/sys/i386/i386/atomic.c
> In file included from /usr/src/sys/i386/i386/atomic.c:48:
> machine/atomic.h: In function `atomic_set_char':
> machine/atomic.h:178: inconsistent operand constraints in an `asm'
> with any optimization, eg -O, there is _NO_ error. Makes me think the optimizer
> is optimizing out the offending contraints. Ouch. Probably not what was intended.
>
> Maybe this is what's biting you ?
This is sort of the opposite of the bug in <machine/mutex.h>. It is
believed to be caused by using the operand-number constraints (e.g.,
"(0)") to declare input-output operands in <machine/atomic.h>.
Input-output operands and/or these constraints apparently never worked
right until a recent versions of gcc introduced the "+" contraint to
declare input-output operations properly. <machine/atomic.h> uses the
new constraint. The problem seems to be that "+" contraints don't
work right either.
The following kludge fixes compilation of cam_periph.c:
diff -c2 mutex.h~ mutex.h
*** mutex.h~ Sun Dec 10 19:28:53 2000
--- mutex.h Sun Dec 10 23:50:21 2000
***************
*** 171,174 ****
--- 176,180 ----
\
__asm __volatile ( \
+ " movl $" _V(MTX_UNOWNED) ",%%eax;" \
" " MPLOCKED "" \
" cmpxchgl %4,%0;" /* try easy rel */ \
***************
*** 181,185 ****
"# exitlock_norecurse" \
: "+m" (mtxp->mtx_lock), /* 0 */ \
! "+a" (_tid) /* 1 */ \
: "gi" (type), /* 2 (input) */ \
"g" (mtxp), /* 3 */ \
--- 187,191 ----
"# exitlock_norecurse" \
: "+m" (mtxp->mtx_lock), /* 0 */ \
! "=&a" (_tid) /* 1 */ \
: "gi" (type), /* 2 (input) */ \
"g" (mtxp), /* 3 */ \
This bug seems to have been encountered before -- I copied this inferior
code from the function before the one that doesn't compile. Several other
functions in <machine/mutex.h> also use it.
Bruce
To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-current" in the body of the message