[libc-commits] [libc] [libc][math] Implement nexttoward functions (PR #72763)

via libc-commits libc-commits at lists.llvm.org
Sat Nov 18 17:57:15 PST 2023


================
@@ -0,0 +1,22 @@
+//===-- Implementation of nexttowardl function ----------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "src/math/nexttowardl.h"
+#include "src/__support/FPUtil/ManipulationFunctions.h"
+#include "src/__support/common.h"
+
+namespace LIBC_NAMESPACE {
+
+LLVM_LIBC_FUNCTION(long double, nexttowardl, (long double x, long double y)) {
+  // We can reuse the nextafter implementation because nexttoward behaves
+  // exactly same as nextafter in case of long doubles. Also, we have explcitly
+  // handled the special 80-bit long doubles in nextafter implementation.
+  return fputil::nextafter(x, y);
----------------
lntue wrote:

It is ok to re-use any `fputil` functions.  We just try not to call other functions that are implemented under `LLVM_LIBC_FUNCTION`, i.e. other entry point targets.

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


More information about the libc-commits mailing list