+2014-07-10 Adhemerval Zanella <azanella@linux.vnet.ibm.com>
+
+ * sysdeps/unix/sysv/linux/powerpc/lowlevellock.h (__lll_base_trylock):
+ New define.
+ (__lll_trylock): Use __lll_base_trylock.
+ (__lll_cond_trylock): Likewise.
+
2014-07-10 Roland McGrath <roland@hack.frob.com>
* nptl/pthread_create.c (start_thread): Use atomic_or and
# endif
#endif
+/* Set *futex to ID if it is 0, atomically. Returns the old value */
+#define __lll_base_trylock(futex, id) \
+ ({ int __val; \
+ __asm __volatile ("1: lwarx %0,0,%2" MUTEX_HINT_ACQ "\n" \
+ " cmpwi 0,%0,0\n" \
+ " bne 2f\n" \
+ " stwcx. %3,0,%2\n" \
+ " bne- 1b\n" \
+ "2: " __lll_acq_instr \
+ : "=&r" (__val), "=m" (*futex) \
+ : "r" (futex), "r" (id), "m" (*futex) \
+ : "cr0", "memory"); \
+ __val; \
+ })
+
/* Set *futex to 1 if it is 0, atomically. Returns the old value */
-#define __lll_trylock(futex) __lll_robust_trylock (futex, 1)
+#define __lll_trylock(futex) __lll_base_trylock (futex, 1)
#define lll_trylock(lock) __lll_trylock (&(lock))
/* Set *futex to 2 if it is 0, atomically. Returns the old value */
-#define __lll_cond_trylock(futex) __lll_robust_trylock (futex, 2)
+#define __lll_cond_trylock(futex) __lll_base_trylock (futex, 2)
#define lll_cond_trylock(lock) __lll_cond_trylock (&(lock))