diff options
author | Aiden Grossman <aidengrossman@google.com> | 2025-09-12 01:05:48 +0000 |
---|---|---|
committer | Aiden Grossman <aidengrossman@google.com> | 2025-09-12 01:05:48 +0000 |
commit | 88a52e1fc6d3e153132f0e0a86431762adf8c0c4 (patch) | |
tree | bae8c1b720736edc54705c325c5bfb95b459eda2 /libc | |
parent | 1873dd7e8bb03319500a9f4b51e9e498a8fb70de (diff) | |
parent | 2740e4b73682eb7a6869c333991a608304938952 (diff) | |
download | llvm-users/boomanaiden154/main.clang-invoke-shell-script-with-bash.zip llvm-users/boomanaiden154/main.clang-invoke-shell-script-with-bash.tar.gz llvm-users/boomanaiden154/main.clang-invoke-shell-script-with-bash.tar.bz2 |
[𝘀𝗽𝗿] changes introduced through rebaseusers/boomanaiden154/main.clang-invoke-shell-script-with-bash
Created using spr 1.3.6
[skip ci]
Diffstat (limited to 'libc')
138 files changed, 960 insertions, 494 deletions
diff --git a/libc/cmake/modules/CheckCompilerFeatures.cmake b/libc/cmake/modules/CheckCompilerFeatures.cmake index a5ea66a..4d50d81 100644 --- a/libc/cmake/modules/CheckCompilerFeatures.cmake +++ b/libc/cmake/modules/CheckCompilerFeatures.cmake @@ -15,6 +15,7 @@ set( "fixed_point" "cfloat16" "cfloat128" + "ext_vector_type" ) # Making sure ALL_COMPILER_FEATURES is sorted. @@ -126,6 +127,8 @@ foreach(feature IN LISTS ALL_COMPILER_FEATURES) set(LIBC_COMPILER_HAS_BUILTIN_ROUND TRUE) elseif(${feature} STREQUAL "builtin_roundeven") set(LIBC_COMPILER_HAS_BUILTIN_ROUNDEVEN TRUE) + elseif(${feature} STREQUAL "ext_vector_type") + set(LIBC_COMPILER_HAS_EXT_VECTOR_TYPE TRUE) endif() endif() endforeach() diff --git a/libc/cmake/modules/LibcParseArguments.cmake b/libc/cmake/modules/LibcParseArguments.cmake new file mode 100644 index 0000000..ef4a2af --- /dev/null +++ b/libc/cmake/modules/LibcParseArguments.cmake @@ -0,0 +1,87 @@ +set(LLVM_LIBC_OPTIONAL_ARGS + ALIAS + PUBLIC + NO_GPU_BUNDLE + NO_RUN_POSTBUILD + C_TEST + NEED_MPFR + NEED_MPC + IS_GPU_BENCHMARK +) + +set(LLVM_LIBC_SINGLE_VALUE_ARGS + CXX_STANDARD + SUITE + CREATE_TARGET_FUNCTION + HDR + DEST_HDR + YAML_FILE + GEN_HDR + NAME +) + +set(LLVM_LIBC_MULTI_VALUE_ARGS + HDRS + SRCS + COMPILE_OPTIONS + LINK_OPTIONS + LINK_LIBRARIES + ENV + DEPENDS + FLAGS + ARGS + LOADER_ARGS +) + +foreach(arg_list LLVM_LIBC_OPTIONAL_ARGS LLVM_LIBC_SINGLE_VALUE_ARGS LLVM_LIBC_MULTI_VALUE_ARGS) + list(TRANSFORM ${arg_list} + PREPEND "OVERLAY_" + OUTPUT_VARIABLE ${arg_list}_OVERLAY + ) + list(TRANSFORM ${arg_list} + PREPEND "FULL_BUILD_" + OUTPUT_VARIABLE ${arg_list}_FULL_BUILD + ) + set(${arg_list}_COMPLETE ${${arg_list}} ${${arg_list}_OVERLAY} ${${arg_list}_FULL_BUILD}) +endforeach() + +macro(llvm_libc_parse_arguments name_prefix) + cmake_parse_arguments( + ${name_prefix} + "${LLVM_LIBC_OPTIONAL_ARGS_COMPLETE}" + "${LLVM_LIBC_SINGLE_VALUE_ARGS_COMPLETE}" + "${LLVM_LIBC_MULTI_VALUE_ARGS_COMPLETE}" + ${ARGN} + ) + + # Collect overlay and full build args + foreach(argument IN LISTS LLVM_LIBC_OPTIONAL_ARGS LLVM_LIBC_SINGLE_VALUE_ARGS LLVM_LIBC_MULTI_VALUE_ARGS) + if(LLVM_LIBC_FULL_BUILD) + if(${name_prefix}_${argument}_FULL_BUILD) + list(APPEND ${name_prefix}_${argument} ${${name_prefix}_${argument}_FULL_BUILD}) + endif() + else() + if(${name_prefix}_${argument}_OVERLAY) + list(APPEND ${name_prefix}_${argument} ${${name_prefix}_${argument}_OVERLAY}) + endif() + endif() + endforeach() +endmacro() + +# Forward all arguments that can be used for llvm_libc_parse_arguments again. +# Assume that *_OVERLAY and *_FULL_BUILD args have been merged properly. +macro(forward_arguments name_prefix output) + set(${output} "") + + foreach(argument ${LLVM_LIBC_OPTIONAL_ARGS}) + if(${name_prefix}_${argument}) + list(APPEND output ${argument}) + endif() + endforeach() + + foreach(argument ${LLVM_LIBC_SINGLE_VALUE_ARGS} ${LLVM_LIBC_MULTI_VALUE_ARGS}) + if(${name_prefix}_${argument}) + list(APPEND output ${argument} "${${name_prefix}_${argument}}") + endif() + endforeach() +endmacro() diff --git a/libc/cmake/modules/compiler_features/check_ext_vector_type.cpp b/libc/cmake/modules/compiler_features/check_ext_vector_type.cpp new file mode 100644 index 0000000..f268a8f --- /dev/null +++ b/libc/cmake/modules/compiler_features/check_ext_vector_type.cpp @@ -0,0 +1,7 @@ +#include "src/__support/macros/attributes.h" + +#if !LIBC_HAS_VECTOR_TYPE +#error unsupported +#endif + +bool [[clang::ext_vector_type(1)]] v; diff --git a/libc/src/__support/CMakeLists.txt b/libc/src/__support/CMakeLists.txt index 2196d9e..b6e87ac 100644 --- a/libc/src/__support/CMakeLists.txt +++ b/libc/src/__support/CMakeLists.txt @@ -97,6 +97,7 @@ add_header_library( common.h endian_internal.h macros/properties/architectures.h + macros/properties/compiler.h macros/attributes.h macros/config.h DEPENDS diff --git a/libc/src/__support/CPP/CMakeLists.txt b/libc/src/__support/CPP/CMakeLists.txt index a389a6d..a9cb67d 100644 --- a/libc/src/__support/CPP/CMakeLists.txt +++ b/libc/src/__support/CPP/CMakeLists.txt @@ -171,6 +171,7 @@ add_header_library( libc.include.llvm-libc-macros.stdfix_macros libc.src.__support.macros.attributes libc.src.__support.macros.properties.types + libc.src.__support.macros.properties.compiler libc.src.__support.macros.properties.complex_types ) @@ -212,7 +213,18 @@ add_object_library( ) add_header_library( + tuple + HDRS + tuple.h + DEPENDS + .utility +) + +add_header_library( simd HDRS simd.h + DEPENDS + .utility + .tuple ) diff --git a/libc/src/__support/CPP/bit.h b/libc/src/__support/CPP/bit.h index df1b177..5a997ef 100644 --- a/libc/src/__support/CPP/bit.h +++ b/libc/src/__support/CPP/bit.h @@ -104,10 +104,16 @@ countr_zero(T value) { } #if __has_builtin(__builtin_ctzs) ADD_SPECIALIZATION(countr_zero, unsigned short, __builtin_ctzs) -#endif +#endif // __has_builtin(__builtin_ctzs) +#if __has_builtin(__builtin_ctz) ADD_SPECIALIZATION(countr_zero, unsigned int, __builtin_ctz) +#endif // __has_builtin(__builtin_ctz) +#if __has_builtin(__builtin_ctzl) ADD_SPECIALIZATION(countr_zero, unsigned long, __builtin_ctzl) +#endif // __has_builtin(__builtin_ctzl) +#if __has_builtin(__builtin_ctzll) ADD_SPECIALIZATION(countr_zero, unsigned long long, __builtin_ctzll) +#endif // __has_builtin(__builtin_ctzll) #endif // __has_builtin(__builtin_ctzg) /// Count number of 0's from the most significant bit to the least @@ -143,10 +149,16 @@ countl_zero(T value) { } #if __has_builtin(__builtin_clzs) ADD_SPECIALIZATION(countl_zero, unsigned short, __builtin_clzs) -#endif +#endif // __has_builtin(__builtin_clzs) +#if __has_builtin(__builtin_clz) ADD_SPECIALIZATION(countl_zero, unsigned int, __builtin_clz) +#endif // __has_builtin(__builtin_clz) +#if __has_builtin(__builtin_clzl) ADD_SPECIALIZATION(countl_zero, unsigned long, __builtin_clzl) +#endif // __has_builtin(__builtin_clzl) +#if __has_builtin(__builtin_clzll) ADD_SPECIALIZATION(countl_zero, unsigned long long, __builtin_clzll) +#endif // __has_builtin(__builtin_clzll) #endif // __has_builtin(__builtin_clzg) #undef ADD_SPECIALIZATION @@ -283,11 +295,17 @@ popcount(T value) { [[nodiscard]] LIBC_INLINE constexpr int popcount<TYPE>(TYPE value) { \ return BUILTIN(value); \ } +#if __has_builtin(__builtin_popcount) ADD_SPECIALIZATION(unsigned char, __builtin_popcount) ADD_SPECIALIZATION(unsigned short, __builtin_popcount) ADD_SPECIALIZATION(unsigned, __builtin_popcount) +#endif // __builtin_popcount +#if __has_builtin(__builtin_popcountl) ADD_SPECIALIZATION(unsigned long, __builtin_popcountl) +#endif // __builtin_popcountl +#if __has_builtin(__builtin_popcountll) ADD_SPECIALIZATION(unsigned long long, __builtin_popcountll) +#endif // __builtin_popcountll #endif // __builtin_popcountg #undef ADD_SPECIALIZATION diff --git a/libc/src/__support/CPP/simd.h b/libc/src/__support/CPP/simd.h index 449455c..3c7e65a 100644 --- a/libc/src/__support/CPP/simd.h +++ b/libc/src/__support/CPP/simd.h @@ -16,7 +16,9 @@ #include "hdr/stdint_proxy.h" #include "src/__support/CPP/algorithm.h" #include "src/__support/CPP/limits.h" +#include "src/__support/CPP/tuple.h" #include "src/__support/CPP/type_traits.h" +#include "src/__support/CPP/utility/integer_sequence.h" #include "src/__support/macros/attributes.h" #include "src/__support/macros/config.h" @@ -32,25 +34,19 @@ namespace cpp { namespace internal { -template <typename T> -using get_as_integer_type_t = unsigned _BitInt(sizeof(T) * CHAR_BIT); - #if defined(LIBC_TARGET_CPU_HAS_AVX512F) template <typename T> -inline constexpr size_t native_vector_size = 64 / sizeof(T); +LIBC_INLINE_VAR constexpr size_t native_vector_size = 64 / sizeof(T); #elif defined(LIBC_TARGET_CPU_HAS_AVX2) template <typename T> -inline constexpr size_t native_vector_size = 32 / sizeof(T); +LIBC_INLINE_VAR constexpr size_t native_vector_size = 32 / sizeof(T); #elif defined(LIBC_TARGET_CPU_HAS_SSE2) || defined(LIBC_TARGET_CPU_HAS_ARM_NEON) template <typename T> -inline constexpr size_t native_vector_size = 16 / sizeof(T); +LIBC_INLINE_VAR constexpr size_t native_vector_size = 16 / sizeof(T); #else -template <typename T> inline constexpr size_t native_vector_size = 1; +template <typename T> LIBC_INLINE constexpr size_t native_vector_size = 1; #endif -template <typename T> LIBC_INLINE constexpr T poison() { - return __builtin_nondeterministic_value(T()); -} } // namespace internal // Type aliases. @@ -61,6 +57,74 @@ using simd = T [[clang::ext_vector_type(N)]]; template <typename T> using simd_mask = simd<bool, internal::native_vector_size<T>>; +namespace internal { + +template <typename T> +using get_as_integer_type_t = unsigned _BitInt(sizeof(T) * CHAR_BIT); + +template <typename T> LIBC_INLINE constexpr T poison() { + return __builtin_nondeterministic_value(T()); +} + +template <typename T, size_t N, size_t OriginalSize, size_t... Indices> +LIBC_INLINE constexpr static cpp::simd<T, sizeof...(Indices)> +extend(cpp::simd<T, N> x, cpp::index_sequence<Indices...>) { + return __builtin_shufflevector( + x, x, (Indices < OriginalSize ? static_cast<int>(Indices) : -1)...); +} + +template <typename T, size_t N, size_t TargetSize, size_t OriginalSize> +LIBC_INLINE constexpr static auto extend(cpp::simd<T, N> x) { + // Recursively resize an input vector to the target size, increasing its size + // by at most double the input size each step due to shufflevector limitation. + if constexpr (N == TargetSize) + return x; + else if constexpr (TargetSize <= 2 * N) + return extend<T, N, TargetSize>(x, cpp::make_index_sequence<TargetSize>{}); + else + return extend<T, 2 * N, TargetSize, OriginalSize>( + extend<T, N, 2 * N>(x, cpp::make_index_sequence<2 * N>{})); +} + +template <typename T, size_t N, size_t M, size_t... Indices> +LIBC_INLINE constexpr static cpp::simd<T, N + M> +concat(cpp::simd<T, N> x, cpp::simd<T, M> y, cpp::index_sequence<Indices...>) { + constexpr size_t Size = cpp::max(N, M); + auto remap = [](size_t idx) -> int { + if (idx < N) + return static_cast<int>(idx); + if (idx < N + M) + return static_cast<int>((idx - N) + Size); + return -1; + }; + + // Extend the input vectors until they are the same size, then use the indices + // to shuffle in only the indices that correspond to the original values. + auto x_ext = extend<T, N, Size, N>(x); + auto y_ext = extend<T, M, Size, M>(y); + return __builtin_shufflevector(x_ext, y_ext, remap(Indices)...); +} + +template <typename T, size_t N, size_t Count, size_t Offset, size_t... Indices> +LIBC_INLINE constexpr static cpp::simd<T, Count> +slice(cpp::simd<T, N> x, cpp::index_sequence<Indices...>) { + return __builtin_shufflevector(x, x, (Offset + Indices)...); +} + +template <typename T, size_t N, size_t Offset, size_t Head, size_t... Tail> +LIBC_INLINE constexpr static auto split(cpp::simd<T, N> x) { + // Recursively splits the input vector by walking the variadic template list, + // increasing our current head each call. + auto result = cpp::make_tuple( + slice<T, N, Head, Offset>(x, cpp::make_index_sequence<Head>{})); + if constexpr (sizeof...(Tail) > 0) + return cpp::tuple_cat(result, split<T, N, Offset + Head, Tail...>(x)); + else + return result; +} + +} // namespace internal + // Type trait helpers. template <typename T> struct simd_size : cpp::integral_constant<size_t, __builtin_vectorelements(T)> { @@ -90,122 +154,127 @@ using enable_if_simd_t = cpp::enable_if_t<is_simd_v<T>, T>; // Casting. template <typename To, typename From, size_t N> -LIBC_INLINE constexpr simd<To, N> simd_cast(simd<From, N> v) { +LIBC_INLINE constexpr static simd<To, N> simd_cast(simd<From, N> v) { return __builtin_convertvector(v, simd<To, N>); } // SIMD mask operations. -template <size_t N> LIBC_INLINE constexpr bool all_of(simd<bool, N> m) { +template <size_t N> LIBC_INLINE constexpr static bool all_of(simd<bool, N> m) { return __builtin_reduce_and(m); } -template <size_t N> LIBC_INLINE constexpr bool any_of(simd<bool, N> m) { +template <size_t N> LIBC_INLINE constexpr static bool any_of(simd<bool, N> m) { return __builtin_reduce_or(m); } -template <size_t N> LIBC_INLINE constexpr bool none_of(simd<bool, N> m) { +template <size_t N> LIBC_INLINE constexpr static bool none_of(simd<bool, N> m) { return !any_of(m); } -template <size_t N> LIBC_INLINE constexpr bool some_of(simd<bool, N> m) { +template <size_t N> LIBC_INLINE constexpr static bool some_of(simd<bool, N> m) { return any_of(m) && !all_of(m); } -template <size_t N> LIBC_INLINE constexpr int popcount(simd<bool, N> m) { +template <size_t N> LIBC_INLINE constexpr static int popcount(simd<bool, N> m) { return __builtin_popcountg(m); } -template <size_t N> LIBC_INLINE constexpr int find_first_set(simd<bool, N> m) { +template <size_t N> +LIBC_INLINE constexpr static int find_first_set(simd<bool, N> m) { return __builtin_ctzg(m); } -template <size_t N> LIBC_INLINE constexpr int find_last_set(simd<bool, N> m) { +template <size_t N> +LIBC_INLINE constexpr static int find_last_set(simd<bool, N> m) { constexpr size_t size = simd_size_v<simd<bool, N>>; - return size - __builtin_clzg(m); + return size - 1 - __builtin_clzg(m); } // Elementwise operations. template <typename T, size_t N> -LIBC_INLINE constexpr simd<T, N> min(simd<T, N> x, simd<T, N> y) { +LIBC_INLINE constexpr static simd<T, N> min(simd<T, N> x, simd<T, N> y) { return __builtin_elementwise_min(x, y); } template <typename T, size_t N> -LIBC_INLINE constexpr simd<T, N> max(simd<T, N> x, simd<T, N> y) { +LIBC_INLINE constexpr static simd<T, N> max(simd<T, N> x, simd<T, N> y) { return __builtin_elementwise_max(x, y); } template <typename T, size_t N> -LIBC_INLINE constexpr simd<T, N> abs(simd<T, N> x) { +LIBC_INLINE constexpr static simd<T, N> abs(simd<T, N> x) { return __builtin_elementwise_abs(x); } template <typename T, size_t N> -LIBC_INLINE constexpr simd<T, N> fma(simd<T, N> x, simd<T, N> y, simd<T, N> z) { +LIBC_INLINE constexpr static simd<T, N> fma(simd<T, N> x, simd<T, N> y, + simd<T, N> z) { return __builtin_elementwise_fma(x, y, z); } template <typename T, size_t N> -LIBC_INLINE constexpr simd<T, N> ceil(simd<T, N> x) { +LIBC_INLINE constexpr static simd<T, N> ceil(simd<T, N> x) { return __builtin_elementwise_ceil(x); } template <typename T, size_t N> -LIBC_INLINE constexpr simd<T, N> floor(simd<T, N> x) { +LIBC_INLINE constexpr static simd<T, N> floor(simd<T, N> x) { return __builtin_elementwise_floor(x); } template <typename T, size_t N> -LIBC_INLINE constexpr simd<T, N> roundeven(simd<T, N> x) { +LIBC_INLINE constexpr static simd<T, N> roundeven(simd<T, N> x) { return __builtin_elementwise_roundeven(x); } template <typename T, size_t N> -LIBC_INLINE constexpr simd<T, N> round(simd<T, N> x) { +LIBC_INLINE constexpr static simd<T, N> round(simd<T, N> x) { return __builtin_elementwise_round(x); } template <typename T, size_t N> -LIBC_INLINE constexpr simd<T, N> trunc(simd<T, N> x) { +LIBC_INLINE constexpr static simd<T, N> trunc(simd<T, N> x) { return __builtin_elementwise_trunc(x); } template <typename T, size_t N> -LIBC_INLINE constexpr simd<T, N> nearbyint(simd<T, N> x) { +LIBC_INLINE constexpr static simd<T, N> nearbyint(simd<T, N> x) { return __builtin_elementwise_nearbyint(x); } template <typename T, size_t N> -LIBC_INLINE constexpr simd<T, N> rint(simd<T, N> x) { +LIBC_INLINE constexpr static simd<T, N> rint(simd<T, N> x) { return __builtin_elementwise_rint(x); } template <typename T, size_t N> -LIBC_INLINE constexpr simd<T, N> canonicalize(simd<T, N> x) { +LIBC_INLINE constexpr static simd<T, N> canonicalize(simd<T, N> x) { return __builtin_elementwise_canonicalize(x); } template <typename T, size_t N> -LIBC_INLINE constexpr simd<T, N> copysign(simd<T, N> x, simd<T, N> y) { +LIBC_INLINE constexpr static simd<T, N> copysign(simd<T, N> x, simd<T, N> y) { return __builtin_elementwise_copysign(x, y); } template <typename T, size_t N> -LIBC_INLINE constexpr simd<T, N> fmod(simd<T, N> x, simd<T, N> y) { +LIBC_INLINE constexpr static simd<T, N> fmod(simd<T, N> x, simd<T, N> y) { return __builtin_elementwise_fmod(x, y); } // Reduction operations. template <typename T, size_t N, typename Op = cpp::plus<>> -LIBC_INLINE constexpr T reduce(simd<T, N> v, Op op = {}) { +LIBC_INLINE constexpr static T reduce(simd<T, N> v, Op op = {}) { return reduce(v, op); } template <typename T, size_t N> -LIBC_INLINE constexpr T reduce(simd<T, N> v, cpp::plus<>) { +LIBC_INLINE constexpr static T reduce(simd<T, N> v, cpp::plus<>) { return __builtin_reduce_add(v); } template <typename T, size_t N> -LIBC_INLINE constexpr T reduce(simd<T, N> v, cpp::multiplies<>) { +LIBC_INLINE constexpr static T reduce(simd<T, N> v, cpp::multiplies<>) { return __builtin_reduce_mul(v); } template <typename T, size_t N> -LIBC_INLINE constexpr T reduce(simd<T, N> v, cpp::bit_and<>) { +LIBC_INLINE constexpr static T reduce(simd<T, N> v, cpp::bit_and<>) { return __builtin_reduce_and(v); } template <typename T, size_t N> -LIBC_INLINE constexpr T reduce(simd<T, N> v, cpp::bit_or<>) { +LIBC_INLINE constexpr static T reduce(simd<T, N> v, cpp::bit_or<>) { return __builtin_reduce_or(v); } template <typename T, size_t N> -LIBC_INLINE constexpr T reduce(simd<T, N> v, cpp::bit_xor<>) { +LIBC_INLINE constexpr static T reduce(simd<T, N> v, cpp::bit_xor<>) { return __builtin_reduce_xor(v); } -template <typename T, size_t N> LIBC_INLINE constexpr T hmin(simd<T, N> v) { +template <typename T, size_t N> +LIBC_INLINE constexpr static T hmin(simd<T, N> v) { return __builtin_reduce_min(v); } -template <typename T, size_t N> LIBC_INLINE constexpr T hmax(simd<T, N> v) { +template <typename T, size_t N> +LIBC_INLINE constexpr static T hmax(simd<T, N> v) { return __builtin_reduce_max(v); } @@ -242,31 +311,51 @@ LIBC_INLINE enable_if_simd_t<T> masked_store(simd<bool, simd_size_v<T>> m, T v, } // Construction helpers. -template <typename T, size_t N> LIBC_INLINE constexpr simd<T, N> splat(T v) { +template <typename T, size_t N> +LIBC_INLINE constexpr static simd<T, N> splat(T v) { return simd<T, N>(v); } -template <typename T> LIBC_INLINE constexpr simd<T> splat(T v) { +template <typename T> LIBC_INLINE constexpr static simd<T> splat(T v) { return splat<T, simd_size_v<simd<T>>>(v); } template <typename T, unsigned N> -LIBC_INLINE constexpr simd<T, N> iota(T base = T(0), T step = T(1)) { +LIBC_INLINE constexpr static simd<T, N> iota(T base = T(0), T step = T(1)) { simd<T, N> v{}; for (unsigned i = 0; i < N; ++i) v[i] = base + T(i) * step; return v; } template <typename T> -LIBC_INLINE constexpr simd<T> iota(T base = T(0), T step = T(1)) { +LIBC_INLINE constexpr static simd<T> iota(T base = T(0), T step = T(1)) { return iota<T, simd_size_v<simd<T>>>(base, step); } // Conditional helpers. template <typename T, size_t N> -LIBC_INLINE constexpr simd<T, N> select(simd<bool, N> m, simd<T, N> x, - simd<T, N> y) { +LIBC_INLINE constexpr static simd<T, N> select(simd<bool, N> m, simd<T, N> x, + simd<T, N> y) { return m ? x : y; } +// Shuffling helpers. +template <typename T, size_t N, size_t M> +LIBC_INLINE constexpr static auto concat(cpp::simd<T, N> x, cpp::simd<T, M> y) { + return internal::concat(x, y, make_index_sequence<N + M>{}); +} +template <typename T, size_t N, size_t M, typename... Rest> +LIBC_INLINE constexpr static auto concat(cpp::simd<T, N> x, cpp::simd<T, M> y, + Rest... rest) { + auto xy = concat(x, y); + if constexpr (sizeof...(Rest)) + return concat(xy, rest...); + else + return xy; +} +template <size_t... Sizes, typename T, size_t N> auto split(cpp::simd<T, N> x) { + static_assert((... + Sizes) == N, "split sizes must sum to vector size"); + return internal::split<T, N, 0, Sizes...>(x); +} + // TODO: where expressions, scalar overloads, ABI types. } // namespace cpp diff --git a/libc/src/__support/CPP/tuple.h b/libc/src/__support/CPP/tuple.h new file mode 100644 index 0000000..cce8e0e --- /dev/null +++ b/libc/src/__support/CPP/tuple.h @@ -0,0 +1,144 @@ +//===-- tuple utility -------------------------------------------*- 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___SUPPORT_CPP_UTILITY_TUPLE_H +#define LLVM_LIBC_SRC___SUPPORT_CPP_UTILITY_TUPLE_H + +#include "src/__support/CPP/type_traits/decay.h" +#include "src/__support/CPP/utility/integer_sequence.h" + +namespace LIBC_NAMESPACE_DECL { +namespace cpp { + +template <typename... Ts> struct tuple; +template <> struct tuple<> {}; + +template <typename Head, typename... Tail> +struct tuple<Head, Tail...> : tuple<Tail...> { + Head head; + + LIBC_INLINE constexpr tuple() = default; + + template <typename OHead, typename... OTail> + LIBC_INLINE constexpr tuple &operator=(const tuple<OHead, OTail...> &other) { + head = other.get_head(); + this->get_tail() = other.get_tail(); + return *this; + } + + LIBC_INLINE constexpr tuple(const Head &h, const Tail &...t) + : tuple<Tail...>(t...), head(h) {} + + LIBC_INLINE constexpr Head &get_head() { return head; } + LIBC_INLINE constexpr const Head &get_head() const { return head; } + + LIBC_INLINE constexpr tuple<Tail...> &get_tail() { return *this; } + LIBC_INLINE constexpr const tuple<Tail...> &get_tail() const { return *this; } +}; + +template <typename... Ts> LIBC_INLINE constexpr auto make_tuple(Ts &&...args) { + return tuple<cpp::decay_t<Ts>...>(static_cast<Ts &&>(args)...); +} +template <typename... Ts> LIBC_INLINE constexpr auto tie(Ts &...args) { + return tuple<Ts &...>(args...); +} + +template <size_t I, typename Head, typename... Tail> +LIBC_INLINE constexpr auto &get(tuple<Head, Tail...> &t) { + if constexpr (I == 0) + return t.get_head(); + else + return get<I - 1>(t.get_tail()); +} +template <size_t I, typename Head, typename... Tail> +LIBC_INLINE constexpr const auto &get(const tuple<Head, Tail...> &t) { + if constexpr (I == 0) + return t.get_head(); + else + return get<I - 1>(t.get_tail()); +} +template <size_t I, typename Head, typename... Tail> +LIBC_INLINE constexpr auto &&get(tuple<Head, Tail...> &&t) { + if constexpr (I == 0) + return static_cast<Head &&>(t.get_head()); + else + return get<I - 1>(static_cast<tuple<Tail...> &&>(t.get_tail())); +} +template <size_t I, typename Head, typename... Tail> +LIBC_INLINE constexpr const auto &&get(const tuple<Head, Tail...> &&t) { + if constexpr (I == 0) + return static_cast<const Head &&>(t.get_head()); + else + return get<I - 1>(static_cast<const tuple<Tail...> &&>(t.get_tail())); +} + +template <typename T> struct tuple_size; +template <typename... Ts> struct tuple_size<tuple<Ts...>> { + static constexpr size_t value = sizeof...(Ts); +}; + +template <size_t I, typename T> struct tuple_element; +template <size_t I, typename Head, typename... Tail> +struct tuple_element<I, tuple<Head, Tail...>> + : tuple_element<I - 1, tuple<Tail...>> {}; +template <typename Head, typename... Tail> +struct tuple_element<0, tuple<Head, Tail...>> { + using type = cpp::remove_cv_t<cpp::remove_reference_t<Head>>; +}; + +namespace internal { +template <typename... As, typename... Bs, size_t... I, size_t... J> +LIBC_INLINE constexpr auto +tuple_cat(const tuple<As...> &a, const tuple<Bs...> &b, + cpp::index_sequence<I...>, cpp::index_sequence<J...>) { + return tuple<As..., Bs...>(get<I>(a)..., get<J>(b)...); +} + +template <typename First, typename Second, typename... Rest> +LIBC_INLINE constexpr auto tuple_cat(const First &f, const Second &s, + const Rest &...rest) { + auto concat = + tuple_cat(f, s, cpp::make_index_sequence<tuple_size<First>::value>{}, + cpp::make_index_sequence<tuple_size<Second>::value>{}); + if constexpr (sizeof...(Rest)) + return tuple_cat(concat, rest...); + else + return concat; +} +} // namespace internal + +template <typename... Tuples> +LIBC_INLINE constexpr auto tuple_cat(const Tuples &...tuples) { + static_assert(sizeof...(Tuples) > 0, "need at least one element"); + if constexpr (sizeof...(Tuples) == 1) + return (tuples, ...); + else + return internal::tuple_cat(tuples...); +} + +} // namespace cpp +} // namespace LIBC_NAMESPACE_DECL + +// Standard namespace definitions required for structured binding support. +namespace std { + +template <class T> struct tuple_size; +template <size_t I, class T> struct tuple_element; + +template <typename... Ts> +struct tuple_size<LIBC_NAMESPACE::cpp::tuple<Ts...>> + : LIBC_NAMESPACE::cpp::tuple_size<LIBC_NAMESPACE::cpp::tuple<Ts...>> {}; + +template <size_t I, typename... Ts> +struct tuple_element<I, LIBC_NAMESPACE::cpp::tuple<Ts...>> + : LIBC_NAMESPACE::cpp::tuple_element<I, LIBC_NAMESPACE::cpp::tuple<Ts...>> { +}; + +} // namespace std + +#endif // LLVM_LIBC_SRC___SUPPORT_CPP_UTILITY_TUPLE_H diff --git a/libc/src/__support/CPP/type_traits/is_complex.h b/libc/src/__support/CPP/type_traits/is_complex.h index 23f05c0..5da1a408 100644 --- a/libc/src/__support/CPP/type_traits/is_complex.h +++ b/libc/src/__support/CPP/type_traits/is_complex.h @@ -13,12 +13,17 @@ #include "src/__support/macros/attributes.h" #include "src/__support/macros/config.h" // LIBC_TYPES_HAS_CFLOAT16 && LIBC_TYPES_HAS_CFLOAT128 +#include "src/__support/macros/properties/compiler.h" #include "src/__support/macros/properties/complex_types.h" namespace LIBC_NAMESPACE_DECL { namespace cpp { // is_complex +#ifdef LIBC_COMPILER_IS_MSVC +// TODO: Add support for complex types with MSVC. +template <typename T> struct is_complex : false_type {}; +#else template <typename T> struct is_complex { private: template <typename Head, typename... Args> @@ -40,6 +45,8 @@ public: #endif >(); }; +#endif // LIBC_COMPILER_IS_MSVC + template <typename T> LIBC_INLINE_VAR constexpr bool is_complex_v = is_complex<T>::value; template <typename T1, typename T2> diff --git a/libc/src/__support/CPP/utility/integer_sequence.h b/libc/src/__support/CPP/utility/integer_sequence.h index 06643d5..17c3dbf 100644 --- a/libc/src/__support/CPP/utility/integer_sequence.h +++ b/libc/src/__support/CPP/utility/integer_sequence.h @@ -5,12 +5,15 @@ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// + #ifndef LLVM_LIBC_SRC___SUPPORT_CPP_UTILITY_INTEGER_SEQUENCE_H #define LLVM_LIBC_SRC___SUPPORT_CPP_UTILITY_INTEGER_SEQUENCE_H #include "src/__support/CPP/type_traits/is_integral.h" #include "src/__support/macros/config.h" +#include <stddef.h> + namespace LIBC_NAMESPACE_DECL { namespace cpp { @@ -34,6 +37,13 @@ template <typename T, int N> using make_integer_sequence = typename detail::make_integer_sequence<T, N - 1>::type; +// index sequence +template <size_t... Ints> +using index_sequence = integer_sequence<size_t, Ints...>; +template <int N> +using make_index_sequence = + typename detail::make_integer_sequence<size_t, N - 1>::type; + } // namespace cpp } // namespace LIBC_NAMESPACE_DECL diff --git a/libc/src/__support/common.h b/libc/src/__support/common.h index 15209b7..a280814 100644 --- a/libc/src/__support/common.h +++ b/libc/src/__support/common.h @@ -16,6 +16,7 @@ #include "src/__support/macros/attributes.h" #include "src/__support/macros/config.h" #include "src/__support/macros/properties/architectures.h" +#include "src/__support/macros/properties/compiler.h" #ifndef LLVM_LIBC_FUNCTION_ATTR #define LLVM_LIBC_FUNCTION_ATTR @@ -41,12 +42,12 @@ // to cleanly export and alias the C++ symbol `LIBC_NAMESPACE::func` with the C // symbol `func`. So for public packaging on MacOS, we will only export the C // symbol. Moreover, a C symbol `func` in macOS is mangled as `_func`. -#if defined(LIBC_COPT_PUBLIC_PACKAGING) +#if defined(LIBC_COPT_PUBLIC_PACKAGING) && !defined(LIBC_COMPILER_IS_MSVC) #ifndef __APPLE__ #define LLVM_LIBC_FUNCTION_IMPL(type, name, arglist) \ LLVM_LIBC_ATTR(name) \ LLVM_LIBC_FUNCTION_ATTR decltype(LIBC_NAMESPACE::name) \ - __##name##_impl__ __asm__(#name); \ + __##name##_impl__ asm(#name); \ decltype(LIBC_NAMESPACE::name) name [[gnu::alias(#name)]]; \ type __##name##_impl__ arglist #else // __APPLE__ diff --git a/libc/src/__support/macros/CMakeLists.txt b/libc/src/__support/macros/CMakeLists.txt index a639d3e..8e17642 100644 --- a/libc/src/__support/macros/CMakeLists.txt +++ b/libc/src/__support/macros/CMakeLists.txt @@ -4,6 +4,9 @@ add_header_library( config HDRS config.h + DEPENDS + libc.src.__support.macros.properties.architectures + libc.src.__support.macros.properties.compiler ) add_header_library( diff --git a/libc/src/__support/macros/config.h b/libc/src/__support/macros/config.h index 2ab0fba..6851888 100644 --- a/libc/src/__support/macros/config.h +++ b/libc/src/__support/macros/config.h @@ -13,6 +13,13 @@ #ifndef LLVM_LIBC_SRC___SUPPORT_MACROS_CONFIG_H #define LLVM_LIBC_SRC___SUPPORT_MACROS_CONFIG_H +#include "src/__support/macros/properties/architectures.h" +#include "src/__support/macros/properties/compiler.h" + +#ifdef LIBC_COMPILER_IS_MSVC +#include <intrin.h> +#endif // LIBC_COMPILER_IS_MSVC + // Workaround for compilers that do not support builtin detection. // FIXME: This is only required for the GPU portion which should be moved. #ifndef __has_builtin @@ -27,6 +34,19 @@ #define LIBC_HAS_FEATURE(f) 0 #endif +#ifdef LIBC_COMPILER_IS_MSVC + +// __builtin_trap replacement +#ifdef LIBC_TARGET_ARCH_IS_X86 +#define __builtin_trap __ud2 +#else // arm64 +#define __builtin_trap() __break(1) +#endif + +#define __builtin_expect(value, expectation) (value) + +#endif // LIBC_COMPILER_IS_MSVC + #ifdef __clang__ // Declare a LIBC_NAMESPACE with hidden visibility. `namespace // LIBC_NAMESPACE_DECL {` should be used around all declarations and definitions diff --git a/libc/src/__support/macros/optimization.h b/libc/src/__support/macros/optimization.h index 250a9e0..dbefd20 100644 --- a/libc/src/__support/macros/optimization.h +++ b/libc/src/__support/macros/optimization.h @@ -34,6 +34,9 @@ LIBC_INLINE constexpr bool expects_bool_condition(T value, T expected) { #elif defined(LIBC_COMPILER_IS_GCC) #define LIBC_LOOP_NOUNROLL _Pragma("GCC unroll 0") #define LIBC_LOOP_UNROLL _Pragma("GCC unroll 2048") +#elif defined(LIBC_COMPILER_IS_MSVC) +#define LIBC_LOOP_NOUNROLL +#define LIBC_LOOP_UNROLL #else #error "Unhandled compiler" #endif diff --git a/libc/src/__support/macros/properties/compiler.h b/libc/src/__support/macros/properties/compiler.h index b9ec0dd..6947bc7 100644 --- a/libc/src/__support/macros/properties/compiler.h +++ b/libc/src/__support/macros/properties/compiler.h @@ -34,10 +34,10 @@ #define LIBC_COMPILER_GCC_VER (__GNUC__ * 100 + __GNUC_MINOR__) #endif -#if defined(_MSC_VER) -#define LIBC_COMPILER_IS_MSC +#if defined(_MSC_VER) && !defined(__clang__) +#define LIBC_COMPILER_IS_MSVC // https://learn.microsoft.com/en-us/cpp/preprocessor/predefined-macros -#define LIBC_COMPILER_MSC_VER (_MSC_VER) +#define LIBC_COMPILER_MSVC_VER (_MSC_VER) #endif #endif // LLVM_LIBC_SRC___SUPPORT_MACROS_PROPERTIES_COMPILER_H diff --git a/libc/test/src/__support/CMakeLists.txt b/libc/test/src/__support/CMakeLists.txt index 5d1d0e0..a025141 100644 --- a/libc/test/src/__support/CMakeLists.txt +++ b/libc/test/src/__support/CMakeLists.txt @@ -123,6 +123,8 @@ add_libc_test( str_to_float_test.cpp str_to_double_test.cpp str_to_long_double_test.cpp + HDRS + str_to_fp_test.h DEPENDS libc.src.__support.integer_literals libc.src.__support.str_to_float diff --git a/libc/test/src/__support/CPP/CMakeLists.txt b/libc/test/src/__support/CPP/CMakeLists.txt index 3e1379d..430cd7b 100644 --- a/libc/test/src/__support/CPP/CMakeLists.txt +++ b/libc/test/src/__support/CPP/CMakeLists.txt @@ -131,6 +131,16 @@ add_libc_test( ) add_libc_test( + tuple_test + SUITE + libc-cpp-utils-tests + SRCS + tuple_test.cpp + DEPENDS + libc.src.__support.CPP.tuple +) + +add_libc_test( span_test SUITE libc-cpp-utils-tests @@ -160,3 +170,15 @@ add_libc_test( DEPENDS libc.src.__support.CPP.type_traits ) + +if(LIBC_COMPILER_HAS_EXT_VECTOR_TYPE) + add_libc_test( + simd_test + SUITE + libc-cpp-utils-tests + SRCS + simd_test.cpp + DEPENDS + libc.src.__support.CPP.simd + ) +endif() diff --git a/libc/test/src/__support/CPP/simd_test.cpp b/libc/test/src/__support/CPP/simd_test.cpp new file mode 100644 index 0000000..b4f5685 --- /dev/null +++ b/libc/test/src/__support/CPP/simd_test.cpp @@ -0,0 +1,86 @@ +//===-- Unittests for cpp::simd -------------------------------------------===// +// +// 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/__support/CPP/simd.h" +#include "src/__support/CPP/utility.h" + +#include "test/UnitTest/Test.h" + +static_assert(LIBC_HAS_VECTOR_TYPE, "compiler needs ext_vector_type support"); + +using namespace LIBC_NAMESPACE; + +TEST(LlvmLibcSIMDTest, Basic) {} +TEST(LlvmLibcSIMDTest, VectorCreation) { + cpp::simd<int> v1 = cpp::splat(5); + cpp::simd<int> v2 = cpp::iota<int>(); + + EXPECT_EQ(v1[0], 5); + EXPECT_EQ(v2[0], 0); +} + +TEST(LlvmLibcSIMDTest, TypeTraits) { + cpp::simd<int> v1 = cpp::splat(0); + + static_assert(cpp::is_simd_v<decltype(v1)>, "v1 should be a SIMD type"); + static_assert(!cpp::is_simd_v<int>, "int is not a SIMD type"); + static_assert(cpp::is_simd_mask_v<cpp::simd<bool, 4>>, + "should be a SIMD mask"); + + using Elem = cpp::simd_element_type_t<decltype(v1)>; + static_assert(cpp::is_same_v<Elem, int>, "element type should be int"); +} + +TEST(LlvmLibcSIMDTest, ElementwiseOperations) { + cpp::simd<int> vi1 = cpp::splat(1); + cpp::simd<int> vi2 = cpp::splat(-1); + + cpp::simd<int> v_abs = cpp::abs(vi2); + cpp::simd<int> v_min = cpp::min(vi1, vi2); + cpp::simd<int> v_max = cpp::max(vi1, vi2); + + EXPECT_EQ(v_abs[0], 1); + EXPECT_EQ(v_min[0], -1); + EXPECT_EQ(v_max[0], 1); +} + +TEST(LlvmLibcSIMDTest, ReductionOperations) { + cpp::simd<int> v = cpp::splat(1); + + int sum = cpp::reduce(v); + int prod = cpp::reduce(v, cpp::multiplies<>{}); + + EXPECT_EQ(sum, static_cast<int>(cpp::simd_size_v<decltype(v)>)); + EXPECT_EQ(prod, 1); +} + +TEST(LlvmLibcSIMDTest, MaskOperations) { + cpp::simd<bool, 8> mask{true, false, true, false, false, false, false, false}; + + EXPECT_TRUE(cpp::any_of(mask)); + EXPECT_FALSE(cpp::all_of(mask)); + EXPECT_TRUE(cpp::some_of(mask)); + EXPECT_EQ(cpp::find_first_set(mask), 0); + EXPECT_EQ(cpp::find_last_set(mask), 2); +} + +TEST(LlvmLibcSIMDTest, SplitConcat) { + cpp::simd<char, 8> v{1, 1, 2, 2, 3, 3, 4, 4}; + auto [v1, v2, v3, v4] = cpp::split<2, 2, 2, 2>(v); + EXPECT_TRUE(cpp::all_of(cpp::simd_cast<bool>(v1 == 1))); + EXPECT_TRUE(cpp::all_of(cpp::simd_cast<bool>(v2 == 2))); + EXPECT_TRUE(cpp::all_of(cpp::simd_cast<bool>(v3 == 3))); + EXPECT_TRUE(cpp::all_of(cpp::simd_cast<bool>(v4 == 4))); + + cpp::simd<char, 8> m = cpp::concat(v1, v2, v3, v4); + EXPECT_TRUE(cpp::all_of(cpp::simd_cast<bool>(m == v))); + + cpp::simd<char, 1> c(~0); + cpp::simd<char, 8> n = cpp::concat(c, c, c, c, c, c, c, c); + EXPECT_TRUE(cpp::all_of(cpp::simd_cast<bool>(n == ~0))); +} diff --git a/libc/test/src/__support/CPP/tuple_test.cpp b/libc/test/src/__support/CPP/tuple_test.cpp new file mode 100644 index 0000000..0b05ae4 --- /dev/null +++ b/libc/test/src/__support/CPP/tuple_test.cpp @@ -0,0 +1,71 @@ +//===-- Unittests for cpp::tuple ------------------------------------------===// +// +// 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/__support/CPP/tuple.h" +#include <stddef.h> + +#include "test/UnitTest/FPMatcher.h" +#include "test/UnitTest/Test.h" + +using namespace LIBC_NAMESPACE::cpp; + +TEST(LlvmLibcTupleTest, Construction) { + tuple<int, double> t(42, 3.14); + EXPECT_EQ(get<0>(t), 42); + EXPECT_FP_EQ(get<1>(t), 3.14); +} + +TEST(LlvmLibcTupleTest, MakeTuple) { + auto t = make_tuple(1, 2.5, 'x'); + EXPECT_EQ(get<0>(t), 1); + EXPECT_FP_EQ(get<1>(t), 2.5); + EXPECT_EQ(get<2>(t), 'x'); +} + +TEST(LlvmLibcTupleTest, TieAssignment) { + int a = 0; + double b = 0; + char c = 0; + auto t = make_tuple(7, 8.5, 'y'); + tie(a, b, c) = t; + EXPECT_EQ(a, 7); + EXPECT_FP_EQ(b, 8.5); + EXPECT_EQ(c, 'y'); +} + +TEST(LlvmLibcTupleTest, StructuredBindings) { + auto t = make_tuple(7, 8.5, 'y'); + auto [x, y, z] = t; + EXPECT_EQ(x, 7); + EXPECT_FP_EQ(y, 8.5); + EXPECT_EQ(z, 'y'); +} + +TEST(LlvmLibcTupleTest, TupleCat) { + tuple<int, double> t(42, 3.14); + auto t1 = make_tuple(1, 2.5, 'x'); + auto t2 = tuple_cat(t, t1); + EXPECT_EQ(get<0>(t2), 42); + EXPECT_FP_EQ(get<1>(t2), 3.14); + EXPECT_EQ(get<2>(t2), 1); + EXPECT_FP_EQ(get<3>(t2), 2.5); + EXPECT_EQ(get<4>(t2), 'x'); +} + +TEST(LlvmLibcTupleTest, ConstTuple) { + const auto t = make_tuple(100, 200.5); + EXPECT_EQ(get<0>(t), 100); + EXPECT_FP_EQ(get<1>(t), 200.5); +} + +TEST(LlvmLibcTupleTest, RvalueAssignment) { + auto t = make_tuple(0, 0.0); + t = make_tuple(9, 9.5); + EXPECT_EQ(get<0>(t), 9); + EXPECT_FP_EQ(get<1>(t), 9.5); +} diff --git a/libc/test/src/__support/str_to_fp_test.h b/libc/test/src/__support/str_to_fp_test.h index 9b4844d..d349192 100644 --- a/libc/test/src/__support/str_to_fp_test.h +++ b/libc/test/src/__support/str_to_fp_test.h @@ -7,7 +7,6 @@ //===----------------------------------------------------------------------===// #include "src/__support/FPUtil/FPBits.h" -#include "src/__support/libc_errno.h" #include "src/__support/macros/config.h" #include "src/__support/str_to_float.h" #include "src/__support/uint128.h" diff --git a/libc/test/src/__support/str_to_integer_test.cpp b/libc/test/src/__support/str_to_integer_test.cpp index 40cb76a..1ec882b 100644 --- a/libc/test/src/__support/str_to_integer_test.cpp +++ b/libc/test/src/__support/str_to_integer_test.cpp @@ -6,7 +6,6 @@ // //===----------------------------------------------------------------------===// -#include "src/__support/libc_errno.h" #include "src/__support/str_to_integer.h" #include <stddef.h> diff --git a/libc/test/src/__support/wcs_to_integer_test.cpp b/libc/test/src/__support/wcs_to_integer_test.cpp index e410792..4554968 100644 --- a/libc/test/src/__support/wcs_to_integer_test.cpp +++ b/libc/test/src/__support/wcs_to_integer_test.cpp @@ -6,7 +6,6 @@ // //===----------------------------------------------------------------------===// -#include "src/__support/libc_errno.h" #include "src/__support/wcs_to_integer.h" #include <stddef.h> diff --git a/libc/test/src/math/CMakeLists.txt b/libc/test/src/math/CMakeLists.txt index 945bc25..378eadcf 100644 --- a/libc/test/src/math/CMakeLists.txt +++ b/libc/test/src/math/CMakeLists.txt @@ -10,7 +10,7 @@ add_fp_unittest( HDRS sdcomp26094.h DEPENDS - libc.src.errno.errno + libc.hdr.errno_macros libc.src.math.cosf libc.src.__support.CPP.array libc.src.__support.FPUtil.fp_bits @@ -49,7 +49,7 @@ add_fp_unittest( HDRS sdcomp26094.h DEPENDS - libc.src.errno.errno + libc.hdr.errno_macros libc.src.math.cospif libc.src.__support.CPP.array libc.src.__support.FPUtil.fp_bits @@ -90,7 +90,7 @@ add_fp_unittest( HDRS sdcomp26094.h DEPENDS - libc.src.errno.errno + libc.hdr.errno_macros libc.src.math.sinf libc.src.__support.CPP.array libc.src.__support.FPUtil.fp_bits @@ -117,7 +117,7 @@ add_fp_unittest( HDRS sdcomp26094.h DEPENDS - libc.src.errno.errno + libc.hdr.errno_macros libc.src.math.sinpif libc.src.__support.CPP.array libc.src.__support.FPUtil.fp_bits @@ -156,7 +156,7 @@ add_fp_unittest( HDRS sdcomp26094.h DEPENDS - libc.src.errno.errno + libc.hdr.errno_macros libc.src.math.sincosf libc.src.__support.CPP.array libc.src.__support.FPUtil.fp_bits @@ -184,7 +184,7 @@ add_fp_unittest( HDRS sdcomp26094.h DEPENDS - libc.src.errno.errno + libc.hdr.errno_macros libc.src.math.tanf libc.src.__support.CPP.array libc.src.__support.FPUtil.fp_bits @@ -1110,7 +1110,6 @@ add_fp_unittest( SRCS exp_test.cpp DEPENDS - libc.src.errno.errno libc.src.math.exp libc.src.__support.FPUtil.fp_bits ) @@ -1147,7 +1146,6 @@ add_fp_unittest( SRCS exp2_test.cpp DEPENDS - libc.src.errno.errno libc.src.math.exp2 libc.src.__support.FPUtil.fp_bits ) @@ -1209,7 +1207,6 @@ add_fp_unittest( SRCS exp10_test.cpp DEPENDS - libc.src.errno.errno libc.src.math.exp10 libc.src.__support.FPUtil.fp_bits ) @@ -1970,7 +1967,6 @@ add_fp_unittest( SRCS expm1_test.cpp DEPENDS - libc.src.errno.errno libc.src.math.expm1 libc.src.__support.FPUtil.fp_bits ) @@ -2007,7 +2003,6 @@ add_fp_unittest( SRCS log_test.cpp DEPENDS - libc.src.errno.errno libc.src.math.log libc.src.__support.FPUtil.fp_bits ) @@ -2020,7 +2015,6 @@ add_fp_unittest( SRCS logf_test.cpp DEPENDS - libc.src.errno.errno libc.src.math.logf libc.src.__support.FPUtil.fp_bits ) @@ -2044,7 +2038,6 @@ log2_test SRCS log2_test.cpp DEPENDS - libc.src.errno.errno libc.src.math.log2 libc.src.__support.FPUtil.fp_bits ) @@ -2081,7 +2074,6 @@ add_fp_unittest( SRCS log10_test.cpp DEPENDS - libc.src.errno.errno libc.src.math.log10 libc.src.__support.FPUtil.fp_bits ) @@ -2094,7 +2086,6 @@ add_fp_unittest( SRCS log10f_test.cpp DEPENDS - libc.src.errno.errno libc.src.math.log10f libc.src.__support.FPUtil.fp_bits ) @@ -2118,7 +2109,6 @@ log1p_test SRCS log1p_test.cpp DEPENDS - libc.src.errno.errno libc.src.math.log1p libc.src.__support.FPUtil.fp_bits ) @@ -2131,7 +2121,6 @@ add_fp_unittest( SRCS log1pf_test.cpp DEPENDS - libc.src.errno.errno libc.src.math.log1pf libc.src.__support.FPUtil.fp_bits ) @@ -2145,7 +2134,7 @@ add_fp_unittest( HDRS FModTest.h DEPENDS - libc.src.errno.errno + libc.hdr.errno_macros libc.src.math.fmodf libc.src.__support.FPUtil.basic_operations libc.src.__support.FPUtil.nearest_integer_operations @@ -2162,7 +2151,7 @@ add_fp_unittest( HDRS FModTest.h DEPENDS - libc.src.errno.errno + libc.hdr.errno_macros libc.src.math.fmod libc.src.__support.FPUtil.basic_operations libc.src.__support.FPUtil.nearest_integer_operations @@ -2196,7 +2185,7 @@ add_fp_unittest( HDRS sdcomp26094.h DEPENDS - libc.src.errno.errno + libc.hdr.errno_macros libc.src.math.coshf libc.src.__support.CPP.array libc.src.__support.FPUtil.fp_bits @@ -2223,7 +2212,7 @@ add_fp_unittest( HDRS sdcomp26094.h DEPENDS - libc.src.errno.errno + libc.hdr.errno_macros libc.src.math.sinhf libc.src.__support.CPP.array libc.src.__support.FPUtil.fp_bits @@ -2271,7 +2260,7 @@ add_fp_unittest( SRCS atanhf_test.cpp DEPENDS - libc.src.errno.errno + libc.hdr.errno_macros libc.src.math.atanhf libc.src.__support.FPUtil.fp_bits ) @@ -2336,7 +2325,6 @@ add_fp_unittest( SRCS asinhf_test.cpp DEPENDS - libc.src.errno.errno libc.src.math.asinhf libc.src.__support.FPUtil.fp_bits ) @@ -2360,7 +2348,7 @@ add_fp_unittest( SRCS acoshf_test.cpp DEPENDS - libc.src.errno.errno + libc.hdr.errno_macros libc.src.math.acoshf libc.src.__support.FPUtil.fp_bits ) @@ -2384,7 +2372,7 @@ add_fp_unittest( SRCS asinf_test.cpp DEPENDS - libc.src.errno.errno + libc.hdr.errno_macros libc.src.math.asinf libc.src.__support.FPUtil.fp_bits ) @@ -2430,7 +2418,7 @@ add_fp_unittest( SRCS acosf_test.cpp DEPENDS - libc.src.errno.errno + libc.hdr.errno_macros libc.src.math.acosf libc.src.__support.FPUtil.fp_bits ) @@ -2476,7 +2464,6 @@ add_fp_unittest( SRCS atanf_test.cpp DEPENDS - libc.src.errno.errno libc.src.math.atanf libc.src.__support.FPUtil.fp_bits ) diff --git a/libc/test/src/math/FModTest.h b/libc/test/src/math/FModTest.h index f761dba..4792409 100644 --- a/libc/test/src/math/FModTest.h +++ b/libc/test/src/math/FModTest.h @@ -9,6 +9,7 @@ #ifndef LLVM_LIBC_TEST_SRC_MATH_FMODTEST_H #define LLVM_LIBC_TEST_SRC_MATH_FMODTEST_H +#include "hdr/errno_macros.h" #include "src/__support/FPUtil/BasicOperations.h" #include "src/__support/FPUtil/NearestIntegerOperations.h" #include "test/UnitTest/FEnvSafeTest.h" diff --git a/libc/test/src/math/acosf_test.cpp b/libc/test/src/math/acosf_test.cpp index 6e2bed7..3b45749 100644 --- a/libc/test/src/math/acosf_test.cpp +++ b/libc/test/src/math/acosf_test.cpp @@ -6,10 +6,10 @@ // //===----------------------------------------------------------------------===// +#include "hdr/errno_macros.h" #include "hdr/math_macros.h" #include "hdr/stdint_proxy.h" #include "src/__support/FPUtil/FPBits.h" -#include "src/__support/libc_errno.h" #include "src/math/acosf.h" #include "test/UnitTest/FPMatcher.h" #include "test/UnitTest/Test.h" @@ -20,8 +20,6 @@ namespace mpfr = LIBC_NAMESPACE::testing::mpfr; using LlvmLibcAcosfTest = LIBC_NAMESPACE::testing::FPTest<float>; TEST_F(LlvmLibcAcosfTest, SpecialNumbers) { - libc_errno = 0; - EXPECT_FP_EQ_ALL_ROUNDING(aNaN, LIBC_NAMESPACE::acosf(aNaN)); EXPECT_MATH_ERRNO(0); diff --git a/libc/test/src/math/acoshf16_test.cpp b/libc/test/src/math/acoshf16_test.cpp index d190cd1..6e9abde 100644 --- a/libc/test/src/math/acoshf16_test.cpp +++ b/libc/test/src/math/acoshf16_test.cpp @@ -7,7 +7,6 @@ //===----------------------------------------------------------------------===// #include "hdr/stdint_proxy.h" -#include "src/__support/libc_errno.h" #include "src/math/acoshf16.h" #include "test/UnitTest/FPMatcher.h" #include "test/UnitTest/Test.h" diff --git a/libc/test/src/math/acoshf_test.cpp b/libc/test/src/math/acoshf_test.cpp index 3305445..506f176 100644 --- a/libc/test/src/math/acoshf_test.cpp +++ b/libc/test/src/math/acoshf_test.cpp @@ -6,10 +6,10 @@ // //===----------------------------------------------------------------------===// +#include "hdr/errno_macros.h" #include "hdr/math_macros.h" #include "hdr/stdint_proxy.h" #include "src/__support/FPUtil/FPBits.h" -#include "src/__support/libc_errno.h" #include "src/math/acoshf.h" #include "test/UnitTest/FPMatcher.h" #include "test/UnitTest/Test.h" @@ -20,8 +20,6 @@ using LlvmLibcAcoshfTest = LIBC_NAMESPACE::testing::FPTest<float>; namespace mpfr = LIBC_NAMESPACE::testing::mpfr; TEST_F(LlvmLibcAcoshfTest, SpecialNumbers) { - libc_errno = 0; - EXPECT_FP_EQ_ALL_ROUNDING(aNaN, LIBC_NAMESPACE::acoshf(aNaN)); EXPECT_MATH_ERRNO(0); diff --git a/libc/test/src/math/asinf_test.cpp b/libc/test/src/math/asinf_test.cpp index f2963f2..824bc1e 100644 --- a/libc/test/src/math/asinf_test.cpp +++ b/libc/test/src/math/asinf_test.cpp @@ -7,10 +7,10 @@ // //===----------------------------------------------------------------------===// +#include "hdr/errno_macros.h" #include "hdr/math_macros.h" #include "hdr/stdint_proxy.h" #include "src/__support/FPUtil/FPBits.h" -#include "src/__support/libc_errno.h" #include "src/math/asinf.h" #include "test/UnitTest/FPMatcher.h" #include "test/UnitTest/Test.h" @@ -21,8 +21,6 @@ using LlvmLibcAsinfTest = LIBC_NAMESPACE::testing::FPTest<float>; namespace mpfr = LIBC_NAMESPACE::testing::mpfr; TEST_F(LlvmLibcAsinfTest, SpecialNumbers) { - libc_errno = 0; - EXPECT_FP_EQ_ALL_ROUNDING(aNaN, LIBC_NAMESPACE::asinf(aNaN)); EXPECT_MATH_ERRNO(0); diff --git a/libc/test/src/math/asinhf_test.cpp b/libc/test/src/math/asinhf_test.cpp index f9dfb0a..4681aad 100644 --- a/libc/test/src/math/asinhf_test.cpp +++ b/libc/test/src/math/asinhf_test.cpp @@ -9,7 +9,6 @@ #include "hdr/math_macros.h" #include "hdr/stdint_proxy.h" #include "src/__support/FPUtil/FPBits.h" -#include "src/__support/libc_errno.h" #include "src/math/asinhf.h" #include "test/UnitTest/FPMatcher.h" #include "test/UnitTest/Test.h" @@ -20,8 +19,6 @@ using LlvmLibcAsinhfTest = LIBC_NAMESPACE::testing::FPTest<float>; namespace mpfr = LIBC_NAMESPACE::testing::mpfr; TEST_F(LlvmLibcAsinhfTest, SpecialNumbers) { - libc_errno = 0; - EXPECT_FP_EQ_ALL_ROUNDING(aNaN, LIBC_NAMESPACE::asinhf(aNaN)); EXPECT_MATH_ERRNO(0); diff --git a/libc/test/src/math/atanf_test.cpp b/libc/test/src/math/atanf_test.cpp index dc489fe..30b42b5 100644 --- a/libc/test/src/math/atanf_test.cpp +++ b/libc/test/src/math/atanf_test.cpp @@ -9,7 +9,6 @@ #include "hdr/math_macros.h" #include "hdr/stdint_proxy.h" #include "src/__support/FPUtil/FPBits.h" -#include "src/__support/libc_errno.h" #include "src/math/atanf.h" #include "test/UnitTest/FPMatcher.h" #include "test/UnitTest/Test.h" @@ -22,7 +21,6 @@ namespace mpfr = LIBC_NAMESPACE::testing::mpfr; // TODO: This test needs to have its checks for exceptions, errno // tightened TEST_F(LlvmLibcAtanfTest, SpecialNumbers) { - libc_errno = 0; LIBC_NAMESPACE::fputil::clear_except(FE_ALL_EXCEPT); EXPECT_FP_EQ_ALL_ROUNDING(aNaN, LIBC_NAMESPACE::atanf(aNaN)); // TODO: Uncomment these checks later, RoundingMode affects running diff --git a/libc/test/src/math/atanhf_test.cpp b/libc/test/src/math/atanhf_test.cpp index 1ec7b6b..43bde8c 100644 --- a/libc/test/src/math/atanhf_test.cpp +++ b/libc/test/src/math/atanhf_test.cpp @@ -6,10 +6,10 @@ // //===----------------------------------------------------------------------===// +#include "hdr/errno_macros.h" #include "hdr/math_macros.h" #include "hdr/stdint_proxy.h" #include "src/__support/FPUtil/FPBits.h" -#include "src/__support/libc_errno.h" #include "src/math/atanhf.h" #include "test/UnitTest/FPMatcher.h" #include "test/UnitTest/Test.h" @@ -23,8 +23,6 @@ namespace mpfr = LIBC_NAMESPACE::testing::mpfr; // TODO: This test needs to have its checks for exceptions, errno // tightened https://github.com/llvm/llvm-project/issues/88819. TEST_F(LlvmLibcAtanhfTest, SpecialNumbers) { - - libc_errno = 0; LIBC_NAMESPACE::fputil::clear_except(FE_ALL_EXCEPT); EXPECT_FP_EQ_ALL_ROUNDING(aNaN, LIBC_NAMESPACE::atanhf(aNaN)); // TODO: Uncomment these checks later, RoundingMode affects running diff --git a/libc/test/src/math/cosf_test.cpp b/libc/test/src/math/cosf_test.cpp index e2b444f..6afaa42 100644 --- a/libc/test/src/math/cosf_test.cpp +++ b/libc/test/src/math/cosf_test.cpp @@ -6,10 +6,10 @@ // //===----------------------------------------------------------------------===// +#include "hdr/errno_macros.h" #include "hdr/math_macros.h" #include "hdr/stdint_proxy.h" #include "src/__support/FPUtil/FPBits.h" -#include "src/__support/libc_errno.h" #include "src/math/cosf.h" #include "test/UnitTest/FPMatcher.h" #include "test/UnitTest/Test.h" @@ -22,8 +22,6 @@ using LlvmLibcCosfTest = LIBC_NAMESPACE::testing::FPTest<float>; namespace mpfr = LIBC_NAMESPACE::testing::mpfr; TEST_F(LlvmLibcCosfTest, SpecialNumbers) { - libc_errno = 0; - EXPECT_FP_EQ(aNaN, LIBC_NAMESPACE::cosf(aNaN)); EXPECT_MATH_ERRNO(0); diff --git a/libc/test/src/math/coshf_test.cpp b/libc/test/src/math/coshf_test.cpp index 98f9a82..6c53fda 100644 --- a/libc/test/src/math/coshf_test.cpp +++ b/libc/test/src/math/coshf_test.cpp @@ -6,11 +6,11 @@ // //===----------------------------------------------------------------------===// +#include "hdr/errno_macros.h" #include "hdr/math_macros.h" #include "hdr/stdint_proxy.h" #include "src/__support/CPP/array.h" #include "src/__support/FPUtil/FPBits.h" -#include "src/__support/libc_errno.h" #include "src/math/coshf.h" #include "test/UnitTest/FPMatcher.h" #include "test/UnitTest/Test.h" @@ -21,8 +21,6 @@ using LlvmLibcCoshfTest = LIBC_NAMESPACE::testing::FPTest<float>; namespace mpfr = LIBC_NAMESPACE::testing::mpfr; TEST_F(LlvmLibcCoshfTest, SpecialNumbers) { - libc_errno = 0; - EXPECT_FP_EQ(aNaN, LIBC_NAMESPACE::coshf(aNaN)); EXPECT_MATH_ERRNO(0); @@ -40,7 +38,6 @@ TEST_F(LlvmLibcCoshfTest, SpecialNumbers) { } TEST_F(LlvmLibcCoshfTest, Overflow) { - libc_errno = 0; EXPECT_FP_EQ_WITH_EXCEPTION( inf, LIBC_NAMESPACE::coshf(FPBits(0x7f7fffffU).get_val()), FE_OVERFLOW); EXPECT_MATH_ERRNO(ERANGE); diff --git a/libc/test/src/math/cospif_test.cpp b/libc/test/src/math/cospif_test.cpp index 5c30fb7..0026e91 100644 --- a/libc/test/src/math/cospif_test.cpp +++ b/libc/test/src/math/cospif_test.cpp @@ -6,7 +6,7 @@ // //===----------------------------------------------------------------------===// -#include "src/__support/libc_errno.h" +#include "hdr/errno_macros.h" #include "src/math/cospif.h" #include "test/UnitTest/FPMatcher.h" #include "test/src/math/sdcomp26094.h" @@ -19,8 +19,6 @@ using LIBC_NAMESPACE::testing::SDCOMP26094_VALUES; namespace mpfr = LIBC_NAMESPACE::testing::mpfr; TEST_F(LlvmLibcCospifTest, SpecialNumbers) { - libc_errno = 0; - EXPECT_FP_EQ(aNaN, LIBC_NAMESPACE::cospif(aNaN)); EXPECT_MATH_ERRNO(0); diff --git a/libc/test/src/math/exp10_test.cpp b/libc/test/src/math/exp10_test.cpp index ee8fe9b..2ddcef0 100644 --- a/libc/test/src/math/exp10_test.cpp +++ b/libc/test/src/math/exp10_test.cpp @@ -8,7 +8,6 @@ #include "hdr/math_macros.h" #include "src/__support/FPUtil/FPBits.h" -#include "src/__support/libc_errno.h" #include "src/math/exp10.h" #include "test/UnitTest/FPMatcher.h" #include "test/UnitTest/Test.h" @@ -105,7 +104,6 @@ TEST_F(LlvmLibcExp10Test, InDoubleRange) { double x = FPBits(v).get_val(); if (FPBits(v).is_nan() || FPBits(v).is_inf() || x < 0.0) continue; - libc_errno = 0; double result = LIBC_NAMESPACE::exp10(x); ++cc; if (FPBits(result).is_nan() || FPBits(result).is_inf()) diff --git a/libc/test/src/math/exp10f_test.cpp b/libc/test/src/math/exp10f_test.cpp index e2021423..f6a8cf5 100644 --- a/libc/test/src/math/exp10f_test.cpp +++ b/libc/test/src/math/exp10f_test.cpp @@ -21,8 +21,6 @@ using LlvmLibcExp10fTest = LIBC_NAMESPACE::testing::FPTest<float>; namespace mpfr = LIBC_NAMESPACE::testing::mpfr; TEST_F(LlvmLibcExp10fTest, SpecialNumbers) { - libc_errno = 0; - EXPECT_FP_EQ(aNaN, LIBC_NAMESPACE::exp10f(aNaN)); EXPECT_MATH_ERRNO(0); @@ -40,7 +38,6 @@ TEST_F(LlvmLibcExp10fTest, SpecialNumbers) { } TEST_F(LlvmLibcExp10fTest, Overflow) { - libc_errno = 0; EXPECT_FP_EQ_WITH_EXCEPTION( inf, LIBC_NAMESPACE::exp10f(FPBits(0x7f7fffffU).get_val()), FE_OVERFLOW); EXPECT_MATH_ERRNO(ERANGE); @@ -55,7 +52,6 @@ TEST_F(LlvmLibcExp10fTest, Overflow) { } TEST_F(LlvmLibcExp10fTest, Underflow) { - libc_errno = 0; EXPECT_FP_EQ_WITH_EXCEPTION( 0.0f, LIBC_NAMESPACE::exp10f(FPBits(0xff7fffffU).get_val()), FE_UNDERFLOW); @@ -97,7 +93,6 @@ TEST_F(LlvmLibcExp10fTest, TrickyInputs) { 0x41200000, // x = 10.0f }; for (int i = 0; i < N; ++i) { - libc_errno = 0; float x = FPBits(INPUTS[i]).get_val(); EXPECT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Exp10, x, LIBC_NAMESPACE::exp10f(x), 0.5); diff --git a/libc/test/src/math/exp10m1f_test.cpp b/libc/test/src/math/exp10m1f_test.cpp index 613fdeb..009c85d 100644 --- a/libc/test/src/math/exp10m1f_test.cpp +++ b/libc/test/src/math/exp10m1f_test.cpp @@ -69,7 +69,6 @@ TEST_F(LlvmLibcExp10m1fTest, TrickyInputs) { }; for (float x : INPUTS) { - libc_errno = 0; EXPECT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Exp10m1, x, LIBC_NAMESPACE::exp10m1f(x), 0.5); } diff --git a/libc/test/src/math/exp2_test.cpp b/libc/test/src/math/exp2_test.cpp index 7866037..a3dcb58 100644 --- a/libc/test/src/math/exp2_test.cpp +++ b/libc/test/src/math/exp2_test.cpp @@ -8,7 +8,6 @@ #include "hdr/math_macros.h" #include "src/__support/FPUtil/FPBits.h" -#include "src/__support/libc_errno.h" #include "src/math/exp2.h" #include "test/UnitTest/FPMatcher.h" #include "test/UnitTest/Test.h" @@ -80,7 +79,6 @@ TEST_F(LlvmLibcExp2Test, InDoubleRange) { double x = FPBits(v).get_val(); if (FPBits(v).is_nan() || FPBits(v).is_inf() || x < 0.0) continue; - libc_errno = 0; double result = LIBC_NAMESPACE::exp2(x); ++cc; if (FPBits(result).is_nan() || FPBits(result).is_inf()) diff --git a/libc/test/src/math/exp2f_test.cpp b/libc/test/src/math/exp2f_test.cpp index 349a4c3..94141dda 100644 --- a/libc/test/src/math/exp2f_test.cpp +++ b/libc/test/src/math/exp2f_test.cpp @@ -21,8 +21,6 @@ using LlvmLibcExp2fTest = LIBC_NAMESPACE::testing::FPTest<float>; namespace mpfr = LIBC_NAMESPACE::testing::mpfr; TEST_F(LlvmLibcExp2fTest, SpecialNumbers) { - libc_errno = 0; - EXPECT_FP_EQ(aNaN, LIBC_NAMESPACE::exp2f(aNaN)); EXPECT_MATH_ERRNO(0); @@ -40,7 +38,6 @@ TEST_F(LlvmLibcExp2fTest, SpecialNumbers) { } TEST_F(LlvmLibcExp2fTest, Overflow) { - libc_errno = 0; EXPECT_FP_EQ_WITH_EXCEPTION( inf, LIBC_NAMESPACE::exp2f(FPBits(0x7f7fffffU).get_val()), FE_OVERFLOW); EXPECT_MATH_ERRNO(ERANGE); @@ -80,7 +77,6 @@ TEST_F(LlvmLibcExp2fTest, TrickyInputs) { } TEST_F(LlvmLibcExp2fTest, Underflow) { - libc_errno = 0; EXPECT_FP_EQ_WITH_EXCEPTION( 0.0f, LIBC_NAMESPACE::exp2f(FPBits(0xff7fffffU).get_val()), FE_UNDERFLOW); EXPECT_MATH_ERRNO(ERANGE); diff --git a/libc/test/src/math/exp2m1f_test.cpp b/libc/test/src/math/exp2m1f_test.cpp index a323bdc..7e9f6b5 100644 --- a/libc/test/src/math/exp2m1f_test.cpp +++ b/libc/test/src/math/exp2m1f_test.cpp @@ -38,7 +38,6 @@ TEST_F(LlvmLibcExp2m1fTest, TrickyInputs) { }; for (float x : INPUTS) { - libc_errno = 0; EXPECT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Exp2m1, x, LIBC_NAMESPACE::exp2m1f(x), 0.5); } diff --git a/libc/test/src/math/exp_test.cpp b/libc/test/src/math/exp_test.cpp index d328d09..854bb51 100644 --- a/libc/test/src/math/exp_test.cpp +++ b/libc/test/src/math/exp_test.cpp @@ -8,7 +8,6 @@ #include "hdr/math_macros.h" #include "src/__support/FPUtil/FPBits.h" -#include "src/__support/libc_errno.h" #include "src/math/exp.h" #include "test/UnitTest/FPMatcher.h" #include "test/UnitTest/Test.h" @@ -78,7 +77,6 @@ TEST_F(LlvmLibcExpTest, InDoubleRange) { double x = FPBits(v).get_val(); if (FPBits(v).is_nan() || FPBits(v).is_inf() || x < 0.0) continue; - libc_errno = 0; double result = LIBC_NAMESPACE::exp(x); ++cc; if (FPBits(result).is_nan() || FPBits(result).is_inf()) diff --git a/libc/test/src/math/expf_test.cpp b/libc/test/src/math/expf_test.cpp index 8329d74..1695a60 100644 --- a/libc/test/src/math/expf_test.cpp +++ b/libc/test/src/math/expf_test.cpp @@ -21,8 +21,6 @@ using LlvmLibcExpfTest = LIBC_NAMESPACE::testing::FPTest<float>; namespace mpfr = LIBC_NAMESPACE::testing::mpfr; TEST_F(LlvmLibcExpfTest, SpecialNumbers) { - libc_errno = 0; - EXPECT_FP_EQ(aNaN, LIBC_NAMESPACE::expf(aNaN)); EXPECT_MATH_ERRNO(0); @@ -40,7 +38,6 @@ TEST_F(LlvmLibcExpfTest, SpecialNumbers) { } TEST_F(LlvmLibcExpfTest, Overflow) { - libc_errno = 0; EXPECT_FP_EQ_WITH_EXCEPTION( inf, LIBC_NAMESPACE::expf(FPBits(0x7f7fffffU).get_val()), FE_OVERFLOW); EXPECT_MATH_ERRNO(ERANGE); @@ -55,7 +52,6 @@ TEST_F(LlvmLibcExpfTest, Overflow) { } TEST_F(LlvmLibcExpfTest, Underflow) { - libc_errno = 0; EXPECT_FP_EQ_WITH_EXCEPTION( 0.0f, LIBC_NAMESPACE::expf(FPBits(0xff7fffffU).get_val()), FE_UNDERFLOW); EXPECT_MATH_ERRNO(ERANGE); @@ -76,7 +72,6 @@ TEST_F(LlvmLibcExpfTest, Underflow) { TEST_F(LlvmLibcExpfTest, Borderline) { float x; - libc_errno = 0; x = FPBits(0x42affff8U).get_val(); ASSERT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Exp, x, LIBC_NAMESPACE::expf(x), 0.5); diff --git a/libc/test/src/math/expm1_test.cpp b/libc/test/src/math/expm1_test.cpp index 5d546de..c185be9 100644 --- a/libc/test/src/math/expm1_test.cpp +++ b/libc/test/src/math/expm1_test.cpp @@ -8,7 +8,6 @@ #include "hdr/math_macros.h" #include "src/__support/FPUtil/FPBits.h" -#include "src/__support/libc_errno.h" #include "src/math/expm1.h" #include "test/UnitTest/FPMatcher.h" #include "test/UnitTest/Test.h" @@ -64,7 +63,6 @@ TEST_F(LlvmLibcExpm1Test, InDoubleRange) { double x = FPBits(v).get_val(); if (FPBits(v).is_nan() || FPBits(v).is_inf() || x < 0.0) continue; - libc_errno = 0; double result = LIBC_NAMESPACE::expm1(x); ++cc; if (FPBits(result).is_nan() || FPBits(result).is_inf()) diff --git a/libc/test/src/math/expm1f_test.cpp b/libc/test/src/math/expm1f_test.cpp index d5c98be..28d7106 100644 --- a/libc/test/src/math/expm1f_test.cpp +++ b/libc/test/src/math/expm1f_test.cpp @@ -21,8 +21,6 @@ using LlvmLibcExpm1fTest = LIBC_NAMESPACE::testing::FPTest<float>; namespace mpfr = LIBC_NAMESPACE::testing::mpfr; TEST_F(LlvmLibcExpm1fTest, SpecialNumbers) { - libc_errno = 0; - EXPECT_FP_EQ(aNaN, LIBC_NAMESPACE::expm1f(aNaN)); EXPECT_MATH_ERRNO(0); @@ -40,7 +38,6 @@ TEST_F(LlvmLibcExpm1fTest, SpecialNumbers) { } TEST_F(LlvmLibcExpm1fTest, Overflow) { - libc_errno = 0; EXPECT_FP_EQ_WITH_EXCEPTION( inf, LIBC_NAMESPACE::expm1f(FPBits(0x7f7fffffU).get_val()), FE_OVERFLOW); EXPECT_MATH_ERRNO(ERANGE); @@ -55,7 +52,6 @@ TEST_F(LlvmLibcExpm1fTest, Overflow) { } TEST_F(LlvmLibcExpm1fTest, Underflow) { - libc_errno = 0; EXPECT_FP_EQ(-1.0f, LIBC_NAMESPACE::expm1f(FPBits(0xff7fffffU).get_val())); float x = FPBits(0xc2cffff8U).get_val(); @@ -70,7 +66,6 @@ TEST_F(LlvmLibcExpm1fTest, Underflow) { TEST_F(LlvmLibcExpm1fTest, Borderline) { float x; - libc_errno = 0; x = FPBits(0x42affff8U).get_val(); ASSERT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Expm1, x, LIBC_NAMESPACE::expm1f(x), 0.5); diff --git a/libc/test/src/math/log10_test.cpp b/libc/test/src/math/log10_test.cpp index 7d087d4e..62a19d02 100644 --- a/libc/test/src/math/log10_test.cpp +++ b/libc/test/src/math/log10_test.cpp @@ -8,7 +8,6 @@ #include "hdr/math_macros.h" #include "src/__support/FPUtil/FPBits.h" -#include "src/__support/libc_errno.h" #include "src/math/log10.h" #include "test/UnitTest/FPMatcher.h" #include "test/UnitTest/Test.h" @@ -101,7 +100,6 @@ TEST_F(LlvmLibcLog10Test, InDoubleRange) { double x = FPBits(v).get_val(); if (FPBits(v).is_nan() || FPBits(v).is_inf() || x < 0.0) continue; - libc_errno = 0; double result = LIBC_NAMESPACE::log10(x); ++cc; if (FPBits(result).is_nan() || FPBits(result).is_inf()) diff --git a/libc/test/src/math/log1p_test.cpp b/libc/test/src/math/log1p_test.cpp index 4d1efe7..be83ce8 100644 --- a/libc/test/src/math/log1p_test.cpp +++ b/libc/test/src/math/log1p_test.cpp @@ -8,7 +8,6 @@ #include "hdr/math_macros.h" #include "src/__support/FPUtil/FPBits.h" -#include "src/__support/libc_errno.h" #include "src/math/log1p.h" #include "test/UnitTest/FPMatcher.h" #include "test/UnitTest/Test.h" @@ -102,7 +101,6 @@ TEST_F(LlvmLibcLog1pTest, InDoubleRange) { double x = FPBits(v).get_val(); if (FPBits(v).is_nan() || FPBits(v).is_inf() || x < 0.0) continue; - libc_errno = 0; double result = LIBC_NAMESPACE::log1p(x); ++cc; if (FPBits(result).is_nan() || FPBits(result).is_inf()) diff --git a/libc/test/src/math/log1pf_test.cpp b/libc/test/src/math/log1pf_test.cpp index 0badbeb..2df4526 100644 --- a/libc/test/src/math/log1pf_test.cpp +++ b/libc/test/src/math/log1pf_test.cpp @@ -8,7 +8,6 @@ #include "hdr/math_macros.h" #include "src/__support/FPUtil/FPBits.h" -#include "src/__support/libc_errno.h" #include "src/math/log1pf.h" #include "test/UnitTest/FPMatcher.h" #include "test/UnitTest/Test.h" @@ -75,7 +74,6 @@ TEST_F(LlvmLibcLog1pfTest, InFloatRange) { float x = FPBits(v).get_val(); if (FPBits(v).is_nan() || FPBits(v).is_inf()) continue; - libc_errno = 0; ASSERT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Log1p, x, LIBC_NAMESPACE::log1pf(x), 0.5); } diff --git a/libc/test/src/math/log2_test.cpp b/libc/test/src/math/log2_test.cpp index dd55bd8..824a8a5 100644 --- a/libc/test/src/math/log2_test.cpp +++ b/libc/test/src/math/log2_test.cpp @@ -8,7 +8,6 @@ #include "hdr/math_macros.h" #include "src/__support/FPUtil/FPBits.h" -#include "src/__support/libc_errno.h" #include "src/math/log2.h" #include "test/UnitTest/FPMatcher.h" #include "test/UnitTest/Test.h" @@ -100,7 +99,6 @@ TEST_F(LlvmLibcLog2Test, InDoubleRange) { double x = FPBits(v).get_val(); if (FPBits(v).is_nan() || FPBits(v).is_inf() || x < 0.0) continue; - libc_errno = 0; double result = LIBC_NAMESPACE::log2(x); ++cc; if (FPBits(result).is_nan() || FPBits(result).is_inf()) diff --git a/libc/test/src/math/log_test.cpp b/libc/test/src/math/log_test.cpp index be156fe..a68d1687 100644 --- a/libc/test/src/math/log_test.cpp +++ b/libc/test/src/math/log_test.cpp @@ -8,7 +8,6 @@ #include "hdr/math_macros.h" #include "src/__support/FPUtil/FPBits.h" -#include "src/__support/libc_errno.h" #include "src/math/log.h" #include "test/UnitTest/FPMatcher.h" #include "test/UnitTest/Test.h" @@ -99,7 +98,6 @@ TEST_F(LlvmLibcLogTest, InDoubleRange) { double x = FPBits(v).get_val(); if (FPBits(v).is_nan() || FPBits(v).is_inf() || x < 0.0) continue; - libc_errno = 0; double result = LIBC_NAMESPACE::log(x); ++cc; if (FPBits(result).is_nan() || FPBits(result).is_inf()) diff --git a/libc/test/src/math/sincosf_test.cpp b/libc/test/src/math/sincosf_test.cpp index 9c2656f..87e995d 100644 --- a/libc/test/src/math/sincosf_test.cpp +++ b/libc/test/src/math/sincosf_test.cpp @@ -6,9 +6,9 @@ // //===----------------------------------------------------------------------===// +#include "hdr/errno_macros.h" #include "hdr/math_macros.h" #include "src/__support/FPUtil/FPBits.h" -#include "src/__support/libc_errno.h" #include "src/math/sincosf.h" #include "test/UnitTest/FPMatcher.h" #include "test/UnitTest/Test.h" @@ -24,7 +24,6 @@ using LIBC_NAMESPACE::testing::SDCOMP26094_VALUES; namespace mpfr = LIBC_NAMESPACE::testing::mpfr; TEST_F(LlvmLibcSinCosfTest, SpecialNumbers) { - libc_errno = 0; float sin, cos; LIBC_NAMESPACE::sincosf(aNaN, &sin, &cos); diff --git a/libc/test/src/math/sinf_test.cpp b/libc/test/src/math/sinf_test.cpp index c4676d9..42de7af 100644 --- a/libc/test/src/math/sinf_test.cpp +++ b/libc/test/src/math/sinf_test.cpp @@ -6,9 +6,9 @@ // //===----------------------------------------------------------------------===// +#include "hdr/errno_macros.h" #include "hdr/math_macros.h" #include "src/__support/FPUtil/FPBits.h" -#include "src/__support/libc_errno.h" #include "src/math/sinf.h" #include "test/UnitTest/FPMatcher.h" #include "test/UnitTest/Test.h" @@ -24,8 +24,6 @@ using LIBC_NAMESPACE::testing::SDCOMP26094_VALUES; namespace mpfr = LIBC_NAMESPACE::testing::mpfr; TEST_F(LlvmLibcSinfTest, SpecialNumbers) { - libc_errno = 0; - EXPECT_FP_EQ(aNaN, LIBC_NAMESPACE::sinf(aNaN)); EXPECT_MATH_ERRNO(0); diff --git a/libc/test/src/math/sinhf_test.cpp b/libc/test/src/math/sinhf_test.cpp index a664010..6f9ac2f 100644 --- a/libc/test/src/math/sinhf_test.cpp +++ b/libc/test/src/math/sinhf_test.cpp @@ -6,10 +6,10 @@ // //===----------------------------------------------------------------------===// +#include "hdr/errno_macros.h" #include "hdr/math_macros.h" #include "src/__support/CPP/array.h" #include "src/__support/FPUtil/FPBits.h" -#include "src/__support/libc_errno.h" #include "src/math/sinhf.h" #include "test/UnitTest/FPMatcher.h" #include "test/UnitTest/Test.h" @@ -22,8 +22,6 @@ using LlvmLibcSinhfTest = LIBC_NAMESPACE::testing::FPTest<float>; namespace mpfr = LIBC_NAMESPACE::testing::mpfr; TEST_F(LlvmLibcSinhfTest, SpecialNumbers) { - libc_errno = 0; - EXPECT_FP_EQ(aNaN, LIBC_NAMESPACE::sinhf(aNaN)); EXPECT_MATH_ERRNO(0); @@ -65,7 +63,6 @@ TEST_F(LlvmLibcSinhfTest, SmallValues) { } TEST_F(LlvmLibcSinhfTest, Overflow) { - libc_errno = 0; EXPECT_FP_EQ_WITH_EXCEPTION( inf, LIBC_NAMESPACE::sinhf(FPBits(0x7f7fffffU).get_val()), FE_OVERFLOW); EXPECT_MATH_ERRNO(ERANGE); diff --git a/libc/test/src/math/sinpif_test.cpp b/libc/test/src/math/sinpif_test.cpp index 2e66ae9..cac79e7 100644 --- a/libc/test/src/math/sinpif_test.cpp +++ b/libc/test/src/math/sinpif_test.cpp @@ -6,7 +6,7 @@ // //===----------------------------------------------------------------------===// -#include "src/__support/libc_errno.h" +#include "hdr/errno_macros.h" #include "src/math/sinpif.h" #include "test/UnitTest/FPMatcher.h" #include "test/src/math/sdcomp26094.h" @@ -21,8 +21,6 @@ using LIBC_NAMESPACE::testing::SDCOMP26094_VALUES; namespace mpfr = LIBC_NAMESPACE::testing::mpfr; TEST_F(LlvmLibcSinpifTest, SpecialNumbers) { - libc_errno = 0; - EXPECT_FP_EQ(aNaN, LIBC_NAMESPACE::sinpif(aNaN)); EXPECT_MATH_ERRNO(0); diff --git a/libc/test/src/math/smoke/CMakeLists.txt b/libc/test/src/math/smoke/CMakeLists.txt index 9c99b8a..b8d5ecf 100644 --- a/libc/test/src/math/smoke/CMakeLists.txt +++ b/libc/test/src/math/smoke/CMakeLists.txt @@ -8,7 +8,7 @@ add_fp_unittest( SRCS cosf_test.cpp DEPENDS - libc.src.errno.errno + libc.hdr.errno_macros libc.src.math.cosf ) @@ -19,7 +19,7 @@ add_fp_unittest( SRCS cosf16_test.cpp DEPENDS - libc.src.errno.errno + libc.hdr.errno_macros libc.src.math.cosf16 ) @@ -30,7 +30,7 @@ add_fp_unittest( SRCS cospif_test.cpp DEPENDS - libc.src.errno.errno + libc.hdr.errno_macros libc.src.math.cospif libc.src.__support.CPP.array libc.src.__support.FPUtil.fp_bits @@ -43,7 +43,7 @@ add_fp_unittest( SRCS cospif16_test.cpp DEPENDS - libc.src.errno.errno + libc.hdr.errno_macros libc.src.math.cospif16 libc.src.__support.FPUtil.cast ) @@ -55,7 +55,7 @@ add_fp_unittest( SRCS sinf_test.cpp DEPENDS - libc.src.errno.errno + libc.hdr.errno_macros libc.src.math.sinf libc.src.__support.CPP.array libc.src.__support.FPUtil.fp_bits @@ -68,7 +68,7 @@ add_fp_unittest( SRCS sinf16_test.cpp DEPENDS - libc.src.errno.errno + libc.hdr.errno_macros libc.src.math.sinf16 libc.src.__support.FPUtil.cast ) @@ -80,7 +80,7 @@ add_fp_unittest( SRCS sinpif_test.cpp DEPENDS - libc.src.errno.errno + libc.hdr.errno_macros libc.src.math.sinpif libc.src.__support.CPP.array libc.src.__support.FPUtil.fp_bits @@ -93,7 +93,7 @@ add_fp_unittest( SRCS sinpif16_test.cpp DEPENDS - libc.src.errno.errno + libc.hdr.errno_macros libc.src.math.sinpif16 ) @@ -104,7 +104,7 @@ add_fp_unittest( SRCS sincosf_test.cpp DEPENDS - libc.src.errno.errno + libc.hdr.errno_macros libc.src.math.sincosf libc.src.__support.CPP.array libc.src.__support.FPUtil.fp_bits @@ -117,7 +117,7 @@ add_fp_unittest( SRCS tanf_test.cpp DEPENDS - libc.src.errno.errno + libc.hdr.errno_macros libc.src.math.tanf libc.src.__support.CPP.array libc.src.__support.FPUtil.fp_bits @@ -130,7 +130,7 @@ add_fp_unittest( SRCS tanf16_test.cpp DEPENDS - libc.src.errno.errno + libc.hdr.errno_macros libc.src.math.tanf16 ) @@ -141,7 +141,7 @@ add_fp_unittest( SRCS tanpif_test.cpp DEPENDS - libc.src.errno.errno + libc.hdr.errno_macros libc.src.math.tanpif ) @@ -152,7 +152,7 @@ add_fp_unittest( SRCS tanpif16_test.cpp DEPENDS - libc.src.errno.errno + libc.hdr.errno_macros libc.src.math.tanpif16 ) @@ -633,7 +633,7 @@ add_fp_unittest( HDRS SubTest.h DEPENDS - libc.src.errno.errno + libc.hdr.errno_macros libc.hdr.fenv_macros libc.src.math.dsubl libc.src.__support.macros.properties.os @@ -1365,7 +1365,7 @@ add_fp_unittest( SRCS exp_test.cpp DEPENDS - libc.src.errno.errno + libc.hdr.errno_macros libc.src.math.exp libc.src.__support.FPUtil.fp_bits ) @@ -1377,7 +1377,7 @@ add_fp_unittest( SRCS expf_test.cpp DEPENDS - libc.src.errno.errno + libc.hdr.errno_macros libc.src.math.expf libc.src.__support.FPUtil.fp_bits ) @@ -1391,7 +1391,6 @@ add_fp_unittest( DEPENDS libc.hdr.errno_macros libc.hdr.fenv_macros - libc.src.errno.errno libc.src.math.expf16 libc.src.__support.FPUtil.cast ) @@ -1403,7 +1402,7 @@ add_fp_unittest( SRCS exp2_test.cpp DEPENDS - libc.src.errno.errno + libc.hdr.errno_macros libc.src.math.exp2 libc.src.__support.FPUtil.fp_bits ) @@ -1415,7 +1414,7 @@ add_fp_unittest( SRCS exp2f_test.cpp DEPENDS - libc.src.errno.errno + libc.hdr.errno_macros libc.src.math.exp2f libc.src.__support.FPUtil.fp_bits ) @@ -1427,8 +1426,8 @@ add_fp_unittest( SRCS exp2f16_test.cpp DEPENDS + libc.hdr.errno_macros libc.hdr.fenv_macros - libc.src.errno.errno libc.src.math.exp2f16 libc.src.__support.FPUtil.cast ) @@ -1440,7 +1439,7 @@ add_fp_unittest( SRCS exp2m1f_test.cpp DEPENDS - libc.src.errno.errno + libc.hdr.errno_macros libc.src.math.exp2m1f ) @@ -1451,8 +1450,8 @@ add_fp_unittest( SRCS exp2m1f16_test.cpp DEPENDS + libc.hdr.errno_macros libc.hdr.fenv_macros - libc.src.errno.errno libc.src.math.exp2m1f16 libc.src.__support.FPUtil.cast ) @@ -1464,7 +1463,7 @@ add_fp_unittest( SRCS exp10_test.cpp DEPENDS - libc.src.errno.errno + libc.hdr.errno_macros libc.src.math.exp10 libc.src.__support.FPUtil.fp_bits ) @@ -1476,7 +1475,7 @@ add_fp_unittest( SRCS exp10f_test.cpp DEPENDS - libc.src.errno.errno + libc.hdr.errno_macros libc.src.math.exp10f libc.src.__support.FPUtil.fp_bits ) @@ -1488,8 +1487,8 @@ add_fp_unittest( SRCS exp10f16_test.cpp DEPENDS + libc.hdr.errno_macros libc.hdr.fenv_macros - libc.src.errno.errno libc.src.math.exp10f16 libc.src.__support.FPUtil.cast ) @@ -1501,8 +1500,8 @@ add_fp_unittest( SRCS exp10m1f16_test.cpp DEPENDS + libc.hdr.errno_macros libc.hdr.fenv_macros - libc.src.errno.errno libc.src.math.exp10m1f16 libc.src.__support.FPUtil.cast ) @@ -1514,7 +1513,7 @@ add_fp_unittest( SRCS exp10m1f_test.cpp DEPENDS - libc.src.errno.errno + libc.hdr.errno_macros libc.src.math.exp10m1f ) @@ -4265,7 +4264,7 @@ add_fp_unittest( SRCS expm1_test.cpp DEPENDS - libc.src.errno.errno + libc.hdr.errno_macros libc.src.math.expm1 libc.src.__support.FPUtil.fp_bits ) @@ -4277,7 +4276,7 @@ add_fp_unittest( SRCS expm1f_test.cpp DEPENDS - libc.src.errno.errno + libc.hdr.errno_macros libc.src.math.expm1f libc.src.__support.FPUtil.fp_bits ) @@ -4291,7 +4290,6 @@ add_fp_unittest( DEPENDS libc.hdr.errno_macros libc.hdr.fenv_macros - libc.src.errno.errno libc.src.math.expm1f16 libc.src.__support.FPUtil.cast ) @@ -4303,7 +4301,7 @@ add_fp_unittest( SRCS log_test.cpp DEPENDS - libc.src.errno.errno + libc.hdr.errno_macros libc.src.math.log libc.src.__support.FPUtil.fp_bits ) @@ -4315,7 +4313,7 @@ add_fp_unittest( SRCS logf_test.cpp DEPENDS - libc.src.errno.errno + libc.hdr.errno_macros libc.src.math.logf libc.src.__support.FPUtil.fp_bits ) @@ -4327,8 +4325,8 @@ add_fp_unittest( SRCS logf16_test.cpp DEPENDS + libc.hdr.errno_macros libc.hdr.fenv_macros - libc.src.errno.errno libc.src.math.logf16 libc.src.__support.FPUtil.cast ) @@ -4340,7 +4338,7 @@ add_fp_unittest( SRCS log2_test.cpp DEPENDS - libc.src.errno.errno + libc.hdr.errno_macros libc.src.math.log2 libc.src.__support.FPUtil.fp_bits ) @@ -4352,7 +4350,7 @@ add_fp_unittest( SRCS log2f_test.cpp DEPENDS - libc.src.errno.errno + libc.hdr.errno_macros libc.src.math.log2f libc.src.__support.FPUtil.fp_bits ) @@ -4364,8 +4362,8 @@ add_fp_unittest( SRCS log2f16_test.cpp DEPENDS + libc.hdr.errno_macros libc.hdr.fenv_macros - libc.src.errno.errno libc.src.math.log2f16 libc.src.__support.FPUtil.cast ) @@ -4377,7 +4375,7 @@ add_fp_unittest( SRCS log10_test.cpp DEPENDS - libc.src.errno.errno + libc.hdr.errno_macros libc.src.math.log10 libc.src.__support.FPUtil.fp_bits ) @@ -4389,7 +4387,7 @@ add_fp_unittest( SRCS log10f_test.cpp DEPENDS - libc.src.errno.errno + libc.hdr.errno_macros libc.src.math.log10f libc.src.__support.FPUtil.fp_bits ) @@ -4401,8 +4399,8 @@ add_fp_unittest( SRCS log10f16_test.cpp DEPENDS + libc.hdr.errno_macros libc.hdr.fenv_macros - libc.src.errno.errno libc.src.math.log10f16 libc.src.__support.FPUtil.cast ) @@ -4414,7 +4412,7 @@ add_fp_unittest( SRCS log1p_test.cpp DEPENDS - libc.src.errno.errno + libc.hdr.errno_macros libc.src.math.log1p libc.src.__support.FPUtil.fp_bits ) @@ -4426,7 +4424,7 @@ add_fp_unittest( SRCS log1pf_test.cpp DEPENDS - libc.src.errno.errno + libc.hdr.errno_macros libc.src.math.log1pf libc.src.__support.FPUtil.fp_bits ) @@ -4440,8 +4438,8 @@ add_fp_unittest( HDRS FModTest.h DEPENDS + libc.hdr.errno_macros libc.hdr.fenv_macros - libc.src.errno.errno libc.src.math.fmodf libc.src.__support.FPUtil.fenv_impl # FIXME: Currently fails on the GPU build. @@ -4457,8 +4455,8 @@ add_fp_unittest( HDRS FModTest.h DEPENDS + libc.hdr.errno_macros libc.hdr.fenv_macros - libc.src.errno.errno libc.src.math.fmod libc.src.__support.FPUtil.fenv_impl # FIXME: Currently fails on the GPU build. @@ -4474,8 +4472,8 @@ add_fp_unittest( HDRS FModTest.h DEPENDS + libc.hdr.errno_macros libc.hdr.fenv_macros - libc.src.errno.errno libc.src.math.fmodl libc.src.__support.FPUtil.fenv_impl # FIXME: Currently fails on the GPU build. @@ -4491,8 +4489,8 @@ add_fp_unittest( HDRS FModTest.h DEPENDS + libc.hdr.errno_macros libc.hdr.fenv_macros - libc.src.errno.errno libc.src.math.fmodf16 libc.src.__support.FPUtil.fenv_impl # FIXME: Currently fails on the GPU build. @@ -4508,8 +4506,8 @@ add_fp_unittest( HDRS FModTest.h DEPENDS + libc.hdr.errno_macros libc.hdr.fenv_macros - libc.src.errno.errno libc.src.math.fmodf128 libc.src.__support.FPUtil.fenv_impl # FIXME: Currently fails on the GPU build. @@ -4525,8 +4523,8 @@ add_fp_unittest( HDRS FModTest.h DEPENDS + libc.hdr.errno_macros libc.hdr.fenv_macros - libc.src.errno.errno libc.src.math.fmodbf16 libc.src.__support.FPUtil.bfloat16 libc.src.__support.FPUtil.fenv_impl @@ -4540,7 +4538,7 @@ add_fp_unittest( SRCS coshf_test.cpp DEPENDS - libc.src.errno.errno + libc.hdr.errno_macros libc.src.math.coshf libc.src.__support.CPP.array libc.src.__support.FPUtil.fp_bits @@ -4553,8 +4551,8 @@ add_fp_unittest( SRCS coshf16_test.cpp DEPENDS + libc.hdr.errno_macros libc.hdr.fenv_macros - libc.src.errno.errno libc.src.math.coshf16 libc.src.__support.FPUtil.cast ) @@ -4566,7 +4564,7 @@ add_fp_unittest( SRCS sinhf_test.cpp DEPENDS - libc.src.errno.errno + libc.hdr.errno_macros libc.src.math.sinhf libc.src.__support.CPP.array libc.src.__support.FPUtil.fp_bits @@ -4579,8 +4577,8 @@ add_fp_unittest( SRCS sinhf16_test.cpp DEPENDS + libc.hdr.errno_macros libc.hdr.fenv_macros - libc.src.errno.errno libc.src.math.sinhf16 libc.src.__support.FPUtil.cast ) @@ -4592,6 +4590,7 @@ add_fp_unittest( SRCS tanhf_test.cpp DEPENDS + libc.hdr.errno_macros libc.src.math.tanhf libc.src.__support.FPUtil.fp_bits ) @@ -4603,8 +4602,8 @@ add_fp_unittest( SRCS tanhf16_test.cpp DEPENDS + libc.hdr.errno_macros libc.hdr.fenv_macros - libc.src.errno.errno libc.src.math.tanhf16 libc.src.__support.FPUtil.cast ) @@ -4616,7 +4615,7 @@ add_fp_unittest( SRCS atanhf_test.cpp DEPENDS - libc.src.errno.errno + libc.hdr.errno_macros libc.src.math.atanhf libc.src.__support.FPUtil.fp_bits ) @@ -4628,7 +4627,7 @@ add_fp_unittest( SRCS atanhf16_test.cpp DEPENDS - libc.src.errno.errno + libc.hdr.errno_macros libc.src.math.atanhf16 libc.src.__support.FPUtil.cast ) @@ -4642,7 +4641,6 @@ add_fp_unittest( atanpif16_test.cpp DEPENDS libc.src.math.atanpif16 - libc.src.errno.errno ) add_fp_unittest( @@ -4790,7 +4788,6 @@ add_fp_unittest( SRCS atanf_test.cpp DEPENDS - libc.src.errno.errno libc.src.math.atanf libc.src.__support.FPUtil.fp_bits ) @@ -4812,7 +4809,6 @@ add_fp_unittest( SRCS atanf16_test.cpp DEPENDS - libc.src.errno.errno libc.src.math.atanf16 ) @@ -4823,7 +4819,6 @@ add_fp_unittest( SRCS atan2f_test.cpp DEPENDS - libc.src.errno.errno libc.src.math.atan2f libc.src.__support.FPUtil.fp_bits ) @@ -5048,7 +5043,6 @@ add_fp_unittest( SRCS pow_test.cpp DEPENDS - libc.src.errno.errno libc.hdr.fenv_macros libc.src.math.pow ) @@ -5919,6 +5913,7 @@ add_fp_unittest( SRCS sincos_test.cpp DEPENDS + libc.hdr.errno_macros libc.src.math.sincos ) diff --git a/libc/test/src/math/smoke/FModTest.h b/libc/test/src/math/smoke/FModTest.h index e74ee09..493f197 100644 --- a/libc/test/src/math/smoke/FModTest.h +++ b/libc/test/src/math/smoke/FModTest.h @@ -9,8 +9,8 @@ #ifndef LLVM_LIBC_TEST_SRC_MATH_FMODTEST_H #define LLVM_LIBC_TEST_SRC_MATH_FMODTEST_H +#include "hdr/errno_macros.h" #include "src/__support/FPUtil/FEnvImpl.h" -#include "src/__support/libc_errno.h" #include "test/UnitTest/FEnvSafeTest.h" #include "test/UnitTest/FPMatcher.h" #include "test/UnitTest/Test.h" diff --git a/libc/test/src/math/smoke/RoundToIntegerTest.h b/libc/test/src/math/smoke/RoundToIntegerTest.h index 6866e91..f8be5a5 100644 --- a/libc/test/src/math/smoke/RoundToIntegerTest.h +++ b/libc/test/src/math/smoke/RoundToIntegerTest.h @@ -12,6 +12,7 @@ #include "src/__support/CPP/algorithm.h" #include "src/__support/FPUtil/FEnvImpl.h" #include "src/__support/FPUtil/FPBits.h" +#include "src/__support/libc_errno.h" #include "test/UnitTest/FEnvSafeTest.h" #include "test/UnitTest/FPMatcher.h" #include "test/UnitTest/Test.h" diff --git a/libc/test/src/math/smoke/atan2f_test.cpp b/libc/test/src/math/smoke/atan2f_test.cpp index 7f8cfb9..83173c6 100644 --- a/libc/test/src/math/smoke/atan2f_test.cpp +++ b/libc/test/src/math/smoke/atan2f_test.cpp @@ -8,7 +8,6 @@ #include "hdr/math_macros.h" #include "src/__support/FPUtil/FPBits.h" -#include "src/__support/libc_errno.h" #include "src/math/atan2f.h" #include "test/UnitTest/FPMatcher.h" #include "test/UnitTest/Test.h" @@ -16,8 +15,6 @@ using LlvmLibcAtan2fTest = LIBC_NAMESPACE::testing::FPTest<float>; TEST_F(LlvmLibcAtan2fTest, SpecialNumbers) { - libc_errno = 0; - EXPECT_FP_EQ_WITH_EXCEPTION(aNaN, LIBC_NAMESPACE::atan2f(sNaN, sNaN), FE_INVALID); EXPECT_MATH_ERRNO(0); diff --git a/libc/test/src/math/smoke/atanf16_test.cpp b/libc/test/src/math/smoke/atanf16_test.cpp index ba1e3b2..1d56fdb 100644 --- a/libc/test/src/math/smoke/atanf16_test.cpp +++ b/libc/test/src/math/smoke/atanf16_test.cpp @@ -6,7 +6,6 @@ // //===----------------------------------------------------------------------===// -#include "src/__support/libc_errno.h" #include "src/math/atanf16.h" #include "test/UnitTest/FPMatcher.h" #include "test/UnitTest/Test.h" @@ -14,7 +13,6 @@ using LlvmLibcAtanf16Test = LIBC_NAMESPACE::testing::FPTest<float16>; TEST_F(LlvmLibcAtanf16Test, SpecialNumbers) { - libc_errno = 0; EXPECT_FP_EQ(aNaN, LIBC_NAMESPACE::atanf16(aNaN)); EXPECT_MATH_ERRNO(0); diff --git a/libc/test/src/math/smoke/atanf_test.cpp b/libc/test/src/math/smoke/atanf_test.cpp index 7d2dfee..e983083 100644 --- a/libc/test/src/math/smoke/atanf_test.cpp +++ b/libc/test/src/math/smoke/atanf_test.cpp @@ -8,7 +8,6 @@ #include "hdr/math_macros.h" #include "src/__support/FPUtil/FPBits.h" -#include "src/__support/libc_errno.h" #include "src/math/atanf.h" #include "test/UnitTest/FPMatcher.h" #include "test/UnitTest/Test.h" @@ -18,7 +17,6 @@ using LlvmLibcAtanfTest = LIBC_NAMESPACE::testing::FPTest<float>; TEST_F(LlvmLibcAtanfTest, SpecialNumbers) { - libc_errno = 0; EXPECT_FP_EQ_WITH_EXCEPTION(aNaN, LIBC_NAMESPACE::atanf(sNaN), FE_INVALID); EXPECT_MATH_ERRNO(0); diff --git a/libc/test/src/math/smoke/atanhf16_test.cpp b/libc/test/src/math/smoke/atanhf16_test.cpp index c2a520f..a417ddd 100644 --- a/libc/test/src/math/smoke/atanhf16_test.cpp +++ b/libc/test/src/math/smoke/atanhf16_test.cpp @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// +#include "hdr/errno_macros.h" #include "src/__support/FPUtil/cast.h" -#include "src/__support/libc_errno.h" #include "src/math/atanhf16.h" #include "test/UnitTest/FPMatcher.h" #include "test/UnitTest/Test.h" @@ -15,7 +15,6 @@ using LlvmLibcAtanhf16Test = LIBC_NAMESPACE::testing::FPTest<float16>; TEST_F(LlvmLibcAtanhf16Test, SpecialNumbers) { - libc_errno = 0; EXPECT_FP_EQ_WITH_EXCEPTION_ALL_ROUNDING(aNaN, LIBC_NAMESPACE::atanhf16(sNaN), FE_INVALID); EXPECT_MATH_ERRNO(0); diff --git a/libc/test/src/math/smoke/atanhf_test.cpp b/libc/test/src/math/smoke/atanhf_test.cpp index 5588ae0..da15534 100644 --- a/libc/test/src/math/smoke/atanhf_test.cpp +++ b/libc/test/src/math/smoke/atanhf_test.cpp @@ -6,9 +6,9 @@ // //===----------------------------------------------------------------------===// +#include "hdr/errno_macros.h" #include "hdr/math_macros.h" #include "src/__support/FPUtil/FPBits.h" -#include "src/__support/libc_errno.h" #include "src/math/atanhf.h" #include "test/UnitTest/FPMatcher.h" #include "test/UnitTest/Test.h" @@ -20,7 +20,6 @@ using LIBC_NAMESPACE::Sign; using LlvmLibcAtanhfTest = LIBC_NAMESPACE::testing::FPTest<float>; TEST_F(LlvmLibcAtanhfTest, SpecialNumbers) { - libc_errno = 0; EXPECT_FP_EQ_WITH_EXCEPTION(aNaN, LIBC_NAMESPACE::atanhf(sNaN), FE_INVALID); EXPECT_MATH_ERRNO(0); // TODO: Strengthen errno,exception checks and remove these assert macros diff --git a/libc/test/src/math/smoke/atanpif16_test.cpp b/libc/test/src/math/smoke/atanpif16_test.cpp index 9eb1005a..ffc8ad7 100644 --- a/libc/test/src/math/smoke/atanpif16_test.cpp +++ b/libc/test/src/math/smoke/atanpif16_test.cpp @@ -6,7 +6,6 @@ // //===----------------------------------------------------------------------===// -#include "src/__support/libc_errno.h" #include "src/math/atanpif16.h" #include "test/UnitTest/FPMatcher.h" diff --git a/libc/test/src/math/smoke/cosf16_test.cpp b/libc/test/src/math/smoke/cosf16_test.cpp index 4362a5a3..0bd228c 100644 --- a/libc/test/src/math/smoke/cosf16_test.cpp +++ b/libc/test/src/math/smoke/cosf16_test.cpp @@ -6,7 +6,7 @@ // //===----------------------------------------------------------------------===// -#include "src/__support/libc_errno.h" +#include "hdr/errno_macros.h" #include "src/math/cosf16.h" #include "test/UnitTest/FPMatcher.h" #include "test/UnitTest/Test.h" @@ -14,8 +14,6 @@ using LlvmLibcCosf16Test = LIBC_NAMESPACE::testing::FPTest<float16>; TEST_F(LlvmLibcCosf16Test, SpecialNumbers) { - libc_errno = 0; - EXPECT_FP_EQ_WITH_EXCEPTION(aNaN, LIBC_NAMESPACE::cosf16(sNaN), FE_INVALID); EXPECT_MATH_ERRNO(0); diff --git a/libc/test/src/math/smoke/cosf_test.cpp b/libc/test/src/math/smoke/cosf_test.cpp index 837fee9..0236c41 100644 --- a/libc/test/src/math/smoke/cosf_test.cpp +++ b/libc/test/src/math/smoke/cosf_test.cpp @@ -6,10 +6,10 @@ // //===----------------------------------------------------------------------===// +#include "hdr/errno_macros.h" #include "hdr/math_macros.h" #include "hdr/stdint_proxy.h" #include "src/__support/FPUtil/FPBits.h" -#include "src/__support/libc_errno.h" #include "src/math/cosf.h" #include "test/UnitTest/FPMatcher.h" #include "test/UnitTest/Test.h" @@ -17,8 +17,6 @@ using LlvmLibcCosfTest = LIBC_NAMESPACE::testing::FPTest<float>; TEST_F(LlvmLibcCosfTest, SpecialNumbers) { - libc_errno = 0; - EXPECT_FP_EQ_WITH_EXCEPTION(aNaN, LIBC_NAMESPACE::cosf(sNaN), FE_INVALID); EXPECT_MATH_ERRNO(0); diff --git a/libc/test/src/math/smoke/coshf16_test.cpp b/libc/test/src/math/smoke/coshf16_test.cpp index 7bf62af..6d5824d 100644 --- a/libc/test/src/math/smoke/coshf16_test.cpp +++ b/libc/test/src/math/smoke/coshf16_test.cpp @@ -6,9 +6,9 @@ // //===----------------------------------------------------------------------===// +#include "hdr/errno_macros.h" #include "hdr/fenv_macros.h" #include "src/__support/FPUtil/cast.h" -#include "src/__support/libc_errno.h" #include "src/math/coshf16.h" #include "test/UnitTest/FPMatcher.h" #include "test/UnitTest/Test.h" @@ -16,8 +16,6 @@ using LlvmLibcCoshf16Test = LIBC_NAMESPACE::testing::FPTest<float16>; TEST_F(LlvmLibcCoshf16Test, SpecialNumbers) { - libc_errno = 0; - EXPECT_FP_EQ_ALL_ROUNDING(aNaN, LIBC_NAMESPACE::coshf16(aNaN)); EXPECT_MATH_ERRNO(0); @@ -40,8 +38,6 @@ TEST_F(LlvmLibcCoshf16Test, SpecialNumbers) { } TEST_F(LlvmLibcCoshf16Test, Overflow) { - libc_errno = 0; - EXPECT_FP_EQ_WITH_EXCEPTION(inf, LIBC_NAMESPACE::coshf16(max_normal), FE_OVERFLOW | FE_INEXACT); EXPECT_MATH_ERRNO(ERANGE); diff --git a/libc/test/src/math/smoke/coshf_test.cpp b/libc/test/src/math/smoke/coshf_test.cpp index 81096fa..f73737f 100644 --- a/libc/test/src/math/smoke/coshf_test.cpp +++ b/libc/test/src/math/smoke/coshf_test.cpp @@ -6,11 +6,11 @@ // //===----------------------------------------------------------------------===// +#include "hdr/errno_macros.h" #include "hdr/math_macros.h" #include "hdr/stdint_proxy.h" #include "src/__support/CPP/array.h" #include "src/__support/FPUtil/FPBits.h" -#include "src/__support/libc_errno.h" #include "src/math/coshf.h" #include "test/UnitTest/FPMatcher.h" #include "test/UnitTest/Test.h" @@ -18,8 +18,6 @@ using LlvmLibcCoshfTest = LIBC_NAMESPACE::testing::FPTest<float>; TEST_F(LlvmLibcCoshfTest, SpecialNumbers) { - libc_errno = 0; - EXPECT_FP_EQ_WITH_EXCEPTION(aNaN, LIBC_NAMESPACE::coshf(sNaN), FE_INVALID); EXPECT_MATH_ERRNO(0); @@ -40,7 +38,6 @@ TEST_F(LlvmLibcCoshfTest, SpecialNumbers) { } TEST_F(LlvmLibcCoshfTest, Overflow) { - libc_errno = 0; EXPECT_FP_EQ_WITH_EXCEPTION( inf, LIBC_NAMESPACE::coshf(FPBits(0x7f7fffffU).get_val()), FE_OVERFLOW); EXPECT_MATH_ERRNO(ERANGE); diff --git a/libc/test/src/math/smoke/cospif16_test.cpp b/libc/test/src/math/smoke/cospif16_test.cpp index fcde0cc..dadf0cf 100644 --- a/libc/test/src/math/smoke/cospif16_test.cpp +++ b/libc/test/src/math/smoke/cospif16_test.cpp @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// +#include "hdr/errno_macros.h" #include "src/__support/FPUtil/cast.h" -#include "src/__support/libc_errno.h" #include "src/math/cospif16.h" #include "test/UnitTest/FPMatcher.h" #include "test/UnitTest/Test.h" @@ -15,8 +15,6 @@ using LlvmLibcCospif16Test = LIBC_NAMESPACE::testing::FPTest<float16>; TEST_F(LlvmLibcCospif16Test, SpecialNumbers) { - libc_errno = 0; - EXPECT_FP_EQ_WITH_EXCEPTION(aNaN, LIBC_NAMESPACE::cospif16(sNaN), FE_INVALID); EXPECT_MATH_ERRNO(0); diff --git a/libc/test/src/math/smoke/cospif_test.cpp b/libc/test/src/math/smoke/cospif_test.cpp index 6f1bb24..b9cb261 100644 --- a/libc/test/src/math/smoke/cospif_test.cpp +++ b/libc/test/src/math/smoke/cospif_test.cpp @@ -6,16 +6,14 @@ // //===----------------------------------------------------------------------===// +#include "hdr/errno_macros.h" #include "hdr/stdint_proxy.h" -#include "src/__support/libc_errno.h" #include "src/math/cospif.h" #include "test/UnitTest/FPMatcher.h" using LlvmLibcCospifTest = LIBC_NAMESPACE::testing::FPTest<float>; TEST_F(LlvmLibcCospifTest, SpecialNumbers) { - libc_errno = 0; - EXPECT_FP_EQ_WITH_EXCEPTION(aNaN, LIBC_NAMESPACE::cospif(sNaN), FE_INVALID); EXPECT_MATH_ERRNO(0); diff --git a/libc/test/src/math/smoke/exp10_test.cpp b/libc/test/src/math/smoke/exp10_test.cpp index 76e6c78..8f564de 100644 --- a/libc/test/src/math/smoke/exp10_test.cpp +++ b/libc/test/src/math/smoke/exp10_test.cpp @@ -6,10 +6,10 @@ // //===----------------------------------------------------------------------===// +#include "hdr/errno_macros.h" #include "hdr/math_macros.h" #include "hdr/stdint_proxy.h" #include "src/__support/FPUtil/FPBits.h" -#include "src/__support/libc_errno.h" #include "src/math/exp10.h" #include "test/UnitTest/FPMatcher.h" #include "test/UnitTest/Test.h" @@ -21,12 +21,19 @@ TEST_F(LlvmLibcExp10Test, SpecialNumbers) { EXPECT_MATH_ERRNO(0); EXPECT_FP_EQ(aNaN, LIBC_NAMESPACE::exp10(aNaN)); + EXPECT_MATH_ERRNO(0); EXPECT_FP_EQ(inf, LIBC_NAMESPACE::exp10(inf)); + EXPECT_MATH_ERRNO(0); EXPECT_FP_EQ_ALL_ROUNDING(zero, LIBC_NAMESPACE::exp10(neg_inf)); + EXPECT_MATH_ERRNO(0); + EXPECT_FP_EQ_WITH_EXCEPTION(zero, LIBC_NAMESPACE::exp10(-0x1.0p20), FE_UNDERFLOW); + EXPECT_MATH_ERRNO(ERANGE); EXPECT_FP_EQ_WITH_EXCEPTION(inf, LIBC_NAMESPACE::exp10(0x1.0p20), FE_OVERFLOW); + EXPECT_MATH_ERRNO(ERANGE); + EXPECT_FP_EQ_ALL_ROUNDING(1.0, LIBC_NAMESPACE::exp10(0.0)); EXPECT_FP_EQ_ALL_ROUNDING(1.0, LIBC_NAMESPACE::exp10(-0.0)); diff --git a/libc/test/src/math/smoke/exp10f16_test.cpp b/libc/test/src/math/smoke/exp10f16_test.cpp index bda4034..c2dffd1 100644 --- a/libc/test/src/math/smoke/exp10f16_test.cpp +++ b/libc/test/src/math/smoke/exp10f16_test.cpp @@ -6,9 +6,9 @@ // //===----------------------------------------------------------------------===// +#include "hdr/errno_macros.h" #include "hdr/fenv_macros.h" #include "src/__support/FPUtil/cast.h" -#include "src/__support/libc_errno.h" #include "src/math/exp10f16.h" #include "test/UnitTest/FPMatcher.h" #include "test/UnitTest/Test.h" @@ -16,8 +16,6 @@ using LlvmLibcExp10f16Test = LIBC_NAMESPACE::testing::FPTest<float16>; TEST_F(LlvmLibcExp10f16Test, SpecialNumbers) { - libc_errno = 0; - EXPECT_FP_EQ_ALL_ROUNDING(aNaN, LIBC_NAMESPACE::exp10f16(aNaN)); EXPECT_MATH_ERRNO(0); @@ -40,8 +38,6 @@ TEST_F(LlvmLibcExp10f16Test, SpecialNumbers) { } TEST_F(LlvmLibcExp10f16Test, Overflow) { - libc_errno = 0; - EXPECT_FP_EQ_WITH_EXCEPTION(inf, LIBC_NAMESPACE::exp10f16(max_normal), FE_OVERFLOW); EXPECT_MATH_ERRNO(ERANGE); @@ -53,8 +49,6 @@ TEST_F(LlvmLibcExp10f16Test, Overflow) { } TEST_F(LlvmLibcExp10f16Test, Underflow) { - libc_errno = 0; - EXPECT_FP_EQ_WITH_EXCEPTION(zero, LIBC_NAMESPACE::exp10f16(neg_max_normal), FE_UNDERFLOW | FE_INEXACT); EXPECT_MATH_ERRNO(ERANGE); diff --git a/libc/test/src/math/smoke/exp10f_test.cpp b/libc/test/src/math/smoke/exp10f_test.cpp index cf2f976..8d7c171 100644 --- a/libc/test/src/math/smoke/exp10f_test.cpp +++ b/libc/test/src/math/smoke/exp10f_test.cpp @@ -6,10 +6,10 @@ // //===----------------------------------------------------------------------===// +#include "hdr/errno_macros.h" #include "hdr/math_macros.h" #include "hdr/stdint_proxy.h" #include "src/__support/FPUtil/FPBits.h" -#include "src/__support/libc_errno.h" #include "src/math/exp10f.h" #include "test/UnitTest/FPMatcher.h" #include "test/UnitTest/Test.h" @@ -17,8 +17,6 @@ using LlvmLibcExp10fTest = LIBC_NAMESPACE::testing::FPTest<float>; TEST_F(LlvmLibcExp10fTest, SpecialNumbers) { - libc_errno = 0; - EXPECT_FP_EQ_WITH_EXCEPTION(aNaN, LIBC_NAMESPACE::exp10f(sNaN), FE_INVALID); EXPECT_MATH_ERRNO(0); @@ -43,7 +41,6 @@ TEST_F(LlvmLibcExp10fTest, SpecialNumbers) { } TEST_F(LlvmLibcExp10fTest, Overflow) { - libc_errno = 0; EXPECT_FP_EQ_WITH_EXCEPTION( inf, LIBC_NAMESPACE::exp10f(FPBits(0x7f7fffffU).get_val()), FE_OVERFLOW); EXPECT_MATH_ERRNO(ERANGE); diff --git a/libc/test/src/math/smoke/exp10m1f16_test.cpp b/libc/test/src/math/smoke/exp10m1f16_test.cpp index ed2d5a4..1ba0e4c 100644 --- a/libc/test/src/math/smoke/exp10m1f16_test.cpp +++ b/libc/test/src/math/smoke/exp10m1f16_test.cpp @@ -6,9 +6,9 @@ // //===----------------------------------------------------------------------===// +#include "hdr/errno_macros.h" #include "hdr/fenv_macros.h" #include "src/__support/FPUtil/cast.h" -#include "src/__support/libc_errno.h" #include "src/math/exp10m1f16.h" #include "test/UnitTest/FPMatcher.h" #include "test/UnitTest/Test.h" @@ -16,8 +16,6 @@ using LlvmLibcExp10m1f16Test = LIBC_NAMESPACE::testing::FPTest<float16>; TEST_F(LlvmLibcExp10m1f16Test, SpecialNumbers) { - libc_errno = 0; - EXPECT_FP_EQ_ALL_ROUNDING(aNaN, LIBC_NAMESPACE::exp10m1f16(aNaN)); EXPECT_MATH_ERRNO(0); @@ -40,8 +38,6 @@ TEST_F(LlvmLibcExp10m1f16Test, SpecialNumbers) { } TEST_F(LlvmLibcExp10m1f16Test, Overflow) { - libc_errno = 0; - EXPECT_FP_EQ_WITH_EXCEPTION(inf, LIBC_NAMESPACE::exp10m1f16(max_normal), FE_OVERFLOW | FE_INEXACT); EXPECT_MATH_ERRNO(ERANGE); @@ -67,8 +63,6 @@ TEST_F(LlvmLibcExp10m1f16Test, Overflow) { } TEST_F(LlvmLibcExp10m1f16Test, ResultNearNegOne) { - libc_errno = 0; - EXPECT_FP_EQ_WITH_EXCEPTION(LIBC_NAMESPACE::fputil::cast<float16>(-1.0), LIBC_NAMESPACE::exp10m1f16(neg_max_normal), FE_INEXACT); diff --git a/libc/test/src/math/smoke/exp10m1f_test.cpp b/libc/test/src/math/smoke/exp10m1f_test.cpp index 19369a89..87320fa 100644 --- a/libc/test/src/math/smoke/exp10m1f_test.cpp +++ b/libc/test/src/math/smoke/exp10m1f_test.cpp @@ -6,7 +6,7 @@ // //===----------------------------------------------------------------------===// -#include "src/__support/libc_errno.h" +#include "hdr/errno_macros.h" #include "src/math/exp10m1f.h" #include "test/UnitTest/FPMatcher.h" #include "test/UnitTest/Test.h" @@ -14,8 +14,6 @@ using LlvmLibcExp10m1fTest = LIBC_NAMESPACE::testing::FPTest<float>; TEST_F(LlvmLibcExp10m1fTest, SpecialNumbers) { - libc_errno = 0; - EXPECT_FP_EQ_WITH_EXCEPTION(aNaN, LIBC_NAMESPACE::exp10m1f(sNaN), FE_INVALID); EXPECT_MATH_ERRNO(0); @@ -34,8 +32,6 @@ TEST_F(LlvmLibcExp10m1fTest, SpecialNumbers) { } TEST_F(LlvmLibcExp10m1fTest, Overflow) { - libc_errno = 0; - EXPECT_FP_EQ_WITH_EXCEPTION(inf, LIBC_NAMESPACE::exp10m1f(0x1.fffffep+127f), FE_OVERFLOW); EXPECT_MATH_ERRNO(ERANGE); @@ -50,8 +46,6 @@ TEST_F(LlvmLibcExp10m1fTest, Overflow) { } TEST_F(LlvmLibcExp10m1fTest, Underflow) { - libc_errno = 0; - EXPECT_FP_EQ_WITH_EXCEPTION(-1.0f, LIBC_NAMESPACE::exp10m1f(-max_normal), FE_UNDERFLOW); EXPECT_MATH_ERRNO(ERANGE); diff --git a/libc/test/src/math/smoke/exp2_test.cpp b/libc/test/src/math/smoke/exp2_test.cpp index 3d26df1..3fd732b 100644 --- a/libc/test/src/math/smoke/exp2_test.cpp +++ b/libc/test/src/math/smoke/exp2_test.cpp @@ -6,10 +6,10 @@ // //===----------------------------------------------------------------------===// +#include "hdr/errno_macros.h" #include "hdr/math_macros.h" #include "hdr/stdint_proxy.h" #include "src/__support/FPUtil/FPBits.h" -#include "src/__support/libc_errno.h" #include "src/math/exp2.h" #include "test/UnitTest/FPMatcher.h" #include "test/UnitTest/Test.h" @@ -21,11 +21,18 @@ TEST_F(LlvmLibcExp2Test, SpecialNumbers) { EXPECT_MATH_ERRNO(0); EXPECT_FP_EQ(aNaN, LIBC_NAMESPACE::exp2(aNaN)); + EXPECT_MATH_ERRNO(0); EXPECT_FP_EQ(inf, LIBC_NAMESPACE::exp2(inf)); + EXPECT_MATH_ERRNO(0); EXPECT_FP_EQ_ALL_ROUNDING(zero, LIBC_NAMESPACE::exp2(neg_inf)); + EXPECT_MATH_ERRNO(0); + EXPECT_FP_EQ_WITH_EXCEPTION(zero, LIBC_NAMESPACE::exp2(-0x1.0p20), FE_UNDERFLOW); + EXPECT_MATH_ERRNO(ERANGE); EXPECT_FP_EQ_WITH_EXCEPTION(inf, LIBC_NAMESPACE::exp2(0x1.0p20), FE_OVERFLOW); + EXPECT_MATH_ERRNO(ERANGE); + EXPECT_FP_EQ_ALL_ROUNDING(1.0, LIBC_NAMESPACE::exp2(0.0)); EXPECT_FP_EQ_ALL_ROUNDING(1.0, LIBC_NAMESPACE::exp2(-0.0)); EXPECT_FP_EQ_ALL_ROUNDING(2.0, LIBC_NAMESPACE::exp2(1.0)); diff --git a/libc/test/src/math/smoke/exp2f16_test.cpp b/libc/test/src/math/smoke/exp2f16_test.cpp index 1eb7343..3122629 100644 --- a/libc/test/src/math/smoke/exp2f16_test.cpp +++ b/libc/test/src/math/smoke/exp2f16_test.cpp @@ -6,9 +6,9 @@ // //===----------------------------------------------------------------------===// +#include "hdr/errno_macros.h" #include "hdr/fenv_macros.h" #include "src/__support/FPUtil/cast.h" -#include "src/__support/libc_errno.h" #include "src/math/exp2f16.h" #include "test/UnitTest/FPMatcher.h" #include "test/UnitTest/Test.h" @@ -16,8 +16,6 @@ using LlvmLibcExp2f16Test = LIBC_NAMESPACE::testing::FPTest<float16>; TEST_F(LlvmLibcExp2f16Test, SpecialNumbers) { - libc_errno = 0; - EXPECT_FP_EQ_ALL_ROUNDING(aNaN, LIBC_NAMESPACE::exp2f16(aNaN)); EXPECT_MATH_ERRNO(0); @@ -40,8 +38,6 @@ TEST_F(LlvmLibcExp2f16Test, SpecialNumbers) { } TEST_F(LlvmLibcExp2f16Test, Overflow) { - libc_errno = 0; - EXPECT_FP_EQ_WITH_EXCEPTION(inf, LIBC_NAMESPACE::exp2f16(max_normal), FE_OVERFLOW); EXPECT_MATH_ERRNO(ERANGE); @@ -53,8 +49,6 @@ TEST_F(LlvmLibcExp2f16Test, Overflow) { } TEST_F(LlvmLibcExp2f16Test, Underflow) { - libc_errno = 0; - EXPECT_FP_EQ_WITH_EXCEPTION(zero, LIBC_NAMESPACE::exp2f16(neg_max_normal), FE_UNDERFLOW | FE_INEXACT); EXPECT_MATH_ERRNO(ERANGE); diff --git a/libc/test/src/math/smoke/exp2f_test.cpp b/libc/test/src/math/smoke/exp2f_test.cpp index 12bcbec..2adfa5f 100644 --- a/libc/test/src/math/smoke/exp2f_test.cpp +++ b/libc/test/src/math/smoke/exp2f_test.cpp @@ -6,10 +6,10 @@ // //===----------------------------------------------------------------------===// +#include "hdr/errno_macros.h" #include "hdr/math_macros.h" #include "hdr/stdint_proxy.h" #include "src/__support/FPUtil/FPBits.h" -#include "src/__support/libc_errno.h" #include "src/math/exp2f.h" #include "test/UnitTest/FPMatcher.h" #include "test/UnitTest/Test.h" @@ -17,8 +17,6 @@ using LlvmLibcExp2fTest = LIBC_NAMESPACE::testing::FPTest<float>; TEST_F(LlvmLibcExp2fTest, SpecialNumbers) { - libc_errno = 0; - EXPECT_FP_EQ_WITH_EXCEPTION(aNaN, LIBC_NAMESPACE::exp2f(sNaN), FE_INVALID); EXPECT_MATH_ERRNO(0); @@ -44,7 +42,6 @@ TEST_F(LlvmLibcExp2fTest, SpecialNumbers) { } TEST_F(LlvmLibcExp2fTest, Overflow) { - libc_errno = 0; EXPECT_FP_EQ_WITH_EXCEPTION( inf, LIBC_NAMESPACE::exp2f(FPBits(0x7f7fffffU).get_val()), FE_OVERFLOW); EXPECT_MATH_ERRNO(ERANGE); diff --git a/libc/test/src/math/smoke/exp2m1f16_test.cpp b/libc/test/src/math/smoke/exp2m1f16_test.cpp index 635b7a6..4917128 100644 --- a/libc/test/src/math/smoke/exp2m1f16_test.cpp +++ b/libc/test/src/math/smoke/exp2m1f16_test.cpp @@ -6,9 +6,9 @@ // //===----------------------------------------------------------------------===// +#include "hdr/errno_macros.h" #include "hdr/fenv_macros.h" #include "src/__support/FPUtil/cast.h" -#include "src/__support/libc_errno.h" #include "src/math/exp2m1f16.h" #include "test/UnitTest/FPMatcher.h" #include "test/UnitTest/Test.h" @@ -16,8 +16,6 @@ using LlvmLibcExp2m1f16Test = LIBC_NAMESPACE::testing::FPTest<float16>; TEST_F(LlvmLibcExp2m1f16Test, SpecialNumbers) { - libc_errno = 0; - EXPECT_FP_EQ_ALL_ROUNDING(aNaN, LIBC_NAMESPACE::exp2m1f16(aNaN)); EXPECT_MATH_ERRNO(0); @@ -39,8 +37,6 @@ TEST_F(LlvmLibcExp2m1f16Test, SpecialNumbers) { } TEST_F(LlvmLibcExp2m1f16Test, Overflow) { - libc_errno = 0; - EXPECT_FP_EQ_WITH_EXCEPTION(inf, LIBC_NAMESPACE::exp2m1f16(max_normal), FE_OVERFLOW | FE_INEXACT); EXPECT_MATH_ERRNO(ERANGE); @@ -65,8 +61,6 @@ TEST_F(LlvmLibcExp2m1f16Test, Overflow) { } TEST_F(LlvmLibcExp2m1f16Test, ResultNearNegOne) { - libc_errno = 0; - EXPECT_FP_EQ_WITH_EXCEPTION(-1.0, LIBC_NAMESPACE::exp2m1f16(neg_max_normal), FE_INEXACT); diff --git a/libc/test/src/math/smoke/exp2m1f_test.cpp b/libc/test/src/math/smoke/exp2m1f_test.cpp index 63852e1..e847cd0 100644 --- a/libc/test/src/math/smoke/exp2m1f_test.cpp +++ b/libc/test/src/math/smoke/exp2m1f_test.cpp @@ -6,7 +6,7 @@ // //===----------------------------------------------------------------------===// -#include "src/__support/libc_errno.h" +#include "hdr/errno_macros.h" #include "src/math/exp2m1f.h" #include "test/UnitTest/FPMatcher.h" #include "test/UnitTest/Test.h" @@ -16,8 +16,6 @@ using LIBC_NAMESPACE::fputil::testing::ForceRoundingMode; using LIBC_NAMESPACE::fputil::testing::RoundingMode; TEST_F(LlvmLibcExp2m1fTest, SpecialNumbers) { - libc_errno = 0; - EXPECT_FP_EQ_WITH_EXCEPTION(aNaN, LIBC_NAMESPACE::exp2m1f(sNaN), FE_INVALID); EXPECT_MATH_ERRNO(0); @@ -34,8 +32,6 @@ TEST_F(LlvmLibcExp2m1fTest, SpecialNumbers) { } TEST_F(LlvmLibcExp2m1fTest, Overflow) { - libc_errno = 0; - EXPECT_FP_EQ_WITH_EXCEPTION(inf, LIBC_NAMESPACE::exp2m1f(0x1.fffffep+127), FE_OVERFLOW); EXPECT_MATH_ERRNO(ERANGE); @@ -50,8 +46,6 @@ TEST_F(LlvmLibcExp2m1fTest, Overflow) { } TEST_F(LlvmLibcExp2m1fTest, Underflow) { - libc_errno = 0; - EXPECT_FP_EQ_WITH_EXCEPTION(-1.0f, LIBC_NAMESPACE::exp2m1f(-0x1.fffffep+127), FE_UNDERFLOW); EXPECT_MATH_ERRNO(ERANGE); diff --git a/libc/test/src/math/smoke/exp_test.cpp b/libc/test/src/math/smoke/exp_test.cpp index 4ce3227..9397277 100644 --- a/libc/test/src/math/smoke/exp_test.cpp +++ b/libc/test/src/math/smoke/exp_test.cpp @@ -6,10 +6,10 @@ // //===----------------------------------------------------------------------===// +#include "hdr/errno_macros.h" #include "hdr/math_macros.h" #include "hdr/stdint_proxy.h" #include "src/__support/FPUtil/FPBits.h" -#include "src/__support/libc_errno.h" #include "src/math/exp.h" #include "test/UnitTest/FPMatcher.h" #include "test/UnitTest/Test.h" @@ -21,11 +21,18 @@ TEST_F(LlvmLibcExpTest, SpecialNumbers) { EXPECT_MATH_ERRNO(0); EXPECT_FP_EQ(aNaN, LIBC_NAMESPACE::exp(aNaN)); + EXPECT_MATH_ERRNO(0); EXPECT_FP_EQ(inf, LIBC_NAMESPACE::exp(inf)); + EXPECT_MATH_ERRNO(0); EXPECT_FP_EQ_ALL_ROUNDING(zero, LIBC_NAMESPACE::exp(neg_inf)); + EXPECT_MATH_ERRNO(0); + EXPECT_FP_EQ_WITH_EXCEPTION(zero, LIBC_NAMESPACE::exp(-0x1.0p20), FE_UNDERFLOW); + EXPECT_MATH_ERRNO(ERANGE); EXPECT_FP_EQ_WITH_EXCEPTION(inf, LIBC_NAMESPACE::exp(0x1.0p20), FE_OVERFLOW); + EXPECT_MATH_ERRNO(ERANGE); + EXPECT_FP_EQ_ALL_ROUNDING(1.0, LIBC_NAMESPACE::exp(0.0)); EXPECT_FP_EQ_ALL_ROUNDING(1.0, LIBC_NAMESPACE::exp(-0.0)); } diff --git a/libc/test/src/math/smoke/expf16_test.cpp b/libc/test/src/math/smoke/expf16_test.cpp index 863f694..85988c5 100644 --- a/libc/test/src/math/smoke/expf16_test.cpp +++ b/libc/test/src/math/smoke/expf16_test.cpp @@ -9,7 +9,6 @@ #include "hdr/errno_macros.h" #include "hdr/fenv_macros.h" #include "src/__support/FPUtil/cast.h" -#include "src/__support/libc_errno.h" #include "src/math/expf16.h" #include "test/UnitTest/FPMatcher.h" #include "test/UnitTest/Test.h" @@ -17,8 +16,6 @@ using LlvmLibcExpf16Test = LIBC_NAMESPACE::testing::FPTest<float16>; TEST_F(LlvmLibcExpf16Test, SpecialNumbers) { - libc_errno = 0; - EXPECT_FP_EQ_ALL_ROUNDING(aNaN, LIBC_NAMESPACE::expf16(aNaN)); EXPECT_MATH_ERRNO(0); @@ -41,8 +38,6 @@ TEST_F(LlvmLibcExpf16Test, SpecialNumbers) { } TEST_F(LlvmLibcExpf16Test, Overflow) { - libc_errno = 0; - EXPECT_FP_EQ_WITH_EXCEPTION(inf, LIBC_NAMESPACE::expf16(max_normal), FE_OVERFLOW); EXPECT_MATH_ERRNO(ERANGE); @@ -54,8 +49,6 @@ TEST_F(LlvmLibcExpf16Test, Overflow) { } TEST_F(LlvmLibcExpf16Test, Underflow) { - libc_errno = 0; - EXPECT_FP_EQ_WITH_EXCEPTION(zero, LIBC_NAMESPACE::expf16(neg_max_normal), FE_UNDERFLOW | FE_INEXACT); EXPECT_MATH_ERRNO(ERANGE); diff --git a/libc/test/src/math/smoke/expf_test.cpp b/libc/test/src/math/smoke/expf_test.cpp index a0e785f..ca5bc59 100644 --- a/libc/test/src/math/smoke/expf_test.cpp +++ b/libc/test/src/math/smoke/expf_test.cpp @@ -6,10 +6,10 @@ // //===----------------------------------------------------------------------===// +#include "hdr/errno_macros.h" #include "hdr/math_macros.h" #include "hdr/stdint_proxy.h" #include "src/__support/FPUtil/FPBits.h" -#include "src/__support/libc_errno.h" #include "src/math/expf.h" #include "test/UnitTest/FPMatcher.h" #include "test/UnitTest/Test.h" @@ -17,8 +17,6 @@ using LlvmLibcExpfTest = LIBC_NAMESPACE::testing::FPTest<float>; TEST_F(LlvmLibcExpfTest, SpecialNumbers) { - libc_errno = 0; - EXPECT_FP_EQ_WITH_EXCEPTION(aNaN, LIBC_NAMESPACE::expf(sNaN), FE_INVALID); EXPECT_MATH_ERRNO(0); @@ -39,7 +37,6 @@ TEST_F(LlvmLibcExpfTest, SpecialNumbers) { } TEST_F(LlvmLibcExpfTest, Overflow) { - libc_errno = 0; EXPECT_FP_EQ_WITH_EXCEPTION( inf, LIBC_NAMESPACE::expf(FPBits(0x7f7fffffU).get_val()), FE_OVERFLOW); EXPECT_MATH_ERRNO(ERANGE); diff --git a/libc/test/src/math/smoke/expm1_test.cpp b/libc/test/src/math/smoke/expm1_test.cpp index db7149d..7d605c0 100644 --- a/libc/test/src/math/smoke/expm1_test.cpp +++ b/libc/test/src/math/smoke/expm1_test.cpp @@ -6,10 +6,10 @@ // //===----------------------------------------------------------------------===// +#include "hdr/errno_macros.h" #include "hdr/math_macros.h" #include "hdr/stdint_proxy.h" #include "src/__support/FPUtil/FPBits.h" -#include "src/__support/libc_errno.h" #include "src/math/expm1.h" #include "test/UnitTest/FPMatcher.h" #include "test/UnitTest/Test.h" @@ -21,10 +21,16 @@ TEST_F(LlvmLibcExpm1Test, SpecialNumbers) { EXPECT_MATH_ERRNO(0); EXPECT_FP_EQ(aNaN, LIBC_NAMESPACE::expm1(aNaN)); + EXPECT_MATH_ERRNO(0); EXPECT_FP_EQ(inf, LIBC_NAMESPACE::expm1(inf)); + EXPECT_MATH_ERRNO(0); EXPECT_FP_EQ_ALL_ROUNDING(-1.0, LIBC_NAMESPACE::expm1(neg_inf)); + EXPECT_MATH_ERRNO(0); + EXPECT_FP_EQ_WITH_EXCEPTION(inf, LIBC_NAMESPACE::expm1(0x1.0p20), FE_OVERFLOW); + EXPECT_MATH_ERRNO(ERANGE); + EXPECT_FP_EQ_ALL_ROUNDING(zero, LIBC_NAMESPACE::expm1(zero)); EXPECT_FP_EQ_ALL_ROUNDING(neg_zero, LIBC_NAMESPACE::expm1(neg_zero)); // |x| < 2^-53, expm1(x) = x diff --git a/libc/test/src/math/smoke/expm1f16_test.cpp b/libc/test/src/math/smoke/expm1f16_test.cpp index 4d19a9b..545304c 100644 --- a/libc/test/src/math/smoke/expm1f16_test.cpp +++ b/libc/test/src/math/smoke/expm1f16_test.cpp @@ -9,7 +9,6 @@ #include "hdr/errno_macros.h" #include "hdr/fenv_macros.h" #include "src/__support/FPUtil/cast.h" -#include "src/__support/libc_errno.h" #include "src/math/expm1f16.h" #include "test/UnitTest/FPMatcher.h" #include "test/UnitTest/Test.h" @@ -17,8 +16,6 @@ using LlvmLibcExpm1f16Test = LIBC_NAMESPACE::testing::FPTest<float16>; TEST_F(LlvmLibcExpm1f16Test, SpecialNumbers) { - libc_errno = 0; - EXPECT_FP_EQ_ALL_ROUNDING(aNaN, LIBC_NAMESPACE::expm1f16(aNaN)); EXPECT_MATH_ERRNO(0); @@ -40,8 +37,6 @@ TEST_F(LlvmLibcExpm1f16Test, SpecialNumbers) { } TEST_F(LlvmLibcExpm1f16Test, Overflow) { - libc_errno = 0; - EXPECT_FP_EQ_WITH_EXCEPTION(inf, LIBC_NAMESPACE::expm1f16(max_normal), FE_OVERFLOW | FE_INEXACT); EXPECT_MATH_ERRNO(ERANGE); @@ -67,8 +62,6 @@ TEST_F(LlvmLibcExpm1f16Test, Overflow) { } TEST_F(LlvmLibcExpm1f16Test, ResultNearNegOne) { - libc_errno = 0; - EXPECT_FP_EQ_WITH_EXCEPTION(LIBC_NAMESPACE::fputil::cast<float16>(-1.0), LIBC_NAMESPACE::expm1f16(neg_max_normal), FE_INEXACT); diff --git a/libc/test/src/math/smoke/expm1f_test.cpp b/libc/test/src/math/smoke/expm1f_test.cpp index 9482bf6f..e923d5b 100644 --- a/libc/test/src/math/smoke/expm1f_test.cpp +++ b/libc/test/src/math/smoke/expm1f_test.cpp @@ -6,10 +6,10 @@ // //===----------------------------------------------------------------------===// +#include "hdr/errno_macros.h" #include "hdr/math_macros.h" #include "hdr/stdint_proxy.h" #include "src/__support/FPUtil/FPBits.h" -#include "src/__support/libc_errno.h" #include "src/math/expm1f.h" #include "test/UnitTest/FPMatcher.h" #include "test/UnitTest/Test.h" @@ -17,8 +17,6 @@ using LlvmLibcExpm1fTest = LIBC_NAMESPACE::testing::FPTest<float>; TEST_F(LlvmLibcExpm1fTest, SpecialNumbers) { - libc_errno = 0; - EXPECT_FP_EQ_WITH_EXCEPTION(aNaN, LIBC_NAMESPACE::expm1f(sNaN), FE_INVALID); EXPECT_MATH_ERRNO(0); @@ -39,7 +37,6 @@ TEST_F(LlvmLibcExpm1fTest, SpecialNumbers) { } TEST_F(LlvmLibcExpm1fTest, Overflow) { - libc_errno = 0; EXPECT_FP_EQ_WITH_EXCEPTION( inf, LIBC_NAMESPACE::expm1f(FPBits(0x7f7fffffU).get_val()), FE_OVERFLOW); EXPECT_MATH_ERRNO(ERANGE); diff --git a/libc/test/src/math/smoke/log10_test.cpp b/libc/test/src/math/smoke/log10_test.cpp index 3af27d4..ab7fc17 100644 --- a/libc/test/src/math/smoke/log10_test.cpp +++ b/libc/test/src/math/smoke/log10_test.cpp @@ -6,10 +6,10 @@ // //===----------------------------------------------------------------------===// +#include "hdr/errno_macros.h" #include "hdr/math_macros.h" #include "hdr/stdint_proxy.h" #include "src/__support/FPUtil/FPBits.h" -#include "src/__support/libc_errno.h" #include "src/math/log10.h" #include "test/UnitTest/FPMatcher.h" #include "test/UnitTest/Test.h" @@ -22,12 +22,18 @@ TEST_F(LlvmLibcLog10Test, SpecialNumbers) { EXPECT_FP_EQ(aNaN, LIBC_NAMESPACE::log10(aNaN)); EXPECT_FP_EQ(inf, LIBC_NAMESPACE::log10(inf)); + EXPECT_MATH_ERRNO(0); + EXPECT_FP_IS_NAN_WITH_EXCEPTION(LIBC_NAMESPACE::log10(neg_inf), FE_INVALID); + EXPECT_MATH_ERRNO(EDOM); EXPECT_FP_EQ_WITH_EXCEPTION(neg_inf, LIBC_NAMESPACE::log10(0.0), FE_DIVBYZERO); + EXPECT_MATH_ERRNO(ERANGE); EXPECT_FP_EQ_WITH_EXCEPTION(neg_inf, LIBC_NAMESPACE::log10(-0.0), FE_DIVBYZERO); + EXPECT_MATH_ERRNO(ERANGE); EXPECT_FP_IS_NAN_WITH_EXCEPTION(LIBC_NAMESPACE::log10(-1.0), FE_INVALID); + EXPECT_MATH_ERRNO(EDOM); EXPECT_FP_EQ_ALL_ROUNDING(zero, LIBC_NAMESPACE::log10(1.0)); double x = 1.0; diff --git a/libc/test/src/math/smoke/log10f16_test.cpp b/libc/test/src/math/smoke/log10f16_test.cpp index 53f5ac4..0e8d054 100644 --- a/libc/test/src/math/smoke/log10f16_test.cpp +++ b/libc/test/src/math/smoke/log10f16_test.cpp @@ -6,9 +6,9 @@ // //===----------------------------------------------------------------------===// +#include "hdr/errno_macros.h" #include "hdr/fenv_macros.h" #include "src/__support/FPUtil/cast.h" -#include "src/__support/libc_errno.h" #include "src/math/log10f16.h" #include "test/UnitTest/FPMatcher.h" #include "test/UnitTest/Test.h" @@ -16,8 +16,6 @@ using LlvmLibcLog10f16Test = LIBC_NAMESPACE::testing::FPTest<float16>; TEST_F(LlvmLibcLog10f16Test, SpecialNumbers) { - libc_errno = 0; - EXPECT_FP_EQ_ALL_ROUNDING(aNaN, LIBC_NAMESPACE::log10f16(aNaN)); EXPECT_MATH_ERRNO(0); diff --git a/libc/test/src/math/smoke/log10f_test.cpp b/libc/test/src/math/smoke/log10f_test.cpp index f15da75..a8b4bd0 100644 --- a/libc/test/src/math/smoke/log10f_test.cpp +++ b/libc/test/src/math/smoke/log10f_test.cpp @@ -6,6 +6,7 @@ // //===----------------------------------------------------------------------===// +#include "hdr/errno_macros.h" #include "hdr/math_macros.h" #include "hdr/stdint_proxy.h" #include "src/__support/FPUtil/FPBits.h" @@ -21,12 +22,19 @@ TEST_F(LlvmLibcLog10fTest, SpecialNumbers) { EXPECT_FP_EQ(aNaN, LIBC_NAMESPACE::log10f(aNaN)); EXPECT_FP_EQ(inf, LIBC_NAMESPACE::log10f(inf)); + EXPECT_MATH_ERRNO(0); + EXPECT_FP_IS_NAN_WITH_EXCEPTION(LIBC_NAMESPACE::log10f(neg_inf), FE_INVALID); + EXPECT_MATH_ERRNO(EDOM); EXPECT_FP_EQ_WITH_EXCEPTION(neg_inf, LIBC_NAMESPACE::log10f(0.0f), FE_DIVBYZERO); + EXPECT_MATH_ERRNO(ERANGE); EXPECT_FP_EQ_WITH_EXCEPTION(neg_inf, LIBC_NAMESPACE::log10f(-0.0f), FE_DIVBYZERO); + EXPECT_MATH_ERRNO(ERANGE); EXPECT_FP_IS_NAN_WITH_EXCEPTION(LIBC_NAMESPACE::log10f(-1.0f), FE_INVALID); + EXPECT_MATH_ERRNO(EDOM); + EXPECT_FP_EQ_ALL_ROUNDING(zero, LIBC_NAMESPACE::log10f(1.0f)); float x = 1.0f; diff --git a/libc/test/src/math/smoke/log1p_test.cpp b/libc/test/src/math/smoke/log1p_test.cpp index 61c56cd..3b9dd05 100644 --- a/libc/test/src/math/smoke/log1p_test.cpp +++ b/libc/test/src/math/smoke/log1p_test.cpp @@ -6,9 +6,9 @@ // //===----------------------------------------------------------------------===// +#include "hdr/errno_macros.h" #include "hdr/math_macros.h" #include "src/__support/FPUtil/FPBits.h" -#include "src/__support/libc_errno.h" #include "src/math/log1p.h" #include "test/UnitTest/FPMatcher.h" #include "test/UnitTest/Test.h" @@ -21,12 +21,16 @@ TEST_F(LlvmLibcLog1pTest, SpecialNumbers) { EXPECT_FP_EQ(aNaN, LIBC_NAMESPACE::log1p(aNaN)); EXPECT_FP_EQ(inf, LIBC_NAMESPACE::log1p(inf)); + EXPECT_MATH_ERRNO(0); EXPECT_FP_IS_NAN_WITH_EXCEPTION(LIBC_NAMESPACE::log1p(neg_inf), FE_INVALID); + EXPECT_MATH_ERRNO(EDOM); EXPECT_FP_IS_NAN_WITH_EXCEPTION(LIBC_NAMESPACE::log1p(-2.0), FE_INVALID); + EXPECT_MATH_ERRNO(EDOM); EXPECT_FP_EQ(zero, LIBC_NAMESPACE::log1p(0.0)); EXPECT_FP_EQ(neg_zero, LIBC_NAMESPACE::log1p(-0.0)); EXPECT_FP_EQ_WITH_EXCEPTION(neg_inf, LIBC_NAMESPACE::log1p(-1.0), FE_DIVBYZERO); + EXPECT_MATH_ERRNO(ERANGE); EXPECT_FP_EQ(0x1.62c829bf8fd9dp9, LIBC_NAMESPACE::log1p(0x1.9b536cac3a09dp1023)); diff --git a/libc/test/src/math/smoke/log1pf_test.cpp b/libc/test/src/math/smoke/log1pf_test.cpp index 82c2f94..6fbeb62b 100644 --- a/libc/test/src/math/smoke/log1pf_test.cpp +++ b/libc/test/src/math/smoke/log1pf_test.cpp @@ -6,10 +6,10 @@ // //===----------------------------------------------------------------------===// +#include "hdr/errno_macros.h" #include "hdr/math_macros.h" #include "hdr/stdint_proxy.h" #include "src/__support/FPUtil/FPBits.h" -#include "src/__support/libc_errno.h" #include "src/math/log1pf.h" #include "test/UnitTest/FPMatcher.h" #include "test/UnitTest/Test.h" @@ -22,11 +22,14 @@ TEST_F(LlvmLibcLog1pfTest, SpecialNumbers) { EXPECT_FP_EQ(aNaN, LIBC_NAMESPACE::log1pf(aNaN)); EXPECT_FP_EQ(inf, LIBC_NAMESPACE::log1pf(inf)); + EXPECT_MATH_ERRNO(0); EXPECT_FP_IS_NAN_WITH_EXCEPTION(LIBC_NAMESPACE::log1pf(neg_inf), FE_INVALID); + EXPECT_MATH_ERRNO(EDOM); EXPECT_FP_EQ(zero, LIBC_NAMESPACE::log1pf(0.0f)); EXPECT_FP_EQ(neg_zero, LIBC_NAMESPACE::log1pf(-0.0f)); EXPECT_FP_EQ_WITH_EXCEPTION(neg_inf, LIBC_NAMESPACE::log1pf(-1.0f), FE_DIVBYZERO); + EXPECT_MATH_ERRNO(ERANGE); } #ifdef LIBC_TEST_FTZ_DAZ diff --git a/libc/test/src/math/smoke/log2_test.cpp b/libc/test/src/math/smoke/log2_test.cpp index 6bf1ce3..8adf81f 100644 --- a/libc/test/src/math/smoke/log2_test.cpp +++ b/libc/test/src/math/smoke/log2_test.cpp @@ -6,10 +6,10 @@ // //===----------------------------------------------------------------------===// +#include "hdr/errno_macros.h" #include "hdr/math_macros.h" #include "hdr/stdint_proxy.h" #include "src/__support/FPUtil/FPBits.h" -#include "src/__support/libc_errno.h" #include "src/math/log2.h" #include "test/UnitTest/FPMatcher.h" #include "test/UnitTest/Test.h" @@ -22,11 +22,16 @@ TEST_F(LlvmLibcLog2Test, SpecialNumbers) { EXPECT_FP_EQ(aNaN, LIBC_NAMESPACE::log2(aNaN)); EXPECT_FP_EQ(inf, LIBC_NAMESPACE::log2(inf)); + EXPECT_MATH_ERRNO(0); EXPECT_FP_IS_NAN_WITH_EXCEPTION(LIBC_NAMESPACE::log2(neg_inf), FE_INVALID); + EXPECT_MATH_ERRNO(EDOM); EXPECT_FP_EQ_WITH_EXCEPTION(neg_inf, LIBC_NAMESPACE::log2(0.0), FE_DIVBYZERO); + EXPECT_MATH_ERRNO(ERANGE); EXPECT_FP_EQ_WITH_EXCEPTION(neg_inf, LIBC_NAMESPACE::log2(-0.0), FE_DIVBYZERO); + EXPECT_MATH_ERRNO(ERANGE); EXPECT_FP_IS_NAN_WITH_EXCEPTION(LIBC_NAMESPACE::log2(-1.0), FE_INVALID); + EXPECT_MATH_ERRNO(EDOM); EXPECT_FP_EQ_ALL_ROUNDING(zero, LIBC_NAMESPACE::log2(1.0)); } diff --git a/libc/test/src/math/smoke/log2f16_test.cpp b/libc/test/src/math/smoke/log2f16_test.cpp index fd20652..abefc67 100644 --- a/libc/test/src/math/smoke/log2f16_test.cpp +++ b/libc/test/src/math/smoke/log2f16_test.cpp @@ -6,9 +6,9 @@ // //===----------------------------------------------------------------------===// +#include "hdr/errno_macros.h" #include "hdr/fenv_macros.h" #include "src/__support/FPUtil/cast.h" -#include "src/__support/libc_errno.h" #include "src/math/log2f16.h" #include "test/UnitTest/FPMatcher.h" #include "test/UnitTest/Test.h" @@ -16,8 +16,6 @@ using LlvmLibcLog2f16Test = LIBC_NAMESPACE::testing::FPTest<float16>; TEST_F(LlvmLibcLog2f16Test, SpecialNumbers) { - libc_errno = 0; - EXPECT_FP_EQ_ALL_ROUNDING(aNaN, LIBC_NAMESPACE::log2f16(aNaN)); EXPECT_MATH_ERRNO(0); diff --git a/libc/test/src/math/smoke/log2f_test.cpp b/libc/test/src/math/smoke/log2f_test.cpp index 80e13a2..56a46a5 100644 --- a/libc/test/src/math/smoke/log2f_test.cpp +++ b/libc/test/src/math/smoke/log2f_test.cpp @@ -6,10 +6,10 @@ // //===----------------------------------------------------------------------===// +#include "hdr/errno_macros.h" #include "hdr/math_macros.h" #include "hdr/stdint_proxy.h" #include "src/__support/FPUtil/FPBits.h" -#include "src/__support/libc_errno.h" #include "src/math/log2f.h" #include "test/UnitTest/FPMatcher.h" #include "test/UnitTest/Test.h" @@ -22,12 +22,17 @@ TEST_F(LlvmLibcLog2fTest, SpecialNumbers) { EXPECT_FP_EQ(aNaN, LIBC_NAMESPACE::log2f(aNaN)); EXPECT_FP_EQ(inf, LIBC_NAMESPACE::log2f(inf)); + EXPECT_MATH_ERRNO(0); EXPECT_FP_IS_NAN_WITH_EXCEPTION(LIBC_NAMESPACE::log2f(neg_inf), FE_INVALID); + EXPECT_MATH_ERRNO(EDOM); EXPECT_FP_EQ_WITH_EXCEPTION(neg_inf, LIBC_NAMESPACE::log2f(0.0f), FE_DIVBYZERO); + EXPECT_MATH_ERRNO(ERANGE); EXPECT_FP_EQ_WITH_EXCEPTION(neg_inf, LIBC_NAMESPACE::log2f(-0.0f), FE_DIVBYZERO); + EXPECT_MATH_ERRNO(ERANGE); EXPECT_FP_IS_NAN_WITH_EXCEPTION(LIBC_NAMESPACE::log2f(-1.0f), FE_INVALID); + EXPECT_MATH_ERRNO(EDOM); EXPECT_FP_EQ_ALL_ROUNDING(zero, LIBC_NAMESPACE::log2f(1.0f)); } #ifdef LIBC_TEST_FTZ_DAZ diff --git a/libc/test/src/math/smoke/log_test.cpp b/libc/test/src/math/smoke/log_test.cpp index 1d7761a..192e6c8 100644 --- a/libc/test/src/math/smoke/log_test.cpp +++ b/libc/test/src/math/smoke/log_test.cpp @@ -6,10 +6,10 @@ // //===----------------------------------------------------------------------===// +#include "hdr/errno_macros.h" #include "hdr/math_macros.h" #include "hdr/stdint_proxy.h" #include "src/__support/FPUtil/FPBits.h" -#include "src/__support/libc_errno.h" #include "src/math/log.h" #include "test/UnitTest/FPMatcher.h" #include "test/UnitTest/Test.h" @@ -22,10 +22,15 @@ TEST_F(LlvmLibcLogTest, SpecialNumbers) { EXPECT_FP_EQ(aNaN, LIBC_NAMESPACE::log(aNaN)); EXPECT_FP_EQ(inf, LIBC_NAMESPACE::log(inf)); + EXPECT_MATH_ERRNO(0); EXPECT_FP_IS_NAN_WITH_EXCEPTION(LIBC_NAMESPACE::log(neg_inf), FE_INVALID); + EXPECT_MATH_ERRNO(EDOM); EXPECT_FP_EQ_WITH_EXCEPTION(neg_inf, LIBC_NAMESPACE::log(0.0), FE_DIVBYZERO); + EXPECT_MATH_ERRNO(ERANGE); EXPECT_FP_EQ_WITH_EXCEPTION(neg_inf, LIBC_NAMESPACE::log(-0.0), FE_DIVBYZERO); + EXPECT_MATH_ERRNO(ERANGE); EXPECT_FP_IS_NAN_WITH_EXCEPTION(LIBC_NAMESPACE::log(-1.0), FE_INVALID); + EXPECT_MATH_ERRNO(EDOM); EXPECT_FP_EQ_ALL_ROUNDING(zero, LIBC_NAMESPACE::log(1.0)); } diff --git a/libc/test/src/math/smoke/logf16_test.cpp b/libc/test/src/math/smoke/logf16_test.cpp index 2784f3d..a8332c6 100644 --- a/libc/test/src/math/smoke/logf16_test.cpp +++ b/libc/test/src/math/smoke/logf16_test.cpp @@ -6,9 +6,9 @@ // //===----------------------------------------------------------------------===// +#include "hdr/errno_macros.h" #include "hdr/fenv_macros.h" #include "src/__support/FPUtil/cast.h" -#include "src/__support/libc_errno.h" #include "src/math/logf16.h" #include "test/UnitTest/FPMatcher.h" #include "test/UnitTest/Test.h" @@ -16,8 +16,6 @@ using LlvmLibcLogf16Test = LIBC_NAMESPACE::testing::FPTest<float16>; TEST_F(LlvmLibcLogf16Test, SpecialNumbers) { - libc_errno = 0; - EXPECT_FP_EQ_ALL_ROUNDING(aNaN, LIBC_NAMESPACE::logf16(aNaN)); EXPECT_MATH_ERRNO(0); diff --git a/libc/test/src/math/smoke/logf_test.cpp b/libc/test/src/math/smoke/logf_test.cpp index f58209e..893d89d 100644 --- a/libc/test/src/math/smoke/logf_test.cpp +++ b/libc/test/src/math/smoke/logf_test.cpp @@ -6,6 +6,7 @@ // //===----------------------------------------------------------------------===// +#include "hdr/errno_macros.h" #include "hdr/math_macros.h" #include "hdr/stdint_proxy.h" #include "src/__support/FPUtil/FPBits.h" @@ -21,12 +22,17 @@ TEST_F(LlvmLibcLogfTest, SpecialNumbers) { EXPECT_FP_EQ(aNaN, LIBC_NAMESPACE::logf(aNaN)); EXPECT_FP_EQ(inf, LIBC_NAMESPACE::logf(inf)); + EXPECT_MATH_ERRNO(0); EXPECT_FP_IS_NAN_WITH_EXCEPTION(LIBC_NAMESPACE::logf(neg_inf), FE_INVALID); + EXPECT_MATH_ERRNO(EDOM); EXPECT_FP_EQ_WITH_EXCEPTION(neg_inf, LIBC_NAMESPACE::logf(0.0f), FE_DIVBYZERO); + EXPECT_MATH_ERRNO(ERANGE); EXPECT_FP_EQ_WITH_EXCEPTION(neg_inf, LIBC_NAMESPACE::logf(-0.0f), FE_DIVBYZERO); + EXPECT_MATH_ERRNO(ERANGE); EXPECT_FP_IS_NAN_WITH_EXCEPTION(LIBC_NAMESPACE::logf(-1.0f), FE_INVALID); + EXPECT_MATH_ERRNO(EDOM); EXPECT_FP_EQ_ALL_ROUNDING(zero, LIBC_NAMESPACE::logf(1.0f)); } #ifdef LIBC_TEST_FTZ_DAZ diff --git a/libc/test/src/math/smoke/sincos_test.cpp b/libc/test/src/math/smoke/sincos_test.cpp index 8bc584d..a98b931 100644 --- a/libc/test/src/math/smoke/sincos_test.cpp +++ b/libc/test/src/math/smoke/sincos_test.cpp @@ -6,6 +6,7 @@ // //===----------------------------------------------------------------------===// +#include "hdr/errno_macros.h" #include "src/math/sincos.h" #include "test/UnitTest/FPMatcher.h" #include "test/UnitTest/Test.h" @@ -35,10 +36,12 @@ TEST_F(LlvmLibcSincosTest, SpecialNumbers) { LIBC_NAMESPACE::sincos(inf, &sin_x, &cos_x); EXPECT_FP_EQ_ALL_ROUNDING(aNaN, cos_x); EXPECT_FP_EQ_ALL_ROUNDING(aNaN, sin_x); + EXPECT_MATH_ERRNO(EDOM); LIBC_NAMESPACE::sincos(neg_inf, &sin_x, &cos_x); EXPECT_FP_EQ_ALL_ROUNDING(aNaN, cos_x); EXPECT_FP_EQ_ALL_ROUNDING(aNaN, sin_x); + EXPECT_MATH_ERRNO(EDOM); LIBC_NAMESPACE::sincos(0x1.0p-28, &sin_x, &cos_x); EXPECT_FP_EQ(1.0, cos_x); diff --git a/libc/test/src/math/smoke/sincosf_test.cpp b/libc/test/src/math/smoke/sincosf_test.cpp index 7ff0ba7..f39a112 100644 --- a/libc/test/src/math/smoke/sincosf_test.cpp +++ b/libc/test/src/math/smoke/sincosf_test.cpp @@ -6,10 +6,10 @@ // //===----------------------------------------------------------------------===// +#include "hdr/errno_macros.h" #include "hdr/math_macros.h" #include "hdr/stdint_proxy.h" #include "src/__support/FPUtil/FPBits.h" -#include "src/__support/libc_errno.h" #include "src/math/sincosf.h" #include "test/UnitTest/FPMatcher.h" #include "test/UnitTest/Test.h" @@ -17,7 +17,6 @@ using LlvmLibcSinCosfTest = LIBC_NAMESPACE::testing::FPTest<float>; TEST_F(LlvmLibcSinCosfTest, SpecialNumbers) { - libc_errno = 0; float sin, cos; LIBC_NAMESPACE::sincosf(sNaN, &sin, &cos); diff --git a/libc/test/src/math/smoke/sinf16_test.cpp b/libc/test/src/math/smoke/sinf16_test.cpp index 6b168ac..9924f35 100644 --- a/libc/test/src/math/smoke/sinf16_test.cpp +++ b/libc/test/src/math/smoke/sinf16_test.cpp @@ -6,7 +6,7 @@ // //===----------------------------------------------------------------------===// -#include "src/__support/libc_errno.h" +#include "hdr/errno_macros.h" #include "src/math/sinf16.h" #include "test/UnitTest/FPMatcher.h" #include "test/UnitTest/Test.h" @@ -14,8 +14,6 @@ using LlvmLibcSinf16Test = LIBC_NAMESPACE::testing::FPTest<float16>; TEST_F(LlvmLibcSinf16Test, SpecialNumbers) { - libc_errno = 0; - EXPECT_FP_EQ_WITH_EXCEPTION(aNaN, LIBC_NAMESPACE::sinf16(sNaN), FE_INVALID); EXPECT_MATH_ERRNO(0); diff --git a/libc/test/src/math/smoke/sinf_test.cpp b/libc/test/src/math/smoke/sinf_test.cpp index 8ba66ed..b0ba81e 100644 --- a/libc/test/src/math/smoke/sinf_test.cpp +++ b/libc/test/src/math/smoke/sinf_test.cpp @@ -6,10 +6,10 @@ // //===----------------------------------------------------------------------===// +#include "hdr/errno_macros.h" #include "hdr/math_macros.h" #include "hdr/stdint_proxy.h" #include "src/__support/FPUtil/FPBits.h" -#include "src/__support/libc_errno.h" #include "src/math/sinf.h" #include "test/UnitTest/FPMatcher.h" #include "test/UnitTest/Test.h" @@ -17,8 +17,6 @@ using LlvmLibcSinfTest = LIBC_NAMESPACE::testing::FPTest<float>; TEST_F(LlvmLibcSinfTest, SpecialNumbers) { - libc_errno = 0; - EXPECT_FP_EQ_WITH_EXCEPTION(aNaN, LIBC_NAMESPACE::sinf(sNaN), FE_INVALID); EXPECT_MATH_ERRNO(0); diff --git a/libc/test/src/math/smoke/sinhf16_test.cpp b/libc/test/src/math/smoke/sinhf16_test.cpp index d52739a..1cbf19c 100644 --- a/libc/test/src/math/smoke/sinhf16_test.cpp +++ b/libc/test/src/math/smoke/sinhf16_test.cpp @@ -6,9 +6,9 @@ // //===----------------------------------------------------------------------===// +#include "hdr/errno_macros.h" #include "hdr/fenv_macros.h" #include "src/__support/FPUtil/cast.h" -#include "src/__support/libc_errno.h" #include "src/math/sinhf16.h" #include "test/UnitTest/FPMatcher.h" #include "test/UnitTest/Test.h" @@ -16,8 +16,6 @@ using LlvmLibcSinhf16Test = LIBC_NAMESPACE::testing::FPTest<float16>; TEST_F(LlvmLibcSinhf16Test, SpecialNumbers) { - libc_errno = 0; - EXPECT_FP_EQ_ALL_ROUNDING(aNaN, LIBC_NAMESPACE::sinhf16(aNaN)); EXPECT_MATH_ERRNO(0); @@ -38,8 +36,6 @@ TEST_F(LlvmLibcSinhf16Test, SpecialNumbers) { } TEST_F(LlvmLibcSinhf16Test, Overflow) { - libc_errno = 0; - EXPECT_FP_EQ_WITH_EXCEPTION(inf, LIBC_NAMESPACE::sinhf16(max_normal), FE_OVERFLOW | FE_INEXACT); EXPECT_MATH_ERRNO(ERANGE); diff --git a/libc/test/src/math/smoke/sinhf_test.cpp b/libc/test/src/math/smoke/sinhf_test.cpp index 5976a1f..8121ccb 100644 --- a/libc/test/src/math/smoke/sinhf_test.cpp +++ b/libc/test/src/math/smoke/sinhf_test.cpp @@ -6,11 +6,11 @@ // //===----------------------------------------------------------------------===// +#include "hdr/errno_macros.h" #include "hdr/math_macros.h" #include "hdr/stdint_proxy.h" #include "src/__support/CPP/array.h" #include "src/__support/FPUtil/FPBits.h" -#include "src/__support/libc_errno.h" #include "src/math/sinhf.h" #include "test/UnitTest/FPMatcher.h" #include "test/UnitTest/Test.h" @@ -18,8 +18,6 @@ using LlvmLibcSinhfTest = LIBC_NAMESPACE::testing::FPTest<float>; TEST_F(LlvmLibcSinhfTest, SpecialNumbers) { - libc_errno = 0; - EXPECT_FP_EQ_WITH_EXCEPTION(aNaN, LIBC_NAMESPACE::sinhf(sNaN), FE_INVALID); EXPECT_MATH_ERRNO(0); @@ -51,7 +49,6 @@ TEST_F(LlvmLibcSinhfTest, SmallValues) { } TEST_F(LlvmLibcSinhfTest, Overflow) { - libc_errno = 0; EXPECT_FP_EQ_WITH_EXCEPTION( inf, LIBC_NAMESPACE::sinhf(FPBits(0x7f7fffffU).get_val()), FE_OVERFLOW); EXPECT_MATH_ERRNO(ERANGE); diff --git a/libc/test/src/math/smoke/sinpif16_test.cpp b/libc/test/src/math/smoke/sinpif16_test.cpp index 9edf2cc..0b4ec91 100644 --- a/libc/test/src/math/smoke/sinpif16_test.cpp +++ b/libc/test/src/math/smoke/sinpif16_test.cpp @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// +#include "hdr/errno_macros.h" #include "src/__support/FPUtil/cast.h" -#include "src/__support/libc_errno.h" #include "src/math/sinpif16.h" #include "test/UnitTest/FPMatcher.h" #include "test/UnitTest/Test.h" @@ -15,8 +15,6 @@ using LlvmLibcSinpif16Test = LIBC_NAMESPACE::testing::FPTest<float16>; TEST_F(LlvmLibcSinpif16Test, SpecialNumbers) { - libc_errno = 0; - EXPECT_FP_EQ_WITH_EXCEPTION(aNaN, LIBC_NAMESPACE::sinpif16(sNaN), FE_INVALID); EXPECT_MATH_ERRNO(0); diff --git a/libc/test/src/math/smoke/sinpif_test.cpp b/libc/test/src/math/smoke/sinpif_test.cpp index 4a725e0..ca2cac5 100644 --- a/libc/test/src/math/smoke/sinpif_test.cpp +++ b/libc/test/src/math/smoke/sinpif_test.cpp @@ -6,16 +6,14 @@ // //===----------------------------------------------------------------------===// +#include "hdr/errno_macros.h" #include "hdr/stdint_proxy.h" -#include "src/__support/libc_errno.h" #include "src/math/sinpif.h" #include "test/UnitTest/FPMatcher.h" using LlvmLibcSinpifTest = LIBC_NAMESPACE::testing::FPTest<float>; TEST_F(LlvmLibcSinpifTest, SpecialNumbers) { - libc_errno = 0; - EXPECT_FP_EQ_WITH_EXCEPTION(aNaN, LIBC_NAMESPACE::sinpif(sNaN), FE_INVALID); EXPECT_MATH_ERRNO(0); diff --git a/libc/test/src/math/smoke/tanf16_test.cpp b/libc/test/src/math/smoke/tanf16_test.cpp index 95d200c..a29f21a 100644 --- a/libc/test/src/math/smoke/tanf16_test.cpp +++ b/libc/test/src/math/smoke/tanf16_test.cpp @@ -7,7 +7,7 @@ // //===----------------------------------------------------------------------===// -#include "src/__support/libc_errno.h" +#include "hdr/errno_macros.h" #include "src/math/tanf16.h" #include "test/UnitTest/FPMatcher.h" #include "test/UnitTest/Test.h" @@ -15,8 +15,6 @@ using LlvmLibcTanf16Test = LIBC_NAMESPACE::testing::FPTest<float16>; TEST_F(LlvmLibcTanf16Test, SpecialNumbers) { - libc_errno = 0; - EXPECT_FP_EQ_WITH_EXCEPTION(aNaN, LIBC_NAMESPACE::tanf16(sNaN), FE_INVALID); EXPECT_MATH_ERRNO(0); diff --git a/libc/test/src/math/smoke/tanf_test.cpp b/libc/test/src/math/smoke/tanf_test.cpp index c85907c..a1bffad 100644 --- a/libc/test/src/math/smoke/tanf_test.cpp +++ b/libc/test/src/math/smoke/tanf_test.cpp @@ -6,10 +6,10 @@ // //===----------------------------------------------------------------------===// +#include "hdr/errno_macros.h" #include "hdr/math_macros.h" #include "hdr/stdint_proxy.h" #include "src/__support/FPUtil/FPBits.h" -#include "src/__support/libc_errno.h" #include "src/math/tanf.h" #include "test/UnitTest/FPMatcher.h" #include "test/UnitTest/Test.h" @@ -17,8 +17,6 @@ using LlvmLibcTanfTest = LIBC_NAMESPACE::testing::FPTest<float>; TEST_F(LlvmLibcTanfTest, SpecialNumbers) { - libc_errno = 0; - EXPECT_FP_EQ_WITH_EXCEPTION(aNaN, LIBC_NAMESPACE::tanf(sNaN), FE_INVALID); EXPECT_MATH_ERRNO(0); diff --git a/libc/test/src/math/smoke/tanhf16_test.cpp b/libc/test/src/math/smoke/tanhf16_test.cpp index eb90f02..e00cb0a 100644 --- a/libc/test/src/math/smoke/tanhf16_test.cpp +++ b/libc/test/src/math/smoke/tanhf16_test.cpp @@ -6,9 +6,9 @@ // //===----------------------------------------------------------------------===// +#include "hdr/errno_macros.h" #include "hdr/fenv_macros.h" #include "src/__support/FPUtil/cast.h" -#include "src/__support/libc_errno.h" #include "src/math/tanhf16.h" #include "test/UnitTest/FPMatcher.h" #include "test/UnitTest/Test.h" @@ -16,8 +16,6 @@ using LlvmLibcTanhf16Test = LIBC_NAMESPACE::testing::FPTest<float16>; TEST_F(LlvmLibcTanhf16Test, SpecialNumbers) { - libc_errno = 0; - EXPECT_FP_EQ_ALL_ROUNDING(aNaN, LIBC_NAMESPACE::tanhf16(aNaN)); EXPECT_MATH_ERRNO(0); @@ -40,8 +38,6 @@ TEST_F(LlvmLibcTanhf16Test, SpecialNumbers) { } TEST_F(LlvmLibcTanhf16Test, ResultNearBounds) { - libc_errno = 0; - EXPECT_FP_EQ_WITH_EXCEPTION(LIBC_NAMESPACE::fputil::cast<float16>(1.0), LIBC_NAMESPACE::tanhf16(max_normal), FE_INEXACT); EXPECT_MATH_ERRNO(0); diff --git a/libc/test/src/math/smoke/tanhf_test.cpp b/libc/test/src/math/smoke/tanhf_test.cpp index 57c0573..a887a99 100644 --- a/libc/test/src/math/smoke/tanhf_test.cpp +++ b/libc/test/src/math/smoke/tanhf_test.cpp @@ -6,10 +6,10 @@ // //===----------------------------------------------------------------------===// +#include "hdr/errno_macros.h" #include "hdr/math_macros.h" #include "hdr/stdint_proxy.h" #include "src/__support/FPUtil/FPBits.h" -#include "src/__support/libc_errno.h" #include "src/math/tanhf.h" #include "test/UnitTest/FPMatcher.h" #include "test/UnitTest/Test.h" @@ -17,8 +17,6 @@ using LlvmLibcTanhfTest = LIBC_NAMESPACE::testing::FPTest<float>; TEST_F(LlvmLibcTanhfTest, SpecialNumbers) { - libc_errno = 0; - EXPECT_FP_EQ_WITH_EXCEPTION(aNaN, LIBC_NAMESPACE::tanhf(sNaN), FE_INVALID); EXPECT_MATH_ERRNO(0); diff --git a/libc/test/src/math/smoke/tanpif16_test.cpp b/libc/test/src/math/smoke/tanpif16_test.cpp index ea896d7..b005dfb 100644 --- a/libc/test/src/math/smoke/tanpif16_test.cpp +++ b/libc/test/src/math/smoke/tanpif16_test.cpp @@ -6,7 +6,7 @@ // //===----------------------------------------------------------------------===// -#include "src/__support/libc_errno.h" +#include "hdr/errno_macros.h" #include "src/math/tanpif16.h" #include "test/UnitTest/FPMatcher.h" #include "test/UnitTest/Test.h" @@ -14,8 +14,6 @@ using LlvmLibcTanpif16Test = LIBC_NAMESPACE::testing::FPTest<float16>; TEST_F(LlvmLibcTanpif16Test, SpecialNumbers) { - libc_errno = 0; - EXPECT_FP_EQ_WITH_EXCEPTION(aNaN, LIBC_NAMESPACE::tanpif16(sNaN), FE_INVALID); EXPECT_MATH_ERRNO(0); diff --git a/libc/test/src/math/smoke/tanpif_test.cpp b/libc/test/src/math/smoke/tanpif_test.cpp index e122f57..0504c9a 100644 --- a/libc/test/src/math/smoke/tanpif_test.cpp +++ b/libc/test/src/math/smoke/tanpif_test.cpp @@ -6,7 +6,7 @@ // //===----------------------------------------------------------------------===// -#include "src/__support/libc_errno.h" +#include "hdr/errno_macros.h" #include "src/math/tanpif.h" #include "test/UnitTest/FPMatcher.h" #include "test/UnitTest/Test.h" @@ -14,8 +14,6 @@ using LlvmLibcTanpifTest = LIBC_NAMESPACE::testing::FPTest<float>; TEST_F(LlvmLibcTanpifTest, SpecialNumbers) { - libc_errno = 0; - EXPECT_FP_EQ_WITH_EXCEPTION(aNaN, LIBC_NAMESPACE::tanpif(sNaN), FE_INVALID); EXPECT_MATH_ERRNO(0); diff --git a/libc/test/src/math/tanf_test.cpp b/libc/test/src/math/tanf_test.cpp index 27949eb..2202bd6 100644 --- a/libc/test/src/math/tanf_test.cpp +++ b/libc/test/src/math/tanf_test.cpp @@ -6,9 +6,9 @@ // //===----------------------------------------------------------------------===// +#include "hdr/errno_macros.h" #include "hdr/math_macros.h" #include "src/__support/FPUtil/FPBits.h" -#include "src/__support/libc_errno.h" #include "src/math/tanf.h" #include "test/UnitTest/FPMatcher.h" #include "test/UnitTest/Test.h" @@ -24,8 +24,6 @@ using LIBC_NAMESPACE::testing::SDCOMP26094_VALUES; namespace mpfr = LIBC_NAMESPACE::testing::mpfr; TEST_F(LlvmLibcTanfTest, SpecialNumbers) { - libc_errno = 0; - EXPECT_FP_EQ(aNaN, LIBC_NAMESPACE::tanf(aNaN)); EXPECT_MATH_ERRNO(0); diff --git a/libc/test/src/math/tanhf_test.cpp b/libc/test/src/math/tanhf_test.cpp index 27a6cbc..106a51a 100644 --- a/libc/test/src/math/tanhf_test.cpp +++ b/libc/test/src/math/tanhf_test.cpp @@ -8,7 +8,6 @@ #include "hdr/math_macros.h" #include "src/__support/FPUtil/FPBits.h" -#include "src/__support/libc_errno.h" #include "src/math/tanhf.h" #include "test/UnitTest/FPMatcher.h" #include "test/UnitTest/Test.h" @@ -21,8 +20,6 @@ using LlvmLibcTanhfTest = LIBC_NAMESPACE::testing::FPTest<float>; namespace mpfr = LIBC_NAMESPACE::testing::mpfr; TEST_F(LlvmLibcTanhfTest, SpecialNumbers) { - libc_errno = 0; - EXPECT_FP_EQ(aNaN, LIBC_NAMESPACE::tanhf(aNaN)); EXPECT_MATH_ERRNO(0); diff --git a/libc/test/src/poll/CMakeLists.txt b/libc/test/src/poll/CMakeLists.txt index c4af141..54e0033 100644 --- a/libc/test/src/poll/CMakeLists.txt +++ b/libc/test/src/poll/CMakeLists.txt @@ -10,5 +10,5 @@ add_libc_unittest( libc.hdr.limits_macros libc.src.errno.errno libc.src.poll.poll - libc.test.UnitTest.ErrnoSetterMatcher + libc.test.UnitTest.ErrnoCheckingTest ) diff --git a/libc/test/src/poll/poll_test.cpp b/libc/test/src/poll/poll_test.cpp index 97b7b02..5bf2d5e 100644 --- a/libc/test/src/poll/poll_test.cpp +++ b/libc/test/src/poll/poll_test.cpp @@ -7,18 +7,19 @@ //===----------------------------------------------------------------------===// #include "hdr/limits_macros.h" // UINT_MAX -#include "src/__support/libc_errno.h" #include "src/poll/poll.h" +#include "test/UnitTest/ErrnoCheckingTest.h" #include "test/UnitTest/Test.h" -TEST(LlvmLibcPollTest, SmokeTest) { - libc_errno = 0; +using LlvmLibcPollTest = LIBC_NAMESPACE::testing::ErrnoCheckingTest; + +TEST_F(LlvmLibcPollTest, SmokeTest) { int ret = LIBC_NAMESPACE::poll(nullptr, 0, 0); ASSERT_ERRNO_SUCCESS(); ASSERT_EQ(0, ret); } -TEST(LlvmLibcPollTest, SmokeFailureTest) { - libc_errno = 0; + +TEST_F(LlvmLibcPollTest, SmokeFailureTest) { int ret = LIBC_NAMESPACE::poll(nullptr, UINT_MAX, 0); ASSERT_ERRNO_EQ(EINVAL); ASSERT_EQ(-1, ret); diff --git a/libc/test/src/spawn/CMakeLists.txt b/libc/test/src/spawn/CMakeLists.txt index 04814db..103925c 100644 --- a/libc/test/src/spawn/CMakeLists.txt +++ b/libc/test/src/spawn/CMakeLists.txt @@ -7,6 +7,7 @@ add_libc_unittest( SRCS posix_spawn_file_actions_test.cpp DEPENDS + libc.hdr.errno_macros libc.hdr.stdint_proxy libc.include.spawn libc.src.spawn.file_actions @@ -15,5 +16,4 @@ add_libc_unittest( libc.src.spawn.posix_spawn_file_actions_addopen libc.src.spawn.posix_spawn_file_actions_destroy libc.src.spawn.posix_spawn_file_actions_init - libc.src.errno.errno ) diff --git a/libc/test/src/spawn/posix_spawn_file_actions_test.cpp b/libc/test/src/spawn/posix_spawn_file_actions_test.cpp index 935a354..20ab312 100644 --- a/libc/test/src/spawn/posix_spawn_file_actions_test.cpp +++ b/libc/test/src/spawn/posix_spawn_file_actions_test.cpp @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// +#include "hdr/errno_macros.h" #include "hdr/stdint_proxy.h" -#include "src/__support/libc_errno.h" #include "src/spawn/file_actions.h" #include "src/spawn/posix_spawn_file_actions_addclose.h" #include "src/spawn/posix_spawn_file_actions_adddup2.h" diff --git a/libc/test/src/sys/ioctl/linux/CMakeLists.txt b/libc/test/src/sys/ioctl/linux/CMakeLists.txt index 2df67e9..2ccef25 100644 --- a/libc/test/src/sys/ioctl/linux/CMakeLists.txt +++ b/libc/test/src/sys/ioctl/linux/CMakeLists.txt @@ -14,5 +14,7 @@ add_libc_unittest( libc.src.unistd.close libc.src.unistd.read libc.src.unistd.write + libc.test.UnitTest.ErrnoCheckingTest + libc.test.UnitTest.ErrnoSetterMatcher ) diff --git a/libc/test/src/sys/ioctl/linux/ioctl_test.cpp b/libc/test/src/sys/ioctl/linux/ioctl_test.cpp index b76dc14..4560bcf 100644 --- a/libc/test/src/sys/ioctl/linux/ioctl_test.cpp +++ b/libc/test/src/sys/ioctl/linux/ioctl_test.cpp @@ -6,13 +6,12 @@ // //===----------------------------------------------------------------------===// -#include "src/__support/libc_errno.h" #include "src/fcntl/open.h" #include "src/sys/ioctl/ioctl.h" #include "src/unistd/close.h" #include "src/unistd/read.h" #include "src/unistd/write.h" - +#include "test/UnitTest/ErrnoCheckingTest.h" #include "test/UnitTest/ErrnoSetterMatcher.h" #include "test/UnitTest/Test.h" @@ -20,11 +19,10 @@ #include "hdr/sys_ioctl_macros.h" +using LlvmLibcSysIoctlTest = LIBC_NAMESPACE::testing::ErrnoCheckingTest; using LIBC_NAMESPACE::testing::ErrnoSetterMatcher::Succeeds; -TEST(LlvmLibcSysIoctlTest, InvalidCommandAndFIONREAD) { - LIBC_NAMESPACE::libc_errno = 0; - +TEST_F(LlvmLibcSysIoctlTest, InvalidCommandAndFIONREAD) { // Setup the test file constexpr const char *TEST_FILE_NAME = "ioctl.test"; constexpr const char TEST_MSG[] = "ioctl test"; diff --git a/libc/test/src/termios/CMakeLists.txt b/libc/test/src/termios/CMakeLists.txt index 302dd30..059c272 100644 --- a/libc/test/src/termios/CMakeLists.txt +++ b/libc/test/src/termios/CMakeLists.txt @@ -18,5 +18,6 @@ add_libc_unittest( libc.src.termios.tcgetsid libc.src.termios.tcsetattr libc.src.unistd.close + libc.test.UnitTest.ErrnoCheckingTest libc.test.UnitTest.ErrnoSetterMatcher ) diff --git a/libc/test/src/termios/termios_test.cpp b/libc/test/src/termios/termios_test.cpp index 5ec169a..7a80759 100644 --- a/libc/test/src/termios/termios_test.cpp +++ b/libc/test/src/termios/termios_test.cpp @@ -16,49 +16,52 @@ #include "src/termios/tcgetsid.h" #include "src/termios/tcsetattr.h" #include "src/unistd/close.h" +#include "test/UnitTest/ErrnoCheckingTest.h" #include "test/UnitTest/ErrnoSetterMatcher.h" #include "test/UnitTest/Test.h" #include <termios.h> -using LIBC_NAMESPACE::testing::ErrnoSetterMatcher::Fails; -using LIBC_NAMESPACE::testing::ErrnoSetterMatcher::Succeeds; +using LlvmLibcTermiosTest = LIBC_NAMESPACE::testing::ErrnoCheckingTest; +using namespace LIBC_NAMESPACE::testing::ErrnoSetterMatcher; // We just list a bunch of smoke tests here as it is not possible to // test functionality at the least because we want to run the tests // from ninja/make which change the terminal behavior. -TEST(LlvmLibcTermiosTest, SpeedSmokeTest) { +TEST_F(LlvmLibcTermiosTest, SpeedSmokeTest) { struct termios t; - libc_errno = 0; ASSERT_THAT(LIBC_NAMESPACE::cfsetispeed(&t, B50), Succeeds(0)); ASSERT_EQ(LIBC_NAMESPACE::cfgetispeed(&t), speed_t(B50)); ASSERT_THAT(LIBC_NAMESPACE::cfsetospeed(&t, B75), Succeeds(0)); ASSERT_EQ(LIBC_NAMESPACE::cfgetospeed(&t), speed_t(B75)); - libc_errno = 0; ASSERT_THAT(LIBC_NAMESPACE::cfsetispeed(&t, ~CBAUD), Fails(EINVAL)); - libc_errno = 0; ASSERT_THAT(LIBC_NAMESPACE::cfsetospeed(&t, ~CBAUD), Fails(EINVAL)); } -TEST(LlvmLibcTermiosTest, GetAttrSmokeTest) { +TEST_F(LlvmLibcTermiosTest, GetAttrSmokeTest) { struct termios t; - libc_errno = 0; int fd = LIBC_NAMESPACE::open("/dev/tty", O_RDONLY); - if (fd < 0) - return; // When /dev/tty is not available, no point continuing. + if (fd < 0) { + // When /dev/tty is not available, no point continuing + libc_errno = 0; + return; + } ASSERT_ERRNO_SUCCESS(); ASSERT_THAT(LIBC_NAMESPACE::tcgetattr(fd, &t), Succeeds(0)); - ASSERT_EQ(LIBC_NAMESPACE::close(fd), 0); + ASSERT_THAT(LIBC_NAMESPACE::close(fd), Succeeds(0)); } -TEST(LlvmLibcTermiosTest, TcGetSidSmokeTest) { - libc_errno = 0; +TEST_F(LlvmLibcTermiosTest, TcGetSidSmokeTest) { int fd = LIBC_NAMESPACE::open("/dev/tty", O_RDONLY); - if (fd < 0) - return; // When /dev/tty is not available, no point continuing. + if (fd < 0) { + // When /dev/tty is not available, no point continuing + libc_errno = 0; + return; + } ASSERT_ERRNO_SUCCESS(); - ASSERT_GT(LIBC_NAMESPACE::tcgetsid(fd), pid_t(0)); - ASSERT_EQ(LIBC_NAMESPACE::close(fd), 0); + ASSERT_THAT(LIBC_NAMESPACE::tcgetsid(fd), + returns(GT(pid_t(0))).with_errno(EQ(0))); + ASSERT_THAT(LIBC_NAMESPACE::close(fd), Succeeds(0)); } diff --git a/libc/test/src/time/CMakeLists.txt b/libc/test/src/time/CMakeLists.txt index 66753b8..03e5428 100644 --- a/libc/test/src/time/CMakeLists.txt +++ b/libc/test/src/time/CMakeLists.txt @@ -12,9 +12,11 @@ add_libc_unittest( CXX_STANDARD 20 DEPENDS + libc.hdr.errno_macros libc.src.time.asctime libc.hdr.types.struct_tm libc.src.time.time_constants + libc.test.UnitTest.ErrnoCheckingTest ) add_libc_unittest( @@ -29,9 +31,11 @@ add_libc_unittest( CXX_STANDARD 20 DEPENDS + libc.hdr.errno_macros libc.src.time.asctime_r libc.hdr.types.struct_tm libc.src.time.time_constants + libc.test.UnitTest.ErrnoCheckingTest ) add_libc_unittest( @@ -51,6 +55,7 @@ add_libc_unittest( libc.src.time.ctime libc.src.time.time_constants libc.hdr.types.struct_tm + libc.test.UnitTest.ErrnoCheckingTest ) add_libc_unittest( @@ -70,6 +75,7 @@ add_libc_unittest( libc.src.time.ctime_r libc.src.time.time_constants libc.hdr.types.struct_tm + libc.test.UnitTest.ErrnoCheckingTest ) add_libc_unittest( @@ -151,10 +157,12 @@ add_libc_unittest( HDRS TmMatcher.h DEPENDS + libc.hdr.errno_macros libc.src.time.gmtime libc.src.__support.CPP.limits libc.hdr.types.struct_tm libc.src.time.time_constants + libc.test.UnitTest.ErrnoCheckingTest ) add_libc_unittest( @@ -169,6 +177,7 @@ add_libc_unittest( libc.src.time.gmtime_r libc.hdr.types.struct_tm libc.src.time.time_constants + libc.test.UnitTest.ErrnoCheckingTest ) add_libc_test( @@ -197,9 +206,9 @@ add_libc_test( nanosleep_test.cpp DEPENDS libc.include.time - libc.src.time.nanosleep - libc.src.errno.errno libc.hdr.types.struct_timespec + libc.src.time.nanosleep + libc.test.UnitTest.ErrnoCheckingTest ) add_libc_test( diff --git a/libc/test/src/time/asctime_r_test.cpp b/libc/test/src/time/asctime_r_test.cpp index d840248..89634176 100644 --- a/libc/test/src/time/asctime_r_test.cpp +++ b/libc/test/src/time/asctime_r_test.cpp @@ -6,12 +6,15 @@ // //===----------------------------------------------------------------------===// -#include "src/__support/libc_errno.h" +#include "hdr/errno_macros.h" #include "src/time/asctime_r.h" #include "src/time/time_constants.h" +#include "test/UnitTest/ErrnoCheckingTest.h" #include "test/UnitTest/Test.h" #include "test/src/time/TmHelper.h" +using LlvmLibcAsctimeR = LIBC_NAMESPACE::testing::ErrnoCheckingTest; + static inline char *call_asctime_r(struct tm *tm_data, int year, int month, int mday, int hour, int min, int sec, int wday, int yday, char *buffer) { @@ -22,7 +25,7 @@ static inline char *call_asctime_r(struct tm *tm_data, int year, int month, // asctime and asctime_r share the same code and thus didn't repeat all the // tests from asctime. Added couple of validation tests. -TEST(LlvmLibcAsctimeR, Nullptr) { +TEST_F(LlvmLibcAsctimeR, Nullptr) { char *result; result = LIBC_NAMESPACE::asctime_r(nullptr, nullptr); ASSERT_ERRNO_EQ(EINVAL); @@ -39,7 +42,7 @@ TEST(LlvmLibcAsctimeR, Nullptr) { ASSERT_STREQ(nullptr, result); } -TEST(LlvmLibcAsctimeR, ValidDate) { +TEST_F(LlvmLibcAsctimeR, ValidDate) { char buffer[LIBC_NAMESPACE::time_constants::ASCTIME_BUFFER_SIZE]; struct tm tm_data; char *result; diff --git a/libc/test/src/time/asctime_test.cpp b/libc/test/src/time/asctime_test.cpp index cad25fff..2868bde 100644 --- a/libc/test/src/time/asctime_test.cpp +++ b/libc/test/src/time/asctime_test.cpp @@ -6,11 +6,14 @@ // //===----------------------------------------------------------------------===// -#include "src/__support/libc_errno.h" +#include "hdr/errno_macros.h" #include "src/time/asctime.h" +#include "test/UnitTest/ErrnoCheckingTest.h" #include "test/UnitTest/Test.h" #include "test/src/time/TmHelper.h" +using LlvmLibcAsctime = LIBC_NAMESPACE::testing::ErrnoCheckingTest; + static inline char *call_asctime(struct tm *tm_data, int year, int month, int mday, int hour, int min, int sec, int wday, int yday) { @@ -19,7 +22,7 @@ static inline char *call_asctime(struct tm *tm_data, int year, int month, return LIBC_NAMESPACE::asctime(tm_data); } -TEST(LlvmLibcAsctime, Nullptr) { +TEST_F(LlvmLibcAsctime, Nullptr) { char *result; result = LIBC_NAMESPACE::asctime(nullptr); ASSERT_ERRNO_EQ(EINVAL); @@ -27,7 +30,7 @@ TEST(LlvmLibcAsctime, Nullptr) { } // Weekdays are in the range 0 to 6. Test passing invalid value in wday. -TEST(LlvmLibcAsctime, InvalidWday) { +TEST_F(LlvmLibcAsctime, InvalidWday) { struct tm tm_data; // Test with wday = -1. @@ -56,7 +59,7 @@ TEST(LlvmLibcAsctime, InvalidWday) { } // Months are from January to December. Test passing invalid value in month. -TEST(LlvmLibcAsctime, InvalidMonth) { +TEST_F(LlvmLibcAsctime, InvalidMonth) { struct tm tm_data; // Test with month = 0. @@ -84,7 +87,7 @@ TEST(LlvmLibcAsctime, InvalidMonth) { ASSERT_ERRNO_EQ(EINVAL); } -TEST(LlvmLibcAsctime, ValidWeekdays) { +TEST_F(LlvmLibcAsctime, ValidWeekdays) { struct tm tm_data; char *result; // 1970-01-01 00:00:00. @@ -124,7 +127,7 @@ TEST(LlvmLibcAsctime, ValidWeekdays) { ASSERT_STREQ("Sun Jan 4 00:00:00 1970\n", result); } -TEST(LlvmLibcAsctime, ValidMonths) { +TEST_F(LlvmLibcAsctime, ValidMonths) { struct tm tm_data; char *result; // 1970-01-01 00:00:00. @@ -164,7 +167,7 @@ TEST(LlvmLibcAsctime, ValidMonths) { ASSERT_STREQ("Thu Dec 31 23:59:59 1970\n", result); } -TEST(LlvmLibcAsctime, EndOf32BitEpochYear) { +TEST_F(LlvmLibcAsctime, EndOf32BitEpochYear) { struct tm tm_data; char *result; // Test for maximum value of a signed 32-bit integer. @@ -181,7 +184,7 @@ TEST(LlvmLibcAsctime, EndOf32BitEpochYear) { ASSERT_STREQ("Tue Jan 19 03:14:07 2038\n", result); } -TEST(LlvmLibcAsctime, Max64BitYear) { +TEST_F(LlvmLibcAsctime, Max64BitYear) { if (sizeof(time_t) == 4) return; // Mon Jan 1 12:50:50 2170 (200 years from 1970), diff --git a/libc/test/src/time/ctime_r_test.cpp b/libc/test/src/time/ctime_r_test.cpp index fe43877..ee06c70 100644 --- a/libc/test/src/time/ctime_r_test.cpp +++ b/libc/test/src/time/ctime_r_test.cpp @@ -6,13 +6,15 @@ // //===----------------------------------------------------------------------===// -#include "src/__support/libc_errno.h" #include "src/time/ctime_r.h" #include "src/time/time_constants.h" +#include "test/UnitTest/ErrnoCheckingTest.h" #include "test/UnitTest/Test.h" #include "test/src/time/TmHelper.h" -TEST(LlvmLibcCtimeR, Nullptr) { +using LlvmLibcCtimeR = LIBC_NAMESPACE::testing::ErrnoCheckingTest; + +TEST_F(LlvmLibcCtimeR, Nullptr) { char *result; result = LIBC_NAMESPACE::ctime_r(nullptr, nullptr); ASSERT_STREQ(nullptr, result); @@ -26,7 +28,7 @@ TEST(LlvmLibcCtimeR, Nullptr) { ASSERT_STREQ(nullptr, result); } -TEST(LlvmLibcCtimeR, ValidUnixTimestamp0) { +TEST_F(LlvmLibcCtimeR, ValidUnixTimestamp0) { char buffer[LIBC_NAMESPACE::time_constants::ASCTIME_BUFFER_SIZE]; time_t t; char *result; @@ -36,7 +38,7 @@ TEST(LlvmLibcCtimeR, ValidUnixTimestamp0) { ASSERT_STREQ("Thu Jan 1 00:00:00 1970\n", result); } -TEST(LlvmLibcCtime, ValidUnixTimestamp32Int) { +TEST_F(LlvmLibcCtimeR, ValidUnixTimestamp32Int) { char buffer[LIBC_NAMESPACE::time_constants::ASCTIME_BUFFER_SIZE]; time_t t; char *result; @@ -46,7 +48,7 @@ TEST(LlvmLibcCtime, ValidUnixTimestamp32Int) { ASSERT_STREQ("Tue Jan 19 03:14:07 2038\n", result); } -TEST(LlvmLibcCtimeR, InvalidArgument) { +TEST_F(LlvmLibcCtimeR, InvalidArgument) { char buffer[LIBC_NAMESPACE::time_constants::ASCTIME_BUFFER_SIZE]; time_t t; char *result; diff --git a/libc/test/src/time/ctime_test.cpp b/libc/test/src/time/ctime_test.cpp index 5ff69f6..34a645f 100644 --- a/libc/test/src/time/ctime_test.cpp +++ b/libc/test/src/time/ctime_test.cpp @@ -6,18 +6,20 @@ // //===----------------------------------------------------------------------===// -#include "src/__support/libc_errno.h" #include "src/time/ctime.h" +#include "test/UnitTest/ErrnoCheckingTest.h" #include "test/UnitTest/Test.h" #include "test/src/time/TmHelper.h" -TEST(LlvmLibcCtime, nullptr) { +using LlvmLibcCtime = LIBC_NAMESPACE::testing::ErrnoCheckingTest; + +TEST_F(LlvmLibcCtime, nullptr) { char *result; result = LIBC_NAMESPACE::ctime(nullptr); ASSERT_STREQ(nullptr, result); } -TEST(LlvmLibcCtime, ValidUnixTimestamp0) { +TEST_F(LlvmLibcCtime, ValidUnixTimestamp0) { time_t t; char *result; t = 0; @@ -25,7 +27,7 @@ TEST(LlvmLibcCtime, ValidUnixTimestamp0) { ASSERT_STREQ("Thu Jan 1 00:00:00 1970\n", result); } -TEST(LlvmLibcCtime, ValidUnixTimestamp32Int) { +TEST_F(LlvmLibcCtime, ValidUnixTimestamp32Int) { time_t t; char *result; t = 2147483647; @@ -33,7 +35,7 @@ TEST(LlvmLibcCtime, ValidUnixTimestamp32Int) { ASSERT_STREQ("Tue Jan 19 03:14:07 2038\n", result); } -TEST(LlvmLibcCtime, InvalidArgument) { +TEST_F(LlvmLibcCtime, InvalidArgument) { time_t t; char *result; t = 2147483648; diff --git a/libc/test/src/time/gmtime_r_test.cpp b/libc/test/src/time/gmtime_r_test.cpp index 9d466f4..b8da357 100644 --- a/libc/test/src/time/gmtime_r_test.cpp +++ b/libc/test/src/time/gmtime_r_test.cpp @@ -8,12 +8,15 @@ #include "src/time/gmtime_r.h" #include "src/time/time_constants.h" +#include "test/UnitTest/ErrnoCheckingTest.h" #include "test/UnitTest/Test.h" #include "test/src/time/TmMatcher.h" +using LlvmLibcGmTimeR = LIBC_NAMESPACE::testing::ErrnoCheckingTest; + // gmtime and gmtime_r share the same code and thus didn't repeat all the tests // from gmtime. Added couple of validation tests. -TEST(LlvmLibcGmTimeR, EndOf32BitEpochYear) { +TEST_F(LlvmLibcGmTimeR, EndOf32BitEpochYear) { // Test for maximum value of a signed 32-bit integer. // Test implementation can encode time for Tue 19 January 2038 03:14:07 UTC. time_t seconds = 0x7FFFFFFF; @@ -34,7 +37,7 @@ TEST(LlvmLibcGmTimeR, EndOf32BitEpochYear) { EXPECT_TM_EQ(*tm_data_ptr, tm_data); } -TEST(LlvmLibcGmTimeR, Max64BitYear) { +TEST_F(LlvmLibcGmTimeR, Max64BitYear) { if (sizeof(time_t) == 4) return; // Test for Tue Jan 1 12:50:50 in 2,147,483,647th year. diff --git a/libc/test/src/time/gmtime_test.cpp b/libc/test/src/time/gmtime_test.cpp index 4123666..a1308b1 100644 --- a/libc/test/src/time/gmtime_test.cpp +++ b/libc/test/src/time/gmtime_test.cpp @@ -6,19 +6,18 @@ // //===----------------------------------------------------------------------===// +#include "hdr/errno_macros.h" #include "hdr/types/struct_tm.h" #include "src/__support/CPP/limits.h" // INT_MAX, INT_MIN -#include "src/__support/libc_errno.h" #include "src/time/gmtime.h" #include "src/time/time_constants.h" -#include "test/UnitTest/ErrnoSetterMatcher.h" +#include "test/UnitTest/ErrnoCheckingTest.h" #include "test/UnitTest/Test.h" #include "test/src/time/TmMatcher.h" -using LIBC_NAMESPACE::testing::ErrnoSetterMatcher::Fails; -using LIBC_NAMESPACE::testing::ErrnoSetterMatcher::Succeeds; +using LlvmLibcGmTime = LIBC_NAMESPACE::testing::ErrnoCheckingTest; -TEST(LlvmLibcGmTime, OutOfRange) { +TEST_F(LlvmLibcGmTime, OutOfRange) { if (sizeof(time_t) < sizeof(int64_t)) return; time_t seconds = @@ -30,7 +29,6 @@ TEST(LlvmLibcGmTime, OutOfRange) { EXPECT_TRUE(tm_data == nullptr); ASSERT_ERRNO_EQ(EOVERFLOW); - libc_errno = 0; seconds = INT_MIN * static_cast<int64_t>( @@ -41,7 +39,7 @@ TEST(LlvmLibcGmTime, OutOfRange) { ASSERT_ERRNO_EQ(EOVERFLOW); } -TEST(LlvmLibcGmTime, InvalidSeconds) { +TEST_F(LlvmLibcGmTime, InvalidSeconds) { time_t seconds = 0; struct tm *tm_data = nullptr; // -1 second from 1970-01-01 00:00:00 returns 1969-12-31 23:59:59. @@ -74,7 +72,7 @@ TEST(LlvmLibcGmTime, InvalidSeconds) { *tm_data); } -TEST(LlvmLibcGmTime, InvalidMinutes) { +TEST_F(LlvmLibcGmTime, InvalidMinutes) { time_t seconds = 0; struct tm *tm_data = nullptr; // -1 minute from 1970-01-01 00:00:00 returns 1969-12-31 23:59:00. @@ -107,7 +105,7 @@ TEST(LlvmLibcGmTime, InvalidMinutes) { *tm_data); } -TEST(LlvmLibcGmTime, InvalidHours) { +TEST_F(LlvmLibcGmTime, InvalidHours) { time_t seconds = 0; struct tm *tm_data = nullptr; // -1 hour from 1970-01-01 00:00:00 returns 1969-12-31 23:00:00. @@ -140,7 +138,7 @@ TEST(LlvmLibcGmTime, InvalidHours) { *tm_data); } -TEST(LlvmLibcGmTime, InvalidYear) { +TEST_F(LlvmLibcGmTime, InvalidYear) { // -1 year from 1970-01-01 00:00:00 returns 1969-01-01 00:00:00. time_t seconds = -LIBC_NAMESPACE::time_constants::DAYS_PER_NON_LEAP_YEAR * LIBC_NAMESPACE::time_constants::SECONDS_PER_DAY; @@ -158,7 +156,7 @@ TEST(LlvmLibcGmTime, InvalidYear) { *tm_data); } -TEST(LlvmLibcGmTime, InvalidMonths) { +TEST_F(LlvmLibcGmTime, InvalidMonths) { time_t seconds = 0; struct tm *tm_data = nullptr; // -1 month from 1970-01-01 00:00:00 returns 1969-12-01 00:00:00. @@ -192,7 +190,7 @@ TEST(LlvmLibcGmTime, InvalidMonths) { *tm_data); } -TEST(LlvmLibcGmTime, InvalidDays) { +TEST_F(LlvmLibcGmTime, InvalidDays) { time_t seconds = 0; struct tm *tm_data = nullptr; // -1 day from 1970-01-01 00:00:00 returns 1969-12-31 00:00:00. @@ -258,7 +256,7 @@ TEST(LlvmLibcGmTime, InvalidDays) { *tm_data); } -TEST(LlvmLibcGmTime, EndOf32BitEpochYear) { +TEST_F(LlvmLibcGmTime, EndOf32BitEpochYear) { // Test for maximum value of a signed 32-bit integer. // Test implementation can encode time for Tue 19 January 2038 03:14:07 UTC. time_t seconds = 0x7FFFFFFF; @@ -276,7 +274,7 @@ TEST(LlvmLibcGmTime, EndOf32BitEpochYear) { *tm_data); } -TEST(LlvmLibcGmTime, Max64BitYear) { +TEST_F(LlvmLibcGmTime, Max64BitYear) { if (sizeof(time_t) == 4) return; // Mon Jan 1 12:50:50 2170 (200 years from 1970), diff --git a/libc/test/src/time/nanosleep_test.cpp b/libc/test/src/time/nanosleep_test.cpp index e0200ff..bd143ac 100644 --- a/libc/test/src/time/nanosleep_test.cpp +++ b/libc/test/src/time/nanosleep_test.cpp @@ -7,21 +7,17 @@ //===----------------------------------------------------------------------===// #include "hdr/types/struct_timespec.h" -#include "src/__support/libc_errno.h" #include "src/time/nanosleep.h" -#include "test/UnitTest/ErrnoSetterMatcher.h" +#include "test/UnitTest/ErrnoCheckingTest.h" #include "test/UnitTest/Test.h" namespace cpp = LIBC_NAMESPACE::cpp; -TEST(LlvmLibcNanosleep, SmokeTest) { - // TODO: When we have the code to read clocks, test that time has passed. - using LIBC_NAMESPACE::testing::ErrnoSetterMatcher::Succeeds; - libc_errno = 0; +using LlvmLibcNanosleep = LIBC_NAMESPACE::testing::ErrnoCheckingTest; +TEST_F(LlvmLibcNanosleep, SmokeTest) { + // TODO: When we have the code to read clocks, test that time has passed. struct timespec tim = {1, 500}; struct timespec tim2 = {0, 0}; - int ret = LIBC_NAMESPACE::nanosleep(&tim, &tim2); - ASSERT_ERRNO_SUCCESS(); - ASSERT_EQ(ret, 0); + ASSERT_EQ(LIBC_NAMESPACE::nanosleep(&tim, &tim2), 0); } diff --git a/libc/test/src/wchar/CMakeLists.txt b/libc/test/src/wchar/CMakeLists.txt index d1a0684..8e1e854 100644 --- a/libc/test/src/wchar/CMakeLists.txt +++ b/libc/test/src/wchar/CMakeLists.txt @@ -53,7 +53,7 @@ add_libc_test( SRCS mbrtowc_test.cpp DEPENDS - libc.src.__support.libc_errno + libc.hdr.errno_macros libc.src.__support.wchar.mbstate libc.src.string.memset libc.src.wchar.mbrtowc @@ -69,7 +69,7 @@ add_libc_test( SRCS mbtowc_test.cpp DEPENDS - libc.src.__support.libc_errno + libc.hdr.errno_macros libc.src.wchar.mbtowc libc.hdr.types.wchar_t libc.test.UnitTest.ErrnoCheckingTest @@ -82,7 +82,7 @@ add_libc_test( SRCS mbstowcs_test.cpp DEPENDS - libc.src.__support.libc_errno + libc.hdr.errno_macros libc.src.wchar.mbstowcs libc.hdr.types.wchar_t libc.test.UnitTest.ErrnoCheckingTest @@ -95,7 +95,7 @@ add_libc_test( SRCS mblen_test.cpp DEPENDS - libc.src.__support.libc_errno + libc.hdr.errno_macros libc.src.wchar.mblen libc.test.UnitTest.ErrnoCheckingTest ) @@ -107,7 +107,7 @@ add_libc_test( SRCS mbsrtowcs_test.cpp DEPENDS - libc.src.__support.libc_errno + libc.hdr.errno_macros libc.src.__support.wchar.mbstate libc.src.string.memset libc.src.wchar.mbsrtowcs @@ -123,7 +123,7 @@ add_libc_test( SRCS mbrlen_test.cpp DEPENDS - libc.src.__support.libc_errno + libc.hdr.errno_macros libc.src.__support.wchar.mbstate libc.src.string.memset libc.src.wchar.mbsrlen @@ -139,14 +139,14 @@ add_libc_test( SRCS mbsnrtowcs_test.cpp DEPENDS - libc.src.__support.libc_errno + libc.hdr.errno_macros libc.src.__support.wchar.mbstate libc.src.string.memset libc.src.wchar.mbsnrtowcs libc.hdr.types.mbstate_t libc.hdr.types.wchar_t libc.test.UnitTest.ErrnoCheckingTest -) +) add_libc_test( mbsinit_test @@ -179,11 +179,11 @@ add_libc_test( SRCS wcrtomb_test.cpp DEPENDS + libc.hdr.errno_macros libc.src.wchar.wcrtomb libc.src.string.memset libc.hdr.types.wchar_t libc.hdr.types.mbstate_t - libc.src.__support.libc_errno libc.src.__support.wchar.mbstate libc.test.UnitTest.ErrnoCheckingTest ) @@ -195,6 +195,7 @@ add_libc_test( SRCS wctomb_test.cpp DEPENDS + libc.hdr.errno_macros libc.src.wchar.wctomb libc.hdr.types.wchar_t ) @@ -478,9 +479,9 @@ add_header_library( HDRS WcstolTest.h DEPENDS + libc.hdr.errno_macros libc.src.__support.CPP.limits libc.src.__support.CPP.type_traits - libc.src.errno.errno libc.test.UnitTest.ErrnoCheckingTest ) @@ -526,4 +527,4 @@ add_libc_test( DEPENDS libc.src.wchar.wcstoull .wcstol_test_support -)
\ No newline at end of file +) diff --git a/libc/test/src/wchar/WcstolTest.h b/libc/test/src/wchar/WcstolTest.h index 8a4294a..4d5b752 100644 --- a/libc/test/src/wchar/WcstolTest.h +++ b/libc/test/src/wchar/WcstolTest.h @@ -6,6 +6,7 @@ // //===----------------------------------------------------------------------===// +#include "hdr/errno_macros.h" #include "src/__support/CPP/limits.h" #include "src/__support/CPP/type_traits.h" #include "src/__support/macros/properties/architectures.h" diff --git a/libc/test/src/wchar/mblen_test.cpp b/libc/test/src/wchar/mblen_test.cpp index efd4df7..10737c6 100644 --- a/libc/test/src/wchar/mblen_test.cpp +++ b/libc/test/src/wchar/mblen_test.cpp @@ -6,7 +6,7 @@ // //===----------------------------------------------------------------------===// -#include "src/__support/libc_errno.h" +#include "hdr/errno_macros.h" #include "src/wchar/mblen.h" #include "test/UnitTest/ErrnoCheckingTest.h" #include "test/UnitTest/Test.h" diff --git a/libc/test/src/wchar/mbrlen_test.cpp b/libc/test/src/wchar/mbrlen_test.cpp index e1452bf4..15892bd 100644 --- a/libc/test/src/wchar/mbrlen_test.cpp +++ b/libc/test/src/wchar/mbrlen_test.cpp @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// +#include "hdr/errno_macros.h" #include "hdr/types/wchar_t.h" -#include "src/__support/libc_errno.h" #include "src/__support/wchar/mbstate.h" #include "src/string/memset.h" #include "src/wchar/mbrlen.h" diff --git a/libc/test/src/wchar/mbrtowc_test.cpp b/libc/test/src/wchar/mbrtowc_test.cpp index ddf8fc7..5604d01 100644 --- a/libc/test/src/wchar/mbrtowc_test.cpp +++ b/libc/test/src/wchar/mbrtowc_test.cpp @@ -6,9 +6,9 @@ // //===----------------------------------------------------------------------===// +#include "hdr/errno_macros.h" #include "hdr/types/mbstate_t.h" #include "hdr/types/wchar_t.h" -#include "src/__support/libc_errno.h" #include "src/__support/wchar/mbstate.h" #include "src/string/memset.h" #include "src/wchar/mbrtowc.h" diff --git a/libc/test/src/wchar/mbsnrtowcs_test.cpp b/libc/test/src/wchar/mbsnrtowcs_test.cpp index a3de68f..3cbe33c 100644 --- a/libc/test/src/wchar/mbsnrtowcs_test.cpp +++ b/libc/test/src/wchar/mbsnrtowcs_test.cpp @@ -6,9 +6,9 @@ // //===----------------------------------------------------------------------===// +#include "hdr/errno_macros.h" #include "hdr/types/mbstate_t.h" #include "hdr/types/wchar_t.h" -#include "src/__support/libc_errno.h" #include "src/__support/macros/null_check.h" #include "src/__support/wchar/mbstate.h" #include "src/string/memset.h" diff --git a/libc/test/src/wchar/mbsrtowcs_test.cpp b/libc/test/src/wchar/mbsrtowcs_test.cpp index 59efc0d..93d10d5 100644 --- a/libc/test/src/wchar/mbsrtowcs_test.cpp +++ b/libc/test/src/wchar/mbsrtowcs_test.cpp @@ -6,9 +6,9 @@ // //===----------------------------------------------------------------------===// +#include "hdr/errno_macros.h" #include "hdr/types/mbstate_t.h" #include "hdr/types/wchar_t.h" -#include "src/__support/libc_errno.h" #include "src/__support/macros/null_check.h" #include "src/__support/wchar/mbstate.h" #include "src/string/memset.h" diff --git a/libc/test/src/wchar/mbstowcs_test.cpp b/libc/test/src/wchar/mbstowcs_test.cpp index f0396e0..742f478 100644 --- a/libc/test/src/wchar/mbstowcs_test.cpp +++ b/libc/test/src/wchar/mbstowcs_test.cpp @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// +#include "hdr/errno_macros.h" #include "hdr/types/wchar_t.h" -#include "src/__support/libc_errno.h" #include "src/__support/macros/null_check.h" #include "src/wchar/mbstowcs.h" #include "test/UnitTest/ErrnoCheckingTest.h" diff --git a/libc/test/src/wchar/mbtowc_test.cpp b/libc/test/src/wchar/mbtowc_test.cpp index b27b05c..7c86d55 100644 --- a/libc/test/src/wchar/mbtowc_test.cpp +++ b/libc/test/src/wchar/mbtowc_test.cpp @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// +#include "hdr/errno_macros.h" #include "hdr/types/wchar_t.h" -#include "src/__support/libc_errno.h" #include "src/wchar/mbtowc.h" #include "test/UnitTest/ErrnoCheckingTest.h" #include "test/UnitTest/Test.h" diff --git a/libc/test/src/wchar/wcrtomb_test.cpp b/libc/test/src/wchar/wcrtomb_test.cpp index b29624e..97aaf5e 100644 --- a/libc/test/src/wchar/wcrtomb_test.cpp +++ b/libc/test/src/wchar/wcrtomb_test.cpp @@ -6,9 +6,9 @@ // //===----------------------------------------------------------------------===// +#include "hdr/errno_macros.h" #include "hdr/types/mbstate_t.h" #include "hdr/types/wchar_t.h" -#include "src/__support/libc_errno.h" #include "src/__support/wchar/mbstate.h" #include "src/string/memset.h" #include "src/wchar/wcrtomb.h" diff --git a/libc/test/src/wchar/wctomb_test.cpp b/libc/test/src/wchar/wctomb_test.cpp index 09fbf528..357f362 100644 --- a/libc/test/src/wchar/wctomb_test.cpp +++ b/libc/test/src/wchar/wctomb_test.cpp @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// +#include "hdr/errno_macros.h" #include "hdr/types/wchar_t.h" -#include "src/__support/libc_errno.h" #include "src/wchar/wctomb.h" #include "test/UnitTest/ErrnoCheckingTest.h" #include "test/UnitTest/Test.h" |