diff --git a/libc/src/math/generic/CMakeLists.txt b/libc/src/math/generic/CMakeLists.txt --- a/libc/src/math/generic/CMakeLists.txt +++ b/libc/src/math/generic/CMakeLists.txt @@ -44,6 +44,8 @@ libc.include.errno libc.include.math libc.src.errno.__errno_location + COMPILE_OPTIONS + -Wno-c++17-extensions ) add_object_library( @@ -54,6 +56,8 @@ sincosf_data.cpp DEPENDS .math_utils + COMPILE_OPTIONS + -Wno-c++17-extensions ) add_entrypoint_object( diff --git a/libc/src/math/generic/math_utils.cpp b/libc/src/math/generic/math_utils.cpp --- a/libc/src/math/generic/math_utils.cpp +++ b/libc/src/math/generic/math_utils.cpp @@ -10,18 +10,12 @@ namespace __llvm_libc { -const float XFlowValues::overflow_value = - as_float(0x70000000); // 0x1p97f -const float XFlowValues::underflow_value = - as_float(0x10000000); // 0x1p97f -const float XFlowValues::may_underflow_value = - as_float(0x1a200000); // 0x1.4p-75f +constexpr float XFlowValues::overflow_value = 0x1p97f; +constexpr float XFlowValues::underflow_value = 0x1p-95f; +constexpr float XFlowValues::may_underflow_value = 0x1.4p-75f; -const double XFlowValues::overflow_value = - as_double(0x7000000000000000); // 0x1p769 -const double XFlowValues::underflow_value = - as_double(0x1000000000000000); // 0x1p-767 -const double XFlowValues::may_underflow_value = - as_double(0x1e58000000000000); // 0x1.8p-538 +constexpr double XFlowValues::overflow_value = 0x1p769; +constexpr double XFlowValues::underflow_value = 0x1p-767; +constexpr double XFlowValues::may_underflow_value = 0x1.8p-538; } // namespace __llvm_libc diff --git a/libc/src/math/generic/sincosf_data.cpp b/libc/src/math/generic/sincosf_data.cpp --- a/libc/src/math/generic/sincosf_data.cpp +++ b/libc/src/math/generic/sincosf_data.cpp @@ -15,34 +15,34 @@ // The constants and polynomials for sine and cosine. The 2nd entry // computes -cos (x) rather than cos (x) to get negation for free. -const sincos_t __SINCOSF_TABLE[2] = { +constexpr sincos_t __SINCOSF_TABLE[2] = { {{1.0, -1.0, -1.0, 1.0}, - as_double(0x41645f306dc9c883), - as_double(0x3ff921fb54442d18), - as_double(0x3ff0000000000000), - as_double(0xbfdffffffd0c621c), - as_double(0x3fa55553e1068f19), - as_double(0xbf56c087e89a359d), - as_double(0x3ef99343027bf8c3), - as_double(0xbfc555545995a603), - as_double(0x3f81107605230bc4), - as_double(0xbf2994eb3774cf24)}, + 0x1.45f306dc9c883p+23, + 0x1.921fb54442d18p+0, + 0x1p+0, + -0x1.ffffffd0c621cp-2, + 0x1.55553e1068f19p-5, + -0x1.6c087e89a359dp-10, + 0x1.99343027bf8c3p-16, + -0x1.555545995a603p-3, + 0x1.1107605230bc4p-7, + -0x1.994eb3774cf24p-13}, {{1.0, -1.0, -1.0, 1.0}, - as_double(0x41645f306dc9c883), - as_double(0x3ff921fb54442d18), - as_double(0xbff0000000000000), - as_double(0x3fdffffffd0c621c), - as_double(0xbfa55553e1068f19), - as_double(0x3f56c087e89a359d), - as_double(0xbef99343027bf8c3), - as_double(0xbfc555545995a603), - as_double(0x3f81107605230bc4), - as_double(0xbf2994eb3774cf24)}, + 0x1.45f306dc9c883p+23, + 0x1.921fb54442d18p+0, + -0x1p+0, + 0x1.ffffffd0c621cp-2, + -0x1.55553e1068f19p-5, + 0x1.6c087e89a359dp-10, + -0x1.99343027bf8c3p-16, + -0x1.555545995a603p-3, + 0x1.1107605230bc4p-7, + -0x1.994eb3774cf24p-13}, }; // Table with 4/PI to 192 bit precision. To avoid unaligned accesses // only 8 new bits are added per entry, making the table 4 times larger. -const uint32_t __INV_PIO4[24] = { +constexpr uint32_t __INV_PIO4[24] = { 0xa2, 0xa2f9, 0xa2f983, 0xa2f9836e, 0xf9836e4e, 0x836e4e44, 0x6e4e4415, 0x4e441529, 0x441529fc, 0x1529fc27, 0x29fc2757, 0xfc2757d1, 0x2757d1f5, 0x57d1f534, 0xd1f534dd, 0xf534ddc0, 0x34ddc0db, 0xddc0db62, diff --git a/libc/src/math/generic/sincosf_utils.h b/libc/src/math/generic/sincosf_utils.h --- a/libc/src/math/generic/sincosf_utils.h +++ b/libc/src/math/generic/sincosf_utils.h @@ -16,9 +16,9 @@ namespace __llvm_libc { // 2PI * 2^-64. -static const double pi63 = as_double(0x3c1921fb54442d18); +static constexpr double pi63 = 0x1.921fb54442d18p-62; // PI / 4. -static const double pio4 = as_double(0x3fe921fb54442d18); +static constexpr double pio4 = 0x1.921fb54442d18p-1; // The constants and polynomials for sine and cosine. typedef struct {