[Gc] [PATCH] Fix missing "unsigned" on fetch CAS calls
Ian Wienand
ian at wienand.org
Sun Jul 1 00:08:02 PDT 2012
Hi,
Debian bug #679680 [1] found this issue
In the generalize-small.h template we have
---
#if defined(AO_HAVE_XSIZE_fetch_compare_and_swap_acquire) \
&& !defined(AO_HAVE_XSIZE_compare_and_swap_acquire)
AO_INLINE int
AO_XSIZE_compare_and_swap_acquire(volatile XCTYPE *addr, XCTYPE old_val,
XCTYPE new_val)
{
return AO_XSIZE_fetch_compare_and_swap_acquire(addr, old_val, new_val)
== old_val;
}
# define AO_HAVE_XSIZE_compare_and_swap_acquire
#endif
---
which matches for ia64; but then it tries to call the fetch CAS with
"addr" which ia64 defines as
---
AO_INLINE unsigned char
AO_char_fetch_compare_and_swap_acquire(volatile unsigned char *addr,
unsigned char old, unsigned char new_val)
---
I'm pretty sure the "unsigned" just got left off in the template
[1] http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=679680
-i
* atomic_ops/generalize-small.template : add unsigned qualifier
when fetch CAS defined (Debian bug #679680)
* atomic_ops/generalize-small.h : regenerate
Signed-off-by: Ian Wienand <ian at wienand.org>
---
src/atomic_ops/generalize-small.h | 45 ++++++++++++++++++------------
src/atomic_ops/generalize-small.template | 15 ++++++----
2 files changed, 36 insertions(+), 24 deletions(-)
diff --git a/src/atomic_ops/generalize-small.h b/src/atomic_ops/generalize-small.h
index f30ebac..6cd6e6a 100644
--- a/src/atomic_ops/generalize-small.h
+++ b/src/atomic_ops/generalize-small.h
@@ -158,8 +158,9 @@
#if defined(AO_HAVE_char_fetch_compare_and_swap_full) \
&& !defined(AO_HAVE_char_compare_and_swap_full)
AO_INLINE int
- AO_char_compare_and_swap_full(volatile char *addr, char old_val,
- char new_val)
+ AO_char_compare_and_swap_full(volatile unsigned char *addr,
+ unsigned char old_val,
+ unsigned char new_val)
{
return AO_char_fetch_compare_and_swap_full(addr, old_val, new_val)
== old_val;
@@ -170,8 +171,9 @@
#if defined(AO_HAVE_char_fetch_compare_and_swap_acquire) \
&& !defined(AO_HAVE_char_compare_and_swap_acquire)
AO_INLINE int
- AO_char_compare_and_swap_acquire(volatile char *addr, char old_val,
- char new_val)
+ AO_char_compare_and_swap_acquire(volatile unsigned char *addr,
+ unsigned char old_val,
+ unsigned char new_val)
{
return AO_char_fetch_compare_and_swap_acquire(addr, old_val, new_val)
== old_val;
@@ -182,8 +184,9 @@
#if defined(AO_HAVE_char_fetch_compare_and_swap_release) \
&& !defined(AO_HAVE_char_compare_and_swap_release)
AO_INLINE int
- AO_char_compare_and_swap_release(volatile char *addr, char old_val,
- char new_val)
+ AO_char_compare_and_swap_release(unsigned volatile char *addr,
+ unsigned char old_val,
+ unsigned char new_val)
{
return AO_char_fetch_compare_and_swap_release(addr, old_val, new_val)
== old_val;
@@ -781,8 +784,9 @@
#if defined(AO_HAVE_short_fetch_compare_and_swap_full) \
&& !defined(AO_HAVE_short_compare_and_swap_full)
AO_INLINE int
- AO_short_compare_and_swap_full(volatile short *addr, short old_val,
- short new_val)
+ AO_short_compare_and_swap_full(volatile unsigned short *addr,
+ unsigned short old_val,
+ unsigned short new_val)
{
return AO_short_fetch_compare_and_swap_full(addr, old_val, new_val)
== old_val;
@@ -793,8 +797,9 @@
#if defined(AO_HAVE_short_fetch_compare_and_swap_acquire) \
&& !defined(AO_HAVE_short_compare_and_swap_acquire)
AO_INLINE int
- AO_short_compare_and_swap_acquire(volatile short *addr, short old_val,
- short new_val)
+ AO_short_compare_and_swap_acquire(volatile unsigned short *addr,
+ unsigned short old_val,
+ unsigned short new_val)
{
return AO_short_fetch_compare_and_swap_acquire(addr, old_val, new_val)
== old_val;
@@ -805,8 +810,9 @@
#if defined(AO_HAVE_short_fetch_compare_and_swap_release) \
&& !defined(AO_HAVE_short_compare_and_swap_release)
AO_INLINE int
- AO_short_compare_and_swap_release(volatile short *addr, short old_val,
- short new_val)
+ AO_short_compare_and_swap_release(unsigned volatile short *addr,
+ unsigned short old_val,
+ unsigned short new_val)
{
return AO_short_fetch_compare_and_swap_release(addr, old_val, new_val)
== old_val;
@@ -1404,8 +1410,9 @@
#if defined(AO_HAVE_int_fetch_compare_and_swap_full) \
&& !defined(AO_HAVE_int_compare_and_swap_full)
AO_INLINE int
- AO_int_compare_and_swap_full(volatile int *addr, int old_val,
- int new_val)
+ AO_int_compare_and_swap_full(volatile unsigned int *addr,
+ unsigned int old_val,
+ unsigned int new_val)
{
return AO_int_fetch_compare_and_swap_full(addr, old_val, new_val)
== old_val;
@@ -1416,8 +1423,9 @@
#if defined(AO_HAVE_int_fetch_compare_and_swap_acquire) \
&& !defined(AO_HAVE_int_compare_and_swap_acquire)
AO_INLINE int
- AO_int_compare_and_swap_acquire(volatile int *addr, int old_val,
- int new_val)
+ AO_int_compare_and_swap_acquire(volatile unsigned int *addr,
+ unsigned int old_val,
+ unsigned int new_val)
{
return AO_int_fetch_compare_and_swap_acquire(addr, old_val, new_val)
== old_val;
@@ -1428,8 +1436,9 @@
#if defined(AO_HAVE_int_fetch_compare_and_swap_release) \
&& !defined(AO_HAVE_int_compare_and_swap_release)
AO_INLINE int
- AO_int_compare_and_swap_release(volatile int *addr, int old_val,
- int new_val)
+ AO_int_compare_and_swap_release(unsigned volatile int *addr,
+ unsigned int old_val,
+ unsigned int new_val)
{
return AO_int_fetch_compare_and_swap_release(addr, old_val, new_val)
== old_val;
diff --git a/src/atomic_ops/generalize-small.template b/src/atomic_ops/generalize-small.template
index b11aa10..f4b573b 100644
--- a/src/atomic_ops/generalize-small.template
+++ b/src/atomic_ops/generalize-small.template
@@ -158,8 +158,9 @@
#if defined(AO_HAVE_XSIZE_fetch_compare_and_swap_full) \
&& !defined(AO_HAVE_XSIZE_compare_and_swap_full)
AO_INLINE int
- AO_XSIZE_compare_and_swap_full(volatile XCTYPE *addr, XCTYPE old_val,
- XCTYPE new_val)
+ AO_XSIZE_compare_and_swap_full(volatile unsigned XCTYPE *addr,
+ unsigned XCTYPE old_val,
+ unsigned XCTYPE new_val)
{
return AO_XSIZE_fetch_compare_and_swap_full(addr, old_val, new_val)
== old_val;
@@ -170,8 +171,9 @@
#if defined(AO_HAVE_XSIZE_fetch_compare_and_swap_acquire) \
&& !defined(AO_HAVE_XSIZE_compare_and_swap_acquire)
AO_INLINE int
- AO_XSIZE_compare_and_swap_acquire(volatile XCTYPE *addr, XCTYPE old_val,
- XCTYPE new_val)
+ AO_XSIZE_compare_and_swap_acquire(volatile unsigned XCTYPE *addr,
+ unsigned XCTYPE old_val,
+ unsigned XCTYPE new_val)
{
return AO_XSIZE_fetch_compare_and_swap_acquire(addr, old_val, new_val)
== old_val;
@@ -182,8 +184,9 @@
#if defined(AO_HAVE_XSIZE_fetch_compare_and_swap_release) \
&& !defined(AO_HAVE_XSIZE_compare_and_swap_release)
AO_INLINE int
- AO_XSIZE_compare_and_swap_release(volatile XCTYPE *addr, XCTYPE old_val,
- XCTYPE new_val)
+ AO_XSIZE_compare_and_swap_release(unsigned volatile XCTYPE *addr,
+ unsigned XCTYPE old_val,
+ unsigned XCTYPE new_val)
{
return AO_XSIZE_fetch_compare_and_swap_release(addr, old_val, new_val)
== old_val;
--
1.7.10
More information about the Gc
mailing list