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) [EMAIL PROTECTED]
Alcatel Australia Limited
41 Mandible St Phone: +61 2 9690 5019
ALEXANDRIA NSW 2015 Fax: +61 2 9690 5982
To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-current" in the body of the message