Start math tests with a clean fenv.

We always want the default floating point environment when running these
tests.

Bug: 17358010
Change-Id: I6ca2552e9f2d3e07d7b9dcaf0aec66905401c466
diff --git a/tests/math_cos_test.cpp b/tests/math_cos_test.cpp
index c0a2d82..4917e87 100644
--- a/tests/math_cos_test.cpp
+++ b/tests/math_cos_test.cpp
@@ -16,6 +16,8 @@
 
 #include <math.h>
 
+#include <fenv.h>
+
 #include <gtest/gtest.h>
 
 #if defined(__BIONIC__)
@@ -5634,6 +5636,7 @@
 
 TEST(math_cos, cos_intel) {
 #if defined(__BIONIC__)
+  fesetenv(FE_DFL_ENV);
   for (size_t i = 0; i < sizeof(g_cos_intel_data)/sizeof(cos_intel_data_t); i++) {
     EXPECT_DOUBLE_EQ(g_cos_intel_data[i].expected, cos(g_cos_intel_data[i].call_data)) << "Failed on element " << i;
   }
diff --git a/tests/math_cosf_test.cpp b/tests/math_cosf_test.cpp
index ea95ff3..8520c1d 100644
--- a/tests/math_cosf_test.cpp
+++ b/tests/math_cosf_test.cpp
@@ -16,6 +16,8 @@
 
 #include <math.h>
 
+#include <fenv.h>
+
 #include <gtest/gtest.h>
 
 #if defined(__BIONIC__)
@@ -4346,6 +4348,7 @@
 
 TEST(math_cosf, cosf_intel) {
 #if defined(__BIONIC__)
+  fesetenv(FE_DFL_ENV);
   for (size_t i = 0; i < sizeof(g_cosf_intel_data)/sizeof(cosf_intel_data_t); i++) {
     EXPECT_FLOAT_EQ(g_cosf_intel_data[i].expected, cosf(g_cosf_intel_data[i].call_data)) << "Failed on element " << i;
   }
diff --git a/tests/math_exp_test.cpp b/tests/math_exp_test.cpp
index beb2584..c9c6ad5 100644
--- a/tests/math_exp_test.cpp
+++ b/tests/math_exp_test.cpp
@@ -16,6 +16,8 @@
 
 #include <math.h>
 
+#include <fenv.h>
+
 #include <gtest/gtest.h>
 
 #if defined(__BIONIC__)
@@ -1966,6 +1968,7 @@
 
 TEST(math_exp, exp_intel) {
 #if defined(__BIONIC__)
+  fesetenv(FE_DFL_ENV);
   for (size_t i = 0; i < sizeof(g_exp_intel_data)/sizeof(exp_intel_data_t); i++) {
     EXPECT_DOUBLE_EQ(g_exp_intel_data[i].expected, exp(g_exp_intel_data[i].call_data)) << "Failed on element " << i;
   }
diff --git a/tests/math_expf_test.cpp b/tests/math_expf_test.cpp
index 257aa26..30bc946 100644
--- a/tests/math_expf_test.cpp
+++ b/tests/math_expf_test.cpp
@@ -16,6 +16,8 @@
 
 #include <math.h>
 
+#include <fenv.h>
+
 #include <gtest/gtest.h>
 
 #if defined(__BIONIC__)
@@ -1430,6 +1432,7 @@
 
 TEST(math_expf, expf_intel) {
 #if defined(__BIONIC__)
+  fesetenv(FE_DFL_ENV);
   for (size_t i = 0; i < sizeof(g_expf_intel_data)/sizeof(expf_intel_data_t); i++) {
     EXPECT_FLOAT_EQ(g_expf_intel_data[i].expected, expf(g_expf_intel_data[i].call_data)) << "Failed on element " << i;
   }
diff --git a/tests/math_log_test.cpp b/tests/math_log_test.cpp
index da2a848..4f136a7 100644
--- a/tests/math_log_test.cpp
+++ b/tests/math_log_test.cpp
@@ -16,6 +16,8 @@
 
 #include <math.h>
 
+#include <fenv.h>
+
 #include <gtest/gtest.h>
 
 #if defined(__BIONIC__)
@@ -1666,6 +1668,7 @@
 
 TEST(math_log, log_intel) {
 #if defined(__BIONIC__)
+  fesetenv(FE_DFL_ENV);
   for (size_t i = 0; i < sizeof(g_log_intel_data)/sizeof(log_intel_data_t); i++) {
     EXPECT_DOUBLE_EQ(g_log_intel_data[i].expected, log(g_log_intel_data[i].call_data)) << "Failed on element " << i;
   }
diff --git a/tests/math_logf_test.cpp b/tests/math_logf_test.cpp
index e5d0921..ca02095 100644
--- a/tests/math_logf_test.cpp
+++ b/tests/math_logf_test.cpp
@@ -16,6 +16,8 @@
 
 #include <math.h>
 
+#include <fenv.h>
+
 #include <gtest/gtest.h>
 
 #if defined(__BIONIC__)
@@ -1318,6 +1320,7 @@
 
 TEST(math_logf, logf_intel) {
 #if defined(__BIONIC__)
+  fesetenv(FE_DFL_ENV);
   for (size_t i = 0; i < sizeof(g_logf_intel_data)/sizeof(logf_intel_data_t); i++) {
     EXPECT_FLOAT_EQ(g_logf_intel_data[i].expected, logf(g_logf_intel_data[i].call_data)) << "Failed on element " << i;
   }
diff --git a/tests/math_pow_test.cpp b/tests/math_pow_test.cpp
index c185424..a4caa36 100644
--- a/tests/math_pow_test.cpp
+++ b/tests/math_pow_test.cpp
@@ -16,6 +16,8 @@
 
 #include <math.h>
 
+#include <fenv.h>
+
 #include <gtest/gtest.h>
 
 #if defined(__BIONIC__)
@@ -3291,6 +3293,7 @@
 
 TEST(math_pow, pow_intel) {
 #if defined(__BIONIC__)
+  fesetenv(FE_DFL_ENV);
   for (size_t i = 0; i < sizeof(g_pow_intel_data)/sizeof(pow_intel_data_t); i++) {
     EXPECT_DOUBLE_EQ(g_pow_intel_data[i].expected, pow(g_pow_intel_data[i].x_call_data, g_pow_intel_data[i].y_call_data)) << "Failed on element " << i;
   }
diff --git a/tests/math_powf_test.cpp b/tests/math_powf_test.cpp
index f77b23a..7272644 100644
--- a/tests/math_powf_test.cpp
+++ b/tests/math_powf_test.cpp
@@ -16,6 +16,8 @@
 
 #include <math.h>
 
+#include <fenv.h>
+
 #include <gtest/gtest.h>
 
 #if defined(__BIONIC__)
@@ -2779,6 +2781,7 @@
 
 TEST(math_powf, powf_intel) {
 #if defined(__BIONIC__)
+  fesetenv(FE_DFL_ENV);
   for (size_t i = 0; i < sizeof(g_powf_intel_data)/sizeof(powf_intel_data_t); i++) {
     EXPECT_FLOAT_EQ(g_powf_intel_data[i].expected, powf(g_powf_intel_data[i].x_call_data, g_powf_intel_data[i].y_call_data)) << "Failed on element " << i;
   }
diff --git a/tests/math_sin_test.cpp b/tests/math_sin_test.cpp
index ffa4340..509642c 100644
--- a/tests/math_sin_test.cpp
+++ b/tests/math_sin_test.cpp
@@ -16,6 +16,8 @@
 
 #include <math.h>
 
+#include <fenv.h>
+
 #include <gtest/gtest.h>
 
 #if defined(__BIONIC__)
@@ -5786,6 +5788,7 @@
 
 TEST(math_sin, sin_intel) {
 #if defined(__BIONIC__)
+  fesetenv(FE_DFL_ENV);
   for (size_t i = 0; i < sizeof(g_sin_intel_data)/sizeof(sin_intel_data_t); i++) {
     EXPECT_DOUBLE_EQ(g_sin_intel_data[i].expected, sin(g_sin_intel_data[i].call_data)) << "Failed on element " << i;
   }
diff --git a/tests/math_sincos_test.cpp b/tests/math_sincos_test.cpp
index f2e30de..4093fb9 100644
--- a/tests/math_sincos_test.cpp
+++ b/tests/math_sincos_test.cpp
@@ -18,6 +18,8 @@
 
 #include <math.h>
 
+#include <fenv.h>
+
 #include <gtest/gtest.h>
 
 #if defined(__BIONIC__)
@@ -4778,6 +4780,7 @@
 
 TEST(math_sincos, sincos_intel) {
 #if defined(__BIONIC__)
+  fesetenv(FE_DFL_ENV);
   for (size_t i = 0; i < sizeof(g_sincos_intel_data)/sizeof(sincos_intel_data_t); i++) {
    double dsin, dcos;
    sincos(g_sincos_intel_data[i].call_data, &dsin, &dcos);
diff --git a/tests/math_sincosf_test.cpp b/tests/math_sincosf_test.cpp
index c1a32c9..d30f72e 100644
--- a/tests/math_sincosf_test.cpp
+++ b/tests/math_sincosf_test.cpp
@@ -16,6 +16,8 @@
 
 #include <math.h>
 
+#include <fenv.h>
+
 #include <gtest/gtest.h>
 
 #if defined(__BIONIC__)
@@ -4646,6 +4648,7 @@
 
 TEST(math_sincosf, sincosf_intel) {
 #if defined(__BIONIC__)
+  fesetenv(FE_DFL_ENV);
   for (size_t i = 0; i < sizeof(g_sincosf_intel_data)/sizeof(sincosf_intel_data_t); i++) {
    float fsin, fcos;
    sincosf(g_sincosf_intel_data[i].call_data, &fsin, &fcos);
diff --git a/tests/math_sinf_test.cpp b/tests/math_sinf_test.cpp
index bb1e2c9..0c2e6f1 100644
--- a/tests/math_sinf_test.cpp
+++ b/tests/math_sinf_test.cpp
@@ -16,6 +16,8 @@
 
 #include <math.h>
 
+#include <fenv.h>
+
 #include <gtest/gtest.h>
 
 #if defined(__BIONIC__)
@@ -4386,6 +4388,7 @@
 
 TEST(math_sinf, sinf_intel) {
 #if defined(__BIONIC__)
+  fesetenv(FE_DFL_ENV);
   for (size_t i = 0; i < sizeof(g_sinf_intel_data)/sizeof(sinf_intel_data_t); i++) {
     EXPECT_FLOAT_EQ(g_sinf_intel_data[i].expected, sinf(g_sinf_intel_data[i].call_data)) << "Failed on element " << i;
   }
diff --git a/tests/math_tan_test.cpp b/tests/math_tan_test.cpp
index 6862019..e555ef3 100644
--- a/tests/math_tan_test.cpp
+++ b/tests/math_tan_test.cpp
@@ -16,6 +16,8 @@
 
 #include <math.h>
 
+#include <fenv.h>
+
 #include <gtest/gtest.h>
 
 #if defined(__BIONIC__)
@@ -5194,6 +5196,7 @@
 
 TEST(math_tan, tan_intel) {
 #if defined(__BIONIC__)
+  fesetenv(FE_DFL_ENV);
   for (size_t i = 0; i < sizeof(g_tan_intel_data)/sizeof(tan_intel_data_t); i++) {
     EXPECT_DOUBLE_EQ(g_tan_intel_data[i].expected, tan(g_tan_intel_data[i].call_data)) << "Failed on element " << i;
   }
diff --git a/tests/math_tanf_test.cpp b/tests/math_tanf_test.cpp
index 9319046..db04116 100644
--- a/tests/math_tanf_test.cpp
+++ b/tests/math_tanf_test.cpp
@@ -16,6 +16,8 @@
 
 #include <math.h>
 
+#include <fenv.h>
+
 #include <gtest/gtest.h>
 
 #if defined(__BIONIC__)
@@ -4450,6 +4452,7 @@
 
 TEST(math_tanf, tanf_intel) {
 #if defined(__BIONIC__)
+  fesetenv(FE_DFL_ENV);
   for (size_t i = 0; i < sizeof(g_tanf_intel_data)/sizeof(tanf_intel_data_t); i++) {
     EXPECT_FLOAT_EQ(g_tanf_intel_data[i].expected, tanf(g_tanf_intel_data[i].call_data)) << "Failed on element " << i;
   }