This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCHv2 05/14] Refactor M_ macros defined in libm-test.inc


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

	* libm-test.inc [M_PI_6l] Rename to
	[pi_6_d]: New Macro.
	[M_PI_34l]: Rename to
	[pi_3_m_4_d]: New Macro.
	[M_PI_34_LOG10El]: Rename to
	[pi_3_ln10_m_4_d]: New Macro.
	[M_PI2_LOG10El]: Rename to
	[pi_2_ln10_m_d]:  New Macro.
	[M_PI4_LOG10El]: Rename to
	[pi_4_ln10_m_d]:  New Macro.
	[M_PI_LOG10El]: Rename to
	[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 4b3964d..e41a2d4 100644
--- a/math/libm-test.inc
+++ b/math/libm-test.inc
@@ -308,13 +308,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 of pi (we must supply them precalculated for accuracy).
+   They are written as a series of postfix operations to try to keep them
+   concise yet somewhat readable.  */
+
+/* pi / 6 */
+#define pi_6_d			LIT (.52359877559829887307710723054658383)
+/* (pi * 3) / 4 */
+#define pi_3_m_4_d		LIT (2.356194490192344928846982537459627163)
+/* (pi * 3 * ln(10) / 4 */
+#define pi_3_m_ln10_m_4_d	LIT (1.023282265381381010614337719073516828)
+/* pi / (2 * ln(10)) */
+#define pi_2_ln10_m_d		LIT (0.682188176920920673742891812715677885)
+/* pi / (4 * ln(10)) */
+#define pi_4_ln10_m_d		LIT (0.341094088460460336871445906357838943)
+/* pi / ln(10) */
+#define pi_ln10_d		LIT (1.364376353841841347485783625431355770)
 
 #define ulps_file_name "ULPs"	/* Name of the ULPs file.  */
 static FILE *ulps_file;		/* File to document difference.  */
@@ -1984,8 +1993,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, pi_3_m_4_d, ERRNO_UNCHANGED),
+    TEST_ff_f (atan2, minus_infty, minus_infty, -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),
@@ -2077,8 +2086,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, pi_3_m_4_d, minus_infty),
+    TEST_c_c (cacos, minus_infty, minus_infty, 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),
@@ -2764,8 +2773,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, pi_3_m_4_d),
+    TEST_c_c (cacosh, minus_infty, minus_infty, plus_infty, -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),
@@ -3467,9 +3476,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, pi_3_m_4_d),
 
-    TEST_c_f (carg, minus_infty, minus_infty, -M_PI_34l),
+    TEST_c_f (carg, minus_infty, minus_infty, -pi_3_m_4_d),
 
     TEST_c_f (carg, qnan_value, qnan_value, qnan_value),
 
@@ -6229,8 +6238,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, pi_3_m_4_d),
+    TEST_c_c (clog, minus_infty, minus_infty, plus_infty, -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),
@@ -6284,30 +6293,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, pi_ln10_d, DIVIDE_BY_ZERO_EXCEPTION),
+    TEST_c_c (clog10, minus_zero, minus_zero, minus_infty, -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, pi_3_m_ln10_m_4_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, pi_4_ln10_m_d),
+    TEST_c_c (clog10, plus_infty, minus_infty, plus_infty, -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, pi_2_ln10_m_d),
+    TEST_c_c (clog10, 3, plus_infty, plus_infty, pi_2_ln10_m_d),
+    TEST_c_c (clog10, minus_zero, plus_infty, plus_infty, pi_2_ln10_m_d),
+    TEST_c_c (clog10, -3, plus_infty, plus_infty, pi_2_ln10_m_d),
+    TEST_c_c (clog10, 0, minus_infty, plus_infty, -pi_2_ln10_m_d),
+    TEST_c_c (clog10, 3, minus_infty, plus_infty, -pi_2_ln10_m_d),
+    TEST_c_c (clog10, minus_zero, minus_infty, plus_infty, -pi_2_ln10_m_d),
+    TEST_c_c (clog10, -3, minus_infty, plus_infty, -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, pi_ln10_d),
+    TEST_c_c (clog10, minus_infty, 1, plus_infty, pi_ln10_d),
+    TEST_c_c (clog10, minus_infty, minus_zero, plus_infty, -pi_ln10_d),
+    TEST_c_c (clog10, minus_infty, -1, plus_infty, -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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]