svn commit: r194469 - projects/mips/sys/mips/include

Oleksandr Tymoshenko gonzo at FreeBSD.org
Fri Jun 19 04:43:49 UTC 2009


Author: gonzo
Date: Fri Jun 19 04:43:49 2009
New Revision: 194469
URL: http://svn.freebsd.org/changeset/base/194469

Log:
  - Mark temp variable as "earlyclobber" in assembler inline in
      atomic_fetchadd_32.  Without it gcc would use it as input
      register for v and sometimes generate following code for
      function call like atomic_fetchadd_32(&(fp)->f_count, -1):
  
  801238b4:       2402ffff        li      v0,-1
  801238b8:       c2230018        ll      v1,24(s1)
  801238bc:       00431021        addu    v0,v0,v1
  801238c0:       e2220018        sc      v0,24(s1)
  801238c4:       1040fffc        beqz    v0,801238b8 <dupfdopen+0x2e8>
  801238c8:       00000000        nop
  
     Which is definitly wrong because if sc fails v0 is set to 0
     and previous value of -1 is overriden hence whole operation
     turns to bogus

Modified:
  projects/mips/sys/mips/include/atomic.h

Modified: projects/mips/sys/mips/include/atomic.h
==============================================================================
--- projects/mips/sys/mips/include/atomic.h	Fri Jun 19 04:25:44 2009	(r194468)
+++ projects/mips/sys/mips/include/atomic.h	Fri Jun 19 04:43:49 2009	(r194469)
@@ -294,7 +294,7 @@ atomic_fetchadd_32(__volatile uint32_t *
 		"addu %2, %3, %0\n\t"		/* calculate new value */
 		"sc %2, %1\n\t"			/* attempt to store */
 		"beqz %2, 1b\n\t"		/* spin if failed */
-		: "=&r" (value), "=m" (*p), "=r" (temp)
+		: "=&r" (value), "=m" (*p), "=&r" (temp)
 		: "r" (v), "m" (*p));
 	return (value);
 }


More information about the svn-src-projects mailing list