about summary refs log tree commit diff
path: root/soft-fp/op-1.h
diff options
context:
space:
mode:
authorJoseph Myers <joseph@codesourcery.com>2014-10-09 17:05:26 +0000
committerJoseph Myers <joseph@codesourcery.com>2014-10-09 17:05:26 +0000
commit5c0508a318af0a6c8be2a4cb2e3b76896218bf35 (patch)
treebb4d0c9b22bad8ba022828c8a36dfeb69f511244 /soft-fp/op-1.h
parenta736ec370a05e4b37e6101eb3168bf8dc4c5af13 (diff)
downloadglibc-5c0508a318af0a6c8be2a4cb2e3b76896218bf35.tar.gz
glibc-5c0508a318af0a6c8be2a4cb2e3b76896218bf35.tar.xz
glibc-5c0508a318af0a6c8be2a4cb2e3b76896218bf35.zip
soft-fp: Use parentheses around macro arguments.
This patch cleans up the soft-fp code to use parentheses around macro
arguments (where possible; many macro arguments are identifiers used
with ## rather than arbitrary expressions, so cannot be put in
parentheses).  (I'm not aware of any bugs caused by the lack of
parentheses, but this is generally good practice.  The patch is not
exhaustive regarding internal macros where the arguments always come
directly from the mantissa of a floating-point number, although
probably those should be cleaned up in this regard as well.)

