From owner-freebsd-current Mon Jun 24 15:32:12 2002 Delivered-To: freebsd-current@freebsd.org Received: from wall.polstra.com (wall-gw.polstra.com [206.213.73.130]) by hub.freebsd.org (Postfix) with ESMTP id F029437B6DC for ; Mon, 24 Jun 2002 15:30:53 -0700 (PDT) Received: from vashon.polstra.com (vashon.polstra.com [206.213.73.13]) by wall.polstra.com (8.11.3/8.11.3) with ESMTP id g5OMUpf40525; Mon, 24 Jun 2002 15:30:51 -0700 (PDT) (envelope-from jdp@wall.polstra.com) Received: (from jdp@localhost) by vashon.polstra.com (8.11.6/8.11.0) id g5OMUpw31505; Mon, 24 Jun 2002 15:30:51 -0700 (PDT) (envelope-from jdp) Date: Mon, 24 Jun 2002 15:30:51 -0700 (PDT) Message-Id: <200206242230.g5OMUpw31505@vashon.polstra.com> To: current@freebsd.org From: John Polstra Cc: ak03@gte.com Subject: Re: Bootstrap problems for asm In-Reply-To: <20020624175612.7abe6e52.ak03@gte.com> References: <200206241524.g5OFO6p30824@vashon.polstra.com> <20020624112151.A55057@dragon.nuxi.com> <20020624175612.7abe6e52.ak03@gte.com> Organization: Polstra & Co., Seattle, WA Sender: owner-freebsd-current@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG In article <20020624175612.7abe6e52.ak03@gte.com>, Alexander Kabaev wrote: > I am not an inline assembler guru, but here is the patch I think get the > job done. If I understannd things correcly, GCC accepts matching > constraints only for parameters for which registers are allowed. > > Any constructive critique is appreciated. Your patch isn't quite right. It's true that matching constraints are allowed only for registers. But read-modify-write operands can still be specified in other ways, specifically using the "+" modifier. Here's the patch which I'm testing at the moment. I'll commit it later today unless I find something wrong with it. John Index: i386/lockdflt.c =================================================================== RCS file: /home/ncvs/src/libexec/rtld-elf/i386/lockdflt.c,v retrieving revision 1.6 diff -u -r1.6 lockdflt.c --- i386/lockdflt.c 17 Jul 2000 17:18:13 -0000 1.6 +++ i386/lockdflt.c 24 Jun 2002 20:46:05 -0000 @@ -80,8 +80,8 @@ int result; __asm __volatile ("lock; cmpxchgl %2, %0" - : "=m"(*m), "=a"(result) - : "r"(new), "0"(*m), "1"(old) + : "+m"(*m), "=a"(result) + : "r"(new), "1"(old) : "cc"); return result; @@ -93,8 +93,8 @@ int result; __asm __volatile ("xchgl %0, %1" - : "=r"(result), "=m"(*m) - : "0"(v), "1"(*m)); + : "=r"(result), "+m"(*m) + : "0"(v)); return result; } Index: i386/rtld_machdep.h =================================================================== RCS file: /home/ncvs/src/libexec/rtld-elf/i386/rtld_machdep.h,v retrieving revision 1.6 diff -u -r1.6 rtld_machdep.h --- i386/rtld_machdep.h 29 Oct 2001 10:10:10 -0000 1.6 +++ i386/rtld_machdep.h 24 Jun 2002 20:44:30 -0000 @@ -55,21 +55,21 @@ static inline void atomic_decr_int(volatile int *p) { - __asm __volatile ("lock; decl %0" : "=m"(*p) : "0"(*p) : "cc"); + __asm __volatile ("lock; decl %0" : "+m"(*p) : : "cc"); } static inline void atomic_incr_int(volatile int *p) { - __asm __volatile ("lock; incl %0" : "=m"(*p) : "0"(*p) : "cc"); + __asm __volatile ("lock; incl %0" : "+m"(*p) : : "cc"); } static inline void atomic_add_int(volatile int *p, int val) { __asm __volatile ("lock; addl %1, %0" - : "=m"(*p) - : "ri"(val), "0"(*p) + : "+m"(*p) + : "ri"(val) : "cc"); } To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-current" in the body of the message