This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH][SH] fix atomic function names
At 18:08 09/08/03 +0900, Kaz Kojima <kkojima@rr.iij4u.or.jp> wrote:
>SUGIOKA Toshinobu <sugioka@itonet.co.jp> wrote:
>> It seems that some atomic functions defined in
>'gcc/config/sh/linux-atomic.asm'
>> have incorrect names. Patch follows.
>
>This patch is OK. Thanks!
>
Thanks for reply.
It seems that there are some missing atomic functions.
Updated patch follows.
Regards.
2009-08-07 SUGIOKA Toshinobu <sugioka@itonet.co.jp>
* config/sh/linux-atomic.asm (ATOMIC_COMPARE_AND_SWAP): Rename
__sync_compare_and_swap_* to __sync_val_compare_and_swap_*.
(ATOMIC_OP_AND_FETCH, ATOMIC_COMBOP_AND_FETCH): Define.
(__sync_*_and_fetch_*, __sync_synchronize, __sync_lock_release_*):
New function.
Index: gcc/config/sh/linux-atomic.asm
===================================================================
--- gcc/config/sh/linux-atomic.asm (revision 150523)
+++ gcc/config/sh/linux-atomic.asm (working copy)
@@ -54,10 +54,10 @@
ATOMIC_TEST_AND_SET (4,l,mov)
#define ATOMIC_COMPARE_AND_SWAP(N,T,EXTS,EXT) \
- .global __sync_compare_and_swap_##N; \
- HIDDEN_FUNC(__sync_compare_and_swap_##N); \
+ .global __sync_val_compare_and_swap_##N; \
+ HIDDEN_FUNC(__sync_val_compare_and_swap_##N); \
.align 2; \
-__sync_compare_and_swap_##N:; \
+__sync_val_compare_and_swap_##N:; \
mova 1f, r0; \
EXTS r5, r5; \
mov r15, r1; \
@@ -69,7 +69,7 @@
1: mov r1, r15; \
rts; \
EXT r2, r0; \
- ENDFUNC(__sync_compare_and_swap_##N)
+ ENDFUNC(__sync_val_compare_and_swap_##N)
ATOMIC_COMPARE_AND_SWAP (1,b,exts.b,extu.b)
ATOMIC_COMPARE_AND_SWAP (2,w,exts.w,extu.w)
@@ -135,4 +135,84 @@
ATOMIC_FETCH_AND_COMBOP(nand,and,not,2,w,extu.w)
ATOMIC_FETCH_AND_COMBOP(nand,and,not,4,l,mov)
+#define ATOMIC_OP_AND_FETCH(OP,N,T,EXT) \
+ .global __sync_##OP##_and_fetch_##N; \
+ HIDDEN_FUNC(__sync_##OP##_and_fetch_##N); \
+ .align 2; \
+__sync_##OP##_and_fetch_##N:; \
+ mova 1f, r0; \
+ mov r15, r1; \
+ mov #(0f-1f), r15; \
+0: mov.##T @r4, r2; \
+ OP r5, r2; \
+ mov.##T r2, @r4; \
+1: mov r1, r15; \
+ rts; \
+ EXT r2, r0; \
+ ENDFUNC(__sync_##OP##_and_fetch_##N)
+
+ATOMIC_OP_AND_FETCH(add,1,b,extu.b)
+ATOMIC_OP_AND_FETCH(add,2,w,extu.w)
+ATOMIC_OP_AND_FETCH(add,4,l,mov)
+
+ATOMIC_OP_AND_FETCH(sub,1,b,extu.b)
+ATOMIC_OP_AND_FETCH(sub,2,w,extu.w)
+ATOMIC_OP_AND_FETCH(sub,4,l,mov)
+
+ATOMIC_OP_AND_FETCH(or,1,b,extu.b)
+ATOMIC_OP_AND_FETCH(or,2,w,extu.w)
+ATOMIC_OP_AND_FETCH(or,4,l,mov)
+
+ATOMIC_OP_AND_FETCH(and,1,b,extu.b)
+ATOMIC_OP_AND_FETCH(and,2,w,extu.w)
+ATOMIC_OP_AND_FETCH(and,4,l,mov)
+
+ATOMIC_OP_AND_FETCH(xor,1,b,extu.b)
+ATOMIC_OP_AND_FETCH(xor,2,w,extu.w)
+ATOMIC_OP_AND_FETCH(xor,4,l,mov)
+
+#define ATOMIC_COMBOP_AND_FETCH(OP,OP0,OP1,N,T,EXT) \
+ .global __sync_##OP##_and_fetch_##N; \
+ HIDDEN_FUNC(__sync_##OP##_and_fetch_##N); \
+ .align 2; \
+__sync_##OP##_and_fetch_##N:; \
+ mova 1f, r0; \
+ nop; \
+ mov r15, r1; \
+ mov #(0f-1f), r15; \
+0: mov.##T @r4, r2; \
+ OP0 r5, r2; \
+ OP1 r2, r2; \
+ mov.##T r2, @r4; \
+1: mov r1, r15; \
+ rts; \
+ EXT r2, r0; \
+ ENDFUNC(__sync_##OP##_and_fetch_##N)
+
+ATOMIC_COMBOP_AND_FETCH(nand,and,not,1,b,extu.b)
+ATOMIC_COMBOP_AND_FETCH(nand,and,not,2,w,extu.w)
+ATOMIC_COMBOP_AND_FETCH(nand,and,not,4,l,mov)
+
+ .global __sync_synchronize; \
+ HIDDEN_FUNC(__sync_synchronize); \
+ .align 2; \
+__sync_synchronize:; \
+ rts; \
+ nop; \
+ ENDFUNC(__sync_synchronize)
+
+#define SYNC_LOCK_RELEASE(N,T) \
+ .global __sync_lock_release_##N; \
+ HIDDEN_FUNC(__sync_lock_release_##N); \
+ .align 2; \
+__sync_lock_release_##N:; \
+ mov #0, r0; \
+ rts; \
+ mov.##T r0, @r4; \
+ ENDFUNC(__sync_lock_release_##N)
+
+SYNC_LOCK_RELEASE(1,b)
+SYNC_LOCK_RELEASE(2,w)
+SYNC_LOCK_RELEASE(4,l)
+
#endif /* ! __SH5__ */
SUGIOKA Toshinobu