Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 10 Nov 2001 13:57:09 -0800 (PST)
From:      John Baldwin <jhb@FreeBSD.org>
To:        Bruce Evans <bde@zeta.org.au>
Cc:        current@FreeBSD.ORG, Jim Bryant <kc5vdj@yahoo.com>
Subject:   Re: kernel won't build - atomic.c/atomic.h errors...
Message-ID:  <XFMail.011110135709.jhb@FreeBSD.org>
In-Reply-To: <20011109000347.J2336-100000@delplex.bde.org>

next in thread | previous in thread | raw e-mail | index | archive | help
On 08-Nov-01 Bruce Evans wrote:
> On Fri, 2 Nov 2001, Jim Bryant wrote:
> 
>> Is anyone else seeing this problem?  I posted a message the other day to
>> this list, and have yet to see a single response.
>>
>> This is from a completely fresh cvsup of everything.
>>
>> buildworld succeeds, but the kernel build fails on atomic.c with the
>> following message about the ATOMIC_ASM macros in atomic.h.
>>
>> The archetecture is 5.0-really-current on an SMP P2-333 machine.
>>
>> the message seems to be: "inconsistent operand constraints in an `asm'"
> 
> Only people who have clobbered -O in CFLAGS in /etc/make.conf should see
> this problem :-).
> 
> The i386 <machine/atomic.h> still uses archaic constraints for some
> input-output operands ("0" for the first operand).  These never worked
> right and if fact don't actually work for compiling this file without
> optimization.

Hmm, would you prefer this diff then, I've had it floating around for a while
now but wasn't sure it was right:

--- //depot/vendor/freebsd/sys/i386/include/atomic.h    2001/10/08 14:41:47
+++ //depot/projects/smpng/sys/i386/include/atomic.h    2001/10/08 22:37:17
@@ -99,8 +99,8 @@
 atomic_##NAME##_##TYPE(volatile u_##TYPE *p, u_##TYPE v)\
 {                                                      \
        __asm __volatile(MPLOCKED OP                    \
-                        : "=m" (*p)                    \
-                        :  "0" (*p), "ir" (V));        \
+                        : "+m" (*p)                    \
+                        : "ir" (V));                   \
 }
 
 /*
@@ -211,25 +211,25 @@
 #endif /* KLD_MODULE */
 
 #if !defined(LOCORE)
-ATOMIC_ASM(set,             char,  "orb %b2,%0",   v)
-ATOMIC_ASM(clear,    char,  "andb %b2,%0", ~v)
-ATOMIC_ASM(add,             char,  "addb %b2,%0",  v)
-ATOMIC_ASM(subtract, char,  "subb %b2,%0",  v)
+ATOMIC_ASM(set,             char,  "orb %b1,%0",   v)
+ATOMIC_ASM(clear,    char,  "andb %b1,%0", ~v)
+ATOMIC_ASM(add,             char,  "addb %b1,%0",  v)
+ATOMIC_ASM(subtract, char,  "subb %b1,%0",  v)
 
-ATOMIC_ASM(set,             short, "orw %w2,%0",   v)
-ATOMIC_ASM(clear,    short, "andw %w2,%0", ~v)
-ATOMIC_ASM(add,             short, "addw %w2,%0",  v)
-ATOMIC_ASM(subtract, short, "subw %w2,%0",  v)
+ATOMIC_ASM(set,             short, "orw %w1,%0",   v)
+ATOMIC_ASM(clear,    short, "andw %w1,%0", ~v)
+ATOMIC_ASM(add,             short, "addw %w1,%0",  v)
+ATOMIC_ASM(subtract, short, "subw %w1,%0",  v)
 
-ATOMIC_ASM(set,             int,   "orl %2,%0",   v)
-ATOMIC_ASM(clear,    int,   "andl %2,%0", ~v)
-ATOMIC_ASM(add,             int,   "addl %2,%0",  v)
-ATOMIC_ASM(subtract, int,   "subl %2,%0",  v)
+ATOMIC_ASM(set,             int,   "orl %1,%0",   v)
+ATOMIC_ASM(clear,    int,   "andl %1,%0", ~v)
+ATOMIC_ASM(add,             int,   "addl %1,%0",  v)
+ATOMIC_ASM(subtract, int,   "subl %1,%0",  v)
 
-ATOMIC_ASM(set,             long,  "orl %2,%0",   v)
-ATOMIC_ASM(clear,    long,  "andl %2,%0", ~v)
-ATOMIC_ASM(add,             long,  "addl %2,%0",  v)
-ATOMIC_ASM(subtract, long,  "subl %2,%0",  v)
+ATOMIC_ASM(set,             long,  "orl %1,%0",   v)
+ATOMIC_ASM(clear,    long,  "andl %1,%0", ~v)
+ATOMIC_ASM(add,             long,  "addl %1,%0",  v)
+ATOMIC_ASM(subtract, long,  "subl %1,%0",  v)
 
 ATOMIC_STORE_LOAD(char,        "cmpxchgb %b0,%1", "xchgb %b1,%0")
 ATOMIC_STORE_LOAD(short,"cmpxchgw %w0,%1", "xchgw %w1,%0")

-- 

John Baldwin <jhb@FreeBSD.org> -- http://www.FreeBSD.org/~jhb/
PGP Key: http://www.baldwin.cx/~john/pgpkey.asc
"Power Users Use the Power to Serve!"  -  http://www.FreeBSD.org/

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-current" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?XFMail.011110135709.jhb>