This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Fix powerpc fpu_control.h namespace and parenthesis issues (bug 15966)
- From: "Joseph S. Myers" <joseph at codesourcery dot com>
- To: <libc-alpha at sourceware dot org>
- Cc: "Ryan S. Arnold" <ryan dot arnold at gmail dot com>
- Date: Tue, 17 Sep 2013 16:57:05 +0000
- Subject: Fix powerpc fpu_control.h namespace and parenthesis issues (bug 15966)
- Authentication-results: sourceware.org; auth=none
While working on the e500 port, I noticed that the existing classic
hard-float case in the powerpc fpu_control.h defined _FPU_GETCW and
_FPU_SETCW in ways that are not namespace-clean (use identifiers "d",
"cw" and "tmp" that are in the user's namespace and don't form part of
the interface provided by this header) and fail to surround a use of
the argument to _FPU_SETCW with parentheses. (The macros *did* use
initial "__" on the parameter name, presumably to avoid conflict with
the field called "cw", but that's exactly the wrong way around to do
things; macro parameter names never interfere with the user's
namespace.)
This patch (untested) fixes these issues in the obvious way.
2013-09-17 Joseph Myers <joseph@codesourcery.com>
[BZ #15966]
* sysdeps/powerpc/fpu_control.h [!_SOFT_FLOAT && !__NO_FPRS__]
(_FPU_GETCW): Use initial "__" on variable and field names but not
on macro parameter name.
[!_SOFT_FLOAT && !__NO_FPRS__] (_FPU_SETCW): Likewise. Use
parentheses around reference to macro parameter.
diff --git a/sysdeps/powerpc/fpu_control.h b/sysdeps/powerpc/fpu_control.h
index 159543b..1a6d395 100644
--- a/sysdeps/powerpc/fpu_control.h
+++ b/sysdeps/powerpc/fpu_control.h
@@ -59,18 +59,18 @@ extern fpu_control_t __fpu_control;
typedef unsigned int fpu_control_t __attribute__ ((__mode__ (__SI__)));
/* Macros for accessing the hardware control word. */
-# define _FPU_GETCW(__cw) ( { \
- union { double d; fpu_control_t cw[2]; } \
- tmp __attribute__ ((__aligned__(8))); \
- __asm__ ("mffs 0; stfd%U0 0,%0" : "=m" (tmp.d) : : "fr0"); \
- (__cw)=tmp.cw[1]; \
- tmp.cw[1]; } )
-# define _FPU_SETCW(__cw) { \
- union { double d; fpu_control_t cw[2]; } \
- tmp __attribute__ ((__aligned__(8))); \
- tmp.cw[0] = 0xFFF80000; /* More-or-less arbitrary; this is a QNaN. */ \
- tmp.cw[1] = __cw; \
- __asm__ ("lfd%U0 0,%0; mtfsf 255,0" : : "m" (tmp.d) : "fr0"); \
+# define _FPU_GETCW(cw) ( { \
+ union { double __d; fpu_control_t __cw[2]; } \
+ __tmp __attribute__ ((__aligned__(8))); \
+ __asm__ ("mffs 0; stfd%U0 0,%0" : "=m" (__tmp.__d) : : "fr0"); \
+ (cw) = __tmp.__cw[1]; \
+ __tmp.__cw[1]; } )
+# define _FPU_SETCW(cw) { \
+ union { double __d; fpu_control_t __cw[2]; } \
+ __tmp __attribute__ ((__aligned__(8))); \
+ __tmp.__cw[0] = 0xFFF80000; /* More-or-less arbitrary; this is a QNaN. */ \
+ __tmp.__cw[1] = (cw); \
+ __asm__ ("lfd%U0 0,%0; mtfsf 255,0" : : "m" (__tmp.__d) : "fr0"); \
}
/* Default control word set at startup. */
--
Joseph S. Myers
joseph@codesourcery.com