[libc-commits] [libc] [libc][math][c23] implement C23 math function asinpif16 (PR #146226)

via libc-commits libc-commits at lists.llvm.org
Wed Jul 9 18:49:17 PDT 2025


================
@@ -0,0 +1,89 @@
+//===-- Unittests for asinpif16 -------------------------------------------===//
+//
+// 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/math/asinpif16.h"
+#include "src/math/fabs.h"
+#include "test/UnitTest/FPMatcher.h"
+
+using LlvmLibcAsinpif16Test = LIBC_NAMESPACE::testing::FPTest<float16>;
+
+TEST_F(LlvmLibcAsinpif16Test, SpecialNumbers) {
+  using FPBits = LIBC_NAMESPACE::fputil::FPBits<float16>;
+
+  // zero
+  EXPECT_FP_EQ(0.0f16, LIBC_NAMESPACE::asinpif16(0.0f16));
+
+  // +/-1
+  EXPECT_FP_EQ(float16(0.5), LIBC_NAMESPACE::asinpif16(float16(1.0)));
+  EXPECT_FP_EQ(float16(-0.5), LIBC_NAMESPACE::asinpif16(float16(-1.0)));
+
+  // NaN inputs
+  EXPECT_FP_EQ(FPBits::quiet_nan().get_val(),
+               LIBC_NAMESPACE::asinpif16(FPBits::quiet_nan().get_val()));
+
+  EXPECT_FP_EQ(FPBits::quiet_nan().get_val(),
+               LIBC_NAMESPACE::asinpif16(FPBits::signaling_nan().get_val()));
+
+  // infinity inputs -> should return NaN
+  errno = 0;
----------------
overmighty wrote:

You should include src/__support/libc_errno.h and use `libc_errno` instead. Same for the rest of the test file.

https://github.com/llvm/llvm-project/pull/146226


More information about the libc-commits mailing list