Project import generated by Copybara.
GitOrigin-RevId: 900be9013fdc3bab9fce906f8a71e59ecd8873b4
Change-Id: I8609a042535f410747b4903f2de82e4de8ffebec
diff --git a/include/llvm-libc-macros/linux/sys-epoll-macros.h b/include/llvm-libc-macros/linux/sys-epoll-macros.h
new file mode 100644
index 0000000..f73d690
--- /dev/null
+++ b/include/llvm-libc-macros/linux/sys-epoll-macros.h
@@ -0,0 +1,40 @@
+//===-- Macros defined in sys/epoll.h header file -------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_MACROS_LINUX_SYS_EPOLL_MACROS_H
+#define LLVM_LIBC_MACROS_LINUX_SYS_EPOLL_MACROS_H
+
+#include "fcntl-macros.h"
+
+// These are also defined in <linux/eventpoll.h> but that also contains a
+// different definition of the epoll_event struct that is different from the
+// userspace version.
+
+#define EPOLL_CLOEXEC O_CLOEXEC
+
+#define EPOLL_CTL_ADD 1
+#define EPOLL_CTL_DEL 2
+#define EPOLL_CTL_MOD 3
+
+#define EPOLLIN 0x1
+#define EPOLLPRI 0x2
+#define EPOLLOUT 0x4
+#define EPOLLERR 0x8
+#define EPOLLHUP 0x10
+#define EPOLLRDNORM 0x40
+#define EPOLLRDBAND 0x80
+#define EPOLLWRNORM 0x100
+#define EPOLLWRBAND 0x200
+#define EPOLLMSG 0x400
+#define EPOLLRDHUP 0x2000
+#define EPOLLEXCLUSIVE 0x10000000
+#define EPOLLWAKEUP 0x20000000
+#define EPOLLONESHOT 0x40000000
+#define EPOLLET 0x80000000
+
+#endif // LLVM_LIBC_MACROS_LINUX_SYS_EPOLL_MACROS_H
diff --git a/include/llvm-libc-macros/math-macros.h b/include/llvm-libc-macros/math-macros.h
index 6046ea9..4783896 100644
--- a/include/llvm-libc-macros/math-macros.h
+++ b/include/llvm-libc-macros/math-macros.h
@@ -9,11 +9,6 @@
#ifndef LLVM_LIBC_MACROS_MATH_MACROS_H
#define LLVM_LIBC_MACROS_MATH_MACROS_H
-// TODO: Remove this. This is a temporary fix for a downstream problem.
-// This cannot be left permanently since it would require downstream users to
-// define this macro.
-#ifdef LIBC_FULL_BUILD
-
#include "limits-macros.h"
#define FP_NAN 0
@@ -56,38 +51,9 @@
#define math_errhandling (MATH_ERRNO | MATH_ERREXCEPT)
#endif
-// These must be type-generic functions. The C standard specifies them as
-// being macros rather than functions, in fact. However, in C++ it's important
-// that there be function declarations that don't interfere with other uses of
-// the identifier, even in places with parentheses where a function-like macro
-// will be expanded (such as a function declaration in a C++ namespace).
-
-#ifdef __cplusplus
-
-template <typename T> inline constexpr bool isfinite(T x) {
- return __builtin_isfinite(x);
-}
-
-template <typename T> inline constexpr bool isinf(T x) {
- return __builtin_isinf(x);
-}
-
-template <typename T> inline constexpr bool isnan(T x) {
- return __builtin_isnan(x);
-}
-
-#else
-
+// TODO: Move generic functional math macros to a separate header file.
#define isfinite(x) __builtin_isfinite(x)
#define isinf(x) __builtin_isinf(x)
#define isnan(x) __builtin_isnan(x)
-#endif
-
-#else // LIBC_FULL_BUILD
-
-#include <math.h>
-
-#endif // LIBC_FULL_BUILD
-
#endif // LLVM_LIBC_MACROS_MATH_MACROS_H
diff --git a/include/llvm-libc-macros/sys-epoll-macros.h b/include/llvm-libc-macros/sys-epoll-macros.h
new file mode 100644
index 0000000..8212df2
--- /dev/null
+++ b/include/llvm-libc-macros/sys-epoll-macros.h
@@ -0,0 +1,16 @@
+//===-- Macros defined in sys/epoll.h header file -------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_MACROS_SYS_EPOLL_MACROS_H
+#define LLVM_LIBC_MACROS_SYS_EPOLL_MACROS_H
+
+#ifdef __linux__
+#include "linux/sys-epoll-macros.h"
+#endif
+
+#endif // LLVM_LIBC_MACROS_SYS_EPOLL_MACROS_H
diff --git a/include/llvm-libc-types/sigset_t.h b/include/llvm-libc-types/sigset_t.h
index 311a92b..5c3e4e6 100644
--- a/include/llvm-libc-types/sigset_t.h
+++ b/include/llvm-libc-types/sigset_t.h
@@ -13,8 +13,8 @@
// This definition can be adjusted/specialized for different targets and
// platforms as necessary. This definition works for Linux on most targets.
-typedef struct {
+struct sigset_t {
unsigned long __signals[__NSIGSET_WORDS];
-} sigset_t;
+};
#endif // LLVM_LIBC_TYPES_SIGSET_T_H
diff --git a/include/llvm-libc-types/struct_epoll_event.h b/include/llvm-libc-types/struct_epoll_event.h
index 66cf86c..b7685df 100644
--- a/include/llvm-libc-types/struct_epoll_event.h
+++ b/include/llvm-libc-types/struct_epoll_event.h
@@ -11,7 +11,11 @@
#include "llvm-libc-types/struct_epoll_data.h"
-typedef struct epoll_event {
+typedef struct
+#ifdef __x86_64__
+ [[gnu::packed]] // Necessary for compatibility.
+#endif
+ epoll_event {
__UINT32_TYPE__ events;
epoll_data_t data;
} epoll_event;
diff --git a/libc/hdr/fenv_macros.h b/libc/hdr/fenv_macros.h
new file mode 100644
index 0000000..1ad28cc
--- /dev/null
+++ b/libc/hdr/fenv_macros.h
@@ -0,0 +1,22 @@
+//===-- Definition of macros from fenv.h ----------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_HDR_FENV_MACROS_H
+#define LLVM_LIBC_HDR_FENV_MACROS_H
+
+#ifdef LIBC_FULL_BUILD
+
+#include "include/llvm-libc-macros/fenv-macros.h"
+
+#else // Overlay mode
+
+#include <fenv.h>
+
+#endif // LLVM_LIBC_FULL_BUILD
+
+#endif // LLVM_LIBC_HDR_FENV_MACROS_H
diff --git a/libc/hdr/math_macros.h b/libc/hdr/math_macros.h
new file mode 100644
index 0000000..d13c5ff
--- /dev/null
+++ b/libc/hdr/math_macros.h
@@ -0,0 +1,43 @@
+//===-- Definition of macros from math.h ----------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_HDR_MATH_MACROS_H
+#define LLVM_LIBC_HDR_MATH_MACROS_H
+
+#ifdef LIBC_FULL_BUILD
+
+#include "include/llvm-libc-macros/math-macros.h"
+
+#else // Overlay mode
+
+#include <math.h>
+
+// Some older math.h header does not have FP_INT_* constants yet.
+#ifndef FP_INT_UPWARD
+#define FP_INT_UPWARD 0
+#endif // FP_INT_UPWARD
+
+#ifndef FP_INT_DOWNWARD
+#define FP_INT_DOWNWARD 1
+#endif // FP_INT_DOWNWARD
+
+#ifndef FP_INT_TOWARDZERO
+#define FP_INT_TOWARDZERO 2
+#endif // FP_INT_TOWARDZERO
+
+#ifndef FP_INT_TONEARESTFROMZERO
+#define FP_INT_TONEARESTFROMZERO 3
+#endif // FP_INT_TONEARESTFROMZERO
+
+#ifndef FP_INT_TONEAREST
+#define FP_INT_TONEAREST 4
+#endif // FP_INT_TONEAREST
+
+#endif // LLVM_LIBC_FULL_BUILD
+
+#endif // LLVM_LIBC_HDR_MATH_MACROS_H
diff --git a/libc/hdr/signal_macros.h b/libc/hdr/signal_macros.h
new file mode 100644
index 0000000..867d17a
--- /dev/null
+++ b/libc/hdr/signal_macros.h
@@ -0,0 +1,22 @@
+//===-- Definition of macros from signal.h --------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_HDR_SIGNAL_MACROS_H
+#define LLVM_LIBC_HDR_SIGNAL_MACROS_H
+
+#ifdef LIBC_FULL_BUILD
+
+#include "include/llvm-libc-macros/signal-macros.h"
+
+#else // Overlay mode
+
+#include <signal.h>
+
+#endif // LLVM_LIBC_FULL_BUILD
+
+#endif // LLVM_LIBC_HDR_SIGNAL_MACROS_H
diff --git a/libc/hdr/sys_epoll_macros.h b/libc/hdr/sys_epoll_macros.h
new file mode 100644
index 0000000..db047f1
--- /dev/null
+++ b/libc/hdr/sys_epoll_macros.h
@@ -0,0 +1,22 @@
+//===-- Definition of macros from sys/epoll.h -----------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_HDR_SYS_EPOLL_MACROS_H
+#define LLVM_LIBC_HDR_SYS_EPOLL_MACROS_H
+
+#ifdef LIBC_FULL_BUILD
+
+#include "include/llvm-libc-macros/sys-epoll-macros.h"
+
+#else // Overlay mode
+
+#include <sys/epoll.h>
+
+#endif // LLVM_LIBC_FULL_BUILD
+
+#endif // LLVM_LIBC_HDR_SYS/EPOLL_MACROS_H
diff --git a/libc/hdr/types/sigset_t.h b/libc/hdr/types/sigset_t.h
new file mode 100644
index 0000000..695ec30
--- /dev/null
+++ b/libc/hdr/types/sigset_t.h
@@ -0,0 +1,21 @@
+//===-- Proxy for sigset_t ------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+#ifndef LLVM_LIBC_HDR_TYPES_SIGSET_T_H
+#define LLVM_LIBC_HDR_TYPES_SIGSET_T_H
+
+#ifdef LIBC_FULL_BUILD
+
+#include "include/llvm-libc-types/sigset_t.h"
+
+#else
+
+#include <signal.h>
+
+#endif // LIBC_FULL_BUILD
+
+#endif // LLVM_LIBC_HDR_TYPES_SIGSET_T_H
diff --git a/libc/hdr/types/struct_epoll_event.h b/libc/hdr/types/struct_epoll_event.h
new file mode 100644
index 0000000..5bb98ce
--- /dev/null
+++ b/libc/hdr/types/struct_epoll_event.h
@@ -0,0 +1,21 @@
+//===-- Proxy for struct epoll_event --------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+#ifndef LLVM_LIBC_HDR_TYPES_STRUCT_EPOLL_EVENT_H
+#define LLVM_LIBC_HDR_TYPES_STRUCT_EPOLL_EVENT_H
+
+#ifdef LIBC_FULL_BUILD
+
+#include "include/llvm-libc-types/struct_epoll_event.h"
+
+#else
+
+#include <sys/epoll.h>
+
+#endif // LIBC_FULL_BUILD
+
+#endif // LLVM_LIBC_HDR_TYPES_STRUCT_EPOLL_EVENT_H
diff --git a/libc/hdr/types/struct_timespec.h b/libc/hdr/types/struct_timespec.h
new file mode 100644
index 0000000..1f121f3
--- /dev/null
+++ b/libc/hdr/types/struct_timespec.h
@@ -0,0 +1,21 @@
+//===-- Proxy for struct timespec ----------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+#ifndef LLVM_LIBC_HDR_TYPES_STRUCT_TIMESPEC_H
+#define LLVM_LIBC_HDR_TYPES_STRUCT_TIMESPEC_H
+
+#ifdef LIBC_FULL_BUILD
+
+#include "include/llvm-libc-types/struct_timespec.h"
+
+#else
+
+#include <time.h>
+
+#endif // LIBC_FULL_BUILD
+
+#endif // LLVM_LIBC_HDR_TYPES_STRUCT_TIMESPEC_H
diff --git a/src/__support/CPP/bit.h b/src/__support/CPP/bit.h
index 80f50fd..8a8951a 100644
--- a/src/__support/CPP/bit.h
+++ b/src/__support/CPP/bit.h
@@ -72,6 +72,14 @@
/// Only unsigned integral types are allowed.
///
/// Returns cpp::numeric_limits<T>::digits on an input of 0.
+// clang-19+, gcc-14+
+#if __has_builtin(__builtin_ctzg)
+template <typename T>
+[[nodiscard]] LIBC_INLINE constexpr cpp::enable_if_t<cpp::is_unsigned_v<T>, int>
+countr_zero(T value) {
+ return __builtin_ctzg(value, cpp::numeric_limits<T>::digits);
+}
+#else
template <typename T>
[[nodiscard]] LIBC_INLINE constexpr cpp::enable_if_t<cpp::is_unsigned_v<T>, int>
countr_zero(T value) {
@@ -99,6 +107,7 @@
ADD_SPECIALIZATION(countr_zero, unsigned int, __builtin_ctz)
ADD_SPECIALIZATION(countr_zero, unsigned long, __builtin_ctzl)
ADD_SPECIALIZATION(countr_zero, unsigned long long, __builtin_ctzll)
+#endif // __has_builtin(__builtin_ctzg)
/// Count number of 0's from the most significant bit to the least
/// stopping at the first 1.
@@ -106,6 +115,14 @@
/// Only unsigned integral types are allowed.
///
/// Returns cpp::numeric_limits<T>::digits on an input of 0.
+// clang-19+, gcc-14+
+#if __has_builtin(__builtin_clzg)
+template <typename T>
+[[nodiscard]] LIBC_INLINE constexpr cpp::enable_if_t<cpp::is_unsigned_v<T>, int>
+countl_zero(T value) {
+ return __builtin_clzg(value, cpp::numeric_limits<T>::digits);
+}
+#else
template <typename T>
[[nodiscard]] LIBC_INLINE constexpr cpp::enable_if_t<cpp::is_unsigned_v<T>, int>
countl_zero(T value) {
@@ -129,6 +146,7 @@
ADD_SPECIALIZATION(countl_zero, unsigned int, __builtin_clz)
ADD_SPECIALIZATION(countl_zero, unsigned long, __builtin_clzl)
ADD_SPECIALIZATION(countl_zero, unsigned long long, __builtin_clzll)
+#endif // __has_builtin(__builtin_clzg)
#undef ADD_SPECIALIZATION
diff --git a/src/__support/FPUtil/BasicOperations.h b/src/__support/FPUtil/BasicOperations.h
index 6e41564..e5ac101 100644
--- a/src/__support/FPUtil/BasicOperations.h
+++ b/src/__support/FPUtil/BasicOperations.h
@@ -14,9 +14,9 @@
#include "FEnvImpl.h"
#include "src/__support/CPP/type_traits.h"
-#include "src/__support/UInt128.h"
#include "src/__support/common.h"
#include "src/__support/macros/optimization.h" // LIBC_UNLIKELY
+#include "src/__support/uint128.h"
namespace LIBC_NAMESPACE {
namespace fputil {
diff --git a/src/__support/FPUtil/FEnvImpl.h b/src/__support/FPUtil/FEnvImpl.h
index 6086d5d..4be1a57 100644
--- a/src/__support/FPUtil/FEnvImpl.h
+++ b/src/__support/FPUtil/FEnvImpl.h
@@ -9,7 +9,7 @@
#ifndef LLVM_LIBC_SRC___SUPPORT_FPUTIL_FENVIMPL_H
#define LLVM_LIBC_SRC___SUPPORT_FPUTIL_FENVIMPL_H
-#include "include/llvm-libc-macros/math-macros.h"
+#include "hdr/math_macros.h"
#include "src/__support/macros/attributes.h" // LIBC_INLINE
#include "src/__support/macros/properties/architectures.h"
#include "src/errno/libc_errno.h"
diff --git a/src/__support/FPUtil/FPBits.h b/src/__support/FPUtil/FPBits.h
index 155bff2..ab05036 100644
--- a/src/__support/FPUtil/FPBits.h
+++ b/src/__support/FPUtil/FPBits.h
@@ -11,13 +11,13 @@
#include "src/__support/CPP/bit.h"
#include "src/__support/CPP/type_traits.h"
-#include "src/__support/UInt128.h"
#include "src/__support/common.h"
#include "src/__support/libc_assert.h" // LIBC_ASSERT
#include "src/__support/macros/attributes.h" // LIBC_INLINE, LIBC_INLINE_VAR
#include "src/__support/macros/properties/types.h" // LIBC_TYPES_HAS_FLOAT128
#include "src/__support/math_extras.h" // mask_trailing_ones
#include "src/__support/sign.h" // Sign
+#include "src/__support/uint128.h"
#include <stdint.h>
diff --git a/src/__support/FPUtil/Hypot.h b/src/__support/FPUtil/Hypot.h
index 2e69965..76b1f07 100644
--- a/src/__support/FPUtil/Hypot.h
+++ b/src/__support/FPUtil/Hypot.h
@@ -15,8 +15,8 @@
#include "rounding_mode.h"
#include "src/__support/CPP/bit.h"
#include "src/__support/CPP/type_traits.h"
-#include "src/__support/UInt128.h"
#include "src/__support/common.h"
+#include "src/__support/uint128.h"
namespace LIBC_NAMESPACE {
namespace fputil {
diff --git a/src/__support/FPUtil/ManipulationFunctions.h b/src/__support/FPUtil/ManipulationFunctions.h
index 2c90b48..a289c2e 100644
--- a/src/__support/FPUtil/ManipulationFunctions.h
+++ b/src/__support/FPUtil/ManipulationFunctions.h
@@ -15,7 +15,7 @@
#include "dyadic_float.h"
#include "rounding_mode.h"
-#include "include/llvm-libc-macros/math-macros.h"
+#include "hdr/math_macros.h"
#include "src/__support/CPP/bit.h"
#include "src/__support/CPP/limits.h" // INT_MAX, INT_MIN
#include "src/__support/CPP/type_traits.h"
diff --git a/src/__support/FPUtil/NearestIntegerOperations.h b/src/__support/FPUtil/NearestIntegerOperations.h
index 6b28e7f..4645ab0 100644
--- a/src/__support/FPUtil/NearestIntegerOperations.h
+++ b/src/__support/FPUtil/NearestIntegerOperations.h
@@ -13,7 +13,7 @@
#include "FPBits.h"
#include "rounding_mode.h"
-#include "include/llvm-libc-macros/math-macros.h"
+#include "hdr/math_macros.h"
#include "src/__support/CPP/type_traits.h"
#include "src/__support/common.h"
diff --git a/src/__support/FPUtil/aarch64/FEnvImpl.h b/src/__support/FPUtil/aarch64/FEnvImpl.h
index e0eec17..4b593cd 100644
--- a/src/__support/FPUtil/aarch64/FEnvImpl.h
+++ b/src/__support/FPUtil/aarch64/FEnvImpl.h
@@ -20,6 +20,7 @@
#include <fenv.h>
#include <stdint.h>
+#include "hdr/fenv_macros.h"
#include "src/__support/FPUtil/FPBits.h"
namespace LIBC_NAMESPACE {
diff --git a/src/__support/FPUtil/aarch64/fenv_darwin_impl.h b/src/__support/FPUtil/aarch64/fenv_darwin_impl.h
index fd91537..773d6bf 100644
--- a/src/__support/FPUtil/aarch64/fenv_darwin_impl.h
+++ b/src/__support/FPUtil/aarch64/fenv_darwin_impl.h
@@ -20,6 +20,7 @@
#include <fenv.h>
#include <stdint.h>
+#include "hdr/fenv_macros.h"
#include "src/__support/FPUtil/FPBits.h"
namespace LIBC_NAMESPACE {
diff --git a/src/__support/FPUtil/arm/FEnvImpl.h b/src/__support/FPUtil/arm/FEnvImpl.h
index ac4673c..ddb0edc 100644
--- a/src/__support/FPUtil/arm/FEnvImpl.h
+++ b/src/__support/FPUtil/arm/FEnvImpl.h
@@ -9,9 +9,9 @@
#ifndef LLVM_LIBC_SRC___SUPPORT_FPUTIL_ARM_FENVIMPL_H
#define LLVM_LIBC_SRC___SUPPORT_FPUTIL_ARM_FENVIMPL_H
+#include "hdr/fenv_macros.h"
#include "src/__support/FPUtil/FPBits.h"
#include "src/__support/macros/attributes.h" // For LIBC_INLINE
-
#include <fenv.h>
#include <stdint.h>
diff --git a/src/__support/FPUtil/dyadic_float.h b/src/__support/FPUtil/dyadic_float.h
index e0c205f..12a6922 100644
--- a/src/__support/FPUtil/dyadic_float.h
+++ b/src/__support/FPUtil/dyadic_float.h
@@ -12,7 +12,7 @@
#include "FPBits.h"
#include "multiply_add.h"
#include "src/__support/CPP/type_traits.h"
-#include "src/__support/UInt.h"
+#include "src/__support/big_int.h"
#include "src/__support/macros/optimization.h" // LIBC_UNLIKELY
#include <stddef.h>
@@ -122,7 +122,8 @@
int exp_lo = exp_hi - static_cast<int>(PRECISION) - 1;
- MantissaType m_hi(mantissa >> shift);
+ MantissaType m_hi =
+ shift >= MantissaType::BITS ? MantissaType(0) : mantissa >> shift;
T d_hi = FPBits<T>::create_value(
sign, exp_hi,
@@ -130,7 +131,8 @@
IMPLICIT_MASK)
.get_val();
- MantissaType round_mask = MantissaType(1) << (shift - 1);
+ MantissaType round_mask =
+ shift > MantissaType::BITS ? 0 : MantissaType(1) << (shift - 1);
MantissaType sticky_mask = round_mask - MantissaType(1);
bool round_bit = !(mantissa & round_mask).is_zero();
diff --git a/src/__support/FPUtil/generic/FMA.h b/src/__support/FPUtil/generic/FMA.h
index f03af92..f403aa7 100644
--- a/src/__support/FPUtil/generic/FMA.h
+++ b/src/__support/FPUtil/generic/FMA.h
@@ -14,9 +14,9 @@
#include "src/__support/FPUtil/FEnvImpl.h"
#include "src/__support/FPUtil/FPBits.h"
#include "src/__support/FPUtil/rounding_mode.h"
-#include "src/__support/UInt128.h"
#include "src/__support/macros/attributes.h" // LIBC_INLINE
#include "src/__support/macros/optimization.h" // LIBC_UNLIKELY
+#include "src/__support/uint128.h"
namespace LIBC_NAMESPACE {
namespace fputil {
diff --git a/src/__support/FPUtil/generic/FMod.h b/src/__support/FPUtil/generic/FMod.h
index 24fb264..211ab92 100644
--- a/src/__support/FPUtil/generic/FMod.h
+++ b/src/__support/FPUtil/generic/FMod.h
@@ -15,7 +15,6 @@
#include "src/__support/FPUtil/FEnvImpl.h"
#include "src/__support/FPUtil/FPBits.h"
#include "src/__support/macros/optimization.h" // LIBC_UNLIKELY
-#include "src/math/generic/math_utils.h"
namespace LIBC_NAMESPACE {
namespace fputil {
diff --git a/src/__support/FPUtil/generic/sqrt.h b/src/__support/FPUtil/generic/sqrt.h
index b6b4aae..7e7600b 100644
--- a/src/__support/FPUtil/generic/sqrt.h
+++ b/src/__support/FPUtil/generic/sqrt.h
@@ -15,8 +15,8 @@
#include "src/__support/FPUtil/FEnvImpl.h"
#include "src/__support/FPUtil/FPBits.h"
#include "src/__support/FPUtil/rounding_mode.h"
-#include "src/__support/UInt128.h"
#include "src/__support/common.h"
+#include "src/__support/uint128.h"
namespace LIBC_NAMESPACE {
namespace fputil {
diff --git a/src/__support/FPUtil/generic/sqrt_80_bit_long_double.h b/src/__support/FPUtil/generic/sqrt_80_bit_long_double.h
index 656ade4..6308ffe 100644
--- a/src/__support/FPUtil/generic/sqrt_80_bit_long_double.h
+++ b/src/__support/FPUtil/generic/sqrt_80_bit_long_double.h
@@ -13,8 +13,8 @@
#include "src/__support/FPUtil/FEnvImpl.h"
#include "src/__support/FPUtil/FPBits.h"
#include "src/__support/FPUtil/rounding_mode.h"
-#include "src/__support/UInt128.h"
#include "src/__support/common.h"
+#include "src/__support/uint128.h"
namespace LIBC_NAMESPACE {
namespace fputil {
diff --git a/src/__support/FPUtil/riscv/FEnvImpl.h b/src/__support/FPUtil/riscv/FEnvImpl.h
index b73c479..a522433 100644
--- a/src/__support/FPUtil/riscv/FEnvImpl.h
+++ b/src/__support/FPUtil/riscv/FEnvImpl.h
@@ -9,6 +9,7 @@
#ifndef LLVM_LIBC_SRC___SUPPORT_FPUTIL_RISCV_FENVIMPL_H
#define LLVM_LIBC_SRC___SUPPORT_FPUTIL_RISCV_FENVIMPL_H
+#include "hdr/fenv_macros.h"
#include "src/__support/FPUtil/FPBits.h"
#include "src/__support/macros/attributes.h" // For LIBC_INLINE_ASM
#include "src/__support/macros/config.h" // For LIBC_INLINE
diff --git a/src/__support/FPUtil/rounding_mode.h b/src/__support/FPUtil/rounding_mode.h
index 91a5b9c..aa5e00f 100644
--- a/src/__support/FPUtil/rounding_mode.h
+++ b/src/__support/FPUtil/rounding_mode.h
@@ -9,10 +9,9 @@
#ifndef LLVM_LIBC_SRC___SUPPORT_FPUTIL_ROUNDING_MODE_H
#define LLVM_LIBC_SRC___SUPPORT_FPUTIL_ROUNDING_MODE_H
+#include "hdr/fenv_macros.h"
#include "src/__support/macros/attributes.h" // LIBC_INLINE
-#include <fenv.h>
-
namespace LIBC_NAMESPACE::fputil {
// Quick free-standing test whether fegetround() == FE_UPWARD.
diff --git a/src/__support/UInt.h b/src/__support/big_int.h
similarity index 99%
rename from src/__support/UInt.h
rename to src/__support/big_int.h
index c1e55ce..e2061c4 100644
--- a/src/__support/UInt.h
+++ b/src/__support/big_int.h
@@ -249,19 +249,15 @@
enum Direction { LEFT, RIGHT };
// A bitwise shift on an array of elements.
-// TODO: Make the result UB when 'offset' is greater or equal to the number of
-// bits in 'array'. This will allow for better code performance.
+// 'offset' must be less than TOTAL_BITS (i.e., sizeof(word) * CHAR_BIT * N)
+// otherwise the behavior is undefined.
template <Direction direction, bool is_signed, typename word, size_t N>
LIBC_INLINE constexpr cpp::array<word, N> shift(cpp::array<word, N> array,
size_t offset) {
static_assert(direction == LEFT || direction == RIGHT);
constexpr size_t WORD_BITS = cpp::numeric_limits<word>::digits;
- constexpr size_t TOTAL_BITS = N * WORD_BITS;
- if (LIBC_UNLIKELY(offset == 0))
- return array;
- if (LIBC_UNLIKELY(offset >= TOTAL_BITS))
- return {};
#ifdef LIBC_TYPES_HAS_INT128
+ constexpr size_t TOTAL_BITS = N * WORD_BITS;
if constexpr (TOTAL_BITS == 128) {
using type = cpp::conditional_t<is_signed, __int128_t, __uint128_t>;
auto tmp = cpp::bit_cast<type>(array);
@@ -272,6 +268,8 @@
return cpp::bit_cast<cpp::array<word, N>>(tmp);
}
#endif
+ if (LIBC_UNLIKELY(offset == 0))
+ return array;
const bool is_neg = is_signed && is_negative(array);
constexpr auto at = [](size_t index) -> int {
// reverse iteration when direction == LEFT.
diff --git a/src/__support/float_to_string.h b/src/__support/float_to_string.h
index 4c59cfd..09b1332 100644
--- a/src/__support/float_to_string.h
+++ b/src/__support/float_to_string.h
@@ -15,7 +15,7 @@
#include "src/__support/CPP/type_traits.h"
#include "src/__support/FPUtil/FPBits.h"
#include "src/__support/FPUtil/dyadic_float.h"
-#include "src/__support/UInt.h"
+#include "src/__support/big_int.h"
#include "src/__support/common.h"
#include "src/__support/libc_assert.h"
#include "src/__support/macros/attributes.h"
diff --git a/src/__support/hash.h b/src/__support/hash.h
index 6b362ba..d1218fd 100644
--- a/src/__support/hash.h
+++ b/src/__support/hash.h
@@ -11,8 +11,8 @@
#include "src/__support/CPP/bit.h" // rotl
#include "src/__support/CPP/limits.h" // numeric_limits
-#include "src/__support/UInt128.h" // UInt128
#include "src/__support/macros/attributes.h" // LIBC_INLINE
+#include "src/__support/uint128.h" // UInt128
#include <stdint.h> // For uint64_t
namespace LIBC_NAMESPACE {
diff --git a/src/__support/integer_literals.h b/src/__support/integer_literals.h
index e99799c..5fb6746 100644
--- a/src/__support/integer_literals.h
+++ b/src/__support/integer_literals.h
@@ -14,8 +14,8 @@
#define LLVM_LIBC_SRC___SUPPORT_INTEGER_LITERALS_H
#include "src/__support/CPP/limits.h" // CHAR_BIT
-#include "src/__support/UInt128.h" // UInt128
#include "src/__support/macros/attributes.h" // LIBC_INLINE
+#include "src/__support/uint128.h" // UInt128
#include <stddef.h> // size_t
#include <stdint.h> // uintxx_t
diff --git a/src/__support/integer_to_string.h b/src/__support/integer_to_string.h
index f72d00d..375f0e8 100644
--- a/src/__support/integer_to_string.h
+++ b/src/__support/integer_to_string.h
@@ -67,7 +67,7 @@
#include "src/__support/CPP/span.h"
#include "src/__support/CPP/string_view.h"
#include "src/__support/CPP/type_traits.h"
-#include "src/__support/UInt.h" // make_integral_or_big_int_unsigned_t
+#include "src/__support/big_int.h" // make_integral_or_big_int_unsigned_t
#include "src/__support/common.h"
namespace LIBC_NAMESPACE {
diff --git a/src/__support/str_to_float.h b/src/__support/str_to_float.h
index f622b7e..fa466ca 100644
--- a/src/__support/str_to_float.h
+++ b/src/__support/str_to_float.h
@@ -17,13 +17,13 @@
#include "src/__support/FPUtil/FPBits.h"
#include "src/__support/FPUtil/dyadic_float.h"
#include "src/__support/FPUtil/rounding_mode.h"
-#include "src/__support/UInt128.h"
#include "src/__support/common.h"
#include "src/__support/ctype_utils.h"
#include "src/__support/detailed_powers_of_ten.h"
#include "src/__support/high_precision_decimal.h"
#include "src/__support/str_to_integer.h"
#include "src/__support/str_to_num_result.h"
+#include "src/__support/uint128.h"
#include "src/errno/libc_errno.h" // For ERANGE
namespace LIBC_NAMESPACE {
@@ -695,10 +695,10 @@
// If the mantissa is truncated, then the result may be off by the LSB, so
// check if rounding the mantissa up changes the result. If not, then it's
// safe, else use the fallback.
- auto secound_output = eisel_lemire<T>({mantissa + 1, exp10}, round);
- if (secound_output.has_value()) {
- if (opt_output->mantissa == secound_output->mantissa &&
- opt_output->exponent == secound_output->exponent) {
+ auto second_output = eisel_lemire<T>({mantissa + 1, exp10}, round);
+ if (second_output.has_value()) {
+ if (opt_output->mantissa == second_output->mantissa &&
+ opt_output->exponent == second_output->exponent) {
return {opt_output.value(), 0};
}
}
diff --git a/src/__support/str_to_integer.h b/src/__support/str_to_integer.h
index 02c71d4..6db851a 100644
--- a/src/__support/str_to_integer.h
+++ b/src/__support/str_to_integer.h
@@ -11,10 +11,10 @@
#include "src/__support/CPP/limits.h"
#include "src/__support/CPP/type_traits.h"
-#include "src/__support/UInt128.h"
#include "src/__support/common.h"
#include "src/__support/ctype_utils.h"
#include "src/__support/str_to_num_result.h"
+#include "src/__support/uint128.h"
#include "src/errno/libc_errno.h" // For ERANGE
namespace LIBC_NAMESPACE {
diff --git a/src/__support/UInt128.h b/src/__support/uint128.h
similarity index 97%
rename from src/__support/UInt128.h
rename to src/__support/uint128.h
index b6ef9ca1..722e79d 100644
--- a/src/__support/UInt128.h
+++ b/src/__support/uint128.h
@@ -9,7 +9,7 @@
#ifndef LLVM_LIBC_SRC___SUPPORT_UINT128_H
#define LLVM_LIBC_SRC___SUPPORT_UINT128_H
-#include "UInt.h"
+#include "big_int.h"
#include "src/__support/macros/properties/types.h" // LIBC_TYPES_HAS_INT128
#ifdef LIBC_TYPES_HAS_INT128
diff --git a/src/fenv/fegetexceptflag.cpp b/src/fenv/fegetexceptflag.cpp
index 71b87ce..c6160da 100644
--- a/src/fenv/fegetexceptflag.cpp
+++ b/src/fenv/fegetexceptflag.cpp
@@ -15,7 +15,8 @@
namespace LIBC_NAMESPACE {
LLVM_LIBC_FUNCTION(int, fegetexceptflag, (fexcept_t * flagp, int excepts)) {
- // TODO: Add a compile time check to see if the excepts actually fit in flagp.
+ static_assert(sizeof(int) >= sizeof(fexcept_t),
+ "fexcept_t value cannot fit in an int value.");
*flagp = static_cast<fexcept_t>(fputil::test_except(FE_ALL_EXCEPT) & excepts);
return 0;
}
diff --git a/src/fenv/feholdexcept.cpp b/src/fenv/feholdexcept.cpp
index 3c73b1f..f264c5a 100644
--- a/src/fenv/feholdexcept.cpp
+++ b/src/fenv/feholdexcept.cpp
@@ -9,7 +9,6 @@
#include "src/fenv/feholdexcept.h"
#include "src/__support/FPUtil/FEnvImpl.h"
#include "src/__support/common.h"
-
#include <fenv.h>
namespace LIBC_NAMESPACE {
diff --git a/src/fenv/fesetexcept.cpp b/src/fenv/fesetexcept.cpp
new file mode 100644
index 0000000..9afa7b7
--- /dev/null
+++ b/src/fenv/fesetexcept.cpp
@@ -0,0 +1,19 @@
+//===-- Implementation of fesetexcept function ----------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "src/fenv/fesetexcept.h"
+#include "src/__support/FPUtil/FEnvImpl.h"
+#include "src/__support/common.h"
+
+namespace LIBC_NAMESPACE {
+
+LLVM_LIBC_FUNCTION(int, fesetexcept, (int excepts)) {
+ return fputil::set_except(excepts);
+}
+
+} // namespace LIBC_NAMESPACE
diff --git a/src/fenv/fesetexcept.h b/src/fenv/fesetexcept.h
new file mode 100644
index 0000000..40a7303
--- /dev/null
+++ b/src/fenv/fesetexcept.h
@@ -0,0 +1,18 @@
+//===-- Implementation header for fesetexcept -------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_SRC_FENV_FESETEXCEPT_H
+#define LLVM_LIBC_SRC_FENV_FESETEXCEPT_H
+
+namespace LIBC_NAMESPACE {
+
+int fesetexcept(int excepts);
+
+} // namespace LIBC_NAMESPACE
+
+#endif // LLVM_LIBC_SRC_FENV_FESETEXCEPT_H
diff --git a/src/fenv/fesetexceptflag.cpp b/src/fenv/fesetexceptflag.cpp
index 2fe7cb5..3ff8e27 100644
--- a/src/fenv/fesetexceptflag.cpp
+++ b/src/fenv/fesetexceptflag.cpp
@@ -9,7 +9,6 @@
#include "src/fenv/fesetexceptflag.h"
#include "src/__support/FPUtil/FEnvImpl.h"
#include "src/__support/common.h"
-
#include <fenv.h>
namespace LIBC_NAMESPACE {
diff --git a/src/math/generic/exp_utils.cpp b/src/math/generic/exp_utils.cpp
index afdaea3..ad13919 100644
--- a/src/math/generic/exp_utils.cpp
+++ b/src/math/generic/exp_utils.cpp
@@ -7,7 +7,6 @@
//===----------------------------------------------------------------------===//
#include "exp_utils.h"
-#include "math_utils.h"
namespace LIBC_NAMESPACE {
diff --git a/src/math/generic/explogxf.h b/src/math/generic/explogxf.h
index 8817ba1..f7d04f5 100644
--- a/src/math/generic/explogxf.h
+++ b/src/math/generic/explogxf.h
@@ -10,7 +10,6 @@
#define LLVM_LIBC_SRC_MATH_GENERIC_EXPLOGXF_H
#include "common_constants.h"
-#include "math_utils.h"
#include "src/__support/CPP/bit.h"
#include "src/__support/CPP/optional.h"
#include "src/__support/FPUtil/FEnvImpl.h"
diff --git a/src/math/generic/log1p.cpp b/src/math/generic/log1p.cpp
index 83bd753..2b18708 100644
--- a/src/math/generic/log1p.cpp
+++ b/src/math/generic/log1p.cpp
@@ -28,8 +28,9 @@
namespace {
-// Extra errors from P is from using x^2 to reduce evaluation latency.
-constexpr double P_ERR = 0x1.0p-50;
+// Extra errors from P is from using x^2 to reduce evaluation latency and
+// directional rounding.
+constexpr double P_ERR = 0x1.0p-49;
// log(2) with 128-bit precision generated by SageMath with:
// def format_hex(value):
diff --git a/src/math/generic/log_range_reduction.h b/src/math/generic/log_range_reduction.h
index 64c0fc3..d12da47 100644
--- a/src/math/generic/log_range_reduction.h
+++ b/src/math/generic/log_range_reduction.h
@@ -11,7 +11,7 @@
#include "common_constants.h"
#include "src/__support/FPUtil/dyadic_float.h"
-#include "src/__support/UInt128.h"
+#include "src/__support/uint128.h"
namespace LIBC_NAMESPACE {
diff --git a/src/math/generic/math_utils.cpp b/src/math/generic/math_utils.cpp
deleted file mode 100644
index 14bbb2b..0000000
--- a/src/math/generic/math_utils.cpp
+++ /dev/null
@@ -1,21 +0,0 @@
-//===-- Implementation of math utils --------------------------------------===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-
-#include "math_utils.h"
-
-namespace LIBC_NAMESPACE {
-
-constexpr float XFlowValues<float>::OVERFLOW_VALUE = 0x1p97f;
-constexpr float XFlowValues<float>::UNDERFLOW_VALUE = 0x1p-95f;
-constexpr float XFlowValues<float>::MAY_UNDERFLOW_VALUE = 0x1.4p-75f;
-
-constexpr double XFlowValues<double>::OVERFLOW_VALUE = 0x1p769;
-constexpr double XFlowValues<double>::UNDERFLOW_VALUE = 0x1p-767;
-constexpr double XFlowValues<double>::MAY_UNDERFLOW_VALUE = 0x1.8p-538;
-
-} // namespace LIBC_NAMESPACE
diff --git a/src/math/generic/math_utils.h b/src/math/generic/math_utils.h
deleted file mode 100644
index cced761..0000000
--- a/src/math/generic/math_utils.h
+++ /dev/null
@@ -1,95 +0,0 @@
-//===-- Collection of utils for implementing math functions -----*- C++ -*-===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef LLVM_LIBC_SRC_MATH_GENERIC_MATH_UTILS_H
-#define LLVM_LIBC_SRC_MATH_GENERIC_MATH_UTILS_H
-
-#include "include/llvm-libc-macros/math-macros.h"
-#include "src/__support/CPP/bit.h"
-#include "src/__support/CPP/type_traits.h"
-#include "src/__support/common.h"
-#include "src/errno/libc_errno.h"
-
-#include <stdint.h>
-
-// TODO: evaluate which functions from this file are actually used.
-
-namespace LIBC_NAMESPACE {
-
-// TODO: Remove this, or move it to exp_utils.cpp which is its only user.
-LIBC_INLINE double as_double(uint64_t x) { return cpp::bit_cast<double>(x); }
-
-// Values to trigger underflow and overflow.
-template <typename T> struct XFlowValues;
-
-template <> struct XFlowValues<float> {
- static const float OVERFLOW_VALUE;
- static const float UNDERFLOW_VALUE;
- static const float MAY_UNDERFLOW_VALUE;
-};
-
-template <> struct XFlowValues<double> {
- static const double OVERFLOW_VALUE;
- static const double UNDERFLOW_VALUE;
- static const double MAY_UNDERFLOW_VALUE;
-};
-
-template <typename T> LIBC_INLINE T with_errno(T x, int err) {
- if (math_errhandling & MATH_ERRNO)
- libc_errno = err;
- return x;
-}
-
-template <typename T> LIBC_INLINE void force_eval(T x) {
- volatile T y LIBC_UNUSED = x;
-}
-
-template <typename T> LIBC_INLINE T opt_barrier(T x) {
- volatile T y = x;
- return y;
-}
-
-template <typename T> struct IsFloatOrDouble {
- static constexpr bool
- Value = // NOLINT so that this Value can match the ones for IsSame
- cpp::is_same_v<T, float> || cpp::is_same_v<T, double>;
-};
-
-template <typename T>
-using EnableIfFloatOrDouble = cpp::enable_if_t<IsFloatOrDouble<T>::Value, int>;
-
-template <typename T, EnableIfFloatOrDouble<T> = 0>
-T xflow(uint32_t sign, T y) {
- // Underflow happens when two extremely small values are multiplied.
- // Likewise, overflow happens when two large values are multiplied.
- y = opt_barrier(sign ? -y : y) * y;
- return with_errno(y, ERANGE);
-}
-
-template <typename T, EnableIfFloatOrDouble<T> = 0> T overflow(uint32_t sign) {
- return xflow(sign, XFlowValues<T>::OVERFLOW_VALUE);
-}
-
-template <typename T, EnableIfFloatOrDouble<T> = 0> T underflow(uint32_t sign) {
- return xflow(sign, XFlowValues<T>::UNDERFLOW_VALUE);
-}
-
-template <typename T, EnableIfFloatOrDouble<T> = 0>
-T may_underflow(uint32_t sign) {
- return xflow(sign, XFlowValues<T>::MAY_UNDERFLOW_VALUE);
-}
-
-template <typename T, EnableIfFloatOrDouble<T> = 0>
-LIBC_INLINE constexpr float invalid(T x) {
- T y = (x - x) / (x - x);
- return isnan(x) ? y : with_errno(y, EDOM);
-}
-
-} // namespace LIBC_NAMESPACE
-
-#endif // LLVM_LIBC_SRC_MATH_GENERIC_MATH_UTILS_H
diff --git a/src/signal/linux/raise.cpp b/src/signal/linux/raise.cpp
index dd6f5eb..2250df5 100644
--- a/src/signal/linux/raise.cpp
+++ b/src/signal/linux/raise.cpp
@@ -7,14 +7,15 @@
//===----------------------------------------------------------------------===//
#include "src/signal/raise.h"
-#include "src/signal/linux/signal_utils.h"
+#include "hdr/types/sigset_t.h"
#include "src/__support/common.h"
+#include "src/signal/linux/signal_utils.h"
namespace LIBC_NAMESPACE {
LLVM_LIBC_FUNCTION(int, raise, (int sig)) {
- ::sigset_t sigset;
+ sigset_t sigset;
block_all_signals(sigset);
long pid = LIBC_NAMESPACE::syscall_impl<long>(SYS_getpid);
long tid = LIBC_NAMESPACE::syscall_impl<long>(SYS_gettid);
diff --git a/src/signal/linux/sigaction.cpp b/src/signal/linux/sigaction.cpp
index 7ddc2dc..7b220e5 100644
--- a/src/signal/linux/sigaction.cpp
+++ b/src/signal/linux/sigaction.cpp
@@ -7,13 +7,12 @@
//===----------------------------------------------------------------------===//
#include "src/signal/sigaction.h"
+
+#include "hdr/types/sigset_t.h"
+#include "src/__support/common.h"
#include "src/errno/libc_errno.h"
#include "src/signal/linux/signal_utils.h"
-#include "src/__support/common.h"
-
-#include <signal.h>
-
namespace LIBC_NAMESPACE {
// TOOD: Some architectures will have their signal trampoline functions in the
diff --git a/src/signal/linux/sigaddset.cpp b/src/signal/linux/sigaddset.cpp
index 5363917..8fc5d43 100644
--- a/src/signal/linux/sigaddset.cpp
+++ b/src/signal/linux/sigaddset.cpp
@@ -7,12 +7,12 @@
//===----------------------------------------------------------------------===//
#include "src/signal/sigaddset.h"
+
+#include "hdr/types/sigset_t.h"
#include "src/__support/common.h"
#include "src/errno/libc_errno.h"
#include "src/signal/linux/signal_utils.h"
-#include <signal.h>
-
namespace LIBC_NAMESPACE {
LLVM_LIBC_FUNCTION(int, sigaddset, (sigset_t * set, int signum)) {
diff --git a/src/signal/linux/sigdelset.cpp b/src/signal/linux/sigdelset.cpp
index 5cb645e..997f457 100644
--- a/src/signal/linux/sigdelset.cpp
+++ b/src/signal/linux/sigdelset.cpp
@@ -7,12 +7,12 @@
//===----------------------------------------------------------------------===//
#include "src/signal/sigdelset.h"
+
+#include "hdr/types/sigset_t.h"
#include "src/__support/common.h"
#include "src/errno/libc_errno.h"
#include "src/signal/linux/signal_utils.h"
-#include <signal.h>
-
namespace LIBC_NAMESPACE {
LLVM_LIBC_FUNCTION(int, sigdelset, (sigset_t * set, int signum)) {
diff --git a/src/signal/linux/sigfillset.cpp b/src/signal/linux/sigfillset.cpp
index e17c85a..d98bbf7 100644
--- a/src/signal/linux/sigfillset.cpp
+++ b/src/signal/linux/sigfillset.cpp
@@ -7,12 +7,12 @@
//===----------------------------------------------------------------------===//
#include "src/signal/sigfillset.h"
+
+#include "hdr/types/sigset_t.h"
#include "src/__support/common.h"
#include "src/errno/libc_errno.h"
#include "src/signal/linux/signal_utils.h"
-#include <signal.h>
-
namespace LIBC_NAMESPACE {
LLVM_LIBC_FUNCTION(int, sigfillset, (sigset_t * set)) {
diff --git a/src/signal/linux/signal_utils.h b/src/signal/linux/signal_utils.h
index 5e9dd9a..3fd0cc0 100644
--- a/src/signal/linux/signal_utils.h
+++ b/src/signal/linux/signal_utils.h
@@ -9,10 +9,11 @@
#ifndef LLVM_LIBC_SRC_SIGNAL_LINUX_SIGNAL_UTILS_H
#define LLVM_LIBC_SRC_SIGNAL_LINUX_SIGNAL_UTILS_H
+#include "hdr/types/sigset_t.h"
#include "src/__support/OSUtil/syscall.h" // For internal syscall function.
#include "src/__support/common.h"
-#include <signal.h>
+#include <signal.h> // sigaction
#include <stddef.h>
#include <sys/syscall.h> // For syscall numbers.
diff --git a/src/signal/linux/sigprocmask.cpp b/src/signal/linux/sigprocmask.cpp
index 79a35dd..0e94efb 100644
--- a/src/signal/linux/sigprocmask.cpp
+++ b/src/signal/linux/sigprocmask.cpp
@@ -7,13 +7,13 @@
//===----------------------------------------------------------------------===//
#include "src/signal/sigprocmask.h"
+
+#include "hdr/types/sigset_t.h"
#include "src/__support/OSUtil/syscall.h" // For internal syscall function.
+#include "src/__support/common.h"
#include "src/errno/libc_errno.h"
#include "src/signal/linux/signal_utils.h"
-#include "src/__support/common.h"
-
-#include <signal.h>
#include <sys/syscall.h> // For syscall numbers.
namespace LIBC_NAMESPACE {
diff --git a/src/signal/sigaddset.h b/src/signal/sigaddset.h
index 626eb20..c703b46b 100644
--- a/src/signal/sigaddset.h
+++ b/src/signal/sigaddset.h
@@ -9,7 +9,7 @@
#ifndef LLVM_LIBC_SRC_SIGNAL_SIGADDSET_H
#define LLVM_LIBC_SRC_SIGNAL_SIGADDSET_H
-#include <signal.h>
+#include "hdr/types/sigset_t.h"
namespace LIBC_NAMESPACE {
diff --git a/src/signal/sigdelset.h b/src/signal/sigdelset.h
index c4fdb99..7bdb6e6 100644
--- a/src/signal/sigdelset.h
+++ b/src/signal/sigdelset.h
@@ -9,7 +9,7 @@
#ifndef LLVM_LIBC_SRC_SIGNAL_SIGDELSET_H
#define LLVM_LIBC_SRC_SIGNAL_SIGDELSET_H
-#include <signal.h>
+#include "hdr/types/sigset_t.h"
namespace LIBC_NAMESPACE {
diff --git a/src/signal/sigemptyset.h b/src/signal/sigemptyset.h
index f3763d1..661fd33 100644
--- a/src/signal/sigemptyset.h
+++ b/src/signal/sigemptyset.h
@@ -9,7 +9,7 @@
#ifndef LLVM_LIBC_SRC_SIGNAL_SIGEMPTYSET_H
#define LLVM_LIBC_SRC_SIGNAL_SIGEMPTYSET_H
-#include <signal.h>
+#include "hdr/types/sigset_t.h"
namespace LIBC_NAMESPACE {
diff --git a/src/signal/sigfillset.h b/src/signal/sigfillset.h
index d8e3168..2849aac 100644
--- a/src/signal/sigfillset.h
+++ b/src/signal/sigfillset.h
@@ -9,7 +9,7 @@
#ifndef LLVM_LIBC_SRC_SIGNAL_SIGFILLSET_H
#define LLVM_LIBC_SRC_SIGNAL_SIGFILLSET_H
-#include <signal.h>
+#include "hdr/types/sigset_t.h"
namespace LIBC_NAMESPACE {
diff --git a/src/signal/sigprocmask.h b/src/signal/sigprocmask.h
index e065886..8569578 100644
--- a/src/signal/sigprocmask.h
+++ b/src/signal/sigprocmask.h
@@ -9,7 +9,7 @@
#ifndef LLVM_LIBC_SRC_SIGNAL_SIGPROCMASK_H
#define LLVM_LIBC_SRC_SIGNAL_SIGPROCMASK_H
-#include <signal.h>
+#include "hdr/types/sigset_t.h"
namespace LIBC_NAMESPACE {
diff --git a/src/stdio/fseeko.h b/src/stdio/fseeko.h
index 3202ed2..77fb412 100644
--- a/src/stdio/fseeko.h
+++ b/src/stdio/fseeko.h
@@ -10,7 +10,6 @@
#define LLVM_LIBC_SRC_STDIO_FSEEKO_H
#include <stdio.h>
-#include <unistd.h>
namespace LIBC_NAMESPACE {
diff --git a/src/stdio/ftello.h b/src/stdio/ftello.h
index 0fdf13a..5ab17f9 100644
--- a/src/stdio/ftello.h
+++ b/src/stdio/ftello.h
@@ -10,7 +10,6 @@
#define LLVM_LIBC_SRC_STDIO_FTELLO_H
#include <stdio.h>
-#include <unistd.h>
namespace LIBC_NAMESPACE {
diff --git a/src/stdio/printf_core/float_dec_converter.h b/src/stdio/printf_core/float_dec_converter.h
index c4e8aaa..666e4c9 100644
--- a/src/stdio/printf_core/float_dec_converter.h
+++ b/src/stdio/printf_core/float_dec_converter.h
@@ -12,7 +12,7 @@
#include "src/__support/CPP/string_view.h"
#include "src/__support/FPUtil/FPBits.h"
#include "src/__support/FPUtil/rounding_mode.h"
-#include "src/__support/UInt.h" // is_big_int_v
+#include "src/__support/big_int.h" // is_big_int_v
#include "src/__support/float_to_string.h"
#include "src/__support/integer_to_string.h"
#include "src/__support/libc_assert.h"
diff --git a/src/sys/epoll/epoll_create.h b/src/sys/epoll/epoll_create.h
new file mode 100644
index 0000000..a1eeabd
--- /dev/null
+++ b/src/sys/epoll/epoll_create.h
@@ -0,0 +1,18 @@
+//===-- Implementation header for epoll_create function ---------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_SRC_SYS_EPOLL_EPOLL_CREATE_H
+#define LLVM_LIBC_SRC_SYS_EPOLL_EPOLL_CREATE_H
+
+namespace LIBC_NAMESPACE {
+
+int epoll_create(int size);
+
+} // namespace LIBC_NAMESPACE
+
+#endif // LLVM_LIBC_SRC_SYS_EPOLL_EPOLL_CREATE_H
diff --git a/src/sys/epoll/epoll_create1.h b/src/sys/epoll/epoll_create1.h
new file mode 100644
index 0000000..70f446b
--- /dev/null
+++ b/src/sys/epoll/epoll_create1.h
@@ -0,0 +1,18 @@
+//===-- Implementation header for epoll_create1 function --------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_SRC_SYS_EPOLL_EPOLL_CREATE1_H
+#define LLVM_LIBC_SRC_SYS_EPOLL_EPOLL_CREATE1_H
+
+namespace LIBC_NAMESPACE {
+
+int epoll_create1(int flags);
+
+} // namespace LIBC_NAMESPACE
+
+#endif // LLVM_LIBC_SRC_SYS_EPOLL_EPOLL_CREATE1_H
diff --git a/src/sys/epoll/epoll_ctl.h b/src/sys/epoll/epoll_ctl.h
new file mode 100644
index 0000000..4240294
--- /dev/null
+++ b/src/sys/epoll/epoll_ctl.h
@@ -0,0 +1,21 @@
+//===-- Implementation header for epoll_ctl function ------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_SRC_SYS_EPOLL_EPOLL_CTL_H
+#define LLVM_LIBC_SRC_SYS_EPOLL_EPOLL_CTL_H
+
+#include "hdr/types/struct_epoll_event.h"
+
+namespace LIBC_NAMESPACE {
+
+// TODO: event should be nullable
+int epoll_ctl(int epfd, int op, int fd, struct epoll_event *event);
+
+} // namespace LIBC_NAMESPACE
+
+#endif // LLVM_LIBC_SRC_SYS_EPOLL_EPOLL_CTL_H
diff --git a/src/sys/epoll/epoll_pwait.h b/src/sys/epoll/epoll_pwait.h
index 9dcb555..bcae72b 100644
--- a/src/sys/epoll/epoll_pwait.h
+++ b/src/sys/epoll/epoll_pwait.h
@@ -9,17 +9,14 @@
#ifndef LLVM_LIBC_SRC_SYS_EPOLL_EPOLL_PWAIT_H
#define LLVM_LIBC_SRC_SYS_EPOLL_EPOLL_PWAIT_H
-// TODO: Use this include once the include headers are also using quotes.
-// #include "include/llvm-libc-types/sigset_t.h"
-// #include "include/llvm-libc-types/struct_epoll_event.h"
-
-#include <sys/epoll.h>
+#include "hdr/types/sigset_t.h"
+#include "hdr/types/struct_epoll_event.h"
namespace LIBC_NAMESPACE {
// TODO: sigmask should be nullable
-int epoll_pwait(int epfd, epoll_event *events, int maxevents, int timeout,
- const sigset_t *sigmask);
+int epoll_pwait(int epfd, struct epoll_event *events, int maxevents,
+ int timeout, const sigset_t *sigmask);
} // namespace LIBC_NAMESPACE
diff --git a/src/sys/epoll/epoll_pwait2.h b/src/sys/epoll/epoll_pwait2.h
index 622ede6..7fc528b 100644
--- a/src/sys/epoll/epoll_pwait2.h
+++ b/src/sys/epoll/epoll_pwait2.h
@@ -9,12 +9,9 @@
#ifndef LLVM_LIBC_SRC_SYS_EPOLL_EPOLL_PWAIT2_H
#define LLVM_LIBC_SRC_SYS_EPOLL_EPOLL_PWAIT2_H
-// TODO: Use this include once the include headers are also using quotes.
-// #include "include/llvm-libc-types/sigset_t.h"
-// #include "include/llvm-libc-types/struct_epoll_event.h"
-// #include "include/llvm-libc-types/struct_timespec.h"
-
-#include <sys/epoll.h>
+#include "hdr/types/sigset_t.h"
+#include "hdr/types/struct_epoll_event.h"
+#include "hdr/types/struct_timespec.h"
namespace LIBC_NAMESPACE {
diff --git a/src/sys/epoll/epoll_wait.h b/src/sys/epoll/epoll_wait.h
index d51c910..b546e91 100644
--- a/src/sys/epoll/epoll_wait.h
+++ b/src/sys/epoll/epoll_wait.h
@@ -9,10 +9,7 @@
#ifndef LLVM_LIBC_SRC_SYS_EPOLL_EPOLL_WAIT_H
#define LLVM_LIBC_SRC_SYS_EPOLL_EPOLL_WAIT_H
-// TODO: Use this include once the include headers are also using quotes.
-// #include "include/llvm-libc-types/struct_epoll_event.h"
-
-#include <sys/epoll.h>
+#include "hdr/types/struct_epoll_event.h"
namespace LIBC_NAMESPACE {
diff --git a/src/sys/epoll/linux/epoll_create.cpp b/src/sys/epoll/linux/epoll_create.cpp
new file mode 100644
index 0000000..d4995c4
--- /dev/null
+++ b/src/sys/epoll/linux/epoll_create.cpp
@@ -0,0 +1,38 @@
+//===---------- Linux implementation of the epoll_create function ---------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "src/sys/epoll/epoll_create.h"
+
+#include "src/__support/OSUtil/syscall.h" // For internal syscall function.
+#include "src/__support/common.h"
+#include "src/errno/libc_errno.h"
+#include <sys/syscall.h> // For syscall numbers.
+
+namespace LIBC_NAMESPACE {
+
+LLVM_LIBC_FUNCTION(int, epoll_create, ([[maybe_unused]] int size)) {
+#ifdef SYS_epoll_create
+ int ret = LIBC_NAMESPACE::syscall_impl<int>(SYS_epoll_create, size);
+#elif defined(SYS_epoll_create1)
+ int ret = LIBC_NAMESPACE::syscall_impl<int>(SYS_epoll_create1, 0);
+#else
+#error \
+ "epoll_create and epoll_create1 are unavailable. Unable to build epoll_create."
+#endif
+
+ // A negative return value indicates an error with the magnitude of the
+ // value being the error code.
+ if (ret < 0) {
+ libc_errno = -ret;
+ return -1;
+ }
+
+ return ret;
+}
+
+} // namespace LIBC_NAMESPACE
diff --git a/src/sys/epoll/linux/epoll_create1.cpp b/src/sys/epoll/linux/epoll_create1.cpp
new file mode 100644
index 0000000..30f1a99
--- /dev/null
+++ b/src/sys/epoll/linux/epoll_create1.cpp
@@ -0,0 +1,31 @@
+//===---------- Linux implementation of the epoll_create1 function --------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "src/sys/epoll/epoll_create1.h"
+
+#include "src/__support/OSUtil/syscall.h" // For internal syscall function.
+#include "src/__support/common.h"
+#include "src/errno/libc_errno.h"
+#include <sys/syscall.h> // For syscall numbers.
+
+namespace LIBC_NAMESPACE {
+
+LLVM_LIBC_FUNCTION(int, epoll_create1, (int flags)) {
+ int ret = LIBC_NAMESPACE::syscall_impl<int>(SYS_epoll_create1, flags);
+
+ // A negative return value indicates an error with the magnitude of the
+ // value being the error code.
+ if (ret < 0) {
+ libc_errno = -ret;
+ return -1;
+ }
+
+ return ret;
+}
+
+} // namespace LIBC_NAMESPACE
diff --git a/src/sys/epoll/linux/epoll_ctl.cpp b/src/sys/epoll/linux/epoll_ctl.cpp
new file mode 100644
index 0000000..c111c5e4
--- /dev/null
+++ b/src/sys/epoll/linux/epoll_ctl.cpp
@@ -0,0 +1,34 @@
+//===---------- Linux implementation of the epoll_ctl function ----------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "src/sys/epoll/epoll_ctl.h"
+
+#include "hdr/types/struct_epoll_event.h"
+#include "src/__support/OSUtil/syscall.h" // For internal syscall function.
+#include "src/__support/common.h"
+#include "src/errno/libc_errno.h"
+#include <sys/syscall.h> // For syscall numbers.
+
+namespace LIBC_NAMESPACE {
+
+LLVM_LIBC_FUNCTION(int, epoll_ctl,
+ (int epfd, int op, int fd, epoll_event *event)) {
+ int ret = LIBC_NAMESPACE::syscall_impl<int>(SYS_epoll_ctl, epfd, op, fd,
+ reinterpret_cast<long>(event));
+
+ // A negative return value indicates an error with the magnitude of the
+ // value being the error code.
+ if (ret < 0) {
+ libc_errno = -ret;
+ return -1;
+ }
+
+ return ret;
+}
+
+} // namespace LIBC_NAMESPACE
diff --git a/src/sys/epoll/linux/epoll_pwait.cpp b/src/sys/epoll/linux/epoll_pwait.cpp
index ee1b4e6..8f498d1 100644
--- a/src/sys/epoll/linux/epoll_pwait.cpp
+++ b/src/sys/epoll/linux/epoll_pwait.cpp
@@ -8,18 +8,15 @@
#include "src/sys/epoll/epoll_pwait.h"
+#include "hdr/signal_macros.h" // for NSIG
+#include "hdr/types/sigset_t.h"
+#include "hdr/types/struct_epoll_event.h"
#include "src/__support/OSUtil/syscall.h" // For internal syscall function.
#include "src/__support/common.h"
-
#include "src/errno/libc_errno.h"
+
#include <sys/syscall.h> // For syscall numbers.
-// TODO: Use this include once the include headers are also using quotes.
-// #include "include/llvm-libc-types/sigset_t.h"
-// #include "include/llvm-libc-types/struct_epoll_event.h"
-
-#include <sys/epoll.h>
-
namespace LIBC_NAMESPACE {
LLVM_LIBC_FUNCTION(int, epoll_pwait,
@@ -27,7 +24,7 @@
int timeout, const sigset_t *sigmask)) {
int ret = LIBC_NAMESPACE::syscall_impl<int>(
SYS_epoll_pwait, epfd, reinterpret_cast<long>(events), maxevents, timeout,
- reinterpret_cast<long>(sigmask), sizeof(sigset_t));
+ reinterpret_cast<long>(sigmask), NSIG / 8);
// A negative return value indicates an error with the magnitude of the
// value being the error code.
@@ -36,7 +33,7 @@
return -1;
}
- return 0;
+ return ret;
}
} // namespace LIBC_NAMESPACE
diff --git a/src/sys/epoll/linux/epoll_pwait2.cpp b/src/sys/epoll/linux/epoll_pwait2.cpp
index 671dede..bd33cb6 100644
--- a/src/sys/epoll/linux/epoll_pwait2.cpp
+++ b/src/sys/epoll/linux/epoll_pwait2.cpp
@@ -8,19 +8,16 @@
#include "src/sys/epoll/epoll_pwait2.h"
+#include "hdr/signal_macros.h" // for NSIG
+#include "hdr/types/sigset_t.h"
+#include "hdr/types/struct_epoll_event.h"
+#include "hdr/types/struct_timespec.h"
#include "src/__support/OSUtil/syscall.h" // For internal syscall function.
#include "src/__support/common.h"
-
#include "src/errno/libc_errno.h"
+
#include <sys/syscall.h> // For syscall numbers.
-// TODO: Use this include once the include headers are also using quotes.
-// #include "include/llvm-libc-types/sigset_t.h"
-// #include "include/llvm-libc-types/struct_epoll_event.h"
-// #include "include/llvm-libc-types/struct_timespec.h"
-
-#include <sys/epoll.h>
-
namespace LIBC_NAMESPACE {
LLVM_LIBC_FUNCTION(int, epoll_pwait2,
@@ -29,7 +26,7 @@
int ret = LIBC_NAMESPACE::syscall_impl<int>(
SYS_epoll_pwait2, epfd, reinterpret_cast<long>(events), maxevents,
reinterpret_cast<long>(timeout), reinterpret_cast<long>(sigmask),
- sizeof(sigset_t));
+ NSIG / 8);
// A negative return value indicates an error with the magnitude of the
// value being the error code.
@@ -38,7 +35,7 @@
return -1;
}
- return 0;
+ return ret;
}
} // namespace LIBC_NAMESPACE
diff --git a/src/sys/epoll/linux/epoll_wait.cpp b/src/sys/epoll/linux/epoll_wait.cpp
index 0c43edf..95238d8 100644
--- a/src/sys/epoll/linux/epoll_wait.cpp
+++ b/src/sys/epoll/linux/epoll_wait.cpp
@@ -8,17 +8,15 @@
#include "src/sys/epoll/epoll_wait.h"
+#include "hdr/signal_macros.h" // for NSIG
+#include "hdr/types/sigset_t.h"
+#include "hdr/types/struct_epoll_event.h"
#include "src/__support/OSUtil/syscall.h" // For internal syscall function.
#include "src/__support/common.h"
#include "src/errno/libc_errno.h"
+
#include <sys/syscall.h> // For syscall numbers.
-// TODO: Use this include once the include headers are also using quotes.
-// #include "include/llvm-libc-types/sigset_t.h"
-// #include "include/llvm-libc-types/struct_epoll_event.h"
-
-#include <sys/epoll.h>
-
namespace LIBC_NAMESPACE {
LLVM_LIBC_FUNCTION(int, epoll_wait,
@@ -30,7 +28,7 @@
#elif defined(SYS_epoll_pwait)
int ret = LIBC_NAMESPACE::syscall_impl<int>(
SYS_epoll_pwait, epfd, reinterpret_cast<long>(events), maxevents, timeout,
- reinterpret_cast<long>(nullptr), sizeof(sigset_t));
+ reinterpret_cast<long>(nullptr), NSIG / 8);
#else
#error "epoll_wait and epoll_pwait are unavailable. Unable to build epoll_wait."
#endif
@@ -41,7 +39,7 @@
return -1;
}
- return 0;
+ return ret;
}
} // namespace LIBC_NAMESPACE
diff --git a/src/sys/select/linux/select.cpp b/src/sys/select/linux/select.cpp
index 3f387c1..9034b75 100644
--- a/src/sys/select/linux/select.cpp
+++ b/src/sys/select/linux/select.cpp
@@ -8,14 +8,14 @@
#include "src/sys/select/select.h"
+#include "hdr/types/sigset_t.h"
+#include "hdr/types/struct_timespec.h"
#include "src/__support/CPP/limits.h"
#include "src/__support/OSUtil/syscall.h" // For internal syscall function.
#include "src/__support/common.h"
-
#include "src/errno/libc_errno.h"
-#include <signal.h>
-#include <stddef.h> // For size_t
-#include <sys/select.h>
+
+#include <stddef.h> // For size_t
#include <sys/syscall.h> // For syscall numbers.
namespace LIBC_NAMESPACE {
diff --git a/src/unistd/linux/pipe.cpp b/src/unistd/linux/pipe.cpp
new file mode 100644
index 0000000..b4e8b9b
--- /dev/null
+++ b/src/unistd/linux/pipe.cpp
@@ -0,0 +1,33 @@
+//===-- Linux implementation of pipe --------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "src/unistd/pipe.h"
+
+#include "src/__support/OSUtil/syscall.h" // For internal syscall function.
+#include "src/__support/common.h"
+#include "src/errno/libc_errno.h"
+#include <sys/syscall.h> // For syscall numbers.
+
+namespace LIBC_NAMESPACE {
+
+LLVM_LIBC_FUNCTION(int, pipe, (int pipefd[2])) {
+#ifdef SYS_pipe
+ int ret = LIBC_NAMESPACE::syscall_impl<int>(SYS_pipe,
+ reinterpret_cast<long>(pipefd));
+#elif defined(SYS_pipe2)
+ int ret = LIBC_NAMESPACE::syscall_impl<int>(
+ SYS_pipe2, reinterpret_cast<long>(pipefd), 0);
+#endif
+ if (ret < 0) {
+ libc_errno = -ret;
+ return -1;
+ }
+ return ret;
+}
+
+} // namespace LIBC_NAMESPACE
diff --git a/test/src/math/RandUtils.cpp b/src/unistd/pipe.h
similarity index 61%
rename from test/src/math/RandUtils.cpp
rename to src/unistd/pipe.h
index 0d09764..0e20bb4 100644
--- a/test/src/math/RandUtils.cpp
+++ b/src/unistd/pipe.h
@@ -1,4 +1,4 @@
-//===-- RandUtils.cpp -----------------------------------------------------===//
+//===-- Implementation header for pipe --------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -6,14 +6,13 @@
//
//===----------------------------------------------------------------------===//
-#include "RandUtils.h"
-
-#include <cstdlib>
+#ifndef LLVM_LIBC_SRC_UNISTD_PIPE_H
+#define LLVM_LIBC_SRC_UNISTD_PIPE_H
namespace LIBC_NAMESPACE {
-namespace testutils {
-int rand() { return std::rand(); }
+int pipe(int pipefd[2]);
-} // namespace testutils
} // namespace LIBC_NAMESPACE
+
+#endif // LLVM_LIBC_SRC_UNISTD_PIPE_H
diff --git a/test/UnitTest/FPMatcher.h b/test/UnitTest/FPMatcher.h
index f4553ea..a76e0b8 100644
--- a/test/UnitTest/FPMatcher.h
+++ b/test/UnitTest/FPMatcher.h
@@ -18,7 +18,7 @@
#include "test/UnitTest/StringUtils.h"
#include "test/UnitTest/Test.h"
-#include "include/llvm-libc-macros/math-macros.h"
+#include "hdr/math_macros.h"
namespace LIBC_NAMESPACE {
namespace testing {
diff --git a/test/UnitTest/LibcDeathTestExecutors.cpp b/test/UnitTest/LibcDeathTestExecutors.cpp
index e891c4e..fa6d164 100644
--- a/test/UnitTest/LibcDeathTestExecutors.cpp
+++ b/test/UnitTest/LibcDeathTestExecutors.cpp
@@ -19,7 +19,7 @@
bool Test::testProcessKilled(testutils::FunctionCaller *Func, int Signal,
const char *LHSStr, const char *RHSStr,
internal::Location Loc) {
- testutils::ProcessStatus Result = testutils::invoke_in_subprocess(Func, 500);
+ testutils::ProcessStatus Result = testutils::invoke_in_subprocess(Func, 1000);
if (const char *error = Result.get_error()) {
Ctx->markFail();
@@ -31,7 +31,7 @@
if (Result.timed_out()) {
Ctx->markFail();
tlog << Loc;
- tlog << "Process timed out after " << 500 << " milliseconds.\n";
+ tlog << "Process timed out after " << 1000 << " milliseconds.\n";
return false;
}
@@ -62,7 +62,7 @@
bool Test::testProcessExits(testutils::FunctionCaller *Func, int ExitCode,
const char *LHSStr, const char *RHSStr,
internal::Location Loc) {
- testutils::ProcessStatus Result = testutils::invoke_in_subprocess(Func, 500);
+ testutils::ProcessStatus Result = testutils::invoke_in_subprocess(Func, 1000);
if (const char *error = Result.get_error()) {
Ctx->markFail();
@@ -74,7 +74,7 @@
if (Result.timed_out()) {
Ctx->markFail();
tlog << Loc;
- tlog << "Process timed out after " << 500 << " milliseconds.\n";
+ tlog << "Process timed out after " << 1000 << " milliseconds.\n";
return false;
}
diff --git a/test/UnitTest/LibcTest.cpp b/test/UnitTest/LibcTest.cpp
index 03cd251..846ad33 100644
--- a/test/UnitTest/LibcTest.cpp
+++ b/test/UnitTest/LibcTest.cpp
@@ -11,9 +11,9 @@
#include "include/llvm-libc-macros/stdfix-macros.h"
#include "src/__support/CPP/string.h"
#include "src/__support/CPP/string_view.h"
-#include "src/__support/UInt128.h"
#include "src/__support/fixed_point/fx_rep.h"
#include "src/__support/macros/properties/types.h" // LIBC_TYPES_HAS_INT128
+#include "src/__support/uint128.h"
#include "test/UnitTest/TestLogger.h"
#if __STDC_HOSTED__
diff --git a/test/UnitTest/RoundingModeUtils.cpp b/test/UnitTest/RoundingModeUtils.cpp
index c8f32f8..cb34c5e 100644
--- a/test/UnitTest/RoundingModeUtils.cpp
+++ b/test/UnitTest/RoundingModeUtils.cpp
@@ -10,7 +10,7 @@
#include "src/__support/FPUtil/FEnvImpl.h"
#include "src/__support/FPUtil/rounding_mode.h"
-#include <fenv.h>
+#include "hdr/fenv_macros.h"
namespace LIBC_NAMESPACE {
namespace fputil {
diff --git a/test/UnitTest/StringUtils.h b/test/UnitTest/StringUtils.h
index cab0b58..61d74b4 100644
--- a/test/UnitTest/StringUtils.h
+++ b/test/UnitTest/StringUtils.h
@@ -11,7 +11,7 @@
#include "src/__support/CPP/string.h"
#include "src/__support/CPP/type_traits.h"
-#include "src/__support/UInt.h"
+#include "src/__support/big_int.h"
namespace LIBC_NAMESPACE {
diff --git a/test/UnitTest/TestLogger.cpp b/test/UnitTest/TestLogger.cpp
index 4756188..feba4b5 100644
--- a/test/UnitTest/TestLogger.cpp
+++ b/test/UnitTest/TestLogger.cpp
@@ -1,10 +1,10 @@
#include "test/UnitTest/TestLogger.h"
#include "src/__support/CPP/string.h"
#include "src/__support/CPP/string_view.h"
-#include "src/__support/OSUtil/io.h" // write_to_stderr
-#include "src/__support/UInt.h" // is_big_int
-#include "src/__support/UInt128.h"
+#include "src/__support/OSUtil/io.h" // write_to_stderr
+#include "src/__support/big_int.h" // is_big_int
#include "src/__support/macros/properties/types.h" // LIBC_TYPES_HAS_INT128
+#include "src/__support/uint128.h"
#include <stdint.h>
diff --git a/test/src/__support/CPP/bit_test.cpp b/test/src/__support/CPP/bit_test.cpp
index 875b47e..299623d 100644
--- a/test/src/__support/CPP/bit_test.cpp
+++ b/test/src/__support/CPP/bit_test.cpp
@@ -7,7 +7,7 @@
//===----------------------------------------------------------------------===//
#include "src/__support/CPP/bit.h"
-#include "src/__support/UInt.h"
+#include "src/__support/big_int.h"
#include "src/__support/macros/properties/types.h" // LIBC_TYPES_HAS_INT128
#include "test/UnitTest/Test.h"
diff --git a/test/src/__support/CPP/limits_test.cpp b/test/src/__support/CPP/limits_test.cpp
index efcd683..bcf7d5e 100644
--- a/test/src/__support/CPP/limits_test.cpp
+++ b/test/src/__support/CPP/limits_test.cpp
@@ -7,7 +7,7 @@
//===----------------------------------------------------------------------===//
#include "src/__support/CPP/limits.h"
-#include "src/__support/UInt.h"
+#include "src/__support/big_int.h"
#include "src/__support/macros/properties/types.h" // LIBC_TYPES_HAS_INT128
#include "test/UnitTest/Test.h"
diff --git a/test/src/__support/FPUtil/dyadic_float_test.cpp b/test/src/__support/FPUtil/dyadic_float_test.cpp
index 5ee9aaa..809381e 100644
--- a/test/src/__support/FPUtil/dyadic_float_test.cpp
+++ b/test/src/__support/FPUtil/dyadic_float_test.cpp
@@ -7,7 +7,7 @@
//===----------------------------------------------------------------------===//
#include "src/__support/FPUtil/dyadic_float.h"
-#include "src/__support/UInt.h"
+#include "src/__support/big_int.h"
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"
#include "utils/MPFRWrapper/MPFRUtils.h"
diff --git a/test/src/__support/FPUtil/rounding_mode_test.cpp b/test/src/__support/FPUtil/rounding_mode_test.cpp
index 8077a5a..5d62bc8 100644
--- a/test/src/__support/FPUtil/rounding_mode_test.cpp
+++ b/test/src/__support/FPUtil/rounding_mode_test.cpp
@@ -10,7 +10,7 @@
#include "test/UnitTest/Test.h"
#include "utils/MPFRWrapper/MPFRUtils.h"
-#include <fenv.h>
+#include "hdr/fenv_macros.h"
using LIBC_NAMESPACE::testing::mpfr::ForceRoundingMode;
using LIBC_NAMESPACE::testing::mpfr::RoundingMode;
diff --git a/test/src/__support/uint_test.cpp b/test/src/__support/big_int_test.cpp
similarity index 98%
rename from test/src/__support/uint_test.cpp
rename to test/src/__support/big_int_test.cpp
index 5696e54..1c4f0ac 100644
--- a/test/src/__support/uint_test.cpp
+++ b/test/src/__support/big_int_test.cpp
@@ -7,11 +7,11 @@
//===----------------------------------------------------------------------===//
#include "src/__support/CPP/optional.h"
-#include "src/__support/UInt.h"
+#include "src/__support/big_int.h"
#include "src/__support/integer_literals.h" // parse_unsigned_bigint
#include "src/__support/macros/properties/types.h" // LIBC_TYPES_HAS_INT128
-#include "include/llvm-libc-macros/math-macros.h" // HUGE_VALF, HUGE_VALF
+#include "hdr/math_macros.h" // HUGE_VALF, HUGE_VALF
#include "test/UnitTest/Test.h"
namespace LIBC_NAMESPACE {
@@ -192,7 +192,7 @@
TYPED_TEST(LlvmLibcUIntClassTest, CountBits, Types) {
if constexpr (!T::SIGNED) {
- for (size_t i = 0; i <= T::BITS; ++i) {
+ for (size_t i = 0; i < T::BITS; ++i) {
const auto l_one = T::all_ones() << i; // 0b111...000
const auto r_one = T::all_ones() >> i; // 0b000...111
const int zeros = i;
@@ -559,10 +559,6 @@
LL_UInt128 result5({0, 0x2468ace000000000});
EXPECT_EQ((val2 << 100), result5);
- LL_UInt128 result6({0, 0});
- EXPECT_EQ((val2 << 128), result6);
- EXPECT_EQ((val2 << 256), result6);
-
LL_UInt192 val3({1, 0, 0});
LL_UInt192 result7({0, 1, 0});
EXPECT_EQ((val3 << 64), result7);
@@ -589,10 +585,6 @@
LL_UInt128 result5({0x0000000001234567, 0});
EXPECT_EQ((val2 >> 100), result5);
- LL_UInt128 result6({0, 0});
- EXPECT_EQ((val2 >> 128), result6);
- EXPECT_EQ((val2 >> 256), result6);
-
LL_UInt128 v1({0x1111222233334444, 0xaaaabbbbccccdddd});
LL_UInt128 r1({0xaaaabbbbccccdddd, 0});
EXPECT_EQ((v1 >> 64), r1);
diff --git a/test/src/__support/high_precision_decimal_test.cpp b/test/src/__support/high_precision_decimal_test.cpp
index 2bb28bc..7a3c323 100644
--- a/test/src/__support/high_precision_decimal_test.cpp
+++ b/test/src/__support/high_precision_decimal_test.cpp
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#include "src/__support/UInt128.h"
#include "src/__support/high_precision_decimal.h"
+#include "src/__support/uint128.h"
#include "test/UnitTest/Test.h"
diff --git a/test/src/__support/integer_to_string_test.cpp b/test/src/__support/integer_to_string_test.cpp
index 270fddd..e644751 100644
--- a/test/src/__support/integer_to_string_test.cpp
+++ b/test/src/__support/integer_to_string_test.cpp
@@ -9,10 +9,10 @@
#include "src/__support/CPP/limits.h"
#include "src/__support/CPP/span.h"
#include "src/__support/CPP/string_view.h"
-#include "src/__support/UInt.h"
-#include "src/__support/UInt128.h"
+#include "src/__support/big_int.h"
#include "src/__support/integer_literals.h"
#include "src/__support/integer_to_string.h"
+#include "src/__support/uint128.h"
#include "test/UnitTest/Test.h"
diff --git a/test/src/__support/math_extras_test.cpp b/test/src/__support/math_extras_test.cpp
index 401e631e..0047888 100644
--- a/test/src/__support/math_extras_test.cpp
+++ b/test/src/__support/math_extras_test.cpp
@@ -6,9 +6,9 @@
//
//===----------------------------------------------------------------------===//
-#include "src/__support/UInt128.h" // UInt<128>
#include "src/__support/integer_literals.h"
#include "src/__support/math_extras.h"
+#include "src/__support/uint128.h" // UInt<128>
#include "test/UnitTest/Test.h"
namespace LIBC_NAMESPACE {
diff --git a/test/src/__support/str_to_fp_test.h b/test/src/__support/str_to_fp_test.h
index bddff03..8d6181c 100644
--- a/test/src/__support/str_to_fp_test.h
+++ b/test/src/__support/str_to_fp_test.h
@@ -7,8 +7,8 @@
//===----------------------------------------------------------------------===//
#include "src/__support/FPUtil/FPBits.h"
-#include "src/__support/UInt128.h"
#include "src/__support/str_to_float.h"
+#include "src/__support/uint128.h"
#include "src/errno/libc_errno.h"
#include "test/UnitTest/Test.h"
diff --git a/test/src/fenv/enabled_exceptions_test.cpp b/test/src/fenv/enabled_exceptions_test.cpp
index 8bc2454..53440b7 100644
--- a/test/src/fenv/enabled_exceptions_test.cpp
+++ b/test/src/fenv/enabled_exceptions_test.cpp
@@ -15,7 +15,7 @@
#include "test/UnitTest/FPExceptMatcher.h"
#include "test/UnitTest/Test.h"
-#include <fenv.h>
+#include "hdr/fenv_macros.h"
#include <signal.h>
// This test enables an exception and verifies that raising that exception
diff --git a/test/src/fenv/exception_status_test.cpp b/test/src/fenv/exception_status_test.cpp
index e4e2240..a700002 100644
--- a/test/src/fenv/exception_status_test.cpp
+++ b/test/src/fenv/exception_status_test.cpp
@@ -1,4 +1,5 @@
-//===-- Unittests for feclearexcept, feraiseexcept and fetestexpect -------===//
+//===-- Unittests for feclearexcept, feraiseexcept, fetestexpect ----------===//
+//===-- and fesetexcept ---------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -8,12 +9,13 @@
#include "src/fenv/feclearexcept.h"
#include "src/fenv/feraiseexcept.h"
+#include "src/fenv/fesetexcept.h"
#include "src/fenv/fetestexcept.h"
#include "src/__support/FPUtil/FEnvImpl.h"
#include "test/UnitTest/Test.h"
-#include <fenv.h>
+#include "hdr/fenv_macros.h"
TEST(LlvmLibcExceptionStatusTest, RaiseAndTest) {
// This test raises a set of exceptions and checks that the exception
@@ -38,6 +40,11 @@
ASSERT_EQ(r, 0);
s = LIBC_NAMESPACE::fetestexcept(e);
ASSERT_EQ(s, 0);
+
+ r = LIBC_NAMESPACE::fesetexcept(e);
+ ASSERT_EQ(r, 0);
+ s = LIBC_NAMESPACE::fetestexcept(e);
+ ASSERT_EQ(s, e);
}
for (int e1 : excepts) {
@@ -52,6 +59,11 @@
ASSERT_EQ(r, 0);
s = LIBC_NAMESPACE::fetestexcept(e);
ASSERT_EQ(s, 0);
+
+ r = LIBC_NAMESPACE::fesetexcept(e);
+ ASSERT_EQ(r, 0);
+ s = LIBC_NAMESPACE::fetestexcept(e);
+ ASSERT_EQ(s, e);
}
}
@@ -68,6 +80,11 @@
ASSERT_EQ(r, 0);
s = LIBC_NAMESPACE::fetestexcept(e);
ASSERT_EQ(s, 0);
+
+ r = LIBC_NAMESPACE::fesetexcept(e);
+ ASSERT_EQ(r, 0);
+ s = LIBC_NAMESPACE::fetestexcept(e);
+ ASSERT_EQ(s, e);
}
}
}
@@ -86,6 +103,11 @@
ASSERT_EQ(r, 0);
s = LIBC_NAMESPACE::fetestexcept(e);
ASSERT_EQ(s, 0);
+
+ r = LIBC_NAMESPACE::fesetexcept(e);
+ ASSERT_EQ(r, 0);
+ s = LIBC_NAMESPACE::fetestexcept(e);
+ ASSERT_EQ(s, e);
}
}
}
@@ -106,6 +128,11 @@
ASSERT_EQ(r, 0);
s = LIBC_NAMESPACE::fetestexcept(e);
ASSERT_EQ(s, 0);
+
+ r = LIBC_NAMESPACE::fesetexcept(e);
+ ASSERT_EQ(r, 0);
+ s = LIBC_NAMESPACE::fetestexcept(e);
+ ASSERT_EQ(s, e);
}
}
}
@@ -116,4 +143,9 @@
ASSERT_EQ(r, 0);
int s = LIBC_NAMESPACE::fetestexcept(ALL_EXCEPTS);
ASSERT_EQ(s, ALL_EXCEPTS);
+
+ r = LIBC_NAMESPACE::fesetexcept(ALL_EXCEPTS);
+ ASSERT_EQ(r, 0);
+ s = LIBC_NAMESPACE::fetestexcept(ALL_EXCEPTS);
+ ASSERT_EQ(s, ALL_EXCEPTS);
}
diff --git a/test/src/fenv/feclearexcept_test.cpp b/test/src/fenv/feclearexcept_test.cpp
index fa3e856..bb42d90 100644
--- a/test/src/fenv/feclearexcept_test.cpp
+++ b/test/src/fenv/feclearexcept_test.cpp
@@ -11,7 +11,7 @@
#include "src/__support/FPUtil/FEnvImpl.h"
#include "test/UnitTest/Test.h"
-#include <fenv.h>
+#include "hdr/fenv_macros.h"
#include <stdint.h>
TEST(LlvmLibcFEnvTest, ClearTest) {
diff --git a/test/src/fenv/feenableexcept_test.cpp b/test/src/fenv/feenableexcept_test.cpp
index 41c1945..aeb4f95 100644
--- a/test/src/fenv/feenableexcept_test.cpp
+++ b/test/src/fenv/feenableexcept_test.cpp
@@ -13,7 +13,7 @@
#include "test/UnitTest/Test.h"
-#include <fenv.h>
+#include "hdr/fenv_macros.h"
TEST(LlvmLibcFEnvTest, EnableTest) {
#if defined(LIBC_TARGET_ARCH_IS_ANY_ARM) || \
diff --git a/test/src/fenv/rounding_mode_test.cpp b/test/src/fenv/rounding_mode_test.cpp
index 4560160..ec2e27e 100644
--- a/test/src/fenv/rounding_mode_test.cpp
+++ b/test/src/fenv/rounding_mode_test.cpp
@@ -11,7 +11,7 @@
#include "test/UnitTest/Test.h"
-#include <fenv.h>
+#include "hdr/fenv_macros.h"
TEST(LlvmLibcRoundingModeTest, SetAndGet) {
struct ResetDefaultRoundingMode {
diff --git a/test/src/math/CeilTest.h b/test/src/math/CeilTest.h
index 74cc906..da3f3c0 100644
--- a/test/src/math/CeilTest.h
+++ b/test/src/math/CeilTest.h
@@ -10,7 +10,7 @@
#include "test/UnitTest/Test.h"
#include "utils/MPFRWrapper/MPFRUtils.h"
-#include "include/llvm-libc-macros/math-macros.h"
+#include "hdr/math_macros.h"
namespace mpfr = LIBC_NAMESPACE::testing::mpfr;
diff --git a/test/src/math/CopySignTest.h b/test/src/math/CopySignTest.h
index 206626d..052ff03 100644
--- a/test/src/math/CopySignTest.h
+++ b/test/src/math/CopySignTest.h
@@ -10,7 +10,7 @@
#include "test/UnitTest/Test.h"
#include "utils/MPFRWrapper/MPFRUtils.h"
-#include "include/llvm-libc-macros/math-macros.h"
+#include "hdr/math_macros.h"
namespace mpfr = LIBC_NAMESPACE::testing::mpfr;
diff --git a/test/src/math/FAbsTest.h b/test/src/math/FAbsTest.h
index 942991f..23ad8a2 100644
--- a/test/src/math/FAbsTest.h
+++ b/test/src/math/FAbsTest.h
@@ -13,7 +13,7 @@
#include "test/UnitTest/Test.h"
#include "utils/MPFRWrapper/MPFRUtils.h"
-#include "include/llvm-libc-macros/math-macros.h"
+#include "hdr/math_macros.h"
namespace mpfr = LIBC_NAMESPACE::testing::mpfr;
diff --git a/test/src/math/FDimTest.h b/test/src/math/FDimTest.h
index df8de91..44aba9c 100644
--- a/test/src/math/FDimTest.h
+++ b/test/src/math/FDimTest.h
@@ -6,7 +6,7 @@
//
//===---------------------------------------------------------------------===//
-#include "include/llvm-libc-macros/math-macros.h"
+#include "hdr/math_macros.h"
#include "src/__support/FPUtil/BasicOperations.h"
#include "src/__support/FPUtil/FPBits.h"
#include "test/UnitTest/FPMatcher.h"
diff --git a/test/src/math/FMaxTest.h b/test/src/math/FMaxTest.h
index 2c7dc3d..e9857f3 100644
--- a/test/src/math/FMaxTest.h
+++ b/test/src/math/FMaxTest.h
@@ -13,7 +13,7 @@
#include "test/UnitTest/Test.h"
#include "utils/MPFRWrapper/MPFRUtils.h"
-#include "include/llvm-libc-macros/math-macros.h"
+#include "hdr/math_macros.h"
namespace mpfr = LIBC_NAMESPACE::testing::mpfr;
diff --git a/test/src/math/FMinTest.h b/test/src/math/FMinTest.h
index a986d524..c6b9f44 100644
--- a/test/src/math/FMinTest.h
+++ b/test/src/math/FMinTest.h
@@ -13,7 +13,7 @@
#include "test/UnitTest/Test.h"
#include "utils/MPFRWrapper/MPFRUtils.h"
-#include "include/llvm-libc-macros/math-macros.h"
+#include "hdr/math_macros.h"
namespace mpfr = LIBC_NAMESPACE::testing::mpfr;
diff --git a/test/src/math/FModTest.h b/test/src/math/FModTest.h
index 96ad299..bc90998 100644
--- a/test/src/math/FModTest.h
+++ b/test/src/math/FModTest.h
@@ -14,7 +14,7 @@
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"
-#include "include/llvm-libc-macros/math-macros.h"
+#include "hdr/math_macros.h"
#define TEST_SPECIAL(x, y, expected, dom_err, expected_exception) \
EXPECT_FP_EQ(expected, f(x, y)); \
diff --git a/test/src/math/FloorTest.h b/test/src/math/FloorTest.h
index 21ae291..679dc26 100644
--- a/test/src/math/FloorTest.h
+++ b/test/src/math/FloorTest.h
@@ -13,7 +13,7 @@
#include "test/UnitTest/Test.h"
#include "utils/MPFRWrapper/MPFRUtils.h"
-#include "include/llvm-libc-macros/math-macros.h"
+#include "hdr/math_macros.h"
namespace mpfr = LIBC_NAMESPACE::testing::mpfr;
diff --git a/test/src/math/FmaTest.h b/test/src/math/FmaTest.h
index 0c93ec8..76bd221 100644
--- a/test/src/math/FmaTest.h
+++ b/test/src/math/FmaTest.h
@@ -10,9 +10,10 @@
#define LLVM_LIBC_TEST_SRC_MATH_FMATEST_H
#include "src/__support/FPUtil/FPBits.h"
+#include "src/stdlib/rand.h"
+#include "src/stdlib/srand.h"
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"
-#include "test/src/math/RandUtils.h"
#include "utils/MPFRWrapper/MPFRUtils.h"
namespace mpfr = LIBC_NAMESPACE::testing::mpfr;
@@ -43,8 +44,7 @@
StorageType get_random_bit_pattern() {
StorageType bits{0};
for (StorageType i = 0; i < sizeof(StorageType) / 2; ++i) {
- bits = (bits << 2) +
- static_cast<uint16_t>(LIBC_NAMESPACE::testutils::rand());
+ bits = (bits << 2) + static_cast<uint16_t>(LIBC_NAMESPACE::rand());
}
return bits;
}
@@ -77,6 +77,7 @@
void test_subnormal_range(Func func) {
constexpr StorageType COUNT = 100'001;
constexpr StorageType STEP = (MAX_SUBNORMAL - MIN_SUBNORMAL) / COUNT;
+ LIBC_NAMESPACE::srand(1);
for (StorageType v = MIN_SUBNORMAL, w = MAX_SUBNORMAL;
v <= MAX_SUBNORMAL && w >= MIN_SUBNORMAL; v += STEP, w -= STEP) {
T x = FPBits(get_random_bit_pattern()).get_val(), y = FPBits(v).get_val(),
@@ -90,6 +91,7 @@
void test_normal_range(Func func) {
constexpr StorageType COUNT = 100'001;
constexpr StorageType STEP = (MAX_NORMAL - MIN_NORMAL) / COUNT;
+ LIBC_NAMESPACE::srand(1);
for (StorageType v = MIN_NORMAL, w = MAX_NORMAL;
v <= MAX_NORMAL && w >= MIN_NORMAL; v += STEP, w -= STEP) {
T x = FPBits(v).get_val(), y = FPBits(w).get_val(),
diff --git a/test/src/math/FrexpTest.h b/test/src/math/FrexpTest.h
index f971b45..5f993f6 100644
--- a/test/src/math/FrexpTest.h
+++ b/test/src/math/FrexpTest.h
@@ -11,7 +11,7 @@
#include "test/UnitTest/Test.h"
#include "utils/MPFRWrapper/MPFRUtils.h"
-#include "include/llvm-libc-macros/math-macros.h"
+#include "hdr/math_macros.h"
namespace mpfr = LIBC_NAMESPACE::testing::mpfr;
diff --git a/test/src/math/HypotTest.h b/test/src/math/HypotTest.h
index df69965..0c15f02 100644
--- a/test/src/math/HypotTest.h
+++ b/test/src/math/HypotTest.h
@@ -14,7 +14,7 @@
#include "test/UnitTest/Test.h"
#include "utils/MPFRWrapper/MPFRUtils.h"
-#include "include/llvm-libc-macros/math-macros.h"
+#include "hdr/math_macros.h"
namespace mpfr = LIBC_NAMESPACE::testing::mpfr;
diff --git a/test/src/math/ILogbTest.h b/test/src/math/ILogbTest.h
index ad47b9b..3d1f047 100644
--- a/test/src/math/ILogbTest.h
+++ b/test/src/math/ILogbTest.h
@@ -9,7 +9,7 @@
#ifndef LLVM_LIBC_TEST_SRC_MATH_ILOGBTEST_H
#define LLVM_LIBC_TEST_SRC_MATH_ILOGBTEST_H
-#include "include/llvm-libc-macros/math-macros.h"
+#include "hdr/math_macros.h"
#include "src/__support/CPP/limits.h" // INT_MAX
#include "src/__support/FPUtil/FPBits.h"
#include "src/__support/FPUtil/ManipulationFunctions.h"
diff --git a/test/src/math/LdExpTest.h b/test/src/math/LdExpTest.h
index 8bfd022..2a406fe 100644
--- a/test/src/math/LdExpTest.h
+++ b/test/src/math/LdExpTest.h
@@ -15,7 +15,7 @@
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"
-#include "include/llvm-libc-macros/math-macros.h"
+#include "hdr/math_macros.h"
#include <stdint.h>
template <typename T>
diff --git a/test/src/math/LogbTest.h b/test/src/math/LogbTest.h
index 3859b56..f066d5f 100644
--- a/test/src/math/LogbTest.h
+++ b/test/src/math/LogbTest.h
@@ -11,7 +11,7 @@
#include "test/UnitTest/Test.h"
#include "utils/MPFRWrapper/MPFRUtils.h"
-#include "include/llvm-libc-macros/math-macros.h"
+#include "hdr/math_macros.h"
namespace mpfr = LIBC_NAMESPACE::testing::mpfr;
diff --git a/test/src/math/ModfTest.h b/test/src/math/ModfTest.h
index 84e26db..49b0328 100644
--- a/test/src/math/ModfTest.h
+++ b/test/src/math/ModfTest.h
@@ -12,7 +12,7 @@
#include "test/UnitTest/Test.h"
#include "utils/MPFRWrapper/MPFRUtils.h"
-#include "include/llvm-libc-macros/math-macros.h"
+#include "hdr/math_macros.h"
namespace mpfr = LIBC_NAMESPACE::testing::mpfr;
diff --git a/test/src/math/NextAfterTest.h b/test/src/math/NextAfterTest.h
index 05803fb..a7248dd 100644
--- a/test/src/math/NextAfterTest.h
+++ b/test/src/math/NextAfterTest.h
@@ -9,7 +9,7 @@
#ifndef LLVM_LIBC_TEST_SRC_MATH_NEXTAFTERTEST_H
#define LLVM_LIBC_TEST_SRC_MATH_NEXTAFTERTEST_H
-#include "include/llvm-libc-macros/math-macros.h"
+#include "hdr/math_macros.h"
#include "src/__support/CPP/bit.h"
#include "src/__support/CPP/type_traits.h"
#include "src/__support/FPUtil/BasicOperations.h"
diff --git a/test/src/math/RIntTest.h b/test/src/math/RIntTest.h
index 301655c..c706ff1 100644
--- a/test/src/math/RIntTest.h
+++ b/test/src/math/RIntTest.h
@@ -15,8 +15,8 @@
#include "test/UnitTest/Test.h"
#include "utils/MPFRWrapper/MPFRUtils.h"
-#include "include/llvm-libc-macros/math-macros.h"
-#include <fenv.h>
+#include "hdr/fenv_macros.h"
+#include "hdr/math_macros.h"
#include <stdio.h>
namespace mpfr = LIBC_NAMESPACE::testing::mpfr;
diff --git a/test/src/math/RandUtils.h b/test/src/math/RandUtils.h
deleted file mode 100644
index fecbd8e..0000000
--- a/test/src/math/RandUtils.h
+++ /dev/null
@@ -1,21 +0,0 @@
-//===-- RandUtils.h ---------------------------------------------*- C++ -*-===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef LLVM_LIBC_TEST_SRC_MATH_RANDUTILS_H
-#define LLVM_LIBC_TEST_SRC_MATH_RANDUTILS_H
-
-namespace LIBC_NAMESPACE {
-namespace testutils {
-
-// Wrapper for std::rand.
-int rand();
-
-} // namespace testutils
-} // namespace LIBC_NAMESPACE
-
-#endif // LLVM_LIBC_TEST_SRC_MATH_RANDUTILS_H
diff --git a/test/src/math/RemQuoTest.h b/test/src/math/RemQuoTest.h
index 1cb8cdb..677772d 100644
--- a/test/src/math/RemQuoTest.h
+++ b/test/src/math/RemQuoTest.h
@@ -9,7 +9,7 @@
#ifndef LLVM_LIBC_TEST_SRC_MATH_REMQUOTEST_H
#define LLVM_LIBC_TEST_SRC_MATH_REMQUOTEST_H
-#include "include/llvm-libc-macros/math-macros.h"
+#include "hdr/math_macros.h"
#include "src/__support/FPUtil/BasicOperations.h"
#include "src/__support/FPUtil/FPBits.h"
#include "test/UnitTest/FPMatcher.h"
diff --git a/test/src/math/RoundEvenTest.h b/test/src/math/RoundEvenTest.h
index db7263a..68b8b9a 100644
--- a/test/src/math/RoundEvenTest.h
+++ b/test/src/math/RoundEvenTest.h
@@ -13,7 +13,7 @@
#include "test/UnitTest/Test.h"
#include "utils/MPFRWrapper/MPFRUtils.h"
-#include "include/llvm-libc-macros/math-macros.h"
+#include "hdr/math_macros.h"
namespace mpfr = LIBC_NAMESPACE::testing::mpfr;
diff --git a/test/src/math/RoundTest.h b/test/src/math/RoundTest.h
index 17da00f..eecf959 100644
--- a/test/src/math/RoundTest.h
+++ b/test/src/math/RoundTest.h
@@ -13,7 +13,7 @@
#include "test/UnitTest/Test.h"
#include "utils/MPFRWrapper/MPFRUtils.h"
-#include "include/llvm-libc-macros/math-macros.h"
+#include "hdr/math_macros.h"
namespace mpfr = LIBC_NAMESPACE::testing::mpfr;
diff --git a/test/src/math/RoundToIntegerTest.h b/test/src/math/RoundToIntegerTest.h
index d2fabd0..7c93451 100644
--- a/test/src/math/RoundToIntegerTest.h
+++ b/test/src/math/RoundToIntegerTest.h
@@ -15,7 +15,7 @@
#include "test/UnitTest/Test.h"
#include "utils/MPFRWrapper/MPFRUtils.h"
-#include "include/llvm-libc-macros/math-macros.h"
+#include "hdr/math_macros.h"
#include <errno.h>
namespace mpfr = LIBC_NAMESPACE::testing::mpfr;
diff --git a/test/src/math/SqrtTest.h b/test/src/math/SqrtTest.h
index 9811b27..799b786 100644
--- a/test/src/math/SqrtTest.h
+++ b/test/src/math/SqrtTest.h
@@ -11,7 +11,7 @@
#include "test/UnitTest/Test.h"
#include "utils/MPFRWrapper/MPFRUtils.h"
-#include "include/llvm-libc-macros/math-macros.h"
+#include "hdr/math_macros.h"
namespace mpfr = LIBC_NAMESPACE::testing::mpfr;
diff --git a/test/src/math/TruncTest.h b/test/src/math/TruncTest.h
index c3a89db..57c953f 100644
--- a/test/src/math/TruncTest.h
+++ b/test/src/math/TruncTest.h
@@ -13,7 +13,7 @@
#include "test/UnitTest/Test.h"
#include "utils/MPFRWrapper/MPFRUtils.h"
-#include "include/llvm-libc-macros/math-macros.h"
+#include "hdr/math_macros.h"
namespace mpfr = LIBC_NAMESPACE::testing::mpfr;
diff --git a/test/src/math/acosf_test.cpp b/test/src/math/acosf_test.cpp
index 6f8321b..0d25a80 100644
--- a/test/src/math/acosf_test.cpp
+++ b/test/src/math/acosf_test.cpp
@@ -6,7 +6,7 @@
//
//===----------------------------------------------------------------------===//
-#include "include/llvm-libc-macros/math-macros.h"
+#include "hdr/math_macros.h"
#include "src/__support/FPUtil/FPBits.h"
#include "src/errno/libc_errno.h"
#include "src/math/acosf.h"
diff --git a/test/src/math/acoshf_test.cpp b/test/src/math/acoshf_test.cpp
index 41d1166..32761e2 100644
--- a/test/src/math/acoshf_test.cpp
+++ b/test/src/math/acoshf_test.cpp
@@ -6,7 +6,7 @@
//
//===----------------------------------------------------------------------===//
-#include "include/llvm-libc-macros/math-macros.h"
+#include "hdr/math_macros.h"
#include "src/__support/FPUtil/FPBits.h"
#include "src/errno/libc_errno.h"
#include "src/math/acoshf.h"
diff --git a/test/src/math/asinf_test.cpp b/test/src/math/asinf_test.cpp
index 4e36f03..91e6108 100644
--- a/test/src/math/asinf_test.cpp
+++ b/test/src/math/asinf_test.cpp
@@ -7,7 +7,7 @@
//
//===----------------------------------------------------------------------===//
-#include "include/llvm-libc-macros/math-macros.h"
+#include "hdr/math_macros.h"
#include "src/__support/FPUtil/FPBits.h"
#include "src/errno/libc_errno.h"
#include "src/math/asinf.h"
diff --git a/test/src/math/asinhf_test.cpp b/test/src/math/asinhf_test.cpp
index 9a3bfbe..b19e26e 100644
--- a/test/src/math/asinhf_test.cpp
+++ b/test/src/math/asinhf_test.cpp
@@ -6,7 +6,7 @@
//
//===----------------------------------------------------------------------===//
-#include "include/llvm-libc-macros/math-macros.h"
+#include "hdr/math_macros.h"
#include "src/__support/FPUtil/FPBits.h"
#include "src/errno/libc_errno.h"
#include "src/math/asinhf.h"
diff --git a/test/src/math/atan2f_test.cpp b/test/src/math/atan2f_test.cpp
index 343e760..1242b7e 100644
--- a/test/src/math/atan2f_test.cpp
+++ b/test/src/math/atan2f_test.cpp
@@ -6,7 +6,7 @@
//
//===----------------------------------------------------------------------===//
-#include "include/llvm-libc-macros/math-macros.h"
+#include "hdr/math_macros.h"
#include "src/__support/FPUtil/FPBits.h"
#include "src/math/atan2f.h"
#include "test/UnitTest/FPMatcher.h"
diff --git a/test/src/math/atanf_test.cpp b/test/src/math/atanf_test.cpp
index 58b0ead..4fa7bad 100644
--- a/test/src/math/atanf_test.cpp
+++ b/test/src/math/atanf_test.cpp
@@ -6,7 +6,7 @@
//
//===----------------------------------------------------------------------===//
-#include "include/llvm-libc-macros/math-macros.h"
+#include "hdr/math_macros.h"
#include "src/__support/FPUtil/FPBits.h"
#include "src/errno/libc_errno.h"
#include "src/math/atanf.h"
diff --git a/test/src/math/atanhf_test.cpp b/test/src/math/atanhf_test.cpp
index c659f17..7fc8c70 100644
--- a/test/src/math/atanhf_test.cpp
+++ b/test/src/math/atanhf_test.cpp
@@ -6,7 +6,7 @@
//
//===----------------------------------------------------------------------===//
-#include "include/llvm-libc-macros/math-macros.h"
+#include "hdr/math_macros.h"
#include "src/__support/FPUtil/FPBits.h"
#include "src/errno/libc_errno.h"
#include "src/math/atanhf.h"
diff --git a/test/src/math/cos_test.cpp b/test/src/math/cos_test.cpp
index 6a112299..9a39616 100644
--- a/test/src/math/cos_test.cpp
+++ b/test/src/math/cos_test.cpp
@@ -11,7 +11,7 @@
#include "test/UnitTest/Test.h"
#include "utils/MPFRWrapper/MPFRUtils.h"
-#include "include/llvm-libc-macros/math-macros.h"
+#include "hdr/math_macros.h"
using LlvmLibcCosTest = LIBC_NAMESPACE::testing::FPTest<double>;
diff --git a/test/src/math/cosf_test.cpp b/test/src/math/cosf_test.cpp
index 8a5eb17..dab35fa 100644
--- a/test/src/math/cosf_test.cpp
+++ b/test/src/math/cosf_test.cpp
@@ -6,7 +6,7 @@
//
//===----------------------------------------------------------------------===//
-#include "include/llvm-libc-macros/math-macros.h"
+#include "hdr/math_macros.h"
#include "src/__support/FPUtil/FPBits.h"
#include "src/errno/libc_errno.h"
#include "src/math/cosf.h"
diff --git a/test/src/math/coshf_test.cpp b/test/src/math/coshf_test.cpp
index 8792f56..7c5d663 100644
--- a/test/src/math/coshf_test.cpp
+++ b/test/src/math/coshf_test.cpp
@@ -6,7 +6,7 @@
//
//===----------------------------------------------------------------------===//
-#include "include/llvm-libc-macros/math-macros.h"
+#include "hdr/math_macros.h"
#include "src/__support/CPP/array.h"
#include "src/__support/FPUtil/FPBits.h"
#include "src/errno/libc_errno.h"
diff --git a/test/src/math/erff_test.cpp b/test/src/math/erff_test.cpp
index 1e43c20..5c848d7 100644
--- a/test/src/math/erff_test.cpp
+++ b/test/src/math/erff_test.cpp
@@ -6,7 +6,7 @@
//
//===----------------------------------------------------------------------===//
-#include "include/llvm-libc-macros/math-macros.h"
+#include "hdr/math_macros.h"
#include "src/__support/FPUtil/FPBits.h"
#include "src/math/erff.h"
#include "test/UnitTest/FPMatcher.h"
diff --git a/test/src/math/exp10_test.cpp b/test/src/math/exp10_test.cpp
index 7781896..4cbdd16 100644
--- a/test/src/math/exp10_test.cpp
+++ b/test/src/math/exp10_test.cpp
@@ -6,7 +6,7 @@
//
//===----------------------------------------------------------------------===//
-#include "include/llvm-libc-macros/math-macros.h"
+#include "hdr/math_macros.h"
#include "src/__support/FPUtil/FPBits.h"
#include "src/errno/libc_errno.h"
#include "src/math/exp10.h"
diff --git a/test/src/math/exp10f_test.cpp b/test/src/math/exp10f_test.cpp
index 9d44e8f..e9b2786 100644
--- a/test/src/math/exp10f_test.cpp
+++ b/test/src/math/exp10f_test.cpp
@@ -6,7 +6,7 @@
//
//===----------------------------------------------------------------------===//
-#include "include/llvm-libc-macros/math-macros.h"
+#include "hdr/math_macros.h"
#include "src/__support/FPUtil/FPBits.h"
#include "src/errno/libc_errno.h"
#include "src/math/exp10f.h"
diff --git a/test/src/math/exp2_test.cpp b/test/src/math/exp2_test.cpp
index 845fda5..73232ed 100644
--- a/test/src/math/exp2_test.cpp
+++ b/test/src/math/exp2_test.cpp
@@ -6,7 +6,7 @@
//
//===----------------------------------------------------------------------===//
-#include "include/llvm-libc-macros/math-macros.h"
+#include "hdr/math_macros.h"
#include "src/__support/FPUtil/FPBits.h"
#include "src/errno/libc_errno.h"
#include "src/math/exp2.h"
diff --git a/test/src/math/exp2f_test.cpp b/test/src/math/exp2f_test.cpp
index f63f091..8ff0ce6 100644
--- a/test/src/math/exp2f_test.cpp
+++ b/test/src/math/exp2f_test.cpp
@@ -6,7 +6,7 @@
//
//===----------------------------------------------------------------------===//
-#include "include/llvm-libc-macros/math-macros.h"
+#include "hdr/math_macros.h"
#include "src/__support/FPUtil/FPBits.h"
#include "src/__support/macros/properties/cpu_features.h" // LIBC_TARGET_CPU_HAS_FMA
#include "src/errno/libc_errno.h"
diff --git a/test/src/math/exp2m1f_test.cpp b/test/src/math/exp2m1f_test.cpp
index a0f0da8..cb94828 100644
--- a/test/src/math/exp2m1f_test.cpp
+++ b/test/src/math/exp2m1f_test.cpp
@@ -6,7 +6,7 @@
//
//===----------------------------------------------------------------------===//
-#include "include/llvm-libc-macros/math-macros.h"
+#include "hdr/math_macros.h"
#include "src/__support/CPP/array.h"
#include "src/__support/FPUtil/FPBits.h"
#include "src/errno/libc_errno.h"
diff --git a/test/src/math/exp_test.cpp b/test/src/math/exp_test.cpp
index 42018e6..64d8198 100644
--- a/test/src/math/exp_test.cpp
+++ b/test/src/math/exp_test.cpp
@@ -6,7 +6,7 @@
//
//===----------------------------------------------------------------------===//
-#include "include/llvm-libc-macros/math-macros.h"
+#include "hdr/math_macros.h"
#include "src/__support/FPUtil/FPBits.h"
#include "src/errno/libc_errno.h"
#include "src/math/exp.h"
diff --git a/test/src/math/expf_test.cpp b/test/src/math/expf_test.cpp
index 634958b..1dce381 100644
--- a/test/src/math/expf_test.cpp
+++ b/test/src/math/expf_test.cpp
@@ -6,7 +6,7 @@
//
//===----------------------------------------------------------------------===//
-#include "include/llvm-libc-macros/math-macros.h"
+#include "hdr/math_macros.h"
#include "src/__support/FPUtil/FPBits.h"
#include "src/errno/libc_errno.h"
#include "src/math/expf.h"
diff --git a/test/src/math/explogxf_test.cpp b/test/src/math/explogxf_test.cpp
index a536a9f3..bcca87f 100644
--- a/test/src/math/explogxf_test.cpp
+++ b/test/src/math/explogxf_test.cpp
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
+#include "hdr/math_macros.h"
#include "in_float_range_test_helper.h"
-#include "include/llvm-libc-macros/math-macros.h"
#include "src/__support/FPUtil/FPBits.h"
#include "src/math/fabs.h"
#include "src/math/fabsf.h"
diff --git a/test/src/math/expm1_test.cpp b/test/src/math/expm1_test.cpp
index 198e6d5..1bf07f1 100644
--- a/test/src/math/expm1_test.cpp
+++ b/test/src/math/expm1_test.cpp
@@ -6,7 +6,7 @@
//
//===----------------------------------------------------------------------===//
-#include "include/llvm-libc-macros/math-macros.h"
+#include "hdr/math_macros.h"
#include "src/__support/FPUtil/FPBits.h"
#include "src/errno/libc_errno.h"
#include "src/math/expm1.h"
diff --git a/test/src/math/expm1f_test.cpp b/test/src/math/expm1f_test.cpp
index c728158..515f988 100644
--- a/test/src/math/expm1f_test.cpp
+++ b/test/src/math/expm1f_test.cpp
@@ -6,7 +6,7 @@
//
//===----------------------------------------------------------------------===//
-#include "include/llvm-libc-macros/math-macros.h"
+#include "hdr/math_macros.h"
#include "src/__support/FPUtil/FPBits.h"
#include "src/errno/libc_errno.h"
#include "src/math/expm1f.h"
diff --git a/test/src/math/fdim_test.cpp b/test/src/math/fdim_test.cpp
index 6c0c3e2..1e8adf0 100644
--- a/test/src/math/fdim_test.cpp
+++ b/test/src/math/fdim_test.cpp
@@ -8,7 +8,7 @@
#include "FDimTest.h"
-#include "include/llvm-libc-macros/math-macros.h"
+#include "hdr/math_macros.h"
#include "src/__support/FPUtil/FPBits.h"
#include "src/math/fdim.h"
#include "test/UnitTest/FPMatcher.h"
diff --git a/test/src/math/fdimf_test.cpp b/test/src/math/fdimf_test.cpp
index a74011b..13e61d9 100644
--- a/test/src/math/fdimf_test.cpp
+++ b/test/src/math/fdimf_test.cpp
@@ -8,7 +8,7 @@
#include "FDimTest.h"
-#include "include/llvm-libc-macros/math-macros.h"
+#include "hdr/math_macros.h"
#include "src/__support/FPUtil/FPBits.h"
#include "src/math/fdimf.h"
#include "test/UnitTest/FPMatcher.h"
diff --git a/test/src/math/fdiml_test.cpp b/test/src/math/fdiml_test.cpp
index d3f2e68..2d99d21 100644
--- a/test/src/math/fdiml_test.cpp
+++ b/test/src/math/fdiml_test.cpp
@@ -8,7 +8,7 @@
#include "FDimTest.h"
-#include "include/llvm-libc-macros/math-macros.h"
+#include "hdr/math_macros.h"
#include "src/__support/FPUtil/FPBits.h"
#include "src/math/fdiml.h"
#include "test/UnitTest/FPMatcher.h"
diff --git a/test/src/math/ilogb_test.cpp b/test/src/math/ilogb_test.cpp
index 45756ff..c8daf2e 100644
--- a/test/src/math/ilogb_test.cpp
+++ b/test/src/math/ilogb_test.cpp
@@ -8,7 +8,7 @@
#include "ILogbTest.h"
-#include "include/llvm-libc-macros/math-macros.h"
+#include "hdr/math_macros.h"
#include "src/__support/FPUtil/FPBits.h"
#include "src/__support/FPUtil/ManipulationFunctions.h"
#include "src/math/ilogb.h"
diff --git a/test/src/math/ilogbf_test.cpp b/test/src/math/ilogbf_test.cpp
index ff19dd14..87a2789 100644
--- a/test/src/math/ilogbf_test.cpp
+++ b/test/src/math/ilogbf_test.cpp
@@ -8,7 +8,7 @@
#include "ILogbTest.h"
-#include "include/llvm-libc-macros/math-macros.h"
+#include "hdr/math_macros.h"
#include "src/__support/FPUtil/FPBits.h"
#include "src/__support/FPUtil/ManipulationFunctions.h"
#include "src/math/ilogbf.h"
diff --git a/test/src/math/ilogbl_test.cpp b/test/src/math/ilogbl_test.cpp
index b2c5246..042a803 100644
--- a/test/src/math/ilogbl_test.cpp
+++ b/test/src/math/ilogbl_test.cpp
@@ -8,7 +8,7 @@
#include "ILogbTest.h"
-#include "include/llvm-libc-macros/math-macros.h"
+#include "hdr/math_macros.h"
#include "src/__support/FPUtil/FPBits.h"
#include "src/__support/FPUtil/ManipulationFunctions.h"
#include "src/math/ilogbl.h"
diff --git a/test/src/math/log10_test.cpp b/test/src/math/log10_test.cpp
index dc4ac89..fd9a615 100644
--- a/test/src/math/log10_test.cpp
+++ b/test/src/math/log10_test.cpp
@@ -6,7 +6,7 @@
//
//===----------------------------------------------------------------------===//
-#include "include/llvm-libc-macros/math-macros.h"
+#include "hdr/math_macros.h"
#include "src/__support/FPUtil/FPBits.h"
#include "src/errno/libc_errno.h"
#include "src/math/log10.h"
diff --git a/test/src/math/log10f_test.cpp b/test/src/math/log10f_test.cpp
index f8a137e..4ba1184 100644
--- a/test/src/math/log10f_test.cpp
+++ b/test/src/math/log10f_test.cpp
@@ -6,7 +6,7 @@
//
//===----------------------------------------------------------------------===//
-#include "include/llvm-libc-macros/math-macros.h"
+#include "hdr/math_macros.h"
#include "src/__support/FPUtil/FPBits.h"
#include "src/math/log10f.h"
#include "test/UnitTest/FPMatcher.h"
diff --git a/test/src/math/log1p_test.cpp b/test/src/math/log1p_test.cpp
index 975fb8e..47dfa40 100644
--- a/test/src/math/log1p_test.cpp
+++ b/test/src/math/log1p_test.cpp
@@ -6,7 +6,7 @@
//
//===----------------------------------------------------------------------===//
-#include "include/llvm-libc-macros/math-macros.h"
+#include "hdr/math_macros.h"
#include "src/__support/FPUtil/FPBits.h"
#include "src/errno/libc_errno.h"
#include "src/math/log1p.h"
@@ -34,7 +34,7 @@
}
TEST_F(LlvmLibcLog1pTest, TrickyInputs) {
- constexpr int N = 41;
+ constexpr int N = 42;
constexpr uint64_t INPUTS[N] = {
0x3ff0000000000000, // x = 1.0
0x4024000000000000, // x = 10.0
@@ -65,6 +65,7 @@
0x3c90c40cef04efb5, 0x449d2ccad399848e, 0x4aa12ccdffd9d2ec,
0x5656f070b92d36ce, 0x6db06dcb74f76bcc, 0x7f1954e72ffd4596,
0x5671e2f1628093e4, 0x73dac56e2bf1a951, 0x8001bc6879ea14c5,
+ 0x45ca5f497ec291df, // x = 0x1.a5f497ec291dfp+93
};
for (int i = 0; i < N; ++i) {
double x = FPBits(INPUTS[i]).get_val();
diff --git a/test/src/math/log1pf_test.cpp b/test/src/math/log1pf_test.cpp
index a1108fe..db0772d 100644
--- a/test/src/math/log1pf_test.cpp
+++ b/test/src/math/log1pf_test.cpp
@@ -6,7 +6,7 @@
//
//===----------------------------------------------------------------------===//
-#include "include/llvm-libc-macros/math-macros.h"
+#include "hdr/math_macros.h"
#include "src/__support/FPUtil/FPBits.h"
#include "src/errno/libc_errno.h"
#include "src/math/log1pf.h"
diff --git a/test/src/math/log2_test.cpp b/test/src/math/log2_test.cpp
index 8765279..9992c13 100644
--- a/test/src/math/log2_test.cpp
+++ b/test/src/math/log2_test.cpp
@@ -6,7 +6,7 @@
//
//===----------------------------------------------------------------------===//
-#include "include/llvm-libc-macros/math-macros.h"
+#include "hdr/math_macros.h"
#include "src/__support/FPUtil/FPBits.h"
#include "src/errno/libc_errno.h"
#include "src/math/log2.h"
diff --git a/test/src/math/log2f_test.cpp b/test/src/math/log2f_test.cpp
index c05b6b9..24b51ad 100644
--- a/test/src/math/log2f_test.cpp
+++ b/test/src/math/log2f_test.cpp
@@ -6,7 +6,7 @@
//
//===----------------------------------------------------------------------===//
-#include "include/llvm-libc-macros/math-macros.h"
+#include "hdr/math_macros.h"
#include "src/__support/FPUtil/FPBits.h"
#include "src/errno/libc_errno.h"
#include "src/math/log2f.h"
diff --git a/test/src/math/log_test.cpp b/test/src/math/log_test.cpp
index 06a0dc5..de1e595 100644
--- a/test/src/math/log_test.cpp
+++ b/test/src/math/log_test.cpp
@@ -6,7 +6,7 @@
//
//===----------------------------------------------------------------------===//
-#include "include/llvm-libc-macros/math-macros.h"
+#include "hdr/math_macros.h"
#include "src/__support/FPUtil/FPBits.h"
#include "src/errno/libc_errno.h"
#include "src/math/log.h"
diff --git a/test/src/math/logf_test.cpp b/test/src/math/logf_test.cpp
index 1ab4807..28a171d 100644
--- a/test/src/math/logf_test.cpp
+++ b/test/src/math/logf_test.cpp
@@ -6,7 +6,7 @@
//
//===----------------------------------------------------------------------===//
-#include "include/llvm-libc-macros/math-macros.h"
+#include "hdr/math_macros.h"
#include "src/__support/FPUtil/FPBits.h"
#include "src/math/logf.h"
#include "test/UnitTest/FPMatcher.h"
diff --git a/test/src/math/powf_test.cpp b/test/src/math/powf_test.cpp
index cf674ec..6913559 100644
--- a/test/src/math/powf_test.cpp
+++ b/test/src/math/powf_test.cpp
@@ -6,7 +6,7 @@
//
//===----------------------------------------------------------------------===//
-#include "include/llvm-libc-macros/math-macros.h"
+#include "hdr/math_macros.h"
#include "src/__support/FPUtil/FPBits.h"
#include "src/math/powf.h"
#include "test/UnitTest/FPMatcher.h"
diff --git a/test/src/math/sin_test.cpp b/test/src/math/sin_test.cpp
index fa1c537..0171b79 100644
--- a/test/src/math/sin_test.cpp
+++ b/test/src/math/sin_test.cpp
@@ -12,7 +12,7 @@
#include "test/UnitTest/Test.h"
#include "utils/MPFRWrapper/MPFRUtils.h"
-#include "include/llvm-libc-macros/math-macros.h"
+#include "hdr/math_macros.h"
using LlvmLibcSinTest = LIBC_NAMESPACE::testing::FPTest<double>;
diff --git a/test/src/math/sincosf_test.cpp b/test/src/math/sincosf_test.cpp
index a7372fd..7c359b3 100644
--- a/test/src/math/sincosf_test.cpp
+++ b/test/src/math/sincosf_test.cpp
@@ -6,7 +6,7 @@
//
//===----------------------------------------------------------------------===//
-#include "include/llvm-libc-macros/math-macros.h"
+#include "hdr/math_macros.h"
#include "src/__support/FPUtil/FPBits.h"
#include "src/errno/libc_errno.h"
#include "src/math/sincosf.h"
diff --git a/test/src/math/sinf_test.cpp b/test/src/math/sinf_test.cpp
index a3c5384..6a8f8f4 100644
--- a/test/src/math/sinf_test.cpp
+++ b/test/src/math/sinf_test.cpp
@@ -6,7 +6,7 @@
//
//===----------------------------------------------------------------------===//
-#include "include/llvm-libc-macros/math-macros.h"
+#include "hdr/math_macros.h"
#include "src/__support/FPUtil/FPBits.h"
#include "src/errno/libc_errno.h"
#include "src/math/sinf.h"
diff --git a/test/src/math/sinhf_test.cpp b/test/src/math/sinhf_test.cpp
index bea9760..cc0552f 100644
--- a/test/src/math/sinhf_test.cpp
+++ b/test/src/math/sinhf_test.cpp
@@ -6,7 +6,7 @@
//
//===----------------------------------------------------------------------===//
-#include "include/llvm-libc-macros/math-macros.h"
+#include "hdr/math_macros.h"
#include "src/__support/CPP/array.h"
#include "src/__support/FPUtil/FPBits.h"
#include "src/errno/libc_errno.h"
diff --git a/test/src/math/smoke/CanonicalizeTest.h b/test/src/math/smoke/CanonicalizeTest.h
index 4361f7d..ab45e0e 100644
--- a/test/src/math/smoke/CanonicalizeTest.h
+++ b/test/src/math/smoke/CanonicalizeTest.h
@@ -14,7 +14,7 @@
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"
-#include "include/llvm-libc-macros/math-macros.h"
+#include "hdr/math_macros.h"
#define TEST_SPECIAL(x, y, expected, expected_exception) \
EXPECT_EQ(expected, f(&x, &y)); \
diff --git a/test/src/math/smoke/CeilTest.h b/test/src/math/smoke/CeilTest.h
index ec70258..70e441a 100644
--- a/test/src/math/smoke/CeilTest.h
+++ b/test/src/math/smoke/CeilTest.h
@@ -12,7 +12,7 @@
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"
-#include "include/llvm-libc-macros/math-macros.h"
+#include "hdr/math_macros.h"
template <typename T> class CeilTest : public LIBC_NAMESPACE::testing::Test {
diff --git a/test/src/math/smoke/CopySignTest.h b/test/src/math/smoke/CopySignTest.h
index 70a6a41..fa9da91 100644
--- a/test/src/math/smoke/CopySignTest.h
+++ b/test/src/math/smoke/CopySignTest.h
@@ -12,7 +12,7 @@
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"
-#include "include/llvm-libc-macros/math-macros.h"
+#include "hdr/math_macros.h"
template <typename T>
class CopySignTest : public LIBC_NAMESPACE::testing::Test {
diff --git a/test/src/math/smoke/FAbsTest.h b/test/src/math/smoke/FAbsTest.h
index 9309c2a..0c8ca95 100644
--- a/test/src/math/smoke/FAbsTest.h
+++ b/test/src/math/smoke/FAbsTest.h
@@ -12,7 +12,7 @@
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"
-#include "include/llvm-libc-macros/math-macros.h"
+#include "hdr/math_macros.h"
template <typename T> class FAbsTest : public LIBC_NAMESPACE::testing::Test {
diff --git a/test/src/math/smoke/FModTest.h b/test/src/math/smoke/FModTest.h
index 96ad299..bc90998 100644
--- a/test/src/math/smoke/FModTest.h
+++ b/test/src/math/smoke/FModTest.h
@@ -14,7 +14,7 @@
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"
-#include "include/llvm-libc-macros/math-macros.h"
+#include "hdr/math_macros.h"
#define TEST_SPECIAL(x, y, expected, dom_err, expected_exception) \
EXPECT_FP_EQ(expected, f(x, y)); \
diff --git a/test/src/math/smoke/FloorTest.h b/test/src/math/smoke/FloorTest.h
index 8886e8e..12944aa 100644
--- a/test/src/math/smoke/FloorTest.h
+++ b/test/src/math/smoke/FloorTest.h
@@ -12,7 +12,7 @@
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"
-#include "include/llvm-libc-macros/math-macros.h"
+#include "hdr/math_macros.h"
template <typename T> class FloorTest : public LIBC_NAMESPACE::testing::Test {
diff --git a/test/src/math/smoke/HypotTest.h b/test/src/math/smoke/HypotTest.h
index 8081603..a1b8f8a 100644
--- a/test/src/math/smoke/HypotTest.h
+++ b/test/src/math/smoke/HypotTest.h
@@ -13,7 +13,7 @@
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"
-#include "include/llvm-libc-macros/math-macros.h"
+#include "hdr/math_macros.h"
template <typename T>
class HypotTestTemplate : public LIBC_NAMESPACE::testing::Test {
diff --git a/test/src/math/smoke/ModfTest.h b/test/src/math/smoke/ModfTest.h
index 10796366..65d6185 100644
--- a/test/src/math/smoke/ModfTest.h
+++ b/test/src/math/smoke/ModfTest.h
@@ -11,7 +11,7 @@
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"
-#include "include/llvm-libc-macros/math-macros.h"
+#include "hdr/math_macros.h"
template <typename T> class ModfTest : public LIBC_NAMESPACE::testing::Test {
diff --git a/test/src/math/smoke/NextAfterTest.h b/test/src/math/smoke/NextAfterTest.h
index 403ea6b..d9c50c8 100644
--- a/test/src/math/smoke/NextAfterTest.h
+++ b/test/src/math/smoke/NextAfterTest.h
@@ -9,7 +9,7 @@
#ifndef LLVM_LIBC_TEST_SRC_MATH_NEXTAFTERTEST_H
#define LLVM_LIBC_TEST_SRC_MATH_NEXTAFTERTEST_H
-#include "include/llvm-libc-macros/math-macros.h"
+#include "hdr/math_macros.h"
#include "src/__support/CPP/bit.h"
#include "src/__support/CPP/type_traits.h"
#include "src/__support/FPUtil/BasicOperations.h"
diff --git a/test/src/math/smoke/NextTowardTest.h b/test/src/math/smoke/NextTowardTest.h
index 0c2abf8..b6c1c8d 100644
--- a/test/src/math/smoke/NextTowardTest.h
+++ b/test/src/math/smoke/NextTowardTest.h
@@ -9,14 +9,14 @@
#ifndef LLVM_LIBC_TEST_SRC_MATH_NEXTTOWARDTEST_H
#define LLVM_LIBC_TEST_SRC_MATH_NEXTTOWARDTEST_H
-#include "include/llvm-libc-macros/math-macros.h"
+#include "hdr/fenv_macros.h"
+#include "hdr/math_macros.h"
#include "src/__support/CPP/bit.h"
#include "src/__support/CPP/type_traits.h"
#include "src/__support/FPUtil/BasicOperations.h"
#include "src/__support/FPUtil/FPBits.h"
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"
-#include <fenv.h>
#define ASSERT_FP_EQ_WITH_EXCEPTION(result, expected, expected_exception) \
ASSERT_FP_EQ(result, expected); \
diff --git a/test/src/math/smoke/RIntTest.h b/test/src/math/smoke/RIntTest.h
index 5a283a8b..cbed9a3b 100644
--- a/test/src/math/smoke/RIntTest.h
+++ b/test/src/math/smoke/RIntTest.h
@@ -14,8 +14,8 @@
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"
-#include "include/llvm-libc-macros/math-macros.h"
-#include <fenv.h>
+#include "hdr/fenv_macros.h"
+#include "hdr/math_macros.h"
#include <stdio.h>
static constexpr int ROUNDING_MODES[4] = {FE_UPWARD, FE_DOWNWARD, FE_TOWARDZERO,
diff --git a/test/src/math/smoke/RemQuoTest.h b/test/src/math/smoke/RemQuoTest.h
index cf56b1d..7df537d 100644
--- a/test/src/math/smoke/RemQuoTest.h
+++ b/test/src/math/smoke/RemQuoTest.h
@@ -9,7 +9,7 @@
#ifndef LLVM_LIBC_TEST_SRC_MATH_REMQUOTEST_H
#define LLVM_LIBC_TEST_SRC_MATH_REMQUOTEST_H
-#include "include/llvm-libc-macros/math-macros.h"
+#include "hdr/math_macros.h"
#include "src/__support/FPUtil/BasicOperations.h"
#include "src/__support/FPUtil/FPBits.h"
#include "test/UnitTest/FPMatcher.h"
diff --git a/test/src/math/smoke/RoundEvenTest.h b/test/src/math/smoke/RoundEvenTest.h
index 107052fa..e168d57 100644
--- a/test/src/math/smoke/RoundEvenTest.h
+++ b/test/src/math/smoke/RoundEvenTest.h
@@ -12,7 +12,7 @@
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"
-#include "include/llvm-libc-macros/math-macros.h"
+#include "hdr/math_macros.h"
template <typename T>
class RoundEvenTest : public LIBC_NAMESPACE::testing::Test {
diff --git a/test/src/math/smoke/RoundTest.h b/test/src/math/smoke/RoundTest.h
index 8cf96f4..49b2a1b 100644
--- a/test/src/math/smoke/RoundTest.h
+++ b/test/src/math/smoke/RoundTest.h
@@ -12,7 +12,7 @@
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"
-#include "include/llvm-libc-macros/math-macros.h"
+#include "hdr/math_macros.h"
template <typename T> class RoundTest : public LIBC_NAMESPACE::testing::Test {
diff --git a/test/src/math/smoke/RoundToIntegerTest.h b/test/src/math/smoke/RoundToIntegerTest.h
index 44b3f89..863cf75 100644
--- a/test/src/math/smoke/RoundToIntegerTest.h
+++ b/test/src/math/smoke/RoundToIntegerTest.h
@@ -14,7 +14,7 @@
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"
-#include "include/llvm-libc-macros/math-macros.h"
+#include "hdr/math_macros.h"
#include <errno.h>
static constexpr int ROUNDING_MODES[4] = {FE_UPWARD, FE_DOWNWARD, FE_TOWARDZERO,
diff --git a/test/src/math/smoke/SqrtTest.h b/test/src/math/smoke/SqrtTest.h
index eea5dc1..46382ed 100644
--- a/test/src/math/smoke/SqrtTest.h
+++ b/test/src/math/smoke/SqrtTest.h
@@ -10,7 +10,7 @@
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"
-#include "include/llvm-libc-macros/math-macros.h"
+#include "hdr/math_macros.h"
template <typename T> class SqrtTest : public LIBC_NAMESPACE::testing::Test {
diff --git a/test/src/math/smoke/TruncTest.h b/test/src/math/smoke/TruncTest.h
index 5612d27..c0fc87f 100644
--- a/test/src/math/smoke/TruncTest.h
+++ b/test/src/math/smoke/TruncTest.h
@@ -12,7 +12,7 @@
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"
-#include "include/llvm-libc-macros/math-macros.h"
+#include "hdr/math_macros.h"
template <typename T> class TruncTest : public LIBC_NAMESPACE::testing::Test {
diff --git a/test/src/math/smoke/acosf_test.cpp b/test/src/math/smoke/acosf_test.cpp
index 573a2c3..732c295 100644
--- a/test/src/math/smoke/acosf_test.cpp
+++ b/test/src/math/smoke/acosf_test.cpp
@@ -6,7 +6,7 @@
//
//===----------------------------------------------------------------------===//
-#include "include/llvm-libc-macros/math-macros.h"
+#include "hdr/math_macros.h"
#include "src/__support/FPUtil/FPBits.h"
#include "src/errno/libc_errno.h"
#include "src/math/acosf.h"
diff --git a/test/src/math/smoke/acoshf_test.cpp b/test/src/math/smoke/acoshf_test.cpp
index f561f23..2e94216 100644
--- a/test/src/math/smoke/acoshf_test.cpp
+++ b/test/src/math/smoke/acoshf_test.cpp
@@ -6,7 +6,7 @@
//
//===----------------------------------------------------------------------===//
-#include "include/llvm-libc-macros/math-macros.h"
+#include "hdr/math_macros.h"
#include "src/__support/FPUtil/FPBits.h"
#include "src/errno/libc_errno.h"
#include "src/math/acoshf.h"
diff --git a/test/src/math/smoke/asinf_test.cpp b/test/src/math/smoke/asinf_test.cpp
index 39d25e7..c67d077 100644
--- a/test/src/math/smoke/asinf_test.cpp
+++ b/test/src/math/smoke/asinf_test.cpp
@@ -6,7 +6,7 @@
//
//===----------------------------------------------------------------------===//
-#include "include/llvm-libc-macros/math-macros.h"
+#include "hdr/math_macros.h"
#include "src/__support/FPUtil/FPBits.h"
#include "src/errno/libc_errno.h"
#include "src/math/asinf.h"
diff --git a/test/src/math/smoke/asinhf_test.cpp b/test/src/math/smoke/asinhf_test.cpp
index 9637bfa..f951846 100644
--- a/test/src/math/smoke/asinhf_test.cpp
+++ b/test/src/math/smoke/asinhf_test.cpp
@@ -6,7 +6,7 @@
//
//===----------------------------------------------------------------------===//
-#include "include/llvm-libc-macros/math-macros.h"
+#include "hdr/math_macros.h"
#include "src/__support/FPUtil/FPBits.h"
#include "src/errno/libc_errno.h"
#include "src/math/asinhf.h"
diff --git a/test/src/math/smoke/atan2f_test.cpp b/test/src/math/smoke/atan2f_test.cpp
index ecac36b..f81d140 100644
--- a/test/src/math/smoke/atan2f_test.cpp
+++ b/test/src/math/smoke/atan2f_test.cpp
@@ -6,7 +6,7 @@
//
//===----------------------------------------------------------------------===//
-#include "include/llvm-libc-macros/math-macros.h"
+#include "hdr/math_macros.h"
#include "src/__support/FPUtil/FPBits.h"
#include "src/errno/libc_errno.h"
#include "src/math/atan2f.h"
diff --git a/test/src/math/smoke/atanf_test.cpp b/test/src/math/smoke/atanf_test.cpp
index abd9835..3800c23 100644
--- a/test/src/math/smoke/atanf_test.cpp
+++ b/test/src/math/smoke/atanf_test.cpp
@@ -6,7 +6,7 @@
//
//===----------------------------------------------------------------------===//
-#include "include/llvm-libc-macros/math-macros.h"
+#include "hdr/math_macros.h"
#include "src/__support/FPUtil/FPBits.h"
#include "src/errno/libc_errno.h"
#include "src/math/atanf.h"
diff --git a/test/src/math/smoke/atanhf_test.cpp b/test/src/math/smoke/atanhf_test.cpp
index 590a7ab..fc3e2dd 100644
--- a/test/src/math/smoke/atanhf_test.cpp
+++ b/test/src/math/smoke/atanhf_test.cpp
@@ -6,7 +6,7 @@
//
//===----------------------------------------------------------------------===//
-#include "include/llvm-libc-macros/math-macros.h"
+#include "hdr/math_macros.h"
#include "src/__support/FPUtil/FPBits.h"
#include "src/errno/libc_errno.h"
#include "src/math/atanhf.h"
diff --git a/test/src/math/smoke/cosf_test.cpp b/test/src/math/smoke/cosf_test.cpp
index 6213299..7000fe2 100644
--- a/test/src/math/smoke/cosf_test.cpp
+++ b/test/src/math/smoke/cosf_test.cpp
@@ -6,7 +6,7 @@
//
//===----------------------------------------------------------------------===//
-#include "include/llvm-libc-macros/math-macros.h"
+#include "hdr/math_macros.h"
#include "src/__support/FPUtil/FPBits.h"
#include "src/errno/libc_errno.h"
#include "src/math/cosf.h"
diff --git a/test/src/math/smoke/coshf_test.cpp b/test/src/math/smoke/coshf_test.cpp
index 9d7ef50..4d915b1 100644
--- a/test/src/math/smoke/coshf_test.cpp
+++ b/test/src/math/smoke/coshf_test.cpp
@@ -6,7 +6,7 @@
//
//===----------------------------------------------------------------------===//
-#include "include/llvm-libc-macros/math-macros.h"
+#include "hdr/math_macros.h"
#include "src/__support/CPP/array.h"
#include "src/__support/FPUtil/FPBits.h"
#include "src/errno/libc_errno.h"
diff --git a/test/src/math/smoke/erff_test.cpp b/test/src/math/smoke/erff_test.cpp
index 24778f8..102126e 100644
--- a/test/src/math/smoke/erff_test.cpp
+++ b/test/src/math/smoke/erff_test.cpp
@@ -6,7 +6,7 @@
//
//===----------------------------------------------------------------------===//
-#include "include/llvm-libc-macros/math-macros.h"
+#include "hdr/math_macros.h"
#include "src/__support/FPUtil/FPBits.h"
#include "src/math/erff.h"
#include "test/UnitTest/FPMatcher.h"
diff --git a/test/src/math/smoke/exp10_test.cpp b/test/src/math/smoke/exp10_test.cpp
index fffffeb..7154cb1 100644
--- a/test/src/math/smoke/exp10_test.cpp
+++ b/test/src/math/smoke/exp10_test.cpp
@@ -6,7 +6,7 @@
//
//===----------------------------------------------------------------------===//
-#include "include/llvm-libc-macros/math-macros.h"
+#include "hdr/math_macros.h"
#include "src/__support/FPUtil/FPBits.h"
#include "src/errno/libc_errno.h"
#include "src/math/exp10.h"
diff --git a/test/src/math/smoke/exp10f_test.cpp b/test/src/math/smoke/exp10f_test.cpp
index c0dcc12..9fb15ae 100644
--- a/test/src/math/smoke/exp10f_test.cpp
+++ b/test/src/math/smoke/exp10f_test.cpp
@@ -6,7 +6,7 @@
//
//===----------------------------------------------------------------------===//
-#include "include/llvm-libc-macros/math-macros.h"
+#include "hdr/math_macros.h"
#include "src/__support/FPUtil/FPBits.h"
#include "src/errno/libc_errno.h"
#include "src/math/exp10f.h"
diff --git a/test/src/math/smoke/exp2_test.cpp b/test/src/math/smoke/exp2_test.cpp
index d362d32..a8ef6cf 100644
--- a/test/src/math/smoke/exp2_test.cpp
+++ b/test/src/math/smoke/exp2_test.cpp
@@ -6,7 +6,7 @@
//
//===----------------------------------------------------------------------===//
-#include "include/llvm-libc-macros/math-macros.h"
+#include "hdr/math_macros.h"
#include "src/__support/FPUtil/FPBits.h"
#include "src/errno/libc_errno.h"
#include "src/math/exp2.h"
diff --git a/test/src/math/smoke/exp2f_test.cpp b/test/src/math/smoke/exp2f_test.cpp
index e2989a6..3ef1a4e 100644
--- a/test/src/math/smoke/exp2f_test.cpp
+++ b/test/src/math/smoke/exp2f_test.cpp
@@ -6,7 +6,7 @@
//
//===----------------------------------------------------------------------===//
-#include "include/llvm-libc-macros/math-macros.h"
+#include "hdr/math_macros.h"
#include "src/__support/FPUtil/FPBits.h"
#include "src/__support/macros/properties/cpu_features.h" // LIBC_TARGET_CPU_HAS_FMA
#include "src/errno/libc_errno.h"
diff --git a/test/src/math/smoke/exp_test.cpp b/test/src/math/smoke/exp_test.cpp
index a2becc7..2abaa72 100644
--- a/test/src/math/smoke/exp_test.cpp
+++ b/test/src/math/smoke/exp_test.cpp
@@ -6,7 +6,7 @@
//
//===----------------------------------------------------------------------===//
-#include "include/llvm-libc-macros/math-macros.h"
+#include "hdr/math_macros.h"
#include "src/__support/FPUtil/FPBits.h"
#include "src/errno/libc_errno.h"
#include "src/math/exp.h"
diff --git a/test/src/math/smoke/expf_test.cpp b/test/src/math/smoke/expf_test.cpp
index 42710c5..b954125 100644
--- a/test/src/math/smoke/expf_test.cpp
+++ b/test/src/math/smoke/expf_test.cpp
@@ -6,7 +6,7 @@
//
//===----------------------------------------------------------------------===//
-#include "include/llvm-libc-macros/math-macros.h"
+#include "hdr/math_macros.h"
#include "src/__support/FPUtil/FPBits.h"
#include "src/errno/libc_errno.h"
#include "src/math/expf.h"
diff --git a/test/src/math/smoke/expm1_test.cpp b/test/src/math/smoke/expm1_test.cpp
index 07963ec..d5f166d 100644
--- a/test/src/math/smoke/expm1_test.cpp
+++ b/test/src/math/smoke/expm1_test.cpp
@@ -6,7 +6,7 @@
//
//===----------------------------------------------------------------------===//
-#include "include/llvm-libc-macros/math-macros.h"
+#include "hdr/math_macros.h"
#include "src/__support/FPUtil/FPBits.h"
#include "src/errno/libc_errno.h"
#include "src/math/expm1.h"
diff --git a/test/src/math/smoke/expm1f_test.cpp b/test/src/math/smoke/expm1f_test.cpp
index 82e0b15..03b6e47 100644
--- a/test/src/math/smoke/expm1f_test.cpp
+++ b/test/src/math/smoke/expm1f_test.cpp
@@ -6,7 +6,7 @@
//
//===----------------------------------------------------------------------===//
-#include "include/llvm-libc-macros/math-macros.h"
+#include "hdr/math_macros.h"
#include "src/__support/FPUtil/FPBits.h"
#include "src/errno/libc_errno.h"
#include "src/math/expm1f.h"
diff --git a/test/src/math/smoke/log10_test.cpp b/test/src/math/smoke/log10_test.cpp
index 36d7534..37baf89 100644
--- a/test/src/math/smoke/log10_test.cpp
+++ b/test/src/math/smoke/log10_test.cpp
@@ -6,7 +6,7 @@
//
//===----------------------------------------------------------------------===//
-#include "include/llvm-libc-macros/math-macros.h"
+#include "hdr/math_macros.h"
#include "src/__support/FPUtil/FPBits.h"
#include "src/errno/libc_errno.h"
#include "src/math/log10.h"
diff --git a/test/src/math/smoke/log10f_test.cpp b/test/src/math/smoke/log10f_test.cpp
index 53e6994..721045d 100644
--- a/test/src/math/smoke/log10f_test.cpp
+++ b/test/src/math/smoke/log10f_test.cpp
@@ -6,7 +6,7 @@
//
//===----------------------------------------------------------------------===//
-#include "include/llvm-libc-macros/math-macros.h"
+#include "hdr/math_macros.h"
#include "src/__support/FPUtil/FPBits.h"
#include "src/math/log10f.h"
#include "test/UnitTest/FPMatcher.h"
diff --git a/test/src/math/smoke/log1p_test.cpp b/test/src/math/smoke/log1p_test.cpp
index 5fe9c60..993dbf8 100644
--- a/test/src/math/smoke/log1p_test.cpp
+++ b/test/src/math/smoke/log1p_test.cpp
@@ -6,7 +6,7 @@
//
//===----------------------------------------------------------------------===//
-#include "include/llvm-libc-macros/math-macros.h"
+#include "hdr/math_macros.h"
#include "src/__support/FPUtil/FPBits.h"
#include "src/errno/libc_errno.h"
#include "src/math/log1p.h"
diff --git a/test/src/math/smoke/log1pf_test.cpp b/test/src/math/smoke/log1pf_test.cpp
index e2fb2f0..6127cc8 100644
--- a/test/src/math/smoke/log1pf_test.cpp
+++ b/test/src/math/smoke/log1pf_test.cpp
@@ -6,7 +6,7 @@
//
//===----------------------------------------------------------------------===//
-#include "include/llvm-libc-macros/math-macros.h"
+#include "hdr/math_macros.h"
#include "src/__support/FPUtil/FPBits.h"
#include "src/errno/libc_errno.h"
#include "src/math/log1pf.h"
diff --git a/test/src/math/smoke/log2_test.cpp b/test/src/math/smoke/log2_test.cpp
index fbeba95..b59767e 100644
--- a/test/src/math/smoke/log2_test.cpp
+++ b/test/src/math/smoke/log2_test.cpp
@@ -6,7 +6,7 @@
//
//===----------------------------------------------------------------------===//
-#include "include/llvm-libc-macros/math-macros.h"
+#include "hdr/math_macros.h"
#include "src/__support/FPUtil/FPBits.h"
#include "src/errno/libc_errno.h"
#include "src/math/log2.h"
diff --git a/test/src/math/smoke/log2f_test.cpp b/test/src/math/smoke/log2f_test.cpp
index 46906e7..00bfb7c 100644
--- a/test/src/math/smoke/log2f_test.cpp
+++ b/test/src/math/smoke/log2f_test.cpp
@@ -6,7 +6,7 @@
//
//===----------------------------------------------------------------------===//
-#include "include/llvm-libc-macros/math-macros.h"
+#include "hdr/math_macros.h"
#include "src/__support/FPUtil/FPBits.h"
#include "src/errno/libc_errno.h"
#include "src/math/log2f.h"
diff --git a/test/src/math/smoke/log_test.cpp b/test/src/math/smoke/log_test.cpp
index b1e3905..fd527dee 100644
--- a/test/src/math/smoke/log_test.cpp
+++ b/test/src/math/smoke/log_test.cpp
@@ -6,7 +6,7 @@
//
//===----------------------------------------------------------------------===//
-#include "include/llvm-libc-macros/math-macros.h"
+#include "hdr/math_macros.h"
#include "src/__support/FPUtil/FPBits.h"
#include "src/errno/libc_errno.h"
#include "src/math/log.h"
diff --git a/test/src/math/smoke/logf_test.cpp b/test/src/math/smoke/logf_test.cpp
index 97b6bdd..a272060 100644
--- a/test/src/math/smoke/logf_test.cpp
+++ b/test/src/math/smoke/logf_test.cpp
@@ -6,7 +6,7 @@
//
//===----------------------------------------------------------------------===//
-#include "include/llvm-libc-macros/math-macros.h"
+#include "hdr/math_macros.h"
#include "src/__support/FPUtil/FPBits.h"
#include "src/math/logf.h"
#include "test/UnitTest/FPMatcher.h"
diff --git a/test/src/math/smoke/nanf128_test.cpp b/test/src/math/smoke/nanf128_test.cpp
index 2a9f57d..652e35c 100644
--- a/test/src/math/smoke/nanf128_test.cpp
+++ b/test/src/math/smoke/nanf128_test.cpp
@@ -7,7 +7,7 @@
//===----------------------------------------------------------------------===//
#include "src/__support/FPUtil/FPBits.h"
-#include "src/__support/UInt128.h"
+#include "src/__support/uint128.h"
#include "src/math/nanf128.h"
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"
diff --git a/test/src/math/smoke/powf_test.cpp b/test/src/math/smoke/powf_test.cpp
index e9de155..98a532f 100644
--- a/test/src/math/smoke/powf_test.cpp
+++ b/test/src/math/smoke/powf_test.cpp
@@ -6,7 +6,7 @@
//
//===----------------------------------------------------------------------===//
-#include "include/llvm-libc-macros/math-macros.h"
+#include "hdr/math_macros.h"
#include "src/__support/FPUtil/FPBits.h"
#include "src/math/powf.h"
#include "test/UnitTest/FPMatcher.h"
diff --git a/test/src/math/smoke/sincosf_test.cpp b/test/src/math/smoke/sincosf_test.cpp
index 5952b20..8c35953 100644
--- a/test/src/math/smoke/sincosf_test.cpp
+++ b/test/src/math/smoke/sincosf_test.cpp
@@ -6,7 +6,7 @@
//
//===----------------------------------------------------------------------===//
-#include "include/llvm-libc-macros/math-macros.h"
+#include "hdr/math_macros.h"
#include "src/__support/FPUtil/FPBits.h"
#include "src/errno/libc_errno.h"
#include "src/math/sincosf.h"
diff --git a/test/src/math/smoke/sinf_test.cpp b/test/src/math/smoke/sinf_test.cpp
index 9450895..9fc208dd 100644
--- a/test/src/math/smoke/sinf_test.cpp
+++ b/test/src/math/smoke/sinf_test.cpp
@@ -6,7 +6,7 @@
//
//===----------------------------------------------------------------------===//
-#include "include/llvm-libc-macros/math-macros.h"
+#include "hdr/math_macros.h"
#include "src/__support/FPUtil/FPBits.h"
#include "src/errno/libc_errno.h"
#include "src/math/sinf.h"
diff --git a/test/src/math/smoke/sinhf_test.cpp b/test/src/math/smoke/sinhf_test.cpp
index 0f005f7..1e05298 100644
--- a/test/src/math/smoke/sinhf_test.cpp
+++ b/test/src/math/smoke/sinhf_test.cpp
@@ -6,7 +6,7 @@
//
//===----------------------------------------------------------------------===//
-#include "include/llvm-libc-macros/math-macros.h"
+#include "hdr/math_macros.h"
#include "src/__support/CPP/array.h"
#include "src/__support/FPUtil/FPBits.h"
#include "src/errno/libc_errno.h"
diff --git a/test/src/math/smoke/tanf_test.cpp b/test/src/math/smoke/tanf_test.cpp
index 68bf493..ab3f7c1 100644
--- a/test/src/math/smoke/tanf_test.cpp
+++ b/test/src/math/smoke/tanf_test.cpp
@@ -6,7 +6,7 @@
//
//===----------------------------------------------------------------------===//
-#include "include/llvm-libc-macros/math-macros.h"
+#include "hdr/math_macros.h"
#include "src/__support/FPUtil/FPBits.h"
#include "src/errno/libc_errno.h"
#include "src/math/tanf.h"
diff --git a/test/src/math/smoke/tanhf_test.cpp b/test/src/math/smoke/tanhf_test.cpp
index f1ce8b4..ddae021 100644
--- a/test/src/math/smoke/tanhf_test.cpp
+++ b/test/src/math/smoke/tanhf_test.cpp
@@ -6,7 +6,7 @@
//
//===----------------------------------------------------------------------===//
-#include "include/llvm-libc-macros/math-macros.h"
+#include "hdr/math_macros.h"
#include "src/__support/FPUtil/FPBits.h"
#include "src/errno/libc_errno.h"
#include "src/math/tanhf.h"
diff --git a/test/src/math/tan_test.cpp b/test/src/math/tan_test.cpp
index 85174db..d813dcc 100644
--- a/test/src/math/tan_test.cpp
+++ b/test/src/math/tan_test.cpp
@@ -11,7 +11,7 @@
#include "test/UnitTest/Test.h"
#include "utils/MPFRWrapper/MPFRUtils.h"
-#include "include/llvm-libc-macros/math-macros.h"
+#include "hdr/math_macros.h"
using LlvmLibcTanTest = LIBC_NAMESPACE::testing::FPTest<double>;
diff --git a/test/src/math/tanf_test.cpp b/test/src/math/tanf_test.cpp
index d40bc44..e624d30 100644
--- a/test/src/math/tanf_test.cpp
+++ b/test/src/math/tanf_test.cpp
@@ -6,7 +6,7 @@
//
//===----------------------------------------------------------------------===//
-#include "include/llvm-libc-macros/math-macros.h"
+#include "hdr/math_macros.h"
#include "src/__support/FPUtil/FPBits.h"
#include "src/errno/libc_errno.h"
#include "src/math/tanf.h"
diff --git a/test/src/math/tanhf_test.cpp b/test/src/math/tanhf_test.cpp
index ef272b1..c34efe8 100644
--- a/test/src/math/tanhf_test.cpp
+++ b/test/src/math/tanhf_test.cpp
@@ -6,7 +6,7 @@
//
//===----------------------------------------------------------------------===//
-#include "include/llvm-libc-macros/math-macros.h"
+#include "hdr/math_macros.h"
#include "src/__support/FPUtil/FPBits.h"
#include "src/errno/libc_errno.h"
#include "src/math/tanhf.h"
diff --git a/test/src/stdlib/strtold_test.cpp b/test/src/stdlib/strtold_test.cpp
index 2066e96..2c9f542 100644
--- a/test/src/stdlib/strtold_test.cpp
+++ b/test/src/stdlib/strtold_test.cpp
@@ -7,7 +7,7 @@
//===----------------------------------------------------------------------===//
#include "src/__support/FPUtil/FPBits.h"
-#include "src/__support/UInt128.h"
+#include "src/__support/uint128.h"
#include "src/errno/libc_errno.h"
#include "src/stdlib/strtold.h"
diff --git a/test/src/sys/epoll/linux/epoll_create1_test.cpp b/test/src/sys/epoll/linux/epoll_create1_test.cpp
new file mode 100644
index 0000000..4059afe
--- /dev/null
+++ b/test/src/sys/epoll/linux/epoll_create1_test.cpp
@@ -0,0 +1,31 @@
+//===-- Unittests for epoll_create1 ---------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+#include "hdr/sys_epoll_macros.h"
+#include "src/errno/libc_errno.h"
+#include "src/sys/epoll/epoll_create1.h"
+#include "src/unistd/close.h"
+#include "test/UnitTest/ErrnoSetterMatcher.h"
+#include "test/UnitTest/Test.h"
+
+using namespace LIBC_NAMESPACE::testing::ErrnoSetterMatcher;
+
+TEST(LlvmLibcEpollCreate1Test, Basic) {
+ int fd = LIBC_NAMESPACE::epoll_create1(0);
+ ASSERT_GT(fd, 0);
+ ASSERT_ERRNO_SUCCESS();
+
+ ASSERT_THAT(LIBC_NAMESPACE::close(fd), Succeeds());
+}
+
+TEST(LlvmLibcEpollCreate1Test, CloseOnExecute) {
+ int fd = LIBC_NAMESPACE::epoll_create1(EPOLL_CLOEXEC);
+ ASSERT_GT(fd, 0);
+ ASSERT_ERRNO_SUCCESS();
+
+ ASSERT_THAT(LIBC_NAMESPACE::close(fd), Succeeds());
+}
diff --git a/test/src/sys/epoll/linux/epoll_create_test.cpp b/test/src/sys/epoll/linux/epoll_create_test.cpp
new file mode 100644
index 0000000..fdcdcf8
--- /dev/null
+++ b/test/src/sys/epoll/linux/epoll_create_test.cpp
@@ -0,0 +1,26 @@
+//===-- Unittests for epoll_create ----------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+#include "src/errno/libc_errno.h"
+#include "src/sys/epoll/epoll_create.h"
+#include "src/unistd/close.h"
+#include "test/UnitTest/ErrnoSetterMatcher.h"
+#include "test/UnitTest/Test.h"
+
+using namespace LIBC_NAMESPACE::testing::ErrnoSetterMatcher;
+
+TEST(LlvmLibcEpollCreateTest, Basic) {
+ int fd = LIBC_NAMESPACE::epoll_create(1);
+ ASSERT_GT(fd, 0);
+ ASSERT_ERRNO_SUCCESS();
+
+ ASSERT_THAT(LIBC_NAMESPACE::close(fd), Succeeds());
+}
+
+TEST(LlvmLibcEpollCreateTest, Fails) {
+ ASSERT_THAT(LIBC_NAMESPACE::epoll_create(0), Fails(EINVAL));
+}
diff --git a/test/src/sys/epoll/linux/epoll_ctl_test.cpp b/test/src/sys/epoll/linux/epoll_ctl_test.cpp
new file mode 100644
index 0000000..fa2d358
--- /dev/null
+++ b/test/src/sys/epoll/linux/epoll_ctl_test.cpp
@@ -0,0 +1,47 @@
+//===-- Unittests for epoll_ctl -------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "hdr/sys_epoll_macros.h"
+#include "hdr/types/struct_epoll_event.h"
+#include "src/errno/libc_errno.h"
+#include "src/sys/epoll/epoll_create1.h"
+#include "src/sys/epoll/epoll_ctl.h"
+#include "src/unistd/close.h"
+#include "src/unistd/pipe.h"
+#include "test/UnitTest/ErrnoSetterMatcher.h"
+#include "test/UnitTest/Test.h"
+
+using namespace LIBC_NAMESPACE::testing::ErrnoSetterMatcher;
+
+TEST(LlvmLibcEpollCtlTest, Basic) {
+ int epfd = LIBC_NAMESPACE::epoll_create1(0);
+ ASSERT_GT(epfd, 0);
+ ASSERT_ERRNO_SUCCESS();
+
+ int pipefd[2];
+
+ ASSERT_THAT(LIBC_NAMESPACE::pipe(pipefd), Succeeds());
+
+ epoll_event event;
+ event.events = EPOLLOUT;
+ event.data.fd = pipefd[0];
+
+ ASSERT_THAT(LIBC_NAMESPACE::epoll_ctl(epfd, EPOLL_CTL_ADD, pipefd[0], &event),
+ Succeeds());
+
+ // adding the same file fail.
+ ASSERT_THAT(LIBC_NAMESPACE::epoll_ctl(epfd, EPOLL_CTL_ADD, pipefd[0], &event),
+ Fails(EEXIST));
+
+ ASSERT_THAT(LIBC_NAMESPACE::epoll_ctl(epfd, EPOLL_CTL_DEL, pipefd[0], &event),
+ Succeeds());
+
+ ASSERT_THAT(LIBC_NAMESPACE::close(pipefd[0]), Succeeds());
+ ASSERT_THAT(LIBC_NAMESPACE::close(pipefd[1]), Succeeds());
+ ASSERT_THAT(LIBC_NAMESPACE::close(epfd), Succeeds());
+}
diff --git a/test/src/sys/epoll/linux/epoll_pwait2_test.cpp b/test/src/sys/epoll/linux/epoll_pwait2_test.cpp
index 83fe12b..2f4c985 100644
--- a/test/src/sys/epoll/linux/epoll_pwait2_test.cpp
+++ b/test/src/sys/epoll/linux/epoll_pwait2_test.cpp
@@ -5,16 +5,53 @@
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
+#include "hdr/sys_epoll_macros.h"
+#include "hdr/types/struct_epoll_event.h"
+#include "hdr/types/struct_timespec.h"
#include "src/errno/libc_errno.h"
+#include "src/sys/epoll/epoll_create1.h"
+#include "src/sys/epoll/epoll_ctl.h"
#include "src/sys/epoll/epoll_pwait2.h"
+#include "src/unistd/close.h"
+#include "src/unistd/pipe.h"
#include "test/UnitTest/ErrnoSetterMatcher.h"
#include "test/UnitTest/Test.h"
using namespace LIBC_NAMESPACE::testing::ErrnoSetterMatcher;
-TEST(LlvmLibcEpollWaitTest, Basic) {
- EXPECT_THAT(LIBC_NAMESPACE::epoll_pwait2(-1, nullptr, 0, nullptr, nullptr),
- returns(EQ(-1ul)).with_errno(EQ(EINVAL)));
-}
+TEST(LlvmLibcEpollPwaitTest, Basic) {
+ int epfd = LIBC_NAMESPACE::epoll_create1(0);
+ ASSERT_GT(epfd, 0);
+ ASSERT_ERRNO_SUCCESS();
-// TODO: Complete these tests when epoll_create is implemented.
+ int pipefd[2];
+
+ ASSERT_THAT(LIBC_NAMESPACE::pipe(pipefd), Succeeds());
+
+ epoll_event event;
+ event.events = EPOLLOUT;
+ event.data.fd = pipefd[0];
+
+ timespec time_spec;
+ time_spec.tv_sec = 0;
+ time_spec.tv_nsec = 0;
+
+ ASSERT_THAT(LIBC_NAMESPACE::epoll_ctl(epfd, EPOLL_CTL_ADD, pipefd[0], &event),
+ Succeeds());
+
+ // Timeout of 0 causes immediate return. We just need to check that the
+ // interface works, we're not testing the kernel behavior here.
+ ASSERT_THAT(
+ LIBC_NAMESPACE::epoll_pwait2(epfd, &event, 1, &time_spec, nullptr),
+ Succeeds());
+
+ ASSERT_THAT(LIBC_NAMESPACE::epoll_pwait2(-1, &event, 1, &time_spec, nullptr),
+ Fails(EBADF));
+
+ ASSERT_THAT(LIBC_NAMESPACE::epoll_ctl(epfd, EPOLL_CTL_DEL, pipefd[0], &event),
+ Succeeds());
+
+ ASSERT_THAT(LIBC_NAMESPACE::close(pipefd[0]), Succeeds());
+ ASSERT_THAT(LIBC_NAMESPACE::close(pipefd[1]), Succeeds());
+ ASSERT_THAT(LIBC_NAMESPACE::close(epfd), Succeeds());
+}
diff --git a/test/src/sys/epoll/linux/epoll_pwait_test.cpp b/test/src/sys/epoll/linux/epoll_pwait_test.cpp
index 217facb..8e14aea 100644
--- a/test/src/sys/epoll/linux/epoll_pwait_test.cpp
+++ b/test/src/sys/epoll/linux/epoll_pwait_test.cpp
@@ -5,16 +5,48 @@
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
+#include "hdr/sys_epoll_macros.h"
+#include "hdr/types/struct_epoll_event.h"
#include "src/errno/libc_errno.h"
+#include "src/sys/epoll/epoll_create1.h"
+#include "src/sys/epoll/epoll_ctl.h"
#include "src/sys/epoll/epoll_pwait.h"
+#include "src/unistd/close.h"
+#include "src/unistd/pipe.h"
+
#include "test/UnitTest/ErrnoSetterMatcher.h"
#include "test/UnitTest/Test.h"
using namespace LIBC_NAMESPACE::testing::ErrnoSetterMatcher;
-TEST(LlvmLibcEpollWaitTest, Basic) {
- EXPECT_THAT(LIBC_NAMESPACE::epoll_pwait(-1, nullptr, 0, 0, nullptr),
- returns(EQ(-1ul)).with_errno(EQ(EINVAL)));
-}
+TEST(LlvmLibcEpollPwaitTest, Basic) {
+ int epfd = LIBC_NAMESPACE::epoll_create1(0);
+ ASSERT_GT(epfd, 0);
+ ASSERT_ERRNO_SUCCESS();
-// TODO: Complete these tests when epoll_create is implemented.
+ int pipefd[2];
+
+ ASSERT_THAT(LIBC_NAMESPACE::pipe(pipefd), Succeeds());
+
+ epoll_event event;
+ event.events = EPOLLOUT;
+ event.data.fd = pipefd[0];
+
+ ASSERT_THAT(LIBC_NAMESPACE::epoll_ctl(epfd, EPOLL_CTL_ADD, pipefd[0], &event),
+ Succeeds());
+
+ // Timeout of 0 causes immediate return. We just need to check that the
+ // interface works, we're not testing the kernel behavior here.
+ ASSERT_THAT(LIBC_NAMESPACE::epoll_pwait(epfd, &event, 1, 0, nullptr),
+ Succeeds());
+
+ ASSERT_THAT(LIBC_NAMESPACE::epoll_pwait(-1, &event, 1, 0, nullptr),
+ Fails(EBADF));
+
+ ASSERT_THAT(LIBC_NAMESPACE::epoll_ctl(epfd, EPOLL_CTL_DEL, pipefd[0], &event),
+ Succeeds());
+
+ ASSERT_THAT(LIBC_NAMESPACE::close(pipefd[0]), Succeeds());
+ ASSERT_THAT(LIBC_NAMESPACE::close(pipefd[1]), Succeeds());
+ ASSERT_THAT(LIBC_NAMESPACE::close(epfd), Succeeds());
+}
diff --git a/test/src/sys/epoll/linux/epoll_wait_test.cpp b/test/src/sys/epoll/linux/epoll_wait_test.cpp
index 57fef3f..f9e855a 100644
--- a/test/src/sys/epoll/linux/epoll_wait_test.cpp
+++ b/test/src/sys/epoll/linux/epoll_wait_test.cpp
@@ -5,16 +5,45 @@
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
+#include "hdr/sys_epoll_macros.h"
+#include "hdr/types/struct_epoll_event.h"
#include "src/errno/libc_errno.h"
+#include "src/sys/epoll/epoll_create1.h"
+#include "src/sys/epoll/epoll_ctl.h"
#include "src/sys/epoll/epoll_wait.h"
+#include "src/unistd/close.h"
+#include "src/unistd/pipe.h"
#include "test/UnitTest/ErrnoSetterMatcher.h"
#include "test/UnitTest/Test.h"
using namespace LIBC_NAMESPACE::testing::ErrnoSetterMatcher;
TEST(LlvmLibcEpollWaitTest, Basic) {
- EXPECT_THAT(LIBC_NAMESPACE::epoll_wait(-1, nullptr, 0, 0),
- returns(EQ(-1ul)).with_errno(EQ(EINVAL)));
-}
+ int epfd = LIBC_NAMESPACE::epoll_create1(0);
+ ASSERT_GT(epfd, 0);
+ ASSERT_ERRNO_SUCCESS();
-// TODO: Complete these tests when epoll_create is implemented.
+ int pipefd[2];
+
+ ASSERT_THAT(LIBC_NAMESPACE::pipe(pipefd), Succeeds());
+
+ epoll_event event;
+ event.events = EPOLLOUT;
+ event.data.fd = pipefd[0];
+
+ ASSERT_THAT(LIBC_NAMESPACE::epoll_ctl(epfd, EPOLL_CTL_ADD, pipefd[0], &event),
+ Succeeds());
+
+ // Timeout of 0 causes immediate return. We just need to check that the
+ // interface works, we're not testing the kernel behavior here.
+ ASSERT_THAT(LIBC_NAMESPACE::epoll_wait(epfd, &event, 1, 0), Succeeds());
+
+ ASSERT_THAT(LIBC_NAMESPACE::epoll_wait(-1, &event, 1, 0), Fails(EBADF));
+
+ ASSERT_THAT(LIBC_NAMESPACE::epoll_ctl(epfd, EPOLL_CTL_DEL, pipefd[0], &event),
+ Succeeds());
+
+ ASSERT_THAT(LIBC_NAMESPACE::close(pipefd[0]), Succeeds());
+ ASSERT_THAT(LIBC_NAMESPACE::close(pipefd[1]), Succeeds());
+ ASSERT_THAT(LIBC_NAMESPACE::close(epfd), Succeeds());
+}
diff --git a/test/src/unistd/pipe_test.cpp b/test/src/unistd/pipe_test.cpp
new file mode 100644
index 0000000..9c633de
--- /dev/null
+++ b/test/src/unistd/pipe_test.cpp
@@ -0,0 +1,26 @@
+//===-- Unittests for pipe ------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+#include "src/unistd/close.h"
+#include "src/unistd/pipe.h"
+
+#include "test/UnitTest/ErrnoSetterMatcher.h"
+#include "test/UnitTest/Test.h"
+
+using namespace LIBC_NAMESPACE::testing::ErrnoSetterMatcher;
+
+TEST(LlvmLibcPipeTest, SmokeTest) {
+
+ int pipefd[2];
+
+ ASSERT_THAT(LIBC_NAMESPACE::pipe(pipefd), Succeeds());
+
+ ASSERT_THAT(LIBC_NAMESPACE::close(pipefd[0]), Succeeds());
+ ASSERT_THAT(LIBC_NAMESPACE::close(pipefd[1]), Succeeds());
+}
+
+// TODO: Functionality tests
diff --git a/test/utils/FPUtil/x86_long_double_test.cpp b/test/utils/FPUtil/x86_long_double_test.cpp
index 3b140c6..87796b5 100644
--- a/test/utils/FPUtil/x86_long_double_test.cpp
+++ b/test/utils/FPUtil/x86_long_double_test.cpp
@@ -9,7 +9,7 @@
#include "src/__support/FPUtil/FPBits.h"
#include "test/UnitTest/Test.h"
-#include "include/llvm-libc-macros/math-macros.h"
+#include "hdr/math_macros.h"
using FPBits = LIBC_NAMESPACE::fputil::FPBits<long double>;