Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
s390: Use generic lowlevellock-futex.h
      * sysdeps/unix/sysv/linux/s390/lowlevellock.h: Include
      <sysdeps/nptl/lowlevellock.h> and remove macros and
      functions that are now defined there.
      (SYS_futex): Remove.
      (lll_compare_and_swap): Remove.
      * sysdeps/s390/bits/atomic.h (atomic_exchange_acq): Define.
  • Loading branch information
Stefan Liebler authored and Andreas Krebbel committed Feb 20, 2015
1 parent 4017615 commit 7133957
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 325 deletions.
9 changes: 9 additions & 0 deletions ChangeLog
@@ -1,3 +1,12 @@
2015-02-20 Stefan Liebler <stli@linux.vnet.ibm.com>

* sysdeps/unix/sysv/linux/s390/lowlevellock.h: Include
<sysdeps/nptl/lowlevellock.h> and remove macros and
functions that are now defined there.
(SYS_futex): Remove.
(lll_compare_and_swap): Remove.
* sysdeps/s390/bits/atomic.h (atomic_exchange_acq): Define.

2015-02-19 Joseph Myers <joseph@codesourcery.com>

[BZ #17999]
Expand Down
41 changes: 41 additions & 0 deletions sysdeps/s390/bits/atomic.h
Expand Up @@ -77,3 +77,44 @@ typedef uintmax_t uatomic_max_t;
# define __arch_compare_and_exchange_val_64_acq(mem, newval, oldval) \
(abort (), (__typeof (*mem)) 0)
#endif

/* Store NEWVALUE in *MEM and return the old value. */
/* On s390, the atomic_exchange_acq is different from generic implementation,
because the generic one does not use the condition-code of cs-instruction
to determine if looping is needed. Instead it saves the old-value and
compares it against old-value returned by cs-instruction. */
#ifdef __s390x__
# define atomic_exchange_acq(mem, newvalue) \
({ __typeof (mem) __atg5_memp = (mem); \
__typeof (*(mem)) __atg5_oldval = *__atg5_memp; \
__typeof (*(mem)) __atg5_value = (newvalue); \
if (sizeof (*mem) == 4) \
__asm __volatile ("0: cs %0,%2,%1\n" \
" jl 0b" \
: "+d" (__atg5_oldval), "=Q" (*__atg5_memp) \
: "d" (__atg5_value), "m" (*__atg5_memp) \
: "cc", "memory" ); \
else if (sizeof (*mem) == 8) \
__asm __volatile ("0: csg %0,%2,%1\n" \
" jl 0b" \
: "+d" ( __atg5_oldval), "=Q" (*__atg5_memp) \
: "d" ((long) __atg5_value), "m" (*__atg5_memp) \
: "cc", "memory" ); \
else \
abort (); \
__atg5_oldval; })
#else
# define atomic_exchange_acq(mem, newvalue) \
({ __typeof (mem) __atg5_memp = (mem); \
__typeof (*(mem)) __atg5_oldval = *__atg5_memp; \
__typeof (*(mem)) __atg5_value = (newvalue); \
if (sizeof (*mem) == 4) \
__asm __volatile ("0: cs %0,%2,%1\n" \
" jl 0b" \
: "+d" (__atg5_oldval), "=Q" (*__atg5_memp) \
: "d" (__atg5_value), "m" (*__atg5_memp) \
: "cc", "memory" ); \
else \
abort (); \
__atg5_oldval; })
#endif

0 comments on commit 7133957

Please sign in to comment.