From 6561a219b9e6c67e49a5154f188004ae1552b46c Mon Sep 17 00:00:00 2001
From: "Paul E. Murphy" <murphyp@linux.vnet.ibm.com>
Date: Fri, 20 May 2016 09:46:39 -0500
Subject: [PATCH 1/9] Refactor M_ macros defined in libm-test.inc

These are local to the test suite.  Rename them as a macro starting
with lit_pi and a series of postfix operations to give us a constant
starting with lit_pi.

The lit prefix is intended to enable easy substitutions via
gen-test-libm.pl if needed.

	* libm-test.inc (M_PI_6l) Rename to
	(lit_pi_6_d): New Macro.
	(M_PI_34l): Rename to
	(lit_pi_3_m_4_d): New Macro.
	(M_PI_34_LOG10El): Rename to
	(lit_pi_3_m_4_ln10_m_d): New Macro.
	(M_PI2_LOG10El): Rename to
	(lit_pi_2_ln10_m_d):  New Macro.
	(M_PI4_LOG10El): Rename to
	(lit_pi_4_ln10_m_d):  New Macro.
	(M_PI_LOG10El): Rename to
	(lit_pi_ln10_d):  New Macro.
---
 math/libm-test.inc | 77 ++++++++++++++++++++++++++++++------------------------
 1 file changed, 43 insertions(+), 34 deletions(-)

diff --git a/math/libm-test.inc b/math/libm-test.inc
index 9c75a01..c27f3cd 100644
--- a/math/libm-test.inc
+++ b/math/libm-test.inc
@@ -305,13 +305,22 @@ struct ulp_data
 # define TEST_COND_x86		0
 #endif
 
-/* Various constants (we must supply them precalculated for accuracy).  */
-#define M_PI_6l			.52359877559829887307710723054658383L
-#define M_PI_34l		2.356194490192344928846982537459627163L	/* 3*pi/4 */
-#define M_PI_34_LOG10El		1.023282265381381010614337719073516828L
-#define M_PI2_LOG10El		0.682188176920920673742891812715677885L
-#define M_PI4_LOG10El		0.341094088460460336871445906357838943L
-#define M_PI_LOG10El		1.364376353841841347485783625431355770L
+/* Various constants derived from pi.  We must supply them precalculated for
+   accuracy.  They are written as a series of postfix operations to keep
+   them concise yet somewhat readable.  */
+
+/* pi / 6 */
+#define lit_pi_6_d		LIT (.52359877559829887307710723054658383)
+/* (pi * 3) / 4 */
+#define lit_pi_3_m_4_d		LIT (2.356194490192344928846982537459627163)
+/* pi * 3 / (4 * ln(10)) */
+#define lit_pi_3_m_4_ln10_m_d	LIT (1.023282265381381010614337719073516828)
+/* pi / (2 * ln(10)) */
+#define lit_pi_2_ln10_m_d	LIT (0.682188176920920673742891812715677885)
+/* pi / (4 * ln(10)) */
+#define lit_pi_4_ln10_m_d	LIT (0.341094088460460336871445906357838943)
+/* pi / ln(10) */
+#define lit_pi_ln10_d		LIT (1.364376353841841347485783625431355770)
 
 #define ulps_file_name "ULPs"	/* Name of the ULPs file.  */
 static FILE *ulps_file;		/* File to document difference.  */
@@ -1989,8 +1998,8 @@ static const struct test_ff_f_data atan2_test_data[] =
 
     TEST_ff_f (atan2, plus_infty, plus_infty, M_PI_4l, ERRNO_UNCHANGED),
     TEST_ff_f (atan2, minus_infty, plus_infty, -M_PI_4l, ERRNO_UNCHANGED),
