Skip to content

Commit

Permalink
[flang] fix build on *BSD after 4762c65 (#86204)
Browse files Browse the repository at this point in the history
The HUGE definition collides with the HUGE macro from math.h. Unlike the
fix in 3149c93 (#84478) (largely reverted in f95710c), add
another #undef HUGE since there is no practical way to make FreeBSD's
headers not define HUGE and still define XSI interfaces such as isascii
or strnlen.

Update comments above `#undef HUGE` instances to reflect the fact that
all major BSD versions (I checked DragonFly, FreeBSD, NetBSD, and
OpenBSD) leak the HUGE macro from math.h to various degrees.

Fixes #86038
  • Loading branch information
brooksdavis committed Apr 9, 2024
1 parent 4a04fca commit 788be0d
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion flang/include/flang/Evaluate/integer.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
#include <string>
#include <type_traits>

// Some environments, viz. glibc 2.17, allow the macro HUGE
// Some environments, viz. glibc 2.17 and *BSD, allow the macro HUGE
// to leak out of <math.h>.
#undef HUGE

Expand Down
2 changes: 1 addition & 1 deletion flang/include/flang/Evaluate/real.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
#include <limits>
#include <string>

// Some environments, viz. glibc 2.17, allow the macro HUGE
// Some environments, viz. glibc 2.17 and *BSD, allow the macro HUGE
// to leak out of <math.h>.
#undef HUGE

Expand Down
4 changes: 4 additions & 0 deletions flang/lib/Decimal/decimal-to-binary.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@
#include <cstring>
#include <utility>

// Some environments, viz. glibc 2.17 and *BSD, allow the macro HUGE
// to leak out of <math.h>.
#undef HUGE

namespace Fortran::decimal {

template <int PREC, int LOG10RADIX>
Expand Down
2 changes: 1 addition & 1 deletion flang/lib/Evaluate/fold-implementation.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
#include <type_traits>
#include <variant>

// Some environments, viz. glibc 2.17, allow the macro HUGE
// Some environments, viz. glibc 2.17 and *BSD, allow the macro HUGE
// to leak out of <math.h>.
#undef HUGE

Expand Down

0 comments on commit 788be0d

Please sign in to comment.