public inbox for libc-ports@sourceware.org
 help / color / mirror / Atom feed
* Fix warnings from aborting MIPS atomic macros
@ 2012-11-20  1:06 Joseph S. Myers
  0 siblings, 0 replies; only message in thread
From: Joseph S. Myers @ 2012-11-20  1:06 UTC (permalink / raw)
  To: libc-ports

The MIPS atomic macros contain versions that abort for unsupported sizes 
for atomic operations (8-bit, 16-bit; 64-bit for o32).  These result in 
compiler warnings from the "__prev = __cmp = 0" assignments, when __prev 
is of pointer type but __cmp = 0 is of integer type.  I've applied this 
patch to fix this by separating the two assignments (since assigning 
constant 0 to both integer and pointer variables is always fine), which in 
turn requires a cast of __cmp to (void) to avoid "set but not used" 
warnings for that variable.

This reduces the number of warnings I see in MIPS glibc builds (with GCC 
4.7) to below 100 for each of the three ABIs.

2012-11-20  Joseph Myers  <joseph@codesourcery.com>

	* sysdeps/mips/bits/atomic.h [!__GNUC_PREREQ (4, 8)]
	(__arch_compare_and_exchange_xxx_8_int): Separate assignments to
	__prev and __cmp.  Cast __cmp to void.
	[!__GNUC_PREREQ (4, 8)] (__arch_compare_and_exchange_xxx_16_int):
	Likewise.
	[!__GNUC_PREREQ (4, 8) && _MIPS_SIM == _ABIO32]
	(__arch_compare_and_exchange_xxx_64_int): Likewise.

diff --git a/ports/sysdeps/mips/bits/atomic.h b/ports/sysdeps/mips/bits/atomic.h
index c5a26b9..3466df7 100644
--- a/ports/sysdeps/mips/bits/atomic.h
+++ b/ports/sysdeps/mips/bits/atomic.h
@@ -209,10 +209,10 @@ typedef uintmax_t uatomic_max_t;
    in which values are returned.  */
 
 # define __arch_compare_and_exchange_xxx_8_int(mem, newval, oldval, rel, acq) \
-  (abort (), __prev = __cmp = 0)
+  (abort (), __prev = 0, __cmp = 0, (void) __cmp)
 
 # define __arch_compare_and_exchange_xxx_16_int(mem, newval, oldval, rel, acq) \
-  (abort (), __prev = __cmp = 0)
+  (abort (), __prev = 0, __cmp = 0, (void) __cmp)
 
 # define __arch_compare_and_exchange_xxx_32_int(mem, newval, oldval, rel, acq) \
      __asm__ __volatile__ (						      \
@@ -236,7 +236,7 @@ typedef uintmax_t uatomic_max_t;
 # if _MIPS_SIM == _ABIO32
 /* We can't do an atomic 64-bit operation in O32.  */
 # define __arch_compare_and_exchange_xxx_64_int(mem, newval, oldval, rel, acq) \
-  (abort (), __prev = __cmp = 0)
+  (abort (), __prev = 0, __cmp = 0, (void) __cmp)
 # else
 # define __arch_compare_and_exchange_xxx_64_int(mem, newval, oldval, rel, acq) \
      __asm__ __volatile__ ("\n"						      \

-- 
Joseph S. Myers
joseph@codesourcery.com

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2012-11-20  1:06 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-11-20  1:06 Fix warnings from aborting MIPS atomic macros Joseph S. Myers

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).