Tested for powerpc-nofpu that the installed shared libraries are
unchanged by this patch.

	* soft-fp/double.h [_FP_W_TYPE_SIZE < 64] (FP_UNPACK_RAW_D): Use
	parentheses around macro arguments.
	[_FP_W_TYPE_SIZE < 64] (FP_UNPACK_RAW_DP): Likewise.
	[_FP_W_TYPE_SIZE < 64] (FP_PACK_RAW_D): Likewise.
	[_FP_W_TYPE_SIZE < 64] (FP_PACK_RAW_DP): Likewise.
	[_FP_W_TYPE_SIZE < 64] (FP_UNPACK_D): Likewise.
	[_FP_W_TYPE_SIZE < 64] (FP_UNPACK_DP): Likewise.
	[_FP_W_TYPE_SIZE < 64] (FP_UNPACK_SEMIRAW_D): Likewise.
	[_FP_W_TYPE_SIZE < 64] (FP_UNPACK_SEMIRAW_DP): Likewise.
	[_FP_W_TYPE_SIZE < 64] (FP_PACK_D): Likewise.
	[_FP_W_TYPE_SIZE < 64] (FP_PACK_DP): Likewise.
	[_FP_W_TYPE_SIZE < 64] (FP_PACK_SEMIRAW_D): Likewise.
	[_FP_W_TYPE_SIZE < 64] (FP_PACK_SEMIRAW_DP): Likewise.
	[_FP_W_TYPE_SIZE < 64] (_FP_SQRT_MEAT_D): Likewise.
	[_FP_W_TYPE_SIZE < 64] (FP_CMP_D): Likewise.
	[_FP_W_TYPE_SIZE < 64] (FP_CMP_EQ_D): Likewise.
	[_FP_W_TYPE_SIZE < 64] (FP_CMP_UNORD_D): Likewise.
	[_FP_W_TYPE_SIZE < 64] (FP_TO_INT_D): Likewise.
	[_FP_W_TYPE_SIZE < 64] (FP_FROM_INT_D): Likewise.
	[_FP_W_TYPE_SIZE >= 64] (FP_UNPACK_RAW_D): Likewise.
	[_FP_W_TYPE_SIZE >= 64] (FP_UNPACK_RAW_DP): Likewise.
	[_FP_W_TYPE_SIZE >= 64] (FP_PACK_RAW_D): Likewise.
	[_FP_W_TYPE_SIZE >= 64] (FP_PACK_RAW_DP): Likewise.
	[_FP_W_TYPE_SIZE >= 64] (FP_UNPACK_D): Likewise.
	[_FP_W_TYPE_SIZE >= 64] (FP_UNPACK_DP): Likewise.
	[_FP_W_TYPE_SIZE >= 64] (FP_UNPACK_SEMIRAW_D): Likewise.
	[_FP_W_TYPE_SIZE >= 64] (FP_UNPACK_SEMIRAW_DP): Likewise.
	[_FP_W_TYPE_SIZE >= 64] (FP_PACK_D): Likewise.
	[_FP_W_TYPE_SIZE >= 64] (FP_PACK_DP): Likewise.
	[_FP_W_TYPE_SIZE >= 64] (FP_PACK_SEMIRAW_D): Likewise.
	[_FP_W_TYPE_SIZE >= 64] (FP_PACK_SEMIRAW_DP): Likewise.
	[_FP_W_TYPE_SIZE >= 64] (_FP_SQRT_MEAT_D): Likewise.
	[_FP_W_TYPE_SIZE >= 64] (FP_CMP_D): Likewise.
	[_FP_W_TYPE_SIZE >= 64] (FP_CMP_EQ_D): Likewise.
	[_FP_W_TYPE_SIZE >= 64] (FP_CMP_UNORD_D): Likewise.
	[_FP_W_TYPE_SIZE >= 64] (FP_TO_INT_D): Likewise.
	[_FP_W_TYPE_SIZE >= 64] (FP_FROM_INT_D): Likewise.
	* soft-fp/extended.h [_FP_W_TYPE_SIZE < 64] (FP_UNPACK_E):
	Likewise.
	[_FP_W_TYPE_SIZE < 64] (FP_UNPACK_EP): Likewise.
	[_FP_W_TYPE_SIZE < 64] (FP_UNPACK_SEMIRAW_E): Likewise.
	[_FP_W_TYPE_SIZE < 64] (FP_UNPACK_SEMIRAW_EP): Likewise.
	[_FP_W_TYPE_SIZE < 64] (FP_PACK_E): Likewise.
	[_FP_W_TYPE_SIZE < 64] (FP_PACK_EP): Likewise.
	[_FP_W_TYPE_SIZE < 64] (FP_PACK_SEMIRAW_E): Likewise.
	[_FP_W_TYPE_SIZE < 64] (FP_PACK_SEMIRAW_EP): Likewise.
	[_FP_W_TYPE_SIZE < 64] (_FP_SQRT_MEAT_E): Likewise.
	[_FP_W_TYPE_SIZE < 64] (FP_CMP_E): Likewise.
	[_FP_W_TYPE_SIZE < 64] (FP_CMP_EQ_E): Likewise.
	[_FP_W_TYPE_SIZE < 64] (FP_CMP_UNORD_E): Likewise.
	[_FP_W_TYPE_SIZE < 64] (FP_TO_INT_E): Likewise.
	[_FP_W_TYPE_SIZE < 64] (FP_FROM_INT_E): Likewise.
	[_FP_W_TYPE_SIZE >= 64] (FP_UNPACK_E): Likewise.
	[_FP_W_TYPE_SIZE >= 64] (FP_UNPACK_EP): Likewise.
	[_FP_W_TYPE_SIZE >= 64] (FP_UNPACK_SEMIRAW_E): Likewise.
	[_FP_W_TYPE_SIZE >= 64] (FP_UNPACK_SEMIRAW_EP): Likewise.
	[_FP_W_TYPE_SIZE >= 64] (FP_PACK_E): Likewise.
	[_FP_W_TYPE_SIZE >= 64] (FP_PACK_EP): Likewise.
	[_FP_W_TYPE_SIZE >= 64] (FP_PACK_SEMIRAW_E): Likewise.
	[_FP_W_TYPE_SIZE >= 64] (FP_PACK_SEMIRAW_EP): Likewise.
	[_FP_W_TYPE_SIZE >= 64] (_FP_SQRT_MEAT_E): Likewise.
	[_FP_W_TYPE_SIZE >= 64] (FP_CMP_E): Likewise.
	[_FP_W_TYPE_SIZE >= 64] (FP_CMP_EQ_E): Likewise.
	[_FP_W_TYPE_SIZE >= 64] (FP_CMP_UNORD_E): Likewise.
	[_FP_W_TYPE_SIZE >= 64] (FP_TO_INT_E): Likewise.
	[_FP_W_TYPE_SIZE >= 64] (FP_FROM_INT_E): Likewise.
	* soft-fp/op-1.h (_FP_FRAC_SRST_1): Likewise.
	(_FP_FRAC_SRS_1): Likewise.
	(_FP_FRAC_CLZ_1): Likewise.
	(_FP_MUL_MEAT_1_imm): Likewise.
	(_FP_MUL_MEAT_1_wide): Likewise.
	(_FP_MUL_MEAT_1_hard): Likewise.
	(_FP_SQRT_MEAT_1): Likewise.
	(_FP_FRAC_ASSEMBLE_1): Likewise.
	(_FP_FRAC_DISASSEMBLE_1): Likewise.
	* soft-fp/op-2.h (_FP_FRAC_CLZ_2): Likewise.
	(__FP_CLZ_2): Likewise.
	(_FP_MUL_MEAT_2_wide): Likewise.
	(_FP_MUL_MEAT_2_wide_3mul): Likewise.
	(_FP_MUL_MEAT_2_gmp): Likewise.
	(_FP_MUL_MEAT_2_120_240_double): Likewise.
	(_FP_SQRT_MEAT_2): Likewise.
	(_FP_FRAC_ASSEMBLE_2): Likewise.
	(_FP_FRAC_DISASSEMBLE_2): Likewise.
	* soft-fp/op-4.h (_FP_FRAC_SRS_4): Likewise.
	(_FP_FRAC_CLZ_4): Likewise.
	(_FP_MUL_MEAT_4_wide): Likewise.
	(_FP_MUL_MEAT_4_gmp): Likewise.
	(_FP_SQRT_MEAT_4): Likewise.
	(_FP_FRAC_ASSEMBLE_4): Likewise.
	(_FP_FRAC_DISASSEMBLE_4): Likewise.
	* soft-fp/op-common.h (_FP_CMP): Likewise.
	(_FP_CMP_EQ): Likewise.
	(_FP_CMP_UNORD): Likewise.
	(_FP_TO_INT): Likewise.
	(_FP_FROM_INT): Likewise.
	[!__FP_CLZ] (__FP_CLZ): Likewise.
	(_FP_DIV_HELP_imm): Likewise.
	* soft-fp/quad.h [_FP_W_TYPE_SIZE < 64] (FP_UNPACK_RAW_Q):
	Likewise.
	[_FP_W_TYPE_SIZE < 64] (FP_UNPACK_RAW_QP): Likewise.
	[_FP_W_TYPE_SIZE < 64] (FP_PACK_RAW_Q): Likewise.
	[_FP_W_TYPE_SIZE < 64] (FP_PACK_RAW_QP): Likewise.
	[_FP_W_TYPE_SIZE < 64] (FP_UNPACK_Q): Likewise.
	[_FP_W_TYPE_SIZE < 64] (FP_UNPACK_QP): Likewise.
	[_FP_W_TYPE_SIZE < 64] (FP_UNPACK_SEMIRAW_Q): Likewise.
	[_FP_W_TYPE_SIZE < 64] (FP_UNPACK_SEMIRAW_QP): Likewise.
	[_FP_W_TYPE_SIZE < 64] (FP_PACK_Q): Likewise.
	[_FP_W_TYPE_SIZE < 64] (FP_PACK_QP): Likewise.
	[_FP_W_TYPE_SIZE < 64] (FP_PACK_SEMIRAW_Q): Likewise.
	[_FP_W_TYPE_SIZE < 64] (FP_PACK_SEMIRAW_QP): Likewise.
	[_FP_W_TYPE_SIZE < 64] (_FP_SQRT_MEAT_Q): Likewise.
	[_FP_W_TYPE_SIZE < 64] (FP_CMP_Q): Likewise.
	[_FP_W_TYPE_SIZE < 64] (FP_CMP_EQ_Q): Likewise.
	[_FP_W_TYPE_SIZE < 64] (FP_CMP_UNORD_Q): Likewise.
	[_FP_W_TYPE_SIZE < 64] (FP_TO_INT_Q): Likewise.
	[_FP_W_TYPE_SIZE < 64] (FP_FROM_INT_Q): Likewise.
	[_FP_W_TYPE_SIZE >= 64] (FP_UNPACK_RAW_Q): Likewise.
	[_FP_W_TYPE_SIZE >= 64] (FP_UNPACK_RAW_QP): Likewise.
	[_FP_W_TYPE_SIZE >= 64] (FP_PACK_RAW_Q): Likewise.
	[_FP_W_TYPE_SIZE >= 64] (FP_PACK_RAW_QP): Likewise.
	[_FP_W_TYPE_SIZE >= 64] (FP_UNPACK_Q): Likewise.
	[_FP_W_TYPE_SIZE >= 64] (FP_UNPACK_QP): Likewise.
	[_FP_W_TYPE_SIZE >= 64] (FP_UNPACK_SEMIRAW_Q): Likewise.
	[_FP_W_TYPE_SIZE >= 64] (FP_UNPACK_SEMIRAW_QP): Likewise.
	[_FP_W_TYPE_SIZE >= 64] (FP_PACK_Q): Likewise.
	[_FP_W_TYPE_SIZE >= 64] (FP_PACK_QP): Likewise.
	[_FP_W_TYPE_SIZE >= 64] (FP_PACK_SEMIRAW_Q): Likewise.
	[_FP_W_TYPE_SIZE >= 64] (FP_PACK_SEMIRAW_QP): Likewise.
	[_FP_W_TYPE_SIZE >= 64] (_FP_SQRT_MEAT_Q): Likewise.
	[_FP_W_TYPE_SIZE >= 64] (FP_CMP_Q): Likewise.
	[_FP_W_TYPE_SIZE >= 64] (FP_CMP_EQ_Q): Likewise.
	[_FP_W_TYPE_SIZE >= 64] (FP_CMP_UNORD_Q): Likewise.
	[_FP_W_TYPE_SIZE >= 64] (FP_TO_INT_Q): Likewise.
	[_FP_W_TYPE_SIZE >= 64] (FP_FROM_INT_Q): Likewise.
	* soft-fp/single.h (FP_UNPACK_RAW_S): Likewise.
	(FP_UNPACK_RAW_SP): Likewise.
	(FP_PACK_RAW_S): Likewise.
	(FP_PACK_RAW_SP): Likewise.
	(FP_UNPACK_S): Likewise.
	(FP_UNPACK_SP): Likewise.
	(FP_UNPACK_SEMIRAW_S): Likewise.
	(FP_UNPACK_SEMIRAW_SP): Likewise.
	(FP_PACK_S): Likewise.
	(FP_PACK_SP): Likewise.
	(FP_PACK_SEMIRAW_S): Likewise.
	(FP_PACK_SEMIRAW_SP): Likewise.
	(_FP_SQRT_MEAT_S): Likewise.
	(FP_CMP_S): Likewise.
	(FP_CMP_EQ_S): Likewise.
	(FP_CMP_UNORD_S): Likewise.
	(FP_TO_INT_S): Likewise.
	(FP_FROM_INT_S): Likewise.
Diffstat (limited to 'soft-fp/op-1.h')
-rw-r--r--soft-fp/op-1.h52
1 files changed, 27 insertions, 25 deletions
diff --git a/soft-fp/op-1.h b/soft-fp/op-1.h
index fa68269910..177705caa3 100644
--- a/soft-fp/op-1.h
+++ b/soft-fp/op-1.h
@@ -50,8 +50,8 @@
 #define _FP_FRAC_SRL_1(X, N)	(X##_f >>= N)
 
 /* Right shift with sticky-lsb.  */
-#define _FP_FRAC_SRST_1(X, S, N, sz)	__FP_FRAC_SRST_1 (X##_f, S, N, sz)
-#define _FP_FRAC_SRS_1(X, N, sz)	__FP_FRAC_SRS_1 (X##_f, N, sz)
+#define _FP_FRAC_SRST_1(X, S, N, sz)	__FP_FRAC_SRST_1 (X##_f, S, (N), (sz))
+#define _FP_FRAC_SRS_1(X, N, sz)	__FP_FRAC_SRS_1 (X##_f, (N), (sz))
 
 #define __FP_FRAC_SRST_1(X, S, N, sz)			\
   do							\
@@ -71,7 +71,7 @@
 #define _FP_FRAC_ADD_1(R, X, Y)	(R##_f = X##_f + Y##_f)
 #define _FP_FRAC_SUB_1(R, X, Y)	(R##_f = X##_f - Y##_f)
 #define _FP_FRAC_DEC_1(X, Y)	(X##_f -= Y##_f)
