From owner-svn-src-head@FreeBSD.ORG Wed Aug 21 21:14:17 2013 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id 4FCA1CE1; Wed, 21 Aug 2013 21:14:17 +0000 (UTC) (envelope-from jkim@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 3C7B92B7A; Wed, 21 Aug 2013 21:14:17 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r7LLEHAl099476; Wed, 21 Aug 2013 21:14:17 GMT (envelope-from jkim@svn.freebsd.org) Received: (from jkim@localhost) by svn.freebsd.org (8.14.7/8.14.5/Submit) id r7LLEGrW099474; Wed, 21 Aug 2013 21:14:16 GMT (envelope-from jkim@svn.freebsd.org) Message-Id: <201308212114.r7LLEGrW099474@svn.freebsd.org> From: Jung-uk Kim Date: Wed, 21 Aug 2013 21:14:16 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r254612 - in head/sys: amd64/include i386/include X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 21 Aug 2013 21:14:17 -0000 Author: jkim Date: Wed Aug 21 21:14:16 2013 New Revision: 254612 URL: http://svnweb.freebsd.org/changeset/base/254612 Log: Use '+' modifier for a memory operand that is both an input and an output. It was actually done in r86301 but reverted in r150182 because GCC 3.x was not able to handle it for a memory operand. Apparently, this problem was fixed in GCC 4.1+ and several contrib sources already rely on this feature. Modified: head/sys/amd64/include/atomic.h head/sys/i386/include/atomic.h Modified: head/sys/amd64/include/atomic.h ============================================================================== --- head/sys/amd64/include/atomic.h Wed Aug 21 20:49:46 2013 (r254611) +++ head/sys/amd64/include/atomic.h Wed Aug 21 21:14:16 2013 (r254612) @@ -108,8 +108,8 @@ static __inline void \ atomic_##NAME##_##TYPE(volatile u_##TYPE *p, u_##TYPE v)\ { \ __asm __volatile(MPLOCKED OP \ - : "=m" (*p) \ - : CONS (V), "m" (*p) \ + : "+m" (*p) \ + : CONS (V) \ : "cc"); \ } \ \ @@ -117,8 +117,8 @@ static __inline void \ atomic_##NAME##_barr_##TYPE(volatile u_##TYPE *p, u_##TYPE v)\ { \ __asm __volatile(MPLOCKED OP \ - : "=m" (*p) \ - : CONS (V), "m" (*p) \ + : "+m" (*p) \ + : CONS (V) \ : "memory", "cc"); \ } \ struct __hack @@ -142,10 +142,9 @@ atomic_cmpset_int(volatile u_int *dst, u " sete %0 ; " "# atomic_cmpset_int" : "=a" (res), /* 0 */ - "=m" (*dst) /* 1 */ + "+m" (*dst) /* 1 */ : "r" (src), /* 2 */ - "a" (expect), /* 3 */ - "m" (*dst) /* 4 */ + "a" (expect) /* 3 */ : "memory", "cc"); return (res); @@ -162,10 +161,9 @@ atomic_cmpset_long(volatile u_long *dst, " sete %0 ; " "# atomic_cmpset_long" : "=a" (res), /* 0 */ - "=m" (*dst) /* 1 */ + "+m" (*dst) /* 1 */ : "r" (src), /* 2 */ - "a" (expect), /* 3 */ - "m" (*dst) /* 4 */ + "a" (expect) /* 3 */ : "memory", "cc"); return (res); @@ -184,9 +182,8 @@ atomic_fetchadd_int(volatile u_int *p, u " xaddl %0,%1 ; " "# atomic_fetchadd_int" : "+r" (v), /* 0 */ - "=m" (*p) /* 1 */ - : "m" (*p) /* 2 */ - : "cc"); + "+m" (*p) /* 1 */ + : : "cc"); return (v); } @@ -203,9 +200,8 @@ atomic_fetchadd_long(volatile u_long *p, " xaddq %0,%1 ; " "# atomic_fetchadd_long" : "+r" (v), /* 0 */ - "=m" (*p) /* 1 */ - : "m" (*p) /* 2 */ - : "cc"); + "+m" (*p) /* 1 */ + : : "cc"); return (v); } @@ -253,9 +249,8 @@ atomic_load_acq_##TYPE(volatile u_##TYPE \ __asm __volatile(MPLOCKED LOP \ : "=a" (res), /* 0 */ \ - "=m" (*p) /* 1 */ \ - : "m" (*p) /* 2 */ \ - : "memory", "cc"); \ + "+m" (*p) /* 1 */ \ + : : "memory", "cc"); \ \ return (res); \ } \ @@ -314,8 +309,7 @@ atomic_readandclear_int(volatile u_int * " xchgl %1,%0 ; " "# atomic_readandclear_int" : "+r" (res), /* 0 */ - "=m" (*p) /* 1 */ - : "m" (*p)); + "+m" (*p)); /* 1 */ return (res); } @@ -330,8 +324,7 @@ atomic_readandclear_long(volatile u_long " xchgq %1,%0 ; " "# atomic_readandclear_long" : "+r" (res), /* 0 */ - "=m" (*p) /* 1 */ - : "m" (*p)); + "+m" (*p)); /* 1 */ return (res); } Modified: head/sys/i386/include/atomic.h ============================================================================== --- head/sys/i386/include/atomic.h Wed Aug 21 20:49:46 2013 (r254611) +++ head/sys/i386/include/atomic.h Wed Aug 21 21:14:16 2013 (r254612) @@ -106,8 +106,8 @@ static __inline void \ atomic_##NAME##_##TYPE(volatile u_##TYPE *p, u_##TYPE v)\ { \ __asm __volatile(MPLOCKED OP \ - : "=m" (*p) \ - : CONS (V), "m" (*p) \ + : "+m" (*p) \ + : CONS (V) \ : "cc"); \ } \ \ @@ -115,8 +115,8 @@ static __inline void \ atomic_##NAME##_barr_##TYPE(volatile u_##TYPE *p, u_##TYPE v)\ { \ __asm __volatile(MPLOCKED OP \ - : "=m" (*p) \ - : CONS (V), "m" (*p) \ + : "+m" (*p) \ + : CONS (V) \ : "memory", "cc"); \ } \ struct __hack @@ -174,11 +174,10 @@ atomic_load_acq_64_i586(volatile uint64_ " movl %%ebx,%%eax ; " " movl %%ecx,%%edx ; " " " MPLOCKED " " - " cmpxchg8b %2" + " cmpxchg8b %1" : "=&A" (res), /* 0 */ - "=m" (*p) /* 1 */ - : "m" (*p) /* 2 */ - : "memory", "cc"); + "+m" (*p) /* 1 */ + : : "memory", "cc"); return (res); } @@ -192,12 +191,11 @@ atomic_store_rel_64_i586(volatile uint64 " movl %%edx,%%ecx ; " "1: " " " MPLOCKED " " - " cmpxchg8b %2 ; " + " cmpxchg8b %0 ; " " jne 1b" - : "=m" (*p), /* 0 */ + : "+m" (*p), /* 0 */ "+A" (v) /* 1 */ - : "m" (*p) /* 2 */ - : "ebx", "ecx", "memory", "cc"); + : : "ebx", "ecx", "memory", "cc"); } #endif /* _KERNEL && !WANT_FUNCTIONS */ @@ -220,7 +218,7 @@ atomic_cmpset_int(volatile u_int *dst, u __asm __volatile( " pushfl ; " " cli ; " - " cmpl %3,%4 ; " + " cmpl %3,%1 ; " " jne 1f ; " " movl %2,%1 ; " "1: " @@ -228,10 +226,9 @@ atomic_cmpset_int(volatile u_int *dst, u " popfl ; " "# atomic_cmpset_int" : "=q" (res), /* 0 */ - "=m" (*dst) /* 1 */ + "+m" (*dst) /* 1 */ : "r" (src), /* 2 */ - "r" (expect), /* 3 */ - "m" (*dst) /* 4 */ + "r" (expect) /* 3 */ : "memory"); return (res); @@ -250,10 +247,9 @@ atomic_cmpset_int(volatile u_int *dst, u " sete %0 ; " "# atomic_cmpset_int" : "=a" (res), /* 0 */ - "=m" (*dst) /* 1 */ + "+m" (*dst) /* 1 */ : "r" (src), /* 2 */ - "a" (expect), /* 3 */ - "m" (*dst) /* 4 */ + "a" (expect) /* 3 */ : "memory", "cc"); return (res); @@ -274,9 +270,8 @@ atomic_fetchadd_int(volatile u_int *p, u " xaddl %0,%1 ; " "# atomic_fetchadd_int" : "+r" (v), /* 0 */ - "=m" (*p) /* 1 */ - : "m" (*p) /* 2 */ - : "cc"); + "+m" (*p) /* 1 */ + : : "cc"); return (v); } @@ -324,9 +319,8 @@ atomic_load_acq_##TYPE(volatile u_##TYPE \ __asm __volatile(MPLOCKED LOP \ : "=a" (res), /* 0 */ \ - "=m" (*p) /* 1 */ \ - : "m" (*p) /* 2 */ \ - : "memory", "cc"); \ + "+m" (*p) /* 1 */ \ + : : "memory", "cc"); \ \ return (res); \ } \ @@ -405,8 +399,7 @@ atomic_readandclear_int(volatile u_int * " xchgl %1,%0 ; " "# atomic_readandclear_int" : "+r" (res), /* 0 */ - "=m" (*p) /* 1 */ - : "m" (*p)); + "+m" (*p)); /* 1 */ return (res); } @@ -421,8 +414,7 @@ atomic_readandclear_long(volatile u_long " xchgl %1,%0 ; " "# atomic_readandclear_long" : "+r" (res), /* 0 */ - "=m" (*p) /* 1 */ - : "m" (*p)); + "+m" (*p)); /* 1 */ return (res); }