aboutsummaryrefslogtreecommitdiff
path: root/sysdeps
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2003-03-21 08:03:25 +0000
committerUlrich Drepper <drepper@redhat.com>2003-03-21 08:03:25 +0000
commit5a3ab2fc180056cb14eaeae0f571421be81e371b (patch)
treeaf48122e19c238a39db145412a11b1b551d472e6 /sysdeps
parent18627f615b80b51778a65cf588f2741ad5f9b0a7 (diff)
downloadglibc-5a3ab2fc180056cb14eaeae0f571421be81e371b.tar
glibc-5a3ab2fc180056cb14eaeae0f571421be81e371b.tar.gz
glibc-5a3ab2fc180056cb14eaeae0f571421be81e371b.tar.bz2
glibc-5a3ab2fc180056cb14eaeae0f571421be81e371b.zip
Update.
2003-03-21 Ulrich Drepper <drepper@redhat.com> * cancellation.c: Adjust for new form of compare&exchange macros. * cleanup_defer.c: Likewise. * init.c: Likewise. * libc-cancellation.c: Likewise. * old_pthread_cond_broadcast.c: Likewise. * old_pthread_cond_signal.c: Likewise. * old_pthread_cond_timedwait.c: Likewise. * old_pthread_cond_wait.c: Likewise. * pthread_cancel.c: Likewise. * pthread_create.c: Likewise. * pthread_detach.c: Likewise. * pthread_join.c: Likewise. * pthread_key_delete.c: Likewise. * pthread_setcancelstate.c: Likewise. * pthread_setcanceltype.c: Likewise. * pthread_timedjoin.c: Likewise. * pthread_tryjoin.c: Likewise. * sysdeps/pthread/createthread.c: Likewise.
Diffstat (limited to 'sysdeps')
-rw-r--r--sysdeps/i386/i486/bits/atomic.h49
-rw-r--r--sysdeps/ia64/bits/atomic.h18
-rw-r--r--sysdeps/powerpc/bits/atomic.h62
-rw-r--r--sysdeps/s390/bits/atomic.h10
-rw-r--r--sysdeps/unix/sysv/linux/getsysstats.c2
-rw-r--r--sysdeps/x86_64/bits/atomic.h16
6 files changed, 80 insertions, 77 deletions
diff --git a/sysdeps/i386/i486/bits/atomic.h b/sysdeps/i386/i486/bits/atomic.h
index e22e560a38..2255e19f8e 100644
--- a/sysdeps/i386/i486/bits/atomic.h
+++ b/sysdeps/i386/i486/bits/atomic.h
@@ -55,23 +55,23 @@ typedef uintmax_t uatomic_max_t;
#endif
-#define __arch_compare_and_exchange_8_acq(mem, newval, oldval) \
- ({ unsigned char ret; \
- __asm __volatile (LOCK "cmpxchgb %b2, %1; setne %0" \
+#define __arch_compare_and_exchange_val_8_acq(mem, newval, oldval) \
+ ({ __typeof (*mem) ret; \
+ __asm __volatile (LOCK "cmpxchgb %b2, %1" \
: "=a" (ret), "=m" (*mem) \
: "q" (newval), "1" (*mem), "0" (oldval)); \
ret; })
-#define __arch_compare_and_exchange_16_acq(mem, newval, oldval) \
- ({ unsigned char ret; \
- __asm __volatile (LOCK "cmpxchgw %w2, %1; setne %0" \
+#define __arch_compare_and_exchange_val_16_acq(mem, newval, oldval) \
+ ({ __typeof (*mem) ret; \
+ __asm __volatile (LOCK "cmpxchgw %w2, %1" \
: "=a" (ret), "=m" (*mem) \
: "r" (newval), "1" (*mem), "0" (oldval)); \
ret; })
-#define __arch_compare_and_exchange_32_acq(mem, newval, oldval) \
- ({ unsigned char ret; \
- __asm __volatile (LOCK "cmpxchgl %2, %1; setne %0" \
+#define __arch_compare_and_exchange_val_32_acq(mem, newval, oldval) \
+ ({ __typeof (*mem) ret; \
+ __asm __volatile (LOCK "cmpxchgl %2, %1" \
: "=a" (ret), "=m" (*mem) \
: "r" (newval), "1" (*mem), "0" (oldval)); \
ret; })
@@ -83,37 +83,34 @@ typedef uintmax_t uatomic_max_t;
really going to be used the code below can be used on Intel Pentium
and later, but NOT on i486. */
#if 1
-# define __arch_compare_and_exchange_64_acq(mem, newval, oldval) \
+# define __arch_compare_and_exchange_val_64_acq(mem, newval, oldval) \
(abort (), 0)
#else
# ifdef __PIC__
-# define __arch_compare_and_exchange_64_acq(mem, newval, oldval) \
- ({ unsigned char ret; \
- int ignore; \
- __asm __volatile ("xchgl %3, %%ebx\n\t" \
- LOCK "cmpxchg8b %2, %1\n\t" \
- "setne %0\n\t" \
- "xchgl %3, %%ebx" \
- : "=a" (ret), "=m" (*mem), "=d" (ignore) \
+# define __arch_compare_and_exchange_val_64_acq(mem, newval, oldval) \
+ ({ __typeof (*mem) ret; \
+ __asm __volatile ("xchgl %2, %%ebx\n\t" \
+ LOCK "cmpxchg8b %1\n\t" \
+ "xchgl %2, %%ebx" \
+ : "=A" (ret), "=m" (*mem) \
: "DS" (((unsigned long long int) (newval)) \
& 0xffffffff), \
"c" (((unsigned long long int) (newval)) >> 32), \
- "1" (*mem), "0" (((unsigned long long int) (oldval)) \
+ "1" (*mem), "a" (((unsigned long long int) (oldval)) \
& 0xffffffff), \
- "2" (((unsigned long long int) (oldval)) >> 32)); \
+ "d" (((unsigned long long int) (oldval)) >> 32)); \
ret; })
# else
# define __arch_compare_and_exchange_64_acq(mem, newval, oldval) \
- ({ unsigned char ret; \
- int ignore; \
- __asm __volatile (LOCK "cmpxchg8b %2, %1; setne %0" \
- : "=a" (ret), "=m" (*mem), "=d" (ignore) \
+ ({ __typeof (*mem) ret; \
+ __asm __volatile (LOCK "cmpxchg8b %1" \
+ : "=A" (ret), "=m" (*mem) \
: "b" (((unsigned long long int) (newval)) \
& 0xffffffff), \
"c" (((unsigned long long int) (newval)) >> 32), \
- "1" (*mem), "0" (((unsigned long long int) (oldval)) \
+ "1" (*mem), "a" (((unsigned long long int) (oldval)) \
& 0xffffffff), \
- "2" (((unsigned long long int) (oldval)) >> 32)); \
+ "d" (((unsigned long long int) (oldval)) >> 32)); \
ret; })
# endif
#endif
diff --git a/sysdeps/ia64/bits/atomic.h b/sysdeps/ia64/bits/atomic.h
index 7c6ebf13ff..27789c0a2e 100644
--- a/sysdeps/ia64/bits/atomic.h
+++ b/sysdeps/ia64/bits/atomic.h
@@ -45,25 +45,31 @@ typedef intmax_t atomic_max_t;
typedef uintmax_t uatomic_max_t;
-#define __arch_compare_and_exchange_8_acq(mem, newval, oldval) \
+#define __arch_compare_and_exchange_bool_8_acq(mem, newval, oldval) \
(abort (), 0)
-#define __arch_compare_and_exchange_16_acq(mem, newval, oldval) \
+#define __arch_compare_and_exchange_bool_16_acq(mem, newval, oldval) \
(abort (), 0)
-#define __arch_compare_and_exchange_32_acq(mem, newval, oldval) \
+#define __arch_compare_and_exchange_bool_32_acq(mem, newval, oldval) \
(!__sync_bool_compare_and_swap_si ((int *) (mem), (int) (long) (oldval), \
(int) (long) (newval)))
-#define __arch_compare_and_exchange_64_acq(mem, newval, oldval) \
+#define __arch_compare_and_exchange_bool_64_acq(mem, newval, oldval) \
(!__sync_bool_compare_and_swap_di ((long *) (mem), (long) (oldval), \
(long) (newval)))
-#define __arch_compare_and_exchange_32_val_acq(mem, newval, oldval) \
+#define __arch_compare_and_exchange_val_8_acq(mem, newval, oldval) \
+ (abort (), 0)
+
+#define __arch_compare_and_exchange_val_16_acq(mem, newval, oldval) \
+ (abort (), 0)
+
+#define __arch_compare_and_exchange_val_32_acq(mem, newval, oldval) \
__sync_val_compare_and_swap_si ((int *) (mem), (int) (long) (oldval), \
(int) (long) (newval))
-#define __arch_compare_and_exchange_64_val_acq(mem, newval, oldval) \
+#define __arch_compare_and_exchange_val_64_acq(mem, newval, oldval) \
__sync_val_compare_and_swap_di ((long *) (mem), (long) (oldval), \
(long) (newval))
diff --git a/sysdeps/powerpc/bits/atomic.h b/sysdeps/powerpc/bits/atomic.h
index 956272c482..49f1c14b9d 100644
--- a/sysdeps/powerpc/bits/atomic.h
+++ b/sysdeps/powerpc/bits/atomic.h
@@ -46,10 +46,10 @@ typedef intmax_t atomic_max_t;
typedef uintmax_t uatomic_max_t;
-#define __arch_compare_and_exchange_8_acq(mem, newval, oldval) \
+#define __arch_compare_and_exchange_bool_8_acq(mem, newval, oldval) \
(abort (), 0)
-#define __arch_compare_and_exchange_16_acq(mem, newval, oldval) \
+#define __arch_compare_and_exchange_bool_16_acq(mem, newval, oldval) \
(abort (), 0)
#ifdef UP
@@ -69,41 +69,41 @@ typedef uintmax_t uatomic_max_t;
* XXX this may not work properly on 64-bit if the register
* containing oldval has the high half non-zero for some reason.
*/
-#define __arch_compare_and_exchange_32_acq(mem, newval, oldval) \
-({ \
- unsigned int __tmp; \
- __asm __volatile (__ARCH_REL_INSTR "\n" \
- "1: lwarx %0,0,%1\n" \
- " subf. %0,%2,%0\n" \
- " bne 2f\n" \
- " stwcx. %3,0,%1\n" \
- " bne- 1b\n" \
- "2: " __ARCH_ACQ_INSTR \
- : "=&r" (__tmp) \
- : "r" (mem), "r" (oldval), "r" (newval) \
- : "cr0", "memory"); \
- __tmp != 0; \
+#define __arch_compare_and_exchange_bool_32_acq(mem, newval, oldval) \
+({ \
+ unsigned int __tmp; \
+ __asm __volatile (__ARCH_REL_INSTR "\n" \
+ "1: lwarx %0,0,%1\n" \
+ " subf. %0,%2,%0\n" \
+ " bne 2f\n" \
+ " stwcx. %3,0,%1\n" \
+ " bne- 1b\n" \
+ "2: " __ARCH_ACQ_INSTR \
+ : "=&r" (__tmp) \
+ : "r" (mem), "r" (oldval), "r" (newval) \
+ : "cr0", "memory"); \
+ __tmp != 0; \
})
#ifdef __powerpc64__
-# define __arch_compare_and_exchange_64_acq(mem, newval, oldval)\
-({ \
- unsigned long __tmp; \
- __asm __volatile (__ARCH_REL_INSTR "\n" \
- "1: ldarx %0,0,%1\n" \
- " subf. %0,%2,%0\n" \
- " bne 2f\n" \
- " stdcx. %3,0,%1\n" \
- " bne- 1b\n" \
- "2: " __ARCH_ACQ_INSTR \
- : "=&r" (__tmp) \
- : "r" (mem), "r" (oldval), "r" (newval) \
- : "cr0", "memory"); \
- __tmp != 0; \
+# define __arch_compare_and_exchange_bool_64_acq(mem, newval, oldval) \
+({ \
+ unsigned long __tmp; \
+ __asm __volatile (__ARCH_REL_INSTR "\n" \
+ "1: ldarx %0,0,%1\n" \
+ " subf. %0,%2,%0\n" \
+ " bne 2f\n" \
+ " stdcx. %3,0,%1\n" \
+ " bne- 1b\n" \
+ "2: " __ARCH_ACQ_INSTR \
+ : "=&r" (__tmp) \
+ : "r" (mem), "r" (oldval), "r" (newval) \
+ : "cr0", "memory"); \
+ __tmp != 0; \
})
#else /* powerpc32 */
-# define __arch_compare_and_exchange_64_acq(mem, newval, oldval) \
+# define __arch_compare_and_exchange_bool_64_acq(mem, newval, oldval) \
(abort (), 0)
#endif
diff --git a/sysdeps/s390/bits/atomic.h b/sysdeps/s390/bits/atomic.h
index 375ae0d5e7..74321b62ae 100644
--- a/sysdeps/s390/bits/atomic.h
+++ b/sysdeps/s390/bits/atomic.h
@@ -45,13 +45,13 @@ typedef intmax_t atomic_max_t;
typedef uintmax_t uatomic_max_t;
-#define __arch_compare_and_exchange_8_acq(mem, newval, oldval) \
+#define __arch_compare_and_exchange_bool_8_acq(mem, newval, oldval) \
(abort (), 0)
-#define __arch_compare_and_exchange_16_acq(mem, newval, oldval) \
+#define __arch_compare_and_exchange_bool_16_acq(mem, newval, oldval) \
(abort (), 0)
-#define __arch_compare_and_exchange_32_acq(mem, newval, oldval) \
+#define __arch_compare_and_exchange_bool_32_acq(mem, newval, oldval) \
({ unsigned int *__mem = (unsigned int *) (mem); \
unsigned int __old = (unsigned int) (oldval); \
unsigned int __cmp = __old; \
@@ -61,7 +61,7 @@ typedef uintmax_t uatomic_max_t;
__cmp != __old; })
#ifdef __s390x__
-# define __arch_compare_and_exchange_64_acq(mem, newval, oldval) \
+# define __arch_compare_and_exchange_bool_64_acq(mem, newval, oldval) \
({ unsigned long int *__mem = (unsigned long int *) (mem); \
unsigned long int __old = (unsigned long int) (oldval); \
unsigned long int __cmp = __old; \
@@ -73,6 +73,6 @@ typedef uintmax_t uatomic_max_t;
/* For 31 bit we do not really need 64-bit compare-and-exchange. We can
implement them by use of the csd instruction. The straightforward
implementation causes warnings so we skip the definition for now. */
-# define __arch_compare_and_exchange_64_acq(mem, newval, oldval) \
+# define __arch_compare_and_exchange_bool_64_acq(mem, newval, oldval) \
(abort (), 0)
#endif
diff --git a/sysdeps/unix/sysv/linux/getsysstats.c b/sysdeps/unix/sysv/linux/getsysstats.c
index c44e45ca6b..71e90fefb1 100644
--- a/sysdeps/unix/sysv/linux/getsysstats.c
+++ b/sysdeps/unix/sysv/linux/getsysstats.c
@@ -85,7 +85,7 @@ get_proc_path (char *buffer, size_t bufsize)
/* Now store the copied value. But do it atomically. */
assert (sizeof (long int) == sizeof (void *__unbounded));
- if (atomic_compare_and_exchange_acq (&mount_proc, copy_result, NULL) == 0)
+ if (! atomic_compare_and_exchange_bool_acq (&mount_proc, copy_result, NULL))
/* Replacing the value failed. This means another thread was
faster and we don't need the copy anymore. */
free (copy_result);
diff --git a/sysdeps/x86_64/bits/atomic.h b/sysdeps/x86_64/bits/atomic.h
index 22d3ab0267..742f8b1773 100644
--- a/sysdeps/x86_64/bits/atomic.h
+++ b/sysdeps/x86_64/bits/atomic.h
@@ -55,29 +55,29 @@ typedef uintmax_t uatomic_max_t;
#endif
-#define __arch_compare_and_exchange_8_acq(mem, newval, oldval) \
- ({ unsigned char ret; \
+#define __arch_compare_and_exchange_val_8_acq(mem, newval, oldval) \
+ ({ __typeof (*mem) ret; \
__asm __volatile (LOCK "cmpxchgb %b2, %1; setne %0" \
: "=a" (ret), "=m" (*mem) \
: "q" (newval), "1" (*mem), "0" (oldval)); \
ret; })
-#define __arch_compare_and_exchange_16_acq(mem, newval, oldval) \
- ({ unsigned char ret; \
+#define __arch_compare_and_exchange_val_16_acq(mem, newval, oldval) \
+ ({ __typeof (*mem) ret; \
__asm __volatile (LOCK "cmpxchgw %w2, %1; setne %0" \
: "=a" (ret), "=m" (*mem) \
: "r" (newval), "1" (*mem), "0" (oldval)); \
ret; })
-#define __arch_compare_and_exchange_32_acq(mem, newval, oldval) \
- ({ unsigned char ret; \
+#define __arch_compare_and_exchange_val_32_acq(mem, newval, oldval) \
+ ({ __typeof (*mem) ret; \
__asm __volatile (LOCK "cmpxchgl %2, %1; setne %0" \
: "=a" (ret), "=m" (*mem) \
: "r" (newval), "1" (*mem), "0" (oldval)); \
ret; })
-#define __arch_compare_and_exchange_64_acq(mem, newval, oldval) \
- ({ unsigned char ret; \
+#define __arch_compare_and_exchange_val_64_acq(mem, newval, oldval) \
+ ({ __typeof (*mem) ret; \
__asm __volatile (LOCK "cmpxchgq %q2, %1; setne %0" \
: "=a" (ret), "=m" (*mem) \
: "r" (newval), "1" (*mem), "0" (oldval)); \