This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH v2] sh: Fix gUSA sequence in atomic function


Hi,

I'd like to commit the patch below based with Iwamatsu-san's
updated patch.  OK?

Regards,
	kaz
--
	* sysdeps/unix/sysv/linux/sh/bits/atomic.h
	(__arch_compare_and_exchange_val_8_acq): Remove explicit nop.
	(__arch_compare_and_exchange_val_16_acq): Likewise.
	(__arch_compare_and_exchange_val_32_acq): Likewise.
	(atomic_exchange_and_add): Fix gUSA sequence.
	(atomic_add): Likewise.
	(atomic_add_negative): Likewise.
	(atomic_add_zero): Likewise.
	(atomic_bit_test_set): Likewise.

diff --git a/sysdeps/unix/sysv/linux/sh/bits/atomic.h b/sysdeps/unix/sysv/linux/sh/bits/atomic.h
index c8f07e5..05e4922 100644
--- a/sysdeps/unix/sysv/linux/sh/bits/atomic.h
+++ b/sysdeps/unix/sysv/linux/sh/bits/atomic.h
@@ -1,5 +1,5 @@
 /* Atomic operations used inside libc.  Linux/SH version.
-   Copyright (C) 2003, 2011 Free Software Foundation, Inc.
+   Copyright (C) 2003-2012 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    The GNU C Library is free software; you can redistribute it and/or
@@ -73,11 +73,10 @@ typedef uintmax_t uatomic_max_t;
 #define __arch_compare_and_exchange_val_8_acq(mem, newval, oldval) \
   ({ __typeof (*(mem)) __result; \
      __asm __volatile ("\
-	.align 2\n\
 	mova 1f,r0\n\
-	nop\n\
+	.align 2\n\
 	mov r15,r1\n\
-	mov #-8,r15\n\
+	mov #(0f-1f),r15\n\
      0: mov.b @%1,%0\n\
 	cmp/eq %0,%3\n\
 	bf 1f\n\
@@ -90,10 +89,10 @@ typedef uintmax_t uatomic_max_t;
 #define __arch_compare_and_exchange_val_16_acq(mem, newval, oldval) \
   ({ __typeof (*(mem)) __result; \
      __asm __volatile ("\
-	.align 2\n\
 	mova 1f,r0\n\
-	nop\n\
 	mov r15,r1\n\
+	.align 2\n\
+	mov #(0f-1f),r15\n\
 	mov #-8,r15\n\
      0: mov.w @%1,%0\n\
 	cmp/eq %0,%3\n\
@@ -107,11 +106,10 @@ typedef uintmax_t uatomic_max_t;
 #define __arch_compare_and_exchange_val_32_acq(mem, newval, oldval) \
   ({ __typeof (*(mem)) __result; \
      __asm __volatile ("\
-	.align 2\n\
 	mova 1f,r0\n\
-	nop\n\
+	.align 2\n\
 	mov r15,r1\n\
-	mov #-8,r15\n\
+	mov #(0f-1f),r15\n\
      0: mov.l @%1,%0\n\
 	cmp/eq %0,%3\n\
 	bf 1f\n\
@@ -133,40 +131,43 @@ typedef uintmax_t uatomic_max_t;
   ({ __typeof (*(mem)) __result, __tmp, __value = (value); \
      if (sizeof (*(mem)) == 1) \
        __asm __volatile ("\
-	  .align 2\n\
 	  mova 1f,r0\n\
+	  .align 2\n\
 	  mov r15,r1\n\
-	  mov #-6,r15\n\
+	  mov #(0f-1f),r15\n\
        0: mov.b @%2,%0\n\
-	  add %0,%1\n\
-	  mov.b %1,@%2\n\
+	  mov %1,r2\n\
+	  add %0,r2\n\
+	  mov.b r2,@%2\n\
        1: mov r1,r15"\
 	: "=&r" (__result), "=&r" (__tmp) : rNOSP (mem), "1" (__value) \
-	: "r0", "r1", "memory"); \
+	: "r0", "r1", "r2", "memory");		       \
      else if (sizeof (*(mem)) == 2) \
        __asm __volatile ("\
-	  .align 2\n\
 	  mova 1f,r0\n\
+	  .align 2\n\
 	  mov r15,r1\n\
-	  mov #-6,r15\n\
+	  mov #(0f-1f),r15\n\
        0: mov.w @%2,%0\n\
-	  add %0,%1\n\
-	  mov.w %1,@%2\n\
+	  mov %1,r2\n\
+	  add %0,r2\n\
+	  mov.w r2,@%2\n\
        1: mov r1,r15"\
 	: "=&r" (__result), "=&r" (__tmp) : rNOSP (mem), "1" (__value) \
-	: "r0", "r1", "memory"); \
+	: "r0", "r1", "r2", "memory"); \
      else if (sizeof (*(mem)) == 4) \
        __asm __volatile ("\
-	  .align 2\n\
 	  mova 1f,r0\n\
+	  .align 2\n\
 	  mov r15,r1\n\
-	  mov #-6,r15\n\
+	  mov #(0f-1f),r15\n\
        0: mov.l @%2,%0\n\
-	  add %0,%1\n\
-	  mov.l %1,@%2\n\
+	  mov %1,r2\n\
+	  add %0,r2\n\
+	  mov.l r2,@%2\n\
        1: mov r1,r15"\
 	: "=&r" (__result), "=&r" (__tmp) : rNOSP (mem), "1" (__value) \
-	: "r0", "r1", "memory"); \
+	: "r0", "r1", "r2", "memory"); \
      else \
        { \
 	 __typeof (mem) memp = (mem); \
@@ -182,37 +183,37 @@ typedef uintmax_t uatomic_max_t;
   (void) ({ __typeof (*(mem)) __tmp, __value = (value); \
 	    if (sizeof (*(mem)) == 1) \
 	      __asm __volatile ("\
-		.align 2\n\
 		mova 1f,r0\n\
 		mov r15,r1\n\
-		mov #-6,r15\n\
+		.align 2\n\
+		mov #(0f-1f),r15\n\
 	     0: mov.b @%1,r2\n\
-		add r2,%0\n\
-		mov.b %0,@%1\n\
+		add %0,r2\n\
+		mov.b r2,@%1\n\
 	     1: mov r1,r15"\
 		: "=&r" (__tmp) : rNOSP (mem), "0" (__value) \
 		: "r0", "r1", "r2", "memory"); \
 	    else if (sizeof (*(mem)) == 2) \
 	      __asm __volatile ("\
-		.align 2\n\
 		mova 1f,r0\n\
 		mov r15,r1\n\
-		mov #-6,r15\n\
+		.align 2\n\
+		mov #(0f-1f),r15\n\
 	     0: mov.w @%1,r2\n\
-		add r2,%0\n\
-		mov.w %0,@%1\n\
+		add %0,r2\n\
+		mov.w r2,@%1\n\
 	     1: mov r1,r15"\
 		: "=&r" (__tmp) : rNOSP (mem), "0" (__value) \
 		: "r0", "r1", "r2", "memory"); \
 	    else if (sizeof (*(mem)) == 4) \
 	      __asm __volatile ("\
-		.align 2\n\
 		mova 1f,r0\n\
 		mov r15,r1\n\
-		mov #-6,r15\n\
+		.align 2\n\
+		mov #(0f-1f),r15\n\
 	     0: mov.l @%1,r2\n\
-		add r2,%0\n\
-		mov.l %0,@%1\n\
+		add %0,r2\n\
+		mov.l r2,@%1\n\
 	     1: mov r1,r15"\
 		: "=&r" (__tmp) : rNOSP (mem), "0" (__value) \
 		: "r0", "r1", "r2", "memory"); \
@@ -233,43 +234,43 @@ typedef uintmax_t uatomic_max_t;
      __typeof (*(mem)) __tmp, __value = (value); \
      if (sizeof (*(mem)) == 1) \
        __asm __volatile ("\
-	  .align 2\n\
 	  mova 1f,r0\n\
 	  mov r15,r1\n\
-	  mov #-6,r15\n\
+	  .align 2\n\
+	  mov #(0f-1f),r15\n\
        0: mov.b @%2,r2\n\
-	  add r2,%1\n\
-	  mov.b %1,@%2\n\
+	  add %1,r2\n\
+	  mov.b r2,@%2\n\
        1: mov r1,r15\n\
-	  shal %1\n\
+	  shal r2\n\
 	  movt %0"\
 	: "=r" (__result), "=&r" (__tmp) : rNOSP (mem), "1" (__value) \
 	: "r0", "r1", "r2", "t", "memory"); \
      else if (sizeof (*(mem)) == 2) \
        __asm __volatile ("\
-	  .align 2\n\
 	  mova 1f,r0\n\
 	  mov r15,r1\n\
-	  mov #-6,r15\n\
+	  .align 2\n\
+	  mov #(0f-1f),r15\n\
        0: mov.w @%2,r2\n\
-	  add r2,%1\n\
-	  mov.w %1,@%2\n\
+	  add %1,r2\n\
+	  mov.w r2,@%2\n\
        1: mov r1,r15\n\
-	  shal %1\n\
+	  shal r2\n\
 	  movt %0"\
 	: "=r" (__result), "=&r" (__tmp) : rNOSP (mem), "1" (__value) \
 	: "r0", "r1", "r2", "t", "memory"); \
      else if (sizeof (*(mem)) == 4) \
        __asm __volatile ("\
-	  .align 2\n\
 	  mova 1f,r0\n\
 	  mov r15,r1\n\
-	  mov #-6,r15\n\
+	  .align 2\n\
+	  mov #(0f-1f),r15\n\
        0: mov.l @%2,r2\n\
-	  add r2,%1\n\
-	  mov.l %1,@%2\n\
+	  add %1,r2\n\
+	  mov.l r2,@%2\n\
        1: mov r1,r15\n\
-	  shal %1\n\
+	  shal r2\n\
 	  movt %0"\
 	: "=r" (__result), "=&r" (__tmp) : rNOSP (mem), "1" (__value) \
 	: "r0", "r1", "r2", "t", "memory"); \
@@ -282,43 +283,43 @@ typedef uintmax_t uatomic_max_t;
      __typeof (*(mem)) __tmp, __value = (value); \
      if (sizeof (*(mem)) == 1) \
        __asm __volatile ("\
-	  .align 2\n\
 	  mova 1f,r0\n\
 	  mov r15,r1\n\
-	  mov #-6,r15\n\
+	  .align 2\n\
+	  mov #(0f-1f),r15\n\
        0: mov.b @%2,r2\n\
-	  add r2,%1\n\
-	  mov.b %1,@%2\n\
+	  add %1,r2\n\
+	  mov.b r2,@%2\n\
        1: mov r1,r15\n\
-	  tst %1,%1\n\
+	  tst r2,r2\n\
 	  movt %0"\
 	: "=r" (__result), "=&r" (__tmp) : rNOSP (mem), "1" (__value) \
 	: "r0", "r1", "r2", "t", "memory"); \
      else if (sizeof (*(mem)) == 2) \
        __asm __volatile ("\
-	  .align 2\n\
 	  mova 1f,r0\n\
 	  mov r15,r1\n\
-	  mov #-6,r15\n\
+	  .align 2\n\
+	  mov #(0f-1f),r15\n\
        0: mov.w @%2,r2\n\
-	  add r2,%1\n\
-	  mov.w %1,@%2\n\
+	  add %1,r2\n\
+	  mov.w r2,@%2\n\
        1: mov r1,r15\n\
-	  tst %1,%1\n\
+	  tst r2,r2\n\
 	  movt %0"\
 	: "=r" (__result), "=&r" (__tmp) : rNOSP (mem), "1" (__value) \
 	: "r0", "r1", "r2", "t", "memory"); \
      else if (sizeof (*(mem)) == 4) \
        __asm __volatile ("\
-	  .align 2\n\
 	  mova 1f,r0\n\
 	  mov r15,r1\n\
-	  mov #-6,r15\n\
+	  .align 2\n\
+	  mov #(0f-1f),r15\n\
        0: mov.l @%2,r2\n\
-	  add r2,%1\n\
-	  mov.l %1,@%2\n\
+	  add %1,r2\n\
+	  mov.l r2,@%2\n\
        1: mov r1,r15\n\
-	  tst %1,%1\n\
+	  tst r2,r2\n\
 	  movt %0"\
 	: "=r" (__result), "=&r" (__tmp) : rNOSP (mem), "1" (__value) \
 	: "r0", "r1", "r2", "t", "memory"); \
@@ -333,10 +334,10 @@ typedef uintmax_t uatomic_max_t;
   (void) ({ unsigned int __mask = 1 << (bit); \
 	    if (sizeof (*(mem)) == 1) \
 	      __asm __volatile ("\
-		.align 2\n\
 		mova 1f,r0\n\
 		mov r15,r1\n\
-		mov #-6,r15\n\
+		.align 2\n\
+		mov #(0f-1f),r15\n\
 	     0: mov.b @%0,r2\n\
 		or %1,r2\n\
 		mov.b r2,@%0\n\
@@ -345,10 +346,10 @@ typedef uintmax_t uatomic_max_t;
 		: "r0", "r1", "r2", "memory"); \
 	    else if (sizeof (*(mem)) == 2) \
 	      __asm __volatile ("\
-		.align 2\n\
 		mova 1f,r0\n\
 		mov r15,r1\n\
-		mov #-6,r15\n\
+		.align 2\n\
+		mov #(0f-1f),r15\n\
 	     0: mov.w @%0,r2\n\
 		or %1,r2\n\
 		mov.w r2,@%0\n\
@@ -357,10 +358,10 @@ typedef uintmax_t uatomic_max_t;
 		: "r0", "r1", "r2", "memory"); \
 	    else if (sizeof (*(mem)) == 4) \
 	      __asm __volatile ("\
-		.align 2\n\
 		mova 1f,r0\n\
 		mov r15,r1\n\
-		mov #-6,r15\n\
+		.align 2\n\
+		mov #(0f-1f),r15\n\
 	     0: mov.l @%0,r2\n\
 		or %1,r2\n\
 		mov.l r2,@%0\n\
@@ -376,49 +377,49 @@ typedef uintmax_t uatomic_max_t;
      unsigned int __result = __mask; \
      if (sizeof (*(mem)) == 1) \
        __asm __volatile ("\
-	  .align 2\n\
 	  mova 1f,r0\n\
-	  nop\n\
+	  .align 2\n\
 	  mov r15,r1\n\
-	  mov #-8,r15\n\
+	  mov #(0f-1f),r15\n\
        0: mov.b @%2,r2\n\
-	  or r2,%1\n\
-	  and r2,%0\n\
-	  mov.b %1,@%2\n\
-       1: mov r1,r15"\
+	  mov r2,r3\n\
+	  or %1,r2\n\
+	  mov.b r2,@%2\n\
+       1: mov r1,r15\n\
+	  and r3,%0"\
 	: "=&r" (__result), "=&r" (__mask) \
 	: rNOSP (mem), "0" (__result), "1" (__mask) \
-	: "r0", "r1", "r2", "memory"); \
+	: "r0", "r1", "r2", "r3", "memory");	\
      else if (sizeof (*(mem)) == 2) \
        __asm __volatile ("\
-	  .align 2\n\
 	  mova 1f,r0\n\
-	  nop\n\
+	  .align 2\n\
 	  mov r15,r1\n\
-	  mov #-8,r15\n\
+	  mov #(0f-1f),r15\n\
        0: mov.w @%2,r2\n\
-	  or r2,%1\n\
-	  and r2,%0\n\
+	  mov r2,r3\n\
+	  or %1,r2\n\
 	  mov.w %1,@%2\n\
-       1: mov r1,r15"\
+       1: mov r1,r15\n\
+	  and r3,%0"\
 	: "=&r" (__result), "=&r" (__mask) \
 	: rNOSP (mem), "0" (__result), "1" (__mask) \
-	: "r0", "r1", "r2", "memory"); \
+	: "r0", "r1", "r2", "r3", "memory"); \
      else if (sizeof (*(mem)) == 4) \
        __asm __volatile ("\
-	  .align 2\n\
 	  mova 1f,r0\n\
-	  nop\n\
+	  .align 2\n\
 	  mov r15,r1\n\
-	  mov #-8,r15\n\
+	  mov #(0f-1f),r15\n\
        0: mov.l @%2,r2\n\
+	  mov r2,r3\n\
 	  or r2,%1\n\
-	  and r2,%0\n\
 	  mov.l %1,@%2\n\
-       1: mov r1,r15"\
+       1: mov r1,r15\n\
+	  and r3,%0"\
 	: "=&r" (__result), "=&r" (__mask) \
 	: rNOSP (mem), "0" (__result), "1" (__mask) \
-	: "r0", "r1", "r2", "memory"); \
+	: "r0", "r1", "r2", "r3", "memory"); \
      else \
        abort (); \
      __result; })


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]