Skip to content

Commit 708c0fe

Browse files
authored
[libc] Simplify the version guard for mpfr. (#146354)
Instead of manually calculating the major and minor version numbers, we can directly use `MPFR_VERSION_NUM` to simplify this.
1 parent f271c6d commit 708c0fe

File tree

1 file changed

+6
-14
lines changed

1 file changed

+6
-14
lines changed

libc/utils/MPFRWrapper/MPCommon.cpp

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,7 @@ MPFRNumber MPFRNumber::acosh() const {
7373
MPFRNumber MPFRNumber::acospi() const {
7474
MPFRNumber result(*this);
7575

76-
#if MPFR_VERSION_MAJOR > 4 || \
77-
(MPFR_VERSION_MAJOR == 4 && MPFR_VERSION_MINOR >= 2)
76+
#if MPFR_VERSION >= MPFR_VERSION_NUM(4, 2, 0)
7877
mpfr_acospi(result.value, value, mpfr_rounding);
7978
return result;
8079
#else
@@ -150,8 +149,7 @@ MPFRNumber MPFRNumber::cosh() const {
150149
MPFRNumber MPFRNumber::cospi() const {
151150
MPFRNumber result(*this);
152151

153-
#if MPFR_VERSION_MAJOR > 4 || \
154-
(MPFR_VERSION_MAJOR == 4 && MPFR_VERSION_MINOR >= 2)
152+
#if MPFR_VERSION >= MPFR_VERSION_NUM(4, 2, 0)
155153
mpfr_cospi(result.value, value, mpfr_rounding);
156154
return result;
157155
#else
@@ -195,8 +193,7 @@ MPFRNumber MPFRNumber::exp2() const {
195193

196194
MPFRNumber MPFRNumber::exp2m1() const {
197195
// TODO: Only use mpfr_exp2m1 once CI and buildbots get MPFR >= 4.2.0.
198-
#if MPFR_VERSION_MAJOR > 4 || \
199-
(MPFR_VERSION_MAJOR == 4 && MPFR_VERSION_MINOR >= 2)
196+
#if MPFR_VERSION >= MPFR_VERSION_NUM(4, 2, 0)
200197
MPFRNumber result(*this);
201198
mpfr_exp2m1(result.value, value, mpfr_rounding);
202199
return result;
@@ -231,8 +228,7 @@ MPFRNumber MPFRNumber::exp10() const {
231228

232229
MPFRNumber MPFRNumber::exp10m1() const {
233230
// TODO: Only use mpfr_exp10m1 once CI and buildbots get MPFR >= 4.2.0.
234-
#if MPFR_VERSION_MAJOR > 4 || \
235-
(MPFR_VERSION_MAJOR == 4 && MPFR_VERSION_MINOR >= 2)
231+
#if MPFR_VERSION >= MPFR_VERSION_NUM(4, 2, 0)
236232
MPFRNumber result(*this);
237233
mpfr_exp10m1(result.value, value, mpfr_rounding);
238234
return result;
@@ -402,9 +398,7 @@ MPFRNumber MPFRNumber::sin() const {
402398
MPFRNumber MPFRNumber::sinpi() const {
403399
MPFRNumber result(*this);
404400

405-
#if MPFR_VERSION_MAJOR > 4 || \
406-
(MPFR_VERSION_MAJOR == 4 && MPFR_VERSION_MINOR >= 2)
407-
401+
#if MPFR_VERSION >= MPFR_VERSION_NUM(4, 2, 0)
408402
mpfr_sinpi(result.value, value, mpfr_rounding);
409403
return result;
410404
#else
@@ -463,9 +457,7 @@ MPFRNumber MPFRNumber::tanh() const {
463457
MPFRNumber MPFRNumber::tanpi() const {
464458
MPFRNumber result(*this);
465459

466-
#if MPFR_VERSION_MAJOR > 4 || \
467-
(MPFR_VERSION_MAJOR == 4 && MPFR_VERSION_MINOR >= 2)
468-
460+
#if MPFR_VERSION >= MPFR_VERSION_NUM(4, 2, 0)
469461
mpfr_tanpi(result.value, value, mpfr_rounding);
470462
return result;
471463
#else

0 commit comments

Comments
 (0)