diff --git a/compiler-rt/lib/builtins/int_lib.h b/compiler-rt/lib/builtins/int_lib.h --- a/compiler-rt/lib/builtins/int_lib.h +++ b/compiler-rt/lib/builtins/int_lib.h @@ -70,12 +70,21 @@ #error Unsupported target #endif -#if defined(__NetBSD__) && (defined(_KERNEL) || defined(_STANDALONE)) +#if (defined(__FreeBSD__) || defined(__NetBSD__)) && \ + (defined(_KERNEL) || defined(_STANDALONE)) // // Kernel and boot environment can't use normal headers, // so use the equivalent system headers. +// NB: FreeBSD (and OpenBSD) deprecate machine/limits.h in +// favour of sys/limits.h, so prefer the former, but fall +// back on the latter if not available since NetBSD only has +// the latter. // +#if defined(__has_include) && __has_include() +#include +#else #include +#endif #include #include #else diff --git a/compiler-rt/lib/builtins/int_types.h b/compiler-rt/lib/builtins/int_types.h --- a/compiler-rt/lib/builtins/int_types.h +++ b/compiler-rt/lib/builtins/int_types.h @@ -121,6 +121,9 @@ #endif // CRT_HAS_128BIT +// FreeBSD's boot environment does not support using floating-point and poisons +// the float and double keywords. +#if !(defined(__FreeBSD__) && defined(_STANDALONE)) typedef union { su_int u; float f; @@ -130,6 +133,7 @@ udwords u; double f; } double_bits; +#endif typedef struct { #if _YUGA_LITTLE_ENDIAN @@ -155,6 +159,9 @@ #define HAS_80_BIT_LONG_DOUBLE 0 #endif +// FreeBSD's boot environment does not support using floating-point and poisons +// the float and double keywords. +#if !(defined(__FreeBSD__) && defined(_STANDALONE)) typedef union { uqwords u; long double f; @@ -183,4 +190,5 @@ #define COMPLEX_REAL(x) (x).real #define COMPLEX_IMAGINARY(x) (x).imaginary #endif +#endif #endif // INT_TYPES_H