-    TEST_ff_f (atan2, plus_infty, minus_infty, M_PI_34l, ERRNO_UNCHANGED),
-    TEST_ff_f (atan2, minus_infty, minus_infty, -M_PI_34l, ERRNO_UNCHANGED),
+    TEST_ff_f (atan2, plus_infty, minus_infty, lit_pi_3_m_4_d, ERRNO_UNCHANGED),
+    TEST_ff_f (atan2, minus_infty, minus_infty, -lit_pi_3_m_4_d, ERRNO_UNCHANGED),
     TEST_ff_f (atan2, qnan_value, qnan_value, qnan_value, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
     TEST_ff_f (atan2, qnan_value, -qnan_value, qnan_value, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
     TEST_ff_f (atan2, -qnan_value, qnan_value, qnan_value, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
@@ -2082,8 +2091,8 @@ static const struct test_c_c_data cacos_test_data[] =
     TEST_c_c (cacos, minus_zero, minus_zero, M_PI_2l, 0.0),
     TEST_c_c (cacos, 0, minus_zero, M_PI_2l, 0.0),
 
-    TEST_c_c (cacos, minus_infty, plus_infty, M_PI_34l, minus_infty),
-    TEST_c_c (cacos, minus_infty, minus_infty, M_PI_34l, plus_infty),
+    TEST_c_c (cacos, minus_infty, plus_infty, lit_pi_3_m_4_d, minus_infty),
+    TEST_c_c (cacos, minus_infty, minus_infty, lit_pi_3_m_4_d, plus_infty),
 
     TEST_c_c (cacos, plus_infty, plus_infty, M_PI_4l, minus_infty),
     TEST_c_c (cacos, plus_infty, minus_infty, M_PI_4l, plus_infty),
@@ -2769,8 +2778,8 @@ static const struct test_c_c_data cacosh_test_data[] =
     TEST_c_c (cacosh, minus_zero, 0, 0.0, M_PI_2l),
     TEST_c_c (cacosh, 0, minus_zero, 0.0, -M_PI_2l),
     TEST_c_c (cacosh, minus_zero, minus_zero, 0.0, -M_PI_2l),
-    TEST_c_c (cacosh, minus_infty, plus_infty, plus_infty, M_PI_34l),
-    TEST_c_c (cacosh, minus_infty, minus_infty, plus_infty, -M_PI_34l),
+    TEST_c_c (cacosh, minus_infty, plus_infty, plus_infty, lit_pi_3_m_4_d),
+    TEST_c_c (cacosh, minus_infty, minus_infty, plus_infty, -lit_pi_3_m_4_d),
 
     TEST_c_c (cacosh, plus_infty, plus_infty, plus_infty, M_PI_4l),
     TEST_c_c (cacosh, plus_infty, minus_infty, plus_infty, -M_PI_4l),
@@ -3472,9 +3481,9 @@ static const struct test_c_f_data carg_test_data[] =
 
     TEST_c_f (carg, plus_infty, minus_infty, -M_PI_4l),
 
-    TEST_c_f (carg, minus_infty, plus_infty, M_PI_34l),
+    TEST_c_f (carg, minus_infty, plus_infty, lit_pi_3_m_4_d),
 
-    TEST_c_f (carg, minus_infty, minus_infty, -M_PI_34l),
+    TEST_c_f (carg, minus_infty, minus_infty, -lit_pi_3_m_4_d),
 
     TEST_c_f (carg, qnan_value, qnan_value, qnan_value),
 
@@ -6236,8 +6245,8 @@ static const struct test_c_c_data clog_test_data[] =
     TEST_c_c (clog, 0, 0, minus_infty, 0.0, DIVIDE_BY_ZERO_EXCEPTION),
     TEST_c_c (clog, 0, minus_zero, minus_infty, minus_zero, DIVIDE_BY_ZERO_EXCEPTION),
 
-    TEST_c_c (clog, minus_infty, plus_infty, plus_infty, M_PI_34l),
-    TEST_c_c (clog, minus_infty, minus_infty, plus_infty, -M_PI_34l),
+    TEST_c_c (clog, minus_infty, plus_infty, plus_infty, lit_pi_3_m_4_d),
+    TEST_c_c (clog, minus_infty, minus_infty, plus_infty, -lit_pi_3_m_4_d),
 
     TEST_c_c (clog, plus_infty, plus_infty, plus_infty, M_PI_4l),
     TEST_c_c (clog, plus_infty, minus_infty, plus_infty, -M_PI_4l),
@@ -6291,30 +6300,30 @@ clog_test (void)
 
 static const struct test_c_c_data clog10_test_data[] =
   {
-    TEST_c_c (clog10, minus_zero, 0, minus_infty, M_PI_LOG10El, DIVIDE_BY_ZERO_EXCEPTION),
-    TEST_c_c (clog10, minus_zero, minus_zero, minus_infty, -M_PI_LOG10El, DIVIDE_BY_ZERO_EXCEPTION),
+    TEST_c_c (clog10, minus_zero, 0, minus_infty, lit_pi_ln10_d, DIVIDE_BY_ZERO_EXCEPTION),
+    TEST_c_c (clog10, minus_zero, minus_zero, minus_infty, -lit_pi_ln10_d, DIVIDE_BY_ZERO_EXCEPTION),
 
     TEST_c_c (clog10, 0, 0, minus_infty, 0.0, DIVIDE_BY_ZERO_EXCEPTION),
     TEST_c_c (clog10, 0, minus_zero, minus_infty, minus_zero, DIVIDE_BY_ZERO_EXCEPTION),
 
-    TEST_c_c (clog10, minus_infty, plus_infty, plus_infty, M_PI_34_LOG10El),
+    TEST_c_c (clog10, minus_infty, plus_infty, plus_infty, lit_pi_3_m_4_ln10_m_d),
 
-    TEST_c_c (clog10, plus_infty, plus_infty, plus_infty, M_PI4_LOG10El),
-    TEST_c_c (clog10, plus_infty, minus_infty, plus_infty, -M_PI4_LOG10El),
+    TEST_c_c (clog10, plus_infty, plus_infty, plus_infty, lit_pi_4_ln10_m_d),
+    TEST_c_c (clog10, plus_infty, minus_infty, plus_infty, -lit_pi_4_ln10_m_d),
 
-    TEST_c_c (clog10, 0, plus_infty, plus_infty, M_PI2_LOG10El),
-    TEST_c_c (clog10, 3, plus_infty, plus_infty, M_PI2_LOG10El),
-    TEST_c_c (clog10, minus_zero, plus_infty, plus_infty, M_PI2_LOG10El),
-    TEST_c_c (clog10, -3, plus_infty, plus_infty, M_PI2_LOG10El),
-    TEST_c_c (clog10, 0, minus_infty, plus_infty, -M_PI2_LOG10El),
-    TEST_c_c (clog10, 3, minus_infty, plus_infty, -M_PI2_LOG10El),
-    TEST_c_c (clog10, minus_zero, minus_infty, plus_infty, -M_PI2_LOG10El),
-    TEST_c_c (clog10, -3, minus_infty, plus_infty, -M_PI2_LOG10El),
+    TEST_c_c (clog10, 0, plus_infty, plus_infty, lit_pi_2_ln10_m_d),
+    TEST_c_c (clog10, 3, plus_infty, plus_infty, lit_pi_2_ln10_m_d),
+    TEST_c_c (clog10, minus_zero, plus_infty, plus_infty, lit_pi_2_ln10_m_d),
+    TEST_c_c (clog10, -3, plus_infty, plus_infty, lit_pi_2_ln10_m_d),
+    TEST_c_c (clog10, 0, minus_infty, plus_infty, -lit_pi_2_ln10_m_d),
+    TEST_c_c (clog10, 3, minus_infty, plus_infty, -lit_pi_2_ln10_m_d),
+    TEST_c_c (clog10, minus_zero, minus_infty, plus_infty, -lit_pi_2_ln10_m_d),
+    TEST_c_c (clog10, -3, minus_infty, plus_infty, -lit_pi_2_ln10_m_d),
 
-    TEST_c_c (clog10, minus_infty, 0, plus_infty, M_PI_LOG10El),
-    TEST_c_c (clog10, minus_infty, 1, plus_infty, M_PI_LOG10El),
-    TEST_c_c (clog10, minus_infty, minus_zero, plus_infty, -M_PI_LOG10El),
-    TEST_c_c (clog10, minus_infty, -1, plus_infty, -M_PI_LOG10El),
+    TEST_c_c (clog10, minus_infty, 0, plus_infty, lit_pi_ln10_d),
+    TEST_c_c (clog10, minus_infty, 1, plus_infty, lit_pi_ln10_d),
+    TEST_c_c (clog10, minus_infty, minus_zero, plus_infty, -lit_pi_ln10_d),
+    TEST_c_c (clog10, minus_infty, -1, plus_infty, -lit_pi_ln10_d),
 
     TEST_c_c (clog10, plus_infty, 0, plus_infty, 0.0),
     TEST_c_c (clog10, plus_infty, 1, plus_infty, 0.0),
-- 
2.4.11

