From owner-freebsd-current Tue Oct 26 17:17:27 1999 Delivered-To: freebsd-current@freebsd.org Received: from alcanet.com.au (border.alcanet.com.au [203.62.196.10]) by hub.freebsd.org (Postfix) with ESMTP id 95CBB14D1D for ; Tue, 26 Oct 1999 17:17:12 -0700 (PDT) (envelope-from jeremyp@gsmx07.alcatel.com.au) Received: by border.alcanet.com.au id <40374>; Wed, 27 Oct 1999 10:12:08 +1000 Content-return: prohibited Date: Wed, 27 Oct 1999 10:16:58 +1000 From: Peter Jeremy Subject: Re: * $FreeBSD: src/sys/i386/include/atomic.h,v 1.9 1999/10/04 16:24:08 peter Exp $ In-reply-to: <199910262343.SAA02009@argus.tfs.net> To: jbryant@tfs.net Cc: freebsd-current@FreeBSD.ORG Reply-To: peter.jeremy@alcatel.com.au Message-Id: <99Oct27.101208est.40374@border.alcanet.com.au> MIME-version: 1.0 X-Mailer: Mutt 1.0pre3i Content-type: text/plain; charset=us-ascii References: <199910262343.SAA02009@argus.tfs.net> Sender: owner-freebsd-current@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG On 1999-Oct-27 09:43:52 +1000, Jim Bryant wrote: >after several months, I decided to re-sync to -current... > >i cannot build a kernel due the the following errors. ... >machine/atomic.h:124: inconsistent operand constraints in an `asm' ... > >how do i get around this? The quick solution is to compile with `-O'. As for the correct solution: There are various problems with the atomic_XXX code on the 386 that get triggered by different combinations of compiler, optimisation options and operand attributes. I had a look at it a few weeks ago and came up with the code below. It isn't a drop-in replacement for the existing atomic.h (because it isn't currently compatible with modules). I intend to convert it into a suitable patch and send it as a PR, but don't know when I'll get a round tuit. In the meantime, feel free to hack the following: #if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 8) #define ATOMIC_DEST "+m" #else /* gcc < 2.8 version */ #define ATOMIC_DEST "=m" #endif #if defined(SMP) #define ATOMIC_LOCK "lock ; " #else #define ATOMIC_LOCK #endif #define atomic_set_char(p, v) \ __asm(ATOMIC_LOCK "orb %b1,%0" \ : ATOMIC_DEST (*(p)) \ : "iq" (v) \ : "cc") #define atomic_clear_char(p, v) \ __asm(ATOMIC_LOCK "andb %b1,%0" \ : ATOMIC_DEST (*(p)) \ : "iq" (~(v)) \ : "cc") #define atomic_add_char(p, v) \ __asm(ATOMIC_LOCK "addb %b1,%0" \ : ATOMIC_DEST (*(p)) \ : "iq" (v) \ : "cc") #define atomic_subtract_char(p, v) \ __asm(ATOMIC_LOCK "subb %b1,%0" \ : ATOMIC_DEST (*(p)) \ : "iq" (v) \ : "cc") #define atomic_set_short(p, v) \ __asm(ATOMIC_LOCK "orw %w1,%0" \ : ATOMIC_DEST (*(p)) \ : "ir" (v) \ : "cc") #define atomic_clear_short(p, v) \ __asm(ATOMIC_LOCK "andw %w1,%0" \ : ATOMIC_DEST (*(p)) \ : "ir" (~(v)) \ : "cc") #define atomic_add_short(p, v) \ __asm(ATOMIC_LOCK "addw %w1,%0" \ : ATOMIC_DEST (*(p)) \ : "ir" (v) \ : "cc") #define atomic_subtract_short(p, v) \ __asm(ATOMIC_LOCK "subw %w1,%0" \ : ATOMIC_DEST (*(p)) \ : "ir" (v) \ : "cc") #define atomic_set_int(p, v) \ __asm(ATOMIC_LOCK "orl %1,%0" \ : ATOMIC_DEST (*(p)) \ : "ir" (v) \ : "cc") #define atomic_clear_int(p, v) \ __asm(ATOMIC_LOCK "andl %1,%0" \ : ATOMIC_DEST (*(p)) \ : "ir" (~(v)) \ : "cc") #define atomic_add_int(p, v) \ __asm(ATOMIC_LOCK "addl %1,%0" \ : ATOMIC_DEST (*(p)) \ : "ir" (v) \ : "cc") #define atomic_subtract_int(p, v) \ __asm(ATOMIC_LOCK "subl %1,%0" \ : ATOMIC_DEST (*(p)) \ : "ir" (v) \ : "cc") #define atomic_set_long(p, v) \ __asm(ATOMIC_LOCK "orl %1,%0" \ : ATOMIC_DEST (*(p)) \ : "ir" (v) \ : "cc") #define atomic_clear_long(p, v) \ __asm(ATOMIC_LOCK "andl %1,%0" \ : ATOMIC_DEST (*(p)) \ : "ir" (~(v)) \ : "cc") #define atomic_add_long(p, v) \ __asm(ATOMIC_LOCK "addl %1,%0" \ : ATOMIC_DEST (*(p)) \ : "ir" (v) \ : "cc") #define atomic_subtract_long(p, v) \ __asm(ATOMIC_LOCK "subl %1,%0" \ : ATOMIC_DEST (*(p)) \ : "ir" (v) \ : "cc") Peter -- Peter Jeremy (VK2PJ) peter.jeremy@alcatel.com.au Alcatel Australia Limited 41 Mandible St Phone: +61 2 9690 5019 ALEXANDRIA NSW 2015 Fax: +61 2 9690 5982 To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-current" in the body of the message