This is the mail archive of the
libc-alpha@sources.redhat.com
mailing list for the glibc project.
two nptl alpha fixes
- From: Richard Henderson <rth at twiddle dot net>
- To: libc-alpha at gcc dot gnu dot org
- Date: Mon, 30 Jun 2003 16:23:29 -0700
- Subject: two nptl alpha fixes
NPTL testing showed up some bugs in atomic.h and clone.S.
Committed.
r~
* sysdeps/alpha/bits/atomic.h (__arch_compare_and_exchange_bool_*_int):
Invert the sense of the return value.
(__arch_exchange_16_int): Fix paste-o.
(__arch_exchange_{32,64}_int): Fix think-o.
* sysdeps/unix/sysv/linux/alpha/clone.S: Load child_tid properly.
Index: sysdeps/alpha/bits/atomic.h
===================================================================
RCS file: /cvs/glibc/libc/sysdeps/alpha/bits/atomic.h,v
retrieving revision 1.1
diff -c -p -d -u -r1.1 atomic.h
--- sysdeps/alpha/bits/atomic.h 24 Jun 2003 17:03:59 -0000 1.1
+++ sysdeps/alpha/bits/atomic.h 30 Jun 2003 23:10:57 -0000
@@ -151,27 +151,27 @@ typedef uintmax_t uatomic_max_t;
: "memory"); \
})
-/* For all "bool" routines, we return true if exchange succesful. */
+/* For all "bool" routines, we return FALSE if exchange succesful. */
#define __arch_compare_and_exchange_bool_8_int(mem, new, old, mb1, mb2) \
({ unsigned long __prev; int __cmp; \
__arch_compare_and_exchange_xxx_8_int(mem, new, old, mb1, mb2); \
- __cmp; })
+ !__cmp; })
#define __arch_compare_and_exchange_bool_16_int(mem, new, old, mb1, mb2) \
({ unsigned long __prev; int __cmp; \
__arch_compare_and_exchange_xxx_16_int(mem, new, old, mb1, mb2); \
- __cmp; })
+ !__cmp; })
#define __arch_compare_and_exchange_bool_32_int(mem, new, old, mb1, mb2) \
({ unsigned long __prev; int __cmp; \
__arch_compare_and_exchange_xxx_32_int(mem, new, old, mb1, mb2); \
- __cmp; })
+ !__cmp; })
#define __arch_compare_and_exchange_bool_64_int(mem, new, old, mb1, mb2) \
({ unsigned long __prev; int __cmp; \
__arch_compare_and_exchange_xxx_64_int(mem, new, old, mb1, mb2); \
- __cmp; })
+ !__cmp; })
/* For all "val" routines, return the old value whether exchange
successful or not. */
@@ -247,7 +247,7 @@ typedef uintmax_t uatomic_max_t;
unsigned long __ret, __tmp, __addr64, __sval; \
__asm__ __volatile__ ( \
mb1 \
- " andnot %[__addr8],7,%[__addr64]\n" \
+ " andnot %[__addr16],7,%[__addr64]\n" \
" inswl %[__value],%[__addr16],%[__sval]\n" \
"1: ldq_l %[__tmp],0(%[__addr64])\n" \
" extwl %[__tmp],%[__addr16],%[__ret]\n" \
@@ -271,13 +271,14 @@ typedef uintmax_t uatomic_max_t;
__asm__ __volatile__ ( \
mb1 \
"1: ldl_l %[__ret],%[__mem]\n" \
- " mov %[__ret],%[__tmp]\n" \
+ " mov %[__val],%[__tmp]\n" \
" stl_c %[__tmp],%[__mem]\n" \
" beq %[__tmp],1b\n" \
mb2 \
: [__ret] "=&r" (__ret), \
[__tmp] "=&r" (__tmp) \
- : [__mem] "m" (*(mem)) \
+ : [__mem] "m" (*(mem)), \
+ [__val] "Ir" (value) \
: "memory"); \
__ret; })
@@ -287,13 +288,14 @@ typedef uintmax_t uatomic_max_t;
__asm__ __volatile__ ( \
mb1 \
"1: ldq_l %[__ret],%[__mem]\n" \
- " mov %[__ret],%[__tmp]\n" \
+ " mov %[__val],%[__tmp]\n" \
" stq_c %[__tmp],%[__mem]\n" \
" beq %[__tmp],1b\n" \
mb2 \
: [__ret] "=&r" (__ret), \
[__tmp] "=&r" (__tmp) \
- : [__mem] "m" (*(mem)) \
+ : [__mem] "m" (*(mem)), \
+ [__val] "Ir" (value) \
: "memory"); \
__ret; })
Index: sysdeps/unix/sysv/linux/alpha/clone.S
===================================================================
RCS file: /cvs/glibc/libc/sysdeps/unix/sysv/linux/alpha/clone.S,v
retrieving revision 1.14
diff -c -p -d -u -r1.14 clone.S
--- sysdeps/unix/sysv/linux/alpha/clone.S 24 Jun 2003 16:38:45 -0000 1.14
+++ sysdeps/unix/sysv/linux/alpha/clone.S 30 Jun 2003 23:11:03 -0000
@@ -24,9 +24,13 @@
#define _ERRNO_H 1
#include <bits/errno.h>
-/* int clone(int (*fn)(void *arg), void *child_stack, int flags, void *arg,
- pid_t *tid, void *tls);
- */
+/* int clone(int (*fn)(void *arg), void *child_stack, int flags,
+ void *arg, pid_t *ptid, void *tls, pid_t *ctid);
+
+ Note that everything past ARG is technically optional, based
+ on FLAGS, and that CTID is arg 7, and thus is on the stack.
+ However, since a load from top-of-stack better be legal always,
+ we don't bother checking FLAGS. */
.text
ENTRY(__clone)
@@ -51,11 +55,13 @@ ENTRY(__clone)
stq a0,0(a1)
stq a3,8(a1)
- /* Shift the flags, tid and tls arguments into place; the
+ /* The syscall is of the form clone(flags, usp, ptid, ctid, tls).
+ Shift the flags, ptid, ctid, tls arguments into place; the
child_stack argument is already correct. */
mov a2,a0
mov a4,a2
- mov a5,a3
+ ldq a3,0(sp)
+ mov a5,a4
/* Do the system call. */
ldiq v0,__NR_clone