aboutsummaryrefslogtreecommitdiff
path: root/sysdeps/m68k
diff options
context:
space:
mode:
authorAndreas Schwab <schwab@suse.de>2003-03-31 16:01:09 +0000
committerAndreas Schwab <schwab@suse.de>2003-03-31 16:01:09 +0000
commite8b113e51752dae10e780e511ce08a1840bcdc63 (patch)
treef24628862c1d0628e3461f838793e4ff3f1c0624 /sysdeps/m68k
parent0a9d1b3b819ea1a43ca39185f6bf77816592fc8b (diff)
downloadglibc-e8b113e51752dae10e780e511ce08a1840bcdc63.tar
glibc-e8b113e51752dae10e780e511ce08a1840bcdc63.tar.gz
glibc-e8b113e51752dae10e780e511ce08a1840bcdc63.tar.bz2
glibc-e8b113e51752dae10e780e511ce08a1840bcdc63.zip
(atomic_increment_and_test): Define. (atomic_decrement_and_test): Fix test.
Diffstat (limited to 'sysdeps/m68k')
-rw-r--r--sysdeps/m68k/m68020/bits/atomic.h42
1 files changed, 38 insertions, 4 deletions
diff --git a/sysdeps/m68k/m68020/bits/atomic.h b/sysdeps/m68k/m68020/bits/atomic.h
index 80b5b8f3bf..6978b27cde 100644
--- a/sysdeps/m68k/m68020/bits/atomic.h
+++ b/sysdeps/m68k/m68020/bits/atomic.h
@@ -179,18 +179,52 @@ typedef uintmax_t uatomic_max_t;
} \
})
+#define atomic_increment_and_test(mem) \
+ ({ char __result; \
+ if (sizeof (*(mem)) == 1) \
+ __asm __volatile ("addq%.b %#1,%1; seq %0" \
+ : "=dm" (__result), "=m" (*(mem)) \
+ : "1" (*(mem))); \
+ else if (sizeof (*(mem)) == 2) \
+ __asm __volatile ("addq%.w %#1,%1; seq %0" \
+ : "=dm" (__result), "=m" (*(mem)) \
+ : "1" (*(mem))); \
+ else if (sizeof (*(mem)) == 4) \
+ __asm __volatile ("addq%.l %#1,%1; seq %0" \
+ : "=dm" (__result), "=m" (*(mem)) \
+ : "1" (*(mem))); \
+ else \
+ { \
+ __typeof (mem) __memp = (mem); \
+ __typeof (*(mem)) __oldval = *__memp; \
+ __typeof (*(mem)) __temp; \
+ __asm __volatile ("1: move%.l %1,%2;" \
+ " move%.l %R1,%R2;" \
+ " addq%.l %#1,%2;" \
+ " addx%.l %5,%R2;" \
+ " seq %0;" \
+ " cas2%.l %1:%R1,%2:%R2,(%3):(%4);" \
+ " jbne 1b" \
+ : "=&dm" (__result), "=d" (__oldval), \
+ "=&d" (__temp) \
+ : "r" (__memp), "r" ((char *) __memp + 4), \
+ "d" (0), "1" (__oldval) \
+ : "memory"); \
+ } \
+ __result; })
+
#define atomic_decrement_and_test(mem) \
({ char __result; \
if (sizeof (*(mem)) == 1) \
- __asm __volatile ("subq%.b %#1,%1; scs %0" \
+ __asm __volatile ("subq%.b %#1,%1; seq %0" \
: "=dm" (__result), "=m" (*(mem)) \
: "1" (*(mem))); \
else if (sizeof (*(mem)) == 2) \
- __asm __volatile ("subq%.w %#1,%1; scs %0" \
+ __asm __volatile ("subq%.w %#1,%1; seq %0" \
: "=dm" (__result), "=m" (*(mem)) \
: "1" (*(mem))); \
else if (sizeof (*(mem)) == 4) \
- __asm __volatile ("subq%.l %#1,%1; scs %0" \
+ __asm __volatile ("subq%.l %#1,%1; seq %0" \
: "=dm" (__result), "=m" (*(mem)) \
: "1" (*(mem))); \
else \
@@ -202,7 +236,7 @@ typedef uintmax_t uatomic_max_t;
" move%.l %R1,%R2;" \
" subq%.l %#1,%2;" \
" subx%.l %5,%R2;" \
- " scs %0;" \
+ " seq %0;" \
" cas2%.l %1:%R1,%2:%R2,(%3):(%4);" \
" jbne 1b" \
: "=&dm" (__result), "=d" (__oldval), \