This is the mail archive of the libc-hacker@sources.redhat.com mailing list for the glibc project.
Note that libc-hacker is a closed list. You may look at the archives of this list, but subscription and posting are not open.
| Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
|---|---|---|
| Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
| Other format: | [Raw text] | |
Hi!
This is on top of my earlier atomic.h patch.
Due to a typo tst-atomic seemed to suceed on some arches altough it actually
failed (like on s390*).
s390/bits/atomic.h had 2 problems: __old clashed with __old use in
include/atomic.h and then there was an aliasing problem: if mem type
is not unsigned int, but say unsigned long or pointer (on 32-bit),
then code using atomic_compare_and_exchange_val_acq would access the
same object using different types (this resulted in 2 checks failed
in tst-atomic-long with -O2 and -O3).
2003-03-22 Jakub Jelinek <jakub at redhat dot com>
* csu/tst-atomic.c (do_test): Return ret, not 0.
* sysdeps/s390/bits/atomic.h (__arch_compare_and_exchange_val_32_acq):
Use __typeof for local variables types instead of assuming int.
Change prefix of local variables to __arch.
--- libc/csu/tst-atomic.c.jj 2003-03-21 11:41:50.000000000 -0500
+++ libc/csu/tst-atomic.c 2003-03-21 17:48:53.000000000 -0500
@@ -269,7 +269,7 @@ do_test (void)
}
#endif
- return 0;
+ return ret;
}
#define TEST_FUNCTION do_test ()
--- libc/sysdeps/s390/bits/atomic.h.jj 2003-03-21 08:23:32.000000000 -0500
+++ libc/sysdeps/s390/bits/atomic.h 2003-03-21 18:23:44.000000000 -0500
@@ -52,21 +52,21 @@ typedef uintmax_t uatomic_max_t;
(abort (), 0)
#define __arch_compare_and_exchange_val_32_acq(mem, newval, oldval) \
- ({ unsigned int *__mem = (unsigned int *) (mem); \
- unsigned int __old = (unsigned int) (oldval); \
+ ({ __typeof (mem) __archmem = (mem); \
+ __typeof (*mem) __archold = (oldval); \
__asm __volatile ("cs %0,%2,%1" \
- : "+d" (__old), "=Q" (*__mem) \
- : "d" (newval), "m" (*__mem) : "cc" ); \
- __old; })
+ : "+d" (__archold), "=Q" (*__archmem) \
+ : "d" (newval), "m" (*__archmem) : "cc" ); \
+ __archold; })
#ifdef __s390x__
# define __arch_compare_and_exchange_val_64_acq(mem, newval, oldval) \
- ({ unsigned long int *__mem = (unsigned long int *) (mem); \
- unsigned long int __old = (unsigned long int) (oldval); \
+ ({ __typeof (mem) __archmem = (mem); \
+ __typeof (*mem) __archold = (oldval); \
__asm __volatile ("csg %0,%2,%1" \
- : "+d" (__old), "=Q" (*__mem) \
- : "d" (newval), "m" (*__mem) : "cc" ); \
- __old; })
+ : "+d" (__archold), "=Q" (*__archmem) \
+ : "d" (newval), "m" (*__archmem) : "cc" ); \
+ __archold; })
#else
/* 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
Jakub
| Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
|---|---|---|
| Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |