From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 12096 invoked by alias); 17 Mar 2004 22:42:31 -0000 Mailing-List: contact gcc-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-owner@gcc.gnu.org Received: (qmail 11888 invoked from network); 17 Mar 2004 22:42:28 -0000 Received: from unknown (HELO av.mvista.com) (12.44.186.158) by sources.redhat.com with SMTP; 17 Mar 2004 22:42:28 -0000 Received: from mvista.com (av [127.0.0.1]) by av.mvista.com (8.9.3/8.9.3) with ESMTP id OAA23455; Wed, 17 Mar 2004 14:42:26 -0800 Message-ID: <4058D42A.EA714F43@mvista.com> Date: Wed, 17 Mar 2004 22:45:00 -0000 From: Michael Eager Organization: MontaVista Software, Inc. MIME-Version: 1.0 To: Phil Edwards CC: gcc , libstdc++@gcc.gnu.org, Paul Koning Subject: Re: locking problem with mips atomicity References: <20040316045706.GA5985@redhat.com> <405726C9.86724574@mvista.com> <1079458507.3799.8.camel@dzur.sfbay.redhat.com> <40573D8F.DAAB6354@mvista.com> <20040316183443.GB12315@redhat.com> <4057833F.37693319@mvista.com> <20040316232242.GA6879@redhat.com> <40579942.3B51A8B3@mvista.com> <20040317004432.GA24875@disaster.jaj.com> <4057A10E.1968551E@mvista.com> <20040317005526.GA25735@disaster.jaj.com> Content-Type: multipart/mixed; boundary="------------0C04933C40BC5CA7B9A58FBE" X-SW-Source: 2004-03/txt/msg01010.txt.bz2 This is a multi-part message in MIME format. --------------0C04933C40BC5CA7B9A58FBE Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Content-length: 1014 Phil Edwards wrote: > > On Tue, Mar 16, 2004 at 04:51:26PM -0800, Michael Eager wrote: > > Phil Edwards wrote: > > > > > > 1) libstdc++-v3 is temporarily frozen. (This is /why/ you need to cc: the > > > list, so that you'll know when it's open for commits again.) > > > > > > 2) Remove 'libstdc++-v3/' from the front of the pathname, please, and > > > add the log entry to libstdc++-v3/ChangeLog, not the toplevel file > > > (when the library is unfrozen, of course). > > > > Updated patch attached. > > > > I don't have check-in privs, so who can/should do this? > > I can do it. Things should be thawed again in a day or so. Thanks to a bit help from Paul Koenig and a bit of head scratching, I've revised the patch. It now only has constraints which are referenced. I added a "memory" constraint. Revised patch attached, and revised test program to invoke __atomic_add. -- Michael Eager eager@mvista.com 408-328-8426 MontaVista Software, Inc. 1237 E. Arques Ave., Sunnyvale, CA 94085 --------------0C04933C40BC5CA7B9A58FBE Content-Type: text/plain; charset=us-ascii; name="FSF-gcc.patch" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="FSF-gcc.patch" Content-length: 1541 2004-03-16 Michael Eager * config/cpu/mips/atomicity.h: Prevent reg loads between LL and SC instructions. Index: config/cpu/mips/atomicity.h =================================================================== RCS file: /cvs/gcc/gcc/libstdc++-v3/config/cpu/mips/atomicity.h,v retrieving revision 1.9 diff -u -r1.9 atomicity.h --- ./libstdc++-v3/config/cpu/mips/atomicity.h 27 Feb 2004 00:49:48 -0000 1.9 +++ ./libstdc++-v3/config/cpu/mips/atomicity.h 17 Mar 2004 22:34:09 -0000 @@ -44,14 +44,15 @@ #if _MIPS_SIM == _ABIO32 ".set mips2\n\t" #endif - "ll %0,%3\n\t" - "addu %1,%4,%0\n\t" - "sc %1,%2\n\t" + "ll %0,0(%2)\n\t" + "addu %1,%3,%0\n\t" + "sc %1,0(%2)\n\t" ".set pop\n\t" "beqz %1,1b\n\t" "/* End exchange & add */" - : "=&r"(__result), "=&r"(__tmp), "=m"(*__mem) - : "m" (*__mem), "r"(__val)); + : "=&r"(__result), "=&r"(__tmp), "+r"(__mem) + : "r"(__val) + : "memory" ); return __result; } @@ -69,13 +70,14 @@ #if _MIPS_SIM == _ABIO32 ".set mips2\n\t" #endif - "ll %0,%2\n\t" - "addu %0,%3,%0\n\t" - "sc %0,%1\n\t" + "ll %0,0(%1)\n\t" + "addu %0,%2,%0\n\t" + "sc %0,0(%1)\n\t" ".set pop\n\t" "beqz %0,1b\n\t" "/* End atomic add */" - : "=&r"(__result), "=m"(*__mem) - : "m" (*__mem), "r"(__val)); + : "=&r"(__result), "+r"(__mem) + : "r"(__val) + : "memory" ); } } // namespace __gnu_cxx --------------0C04933C40BC5CA7B9A58FBE Content-Type: text/plain; charset=us-ascii; name="mcount.c" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="mcount.c" Content-length: 324 #include "atomicity.h" struct gmonparam { long int state; }; extern struct gmonparam _gmonparam ; static void __attribute__ ((__used__)) __mcount () { register struct gmonparam *p; p = &_gmonparam; if (! compare_and_swap (&p->state, 0, 1)) return; p->state = 0; } --------------0C04933C40BC5CA7B9A58FBE--