-#define _FP_FRAC_CLZ_1(z, X)	__FP_CLZ (z, X##_f)
+#define _FP_FRAC_CLZ_1(z, X)	__FP_CLZ ((z), X##_f)
 
 /* Predicates.  */
 #define _FP_FRAC_NEGP_1(X)	((_FP_WS_TYPE) X##_f < 0)
@@ -157,11 +157,11 @@
 #define _FP_MUL_MEAT_1_imm(wfracbits, R, X, Y)				\
   do									\
     {									\
-      _FP_MUL_MEAT_DW_1_imm (wfracbits, R, X, Y);			\
+      _FP_MUL_MEAT_DW_1_imm ((wfracbits), R, X, Y);			\
       /* Normalize since we know where the msb of the multiplicands	\
 	 were (bit B), we know that the msb of the of the product is	\
 	 at either 2B or 2B-1.  */					\
-      _FP_FRAC_SRS_1 (R, wfracbits-1, 2*wfracbits);			\
+      _FP_FRAC_SRS_1 (R, (wfracbits)-1, 2*(wfracbits));			\
     }									\
   while (0)
 
@@ -178,12 +178,13 @@
   do									\
     {									\
       _FP_FRAC_DECL_2 (_FP_MUL_MEAT_1_wide_Z);				\
-      _FP_MUL_MEAT_DW_1_wide (wfracbits, _FP_MUL_MEAT_1_wide_Z,		\
+      _FP_MUL_MEAT_DW_1_wide ((wfracbits), _FP_MUL_MEAT_1_wide_Z,	\
 			      X, Y, doit);				\
       /* Normalize since we know where the msb of the multiplicands	\
 	 were (bit B), we know that the msb of the of the product is	\
 	 at either 2B or 2B-1.  */					\
-      _FP_FRAC_SRS_2 (_FP_MUL_MEAT_1_wide_Z, wfracbits-1, 2*wfracbits);	\
+      _FP_FRAC_SRS_2 (_FP_MUL_MEAT_1_wide_Z, (wfracbits)-1,		\
+		      2*(wfracbits));					\
       R##_f = _FP_MUL_MEAT_1_wide_Z_f0;					\
     }									\
   while (0)
@@ -225,17 +226,18 @@
     }									\
   while (0)
 
