mirror of
https://sourceware.org/git/glibc.git
synced 2024-11-25 22:40:05 +00:00
(atomic_increment_and_test): Define. (atomic_decrement_and_test): Fix test.
This commit is contained in:
parent
0a9d1b3b81
commit
e8b113e517
@ -179,18 +179,52 @@ typedef uintmax_t uatomic_max_t;
|
|||||||
} \
|
} \
|
||||||
})
|
})
|
||||||
|
|
||||||
#define atomic_decrement_and_test(mem) \
|
#define atomic_increment_and_test(mem) \
|
||||||
({ char __result; \
|
({ char __result; \
|
||||||
if (sizeof (*(mem)) == 1) \
|
if (sizeof (*(mem)) == 1) \
|
||||||
__asm __volatile ("subq%.b %#1,%1; scs %0" \
|
__asm __volatile ("addq%.b %#1,%1; seq %0" \
|
||||||
: "=dm" (__result), "=m" (*(mem)) \
|
: "=dm" (__result), "=m" (*(mem)) \
|
||||||
: "1" (*(mem))); \
|
: "1" (*(mem))); \
|
||||||
else if (sizeof (*(mem)) == 2) \
|
else if (sizeof (*(mem)) == 2) \
|
||||||
__asm __volatile ("subq%.w %#1,%1; scs %0" \
|
__asm __volatile ("addq%.w %#1,%1; seq %0" \
|
||||||
: "=dm" (__result), "=m" (*(mem)) \
|
: "=dm" (__result), "=m" (*(mem)) \
|
||||||
: "1" (*(mem))); \
|
: "1" (*(mem))); \
|
||||||
else if (sizeof (*(mem)) == 4) \
|
else if (sizeof (*(mem)) == 4) \
|
||||||
__asm __volatile ("subq%.l %#1,%1; scs %0" \
|
__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; seq %0" \
|
||||||
|
: "=dm" (__result), "=m" (*(mem)) \
|
||||||
|
: "1" (*(mem))); \
|
||||||
|
else if (sizeof (*(mem)) == 2) \
|
||||||
|
__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; seq %0" \
|
||||||
: "=dm" (__result), "=m" (*(mem)) \
|
: "=dm" (__result), "=m" (*(mem)) \
|
||||||
: "1" (*(mem))); \
|
: "1" (*(mem))); \
|
||||||
else \
|
else \
|
||||||
@ -202,7 +236,7 @@ typedef uintmax_t uatomic_max_t;
|
|||||||
" move%.l %R1,%R2;" \
|
" move%.l %R1,%R2;" \
|
||||||
" subq%.l %#1,%2;" \
|
" subq%.l %#1,%2;" \
|
||||||
" subx%.l %5,%R2;" \
|
" subx%.l %5,%R2;" \
|
||||||
" scs %0;" \
|
" seq %0;" \
|
||||||
" cas2%.l %1:%R1,%2:%R2,(%3):(%4);" \
|
" cas2%.l %1:%R1,%2:%R2,(%3):(%4);" \
|
||||||
" jbne 1b" \
|
" jbne 1b" \
|
||||||
: "=&dm" (__result), "=d" (__oldval), \
|
: "=&dm" (__result), "=d" (__oldval), \
|
||||||
|
Loading…
Reference in New Issue
Block a user