-#define _FP_MUL_MEAT_1_hard(wfracbits, R, X, Y)				\
-  do									\
-    {									\
-      _FP_FRAC_DECL_2 (_FP_MUL_MEAT_1_hard_z);				\
-      _FP_MUL_MEAT_DW_1_hard (wfracbits, _FP_MUL_MEAT_1_hard_z, X, Y);	\
-									\
-      /* Normalize.  */							\
-      _FP_FRAC_SRS_2 (_FP_MUL_MEAT_1_hard_z,				\
-		      wfracbits - 1, 2*wfracbits);			\
-      R##_f = _FP_MUL_MEAT_1_hard_z_f0;					\
-    }									\
+#define _FP_MUL_MEAT_1_hard(wfracbits, R, X, Y)			\
+  do								\
+    {								\
+      _FP_FRAC_DECL_2 (_FP_MUL_MEAT_1_hard_z);			\
+      _FP_MUL_MEAT_DW_1_hard ((wfracbits),			\
+			      _FP_MUL_MEAT_1_hard_z, X, Y);	\
+								\
+      /* Normalize.  */						\
+      _FP_FRAC_SRS_2 (_FP_MUL_MEAT_1_hard_z,			\
+		      (wfracbits) - 1, 2*(wfracbits));		\
+      R##_f = _FP_MUL_MEAT_1_hard_z_f0;				\
+    }								\
   while (0)
 
 
@@ -329,17 +331,17 @@
 #define _FP_SQRT_MEAT_1(R, S, T, X, q)		\
   do						\
     {						\
-      while (q != _FP_WORK_ROUND)		\
+      while ((q) != _FP_WORK_ROUND)		\
 	{					\
-	  T##_f = S##_f + q;			\
+	  T##_f = S##_f + (q);			\
 	  if (T##_f <= X##_f)			\
 	    {					\
-	      S##_f = T##_f + q;		\
+	      S##_f = T##_f + (q);		\
 	      X##_f -= T##_f;			\
-	      R##_f += q;			\
+	      R##_f += (q);			\
 	    }					\
 	  _FP_FRAC_SLL_1 (X, 1);		\
-	  q >>= 1;				\
+	  (q) >>= 1;				\
 	}					\
       if (X##_f)				\
 	{					\
@@ -353,8 +355,8 @@
 /* Assembly/disassembly for converting to/from integral types.
    No shifting or overflow handled here.  */
 
-#define _FP_FRAC_ASSEMBLE_1(r, X, rsize)	(r = X##_f)
-#define _FP_FRAC_DISASSEMBLE_1(X, r, rsize)	(X##_f = r)
+#define _FP_FRAC_ASSEMBLE_1(r, X, rsize)	((r) = X##_f)
+#define _FP_FRAC_DISASSEMBLE_1(X, r, rsize)	(X##_f = (r))
 
 
 /* Convert FP values between word sizes.  */