[libc-commits] [libc] [llvm] [libc][math] Refactor lrint_lround family to header-only (PR #195441)

via libc-commits libc-commits at lists.llvm.org
Sat May 2 04:34:35 PDT 2026


https://github.com/AnonMiraj updated https://github.com/llvm/llvm-project/pull/195441

>From e89381c19ee18fc3b6dd6e1592e27b899781f7a5 Mon Sep 17 00:00:00 2001
From: Anonmiraj <ezzibrahimx at gmail.com>
Date: Sat, 2 May 2026 14:17:41 +0300
Subject: [PATCH] [libc][math] Refactor lrint_lround family to header-only

Refactored functions:
  - llrint
  - llrintbf16
  - llrintf
  - llrintf128
  - llrintf16
  - llrintl
  - llround
  - llroundbf16
  - llroundf
  - llroundf128
  - llroundf16
  - llroundl
  - lrint
  - lrintbf16
  - lrintf
  - lrintf128
  - lrintf16
  - lrintl
  - lround
  - lroundbf16
  - lroundf
  - lroundf128
  - lroundf16
  - lroundl
---
 libc/shared/math.h                            |  24 ++
 libc/shared/math/llrint.h                     |  23 ++
 libc/shared/math/llrintbf16.h                 |  23 ++
 libc/shared/math/llrintf.h                    |  23 ++
 libc/shared/math/llrintf128.h                 |  29 ++
 libc/shared/math/llrintf16.h                  |  29 ++
 libc/shared/math/llrintl.h                    |  23 ++
 libc/shared/math/llround.h                    |  23 ++
 libc/shared/math/llroundbf16.h                |  23 ++
 libc/shared/math/llroundf.h                   |  23 ++
 libc/shared/math/llroundf128.h                |  29 ++
 libc/shared/math/llroundf16.h                 |  29 ++
 libc/shared/math/llroundl.h                   |  23 ++
 libc/shared/math/lrint.h                      |  23 ++
 libc/shared/math/lrintbf16.h                  |  23 ++
 libc/shared/math/lrintf.h                     |  23 ++
 libc/shared/math/lrintf128.h                  |  29 ++
 libc/shared/math/lrintf16.h                   |  29 ++
 libc/shared/math/lrintl.h                     |  23 ++
 libc/shared/math/lround.h                     |  23 ++
 libc/shared/math/lroundbf16.h                 |  23 ++
 libc/shared/math/lroundf.h                    |  23 ++
 libc/shared/math/lroundf128.h                 |  29 ++
 libc/shared/math/lroundf16.h                  |  29 ++
 libc/shared/math/lroundl.h                    |  23 ++
 libc/src/__support/math/CMakeLists.txt        | 227 +++++++++++
 libc/src/__support/math/llrint.h              |  27 ++
 libc/src/__support/math/llrintbf16.h          |  28 ++
 libc/src/__support/math/llrintf.h             |  27 ++
 libc/src/__support/math/llrintf128.h          |  33 ++
 libc/src/__support/math/llrintf16.h           |  33 ++
 libc/src/__support/math/llrintl.h             |  26 ++
 libc/src/__support/math/llround.h             |  25 ++
 libc/src/__support/math/llroundbf16.h         |  26 ++
 libc/src/__support/math/llroundf.h            |  25 ++
 libc/src/__support/math/llroundf128.h         |  31 ++
 libc/src/__support/math/llroundf16.h          |  31 ++
 libc/src/__support/math/llroundl.h            |  25 ++
 libc/src/__support/math/lrint.h               |  26 ++
 libc/src/__support/math/lrintbf16.h           |  27 ++
 libc/src/__support/math/lrintf.h              |  26 ++
 libc/src/__support/math/lrintf128.h           |  32 ++
 libc/src/__support/math/lrintf16.h            |  32 ++
 libc/src/__support/math/lrintl.h              |  26 ++
 libc/src/__support/math/lround.h              |  25 ++
 libc/src/__support/math/lroundbf16.h          |  26 ++
 libc/src/__support/math/lroundf.h             |  25 ++
 libc/src/__support/math/lroundf128.h          |  31 ++
 libc/src/__support/math/lroundf16.h           |  31 ++
 libc/src/__support/math/lroundl.h             |  25 ++
 libc/src/math/generic/CMakeLists.txt          |  66 ++--
 libc/src/math/generic/llrint.cpp              |  10 +-
 libc/src/math/generic/llrintbf16.cpp          |   9 +-
 libc/src/math/generic/llrintf.cpp             |  10 +-
 libc/src/math/generic/llrintf128.cpp          |   8 +-
 libc/src/math/generic/llrintf16.cpp           |   8 +-
 libc/src/math/generic/llrintl.cpp             |   7 +-
 libc/src/math/generic/llround.cpp             |   8 +-
 libc/src/math/generic/llroundbf16.cpp         |   7 +-
 libc/src/math/generic/llroundf.cpp            |   8 +-
 libc/src/math/generic/llroundf128.cpp         |   6 +-
 libc/src/math/generic/llroundf16.cpp          |   6 +-
 libc/src/math/generic/llroundl.cpp            |   6 +-
 libc/src/math/generic/lrint.cpp               |   9 +-
 libc/src/math/generic/lrintbf16.cpp           |  10 +-
 libc/src/math/generic/lrintf.cpp              |   9 +-
 libc/src/math/generic/lrintf128.cpp           |   9 +-
 libc/src/math/generic/lrintf16.cpp            |   9 +-
 libc/src/math/generic/lrintl.cpp              |   9 +-
 libc/src/math/generic/lround.cpp              |   8 +-
 libc/src/math/generic/lroundbf16.cpp          |   7 +-
 libc/src/math/generic/lroundf.cpp             |   8 +-
 libc/src/math/generic/lroundf128.cpp          |   6 +-
 libc/src/math/generic/lroundf16.cpp           |   8 +-
 libc/src/math/generic/lroundl.cpp             |   8 +-
 libc/test/shared/CMakeLists.txt               |  48 +++
 .../shared/shared_math_constexpr_test.cpp     |  25 ++
 libc/test/shared/shared_math_test.cpp         |  25 ++
 .../llvm-project-overlay/libc/BUILD.bazel     | 363 +++++++++++++++++-
 79 files changed, 2041 insertions(+), 199 deletions(-)
 create mode 100644 libc/shared/math/llrint.h
 create mode 100644 libc/shared/math/llrintbf16.h
 create mode 100644 libc/shared/math/llrintf.h
 create mode 100644 libc/shared/math/llrintf128.h
 create mode 100644 libc/shared/math/llrintf16.h
 create mode 100644 libc/shared/math/llrintl.h
 create mode 100644 libc/shared/math/llround.h
 create mode 100644 libc/shared/math/llroundbf16.h
 create mode 100644 libc/shared/math/llroundf.h
 create mode 100644 libc/shared/math/llroundf128.h
 create mode 100644 libc/shared/math/llroundf16.h
 create mode 100644 libc/shared/math/llroundl.h
 create mode 100644 libc/shared/math/lrint.h
 create mode 100644 libc/shared/math/lrintbf16.h
 create mode 100644 libc/shared/math/lrintf.h
 create mode 100644 libc/shared/math/lrintf128.h
 create mode 100644 libc/shared/math/lrintf16.h
 create mode 100644 libc/shared/math/lrintl.h
 create mode 100644 libc/shared/math/lround.h
 create mode 100644 libc/shared/math/lroundbf16.h
 create mode 100644 libc/shared/math/lroundf.h
 create mode 100644 libc/shared/math/lroundf128.h
 create mode 100644 libc/shared/math/lroundf16.h
 create mode 100644 libc/shared/math/lroundl.h
 create mode 100644 libc/src/__support/math/llrint.h
 create mode 100644 libc/src/__support/math/llrintbf16.h
 create mode 100644 libc/src/__support/math/llrintf.h
 create mode 100644 libc/src/__support/math/llrintf128.h
 create mode 100644 libc/src/__support/math/llrintf16.h
 create mode 100644 libc/src/__support/math/llrintl.h
 create mode 100644 libc/src/__support/math/llround.h
 create mode 100644 libc/src/__support/math/llroundbf16.h
 create mode 100644 libc/src/__support/math/llroundf.h
 create mode 100644 libc/src/__support/math/llroundf128.h
 create mode 100644 libc/src/__support/math/llroundf16.h
 create mode 100644 libc/src/__support/math/llroundl.h
 create mode 100644 libc/src/__support/math/lrint.h
 create mode 100644 libc/src/__support/math/lrintbf16.h
 create mode 100644 libc/src/__support/math/lrintf.h
 create mode 100644 libc/src/__support/math/lrintf128.h
 create mode 100644 libc/src/__support/math/lrintf16.h
 create mode 100644 libc/src/__support/math/lrintl.h
 create mode 100644 libc/src/__support/math/lround.h
 create mode 100644 libc/src/__support/math/lroundbf16.h
 create mode 100644 libc/src/__support/math/lroundf.h
 create mode 100644 libc/src/__support/math/lroundf128.h
 create mode 100644 libc/src/__support/math/lroundf16.h
 create mode 100644 libc/src/__support/math/lroundl.h

diff --git a/libc/shared/math.h b/libc/shared/math.h
index 4cd943a2435f2..ec1cfba7c0834 100644
--- a/libc/shared/math.h
+++ b/libc/shared/math.h
@@ -293,6 +293,18 @@
 #include "math/llogbf128.h"
 #include "math/llogbf16.h"
 #include "math/llogbl.h"
+#include "math/llrint.h"
+#include "math/llrintbf16.h"
+#include "math/llrintf.h"
+#include "math/llrintf128.h"
+#include "math/llrintf16.h"
+#include "math/llrintl.h"
+#include "math/llround.h"
+#include "math/llroundbf16.h"
+#include "math/llroundf.h"
+#include "math/llroundf128.h"
+#include "math/llroundf16.h"
+#include "math/llroundl.h"
 #include "math/log.h"
 #include "math/log10.h"
 #include "math/log10f.h"
@@ -313,6 +325,18 @@
 #include "math/logbl.h"
 #include "math/logf.h"
 #include "math/logf16.h"
+#include "math/lrint.h"
+#include "math/lrintbf16.h"
+#include "math/lrintf.h"
+#include "math/lrintf128.h"
+#include "math/lrintf16.h"
+#include "math/lrintl.h"
+#include "math/lround.h"
+#include "math/lroundbf16.h"
+#include "math/lroundf.h"
+#include "math/lroundf128.h"
+#include "math/lroundf16.h"
+#include "math/lroundl.h"
 #include "math/modf.h"
 #include "math/modfbf16.h"
 #include "math/modff.h"
diff --git a/libc/shared/math/llrint.h b/libc/shared/math/llrint.h
new file mode 100644
index 0000000000000..b61f670821df3
--- /dev/null
+++ b/libc/shared/math/llrint.h
@@ -0,0 +1,23 @@
+//===-- Shared llrint function ----------------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_SHARED_MATH_LLRINT_H
+#define LLVM_LIBC_SHARED_MATH_LLRINT_H
+
+#include "shared/libc_common.h"
+#include "src/__support/math/llrint.h"
+
+namespace LIBC_NAMESPACE_DECL {
+namespace shared {
+
+using math::llrint;
+
+} // namespace shared
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SHARED_MATH_LLRINT_H
diff --git a/libc/shared/math/llrintbf16.h b/libc/shared/math/llrintbf16.h
new file mode 100644
index 0000000000000..ea51cd2dd2dbb
--- /dev/null
+++ b/libc/shared/math/llrintbf16.h
@@ -0,0 +1,23 @@
+//===-- Shared llrintbf16 function ------------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_SHARED_MATH_LLRINTBF16_H
+#define LLVM_LIBC_SHARED_MATH_LLRINTBF16_H
+
+#include "shared/libc_common.h"
+#include "src/__support/math/llrintbf16.h"
+
+namespace LIBC_NAMESPACE_DECL {
+namespace shared {
+
+using math::llrintbf16;
+
+} // namespace shared
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SHARED_MATH_LLRINTBF16_H
diff --git a/libc/shared/math/llrintf.h b/libc/shared/math/llrintf.h
new file mode 100644
index 0000000000000..645d2cb2e53bc
--- /dev/null
+++ b/libc/shared/math/llrintf.h
@@ -0,0 +1,23 @@
+//===-- Shared llrintf function ---------------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_SHARED_MATH_LLRINTF_H
+#define LLVM_LIBC_SHARED_MATH_LLRINTF_H
+
+#include "shared/libc_common.h"
+#include "src/__support/math/llrintf.h"
+
+namespace LIBC_NAMESPACE_DECL {
+namespace shared {
+
+using math::llrintf;
+
+} // namespace shared
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SHARED_MATH_LLRINTF_H
diff --git a/libc/shared/math/llrintf128.h b/libc/shared/math/llrintf128.h
new file mode 100644
index 0000000000000..02e4edc23573e
--- /dev/null
+++ b/libc/shared/math/llrintf128.h
@@ -0,0 +1,29 @@
+//===-- Shared llrintf128 function ------------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_SHARED_MATH_LLRINTF128_H
+#define LLVM_LIBC_SHARED_MATH_LLRINTF128_H
+
+#include "include/llvm-libc-types/float128.h"
+
+#ifdef LIBC_TYPES_HAS_FLOAT128
+
+#include "shared/libc_common.h"
+#include "src/__support/math/llrintf128.h"
+
+namespace LIBC_NAMESPACE_DECL {
+namespace shared {
+
+using math::llrintf128;
+
+} // namespace shared
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LIBC_TYPES_HAS_FLOAT128
+
+#endif // LLVM_LIBC_SHARED_MATH_LLRINTF128_H
diff --git a/libc/shared/math/llrintf16.h b/libc/shared/math/llrintf16.h
new file mode 100644
index 0000000000000..cde6ac42dde8c
--- /dev/null
+++ b/libc/shared/math/llrintf16.h
@@ -0,0 +1,29 @@
+//===-- Shared llrintf16 function -------------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_SHARED_MATH_LLRINTF16_H
+#define LLVM_LIBC_SHARED_MATH_LLRINTF16_H
+
+#include "include/llvm-libc-macros/float16-macros.h"
+
+#ifdef LIBC_TYPES_HAS_FLOAT16
+
+#include "shared/libc_common.h"
+#include "src/__support/math/llrintf16.h"
+
+namespace LIBC_NAMESPACE_DECL {
+namespace shared {
+
+using math::llrintf16;
+
+} // namespace shared
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LIBC_TYPES_HAS_FLOAT16
+
+#endif // LLVM_LIBC_SHARED_MATH_LLRINTF16_H
diff --git a/libc/shared/math/llrintl.h b/libc/shared/math/llrintl.h
new file mode 100644
index 0000000000000..a2f8721b4b556
--- /dev/null
+++ b/libc/shared/math/llrintl.h
@@ -0,0 +1,23 @@
+//===-- Shared llrintl function ---------------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_SHARED_MATH_LLRINTL_H
+#define LLVM_LIBC_SHARED_MATH_LLRINTL_H
+
+#include "shared/libc_common.h"
+#include "src/__support/math/llrintl.h"
+
+namespace LIBC_NAMESPACE_DECL {
+namespace shared {
+
+using math::llrintl;
+
+} // namespace shared
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SHARED_MATH_LLRINTL_H
diff --git a/libc/shared/math/llround.h b/libc/shared/math/llround.h
new file mode 100644
index 0000000000000..5d6301b68e4cd
--- /dev/null
+++ b/libc/shared/math/llround.h
@@ -0,0 +1,23 @@
+//===-- Shared llround function ---------------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_SHARED_MATH_LLROUND_H
+#define LLVM_LIBC_SHARED_MATH_LLROUND_H
+
+#include "shared/libc_common.h"
+#include "src/__support/math/llround.h"
+
+namespace LIBC_NAMESPACE_DECL {
+namespace shared {
+
+using math::llround;
+
+} // namespace shared
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SHARED_MATH_LLROUND_H
diff --git a/libc/shared/math/llroundbf16.h b/libc/shared/math/llroundbf16.h
new file mode 100644
index 0000000000000..2466845eb58b2
--- /dev/null
+++ b/libc/shared/math/llroundbf16.h
@@ -0,0 +1,23 @@
+//===-- Shared llroundbf16 function -----------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_SHARED_MATH_LLROUNDBF16_H
+#define LLVM_LIBC_SHARED_MATH_LLROUNDBF16_H
+
+#include "shared/libc_common.h"
+#include "src/__support/math/llroundbf16.h"
+
+namespace LIBC_NAMESPACE_DECL {
+namespace shared {
+
+using math::llroundbf16;
+
+} // namespace shared
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SHARED_MATH_LLROUNDBF16_H
diff --git a/libc/shared/math/llroundf.h b/libc/shared/math/llroundf.h
new file mode 100644
index 0000000000000..c851b7817cca8
--- /dev/null
+++ b/libc/shared/math/llroundf.h
@@ -0,0 +1,23 @@
+//===-- Shared llroundf function --------------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_SHARED_MATH_LLROUNDF_H
+#define LLVM_LIBC_SHARED_MATH_LLROUNDF_H
+
+#include "shared/libc_common.h"
+#include "src/__support/math/llroundf.h"
+
+namespace LIBC_NAMESPACE_DECL {
+namespace shared {
+
+using math::llroundf;
+
+} // namespace shared
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SHARED_MATH_LLROUNDF_H
diff --git a/libc/shared/math/llroundf128.h b/libc/shared/math/llroundf128.h
new file mode 100644
index 0000000000000..7e4654c4ff5c7
--- /dev/null
+++ b/libc/shared/math/llroundf128.h
@@ -0,0 +1,29 @@
+//===-- Shared llroundf128 function -----------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_SHARED_MATH_LLROUNDF128_H
+#define LLVM_LIBC_SHARED_MATH_LLROUNDF128_H
+
+#include "include/llvm-libc-types/float128.h"
+
+#ifdef LIBC_TYPES_HAS_FLOAT128
+
+#include "shared/libc_common.h"
+#include "src/__support/math/llroundf128.h"
+
+namespace LIBC_NAMESPACE_DECL {
+namespace shared {
+
+using math::llroundf128;
+
+} // namespace shared
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LIBC_TYPES_HAS_FLOAT128
+
+#endif // LLVM_LIBC_SHARED_MATH_LLROUNDF128_H
diff --git a/libc/shared/math/llroundf16.h b/libc/shared/math/llroundf16.h
new file mode 100644
index 0000000000000..2f3c629c8d1c2
--- /dev/null
+++ b/libc/shared/math/llroundf16.h
@@ -0,0 +1,29 @@
+//===-- Shared llroundf16 function ------------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_SHARED_MATH_LLROUNDF16_H
+#define LLVM_LIBC_SHARED_MATH_LLROUNDF16_H
+
+#include "include/llvm-libc-macros/float16-macros.h"
+
+#ifdef LIBC_TYPES_HAS_FLOAT16
+
+#include "shared/libc_common.h"
+#include "src/__support/math/llroundf16.h"
+
+namespace LIBC_NAMESPACE_DECL {
+namespace shared {
+
+using math::llroundf16;
+
+} // namespace shared
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LIBC_TYPES_HAS_FLOAT16
+
+#endif // LLVM_LIBC_SHARED_MATH_LLROUNDF16_H
diff --git a/libc/shared/math/llroundl.h b/libc/shared/math/llroundl.h
new file mode 100644
index 0000000000000..5c25b00959ba4
--- /dev/null
+++ b/libc/shared/math/llroundl.h
@@ -0,0 +1,23 @@
+//===-- Shared llroundl function --------------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_SHARED_MATH_LLROUNDL_H
+#define LLVM_LIBC_SHARED_MATH_LLROUNDL_H
+
+#include "shared/libc_common.h"
+#include "src/__support/math/llroundl.h"
+
+namespace LIBC_NAMESPACE_DECL {
+namespace shared {
+
+using math::llroundl;
+
+} // namespace shared
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SHARED_MATH_LLROUNDL_H
diff --git a/libc/shared/math/lrint.h b/libc/shared/math/lrint.h
new file mode 100644
index 0000000000000..8623a2fd170f7
--- /dev/null
+++ b/libc/shared/math/lrint.h
@@ -0,0 +1,23 @@
+//===-- Shared lrint function -----------------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_SHARED_MATH_LRINT_H
+#define LLVM_LIBC_SHARED_MATH_LRINT_H
+
+#include "shared/libc_common.h"
+#include "src/__support/math/lrint.h"
+
+namespace LIBC_NAMESPACE_DECL {
+namespace shared {
+
+using math::lrint;
+
+} // namespace shared
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SHARED_MATH_LRINT_H
diff --git a/libc/shared/math/lrintbf16.h b/libc/shared/math/lrintbf16.h
new file mode 100644
index 0000000000000..d4fd53bea872b
--- /dev/null
+++ b/libc/shared/math/lrintbf16.h
@@ -0,0 +1,23 @@
+//===-- Shared lrintbf16 function -------------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_SHARED_MATH_LRINTBF16_H
+#define LLVM_LIBC_SHARED_MATH_LRINTBF16_H
+
+#include "shared/libc_common.h"
+#include "src/__support/math/lrintbf16.h"
+
+namespace LIBC_NAMESPACE_DECL {
+namespace shared {
+
+using math::lrintbf16;
+
+} // namespace shared
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SHARED_MATH_LRINTBF16_H
diff --git a/libc/shared/math/lrintf.h b/libc/shared/math/lrintf.h
new file mode 100644
index 0000000000000..e3066f3b098bb
--- /dev/null
+++ b/libc/shared/math/lrintf.h
@@ -0,0 +1,23 @@
+//===-- Shared lrintf function ----------------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_SHARED_MATH_LRINTF_H
+#define LLVM_LIBC_SHARED_MATH_LRINTF_H
+
+#include "shared/libc_common.h"
+#include "src/__support/math/lrintf.h"
+
+namespace LIBC_NAMESPACE_DECL {
+namespace shared {
+
+using math::lrintf;
+
+} // namespace shared
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SHARED_MATH_LRINTF_H
diff --git a/libc/shared/math/lrintf128.h b/libc/shared/math/lrintf128.h
new file mode 100644
index 0000000000000..86fc0b3b081b9
--- /dev/null
+++ b/libc/shared/math/lrintf128.h
@@ -0,0 +1,29 @@
+//===-- Shared lrintf128 function -------------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_SHARED_MATH_LRINTF128_H
+#define LLVM_LIBC_SHARED_MATH_LRINTF128_H
+
+#include "include/llvm-libc-types/float128.h"
+
+#ifdef LIBC_TYPES_HAS_FLOAT128
+
+#include "shared/libc_common.h"
+#include "src/__support/math/lrintf128.h"
+
+namespace LIBC_NAMESPACE_DECL {
+namespace shared {
+
+using math::lrintf128;
+
+} // namespace shared
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LIBC_TYPES_HAS_FLOAT128
+
+#endif // LLVM_LIBC_SHARED_MATH_LRINTF128_H
diff --git a/libc/shared/math/lrintf16.h b/libc/shared/math/lrintf16.h
new file mode 100644
index 0000000000000..494774a7e7f41
--- /dev/null
+++ b/libc/shared/math/lrintf16.h
@@ -0,0 +1,29 @@
+//===-- Shared lrintf16 function --------------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_SHARED_MATH_LRINTF16_H
+#define LLVM_LIBC_SHARED_MATH_LRINTF16_H
+
+#include "include/llvm-libc-macros/float16-macros.h"
+
+#ifdef LIBC_TYPES_HAS_FLOAT16
+
+#include "shared/libc_common.h"
+#include "src/__support/math/lrintf16.h"
+
+namespace LIBC_NAMESPACE_DECL {
+namespace shared {
+
+using math::lrintf16;
+
+} // namespace shared
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LIBC_TYPES_HAS_FLOAT16
+
+#endif // LLVM_LIBC_SHARED_MATH_LRINTF16_H
diff --git a/libc/shared/math/lrintl.h b/libc/shared/math/lrintl.h
new file mode 100644
index 0000000000000..7fe880e16912b
--- /dev/null
+++ b/libc/shared/math/lrintl.h
@@ -0,0 +1,23 @@
+//===-- Shared lrintl function ----------------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_SHARED_MATH_LRINTL_H
+#define LLVM_LIBC_SHARED_MATH_LRINTL_H
+
+#include "shared/libc_common.h"
+#include "src/__support/math/lrintl.h"
+
+namespace LIBC_NAMESPACE_DECL {
+namespace shared {
+
+using math::lrintl;
+
+} // namespace shared
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SHARED_MATH_LRINTL_H
diff --git a/libc/shared/math/lround.h b/libc/shared/math/lround.h
new file mode 100644
index 0000000000000..0e312840fe7d5
--- /dev/null
+++ b/libc/shared/math/lround.h
@@ -0,0 +1,23 @@
+//===-- Shared lround function ----------------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_SHARED_MATH_LROUND_H
+#define LLVM_LIBC_SHARED_MATH_LROUND_H
+
+#include "shared/libc_common.h"
+#include "src/__support/math/lround.h"
+
+namespace LIBC_NAMESPACE_DECL {
+namespace shared {
+
+using math::lround;
+
+} // namespace shared
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SHARED_MATH_LROUND_H
diff --git a/libc/shared/math/lroundbf16.h b/libc/shared/math/lroundbf16.h
new file mode 100644
index 0000000000000..9635e9ab1383f
--- /dev/null
+++ b/libc/shared/math/lroundbf16.h
@@ -0,0 +1,23 @@
+//===-- Shared lroundbf16 function ------------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_SHARED_MATH_LROUNDBF16_H
+#define LLVM_LIBC_SHARED_MATH_LROUNDBF16_H
+
+#include "shared/libc_common.h"
+#include "src/__support/math/lroundbf16.h"
+
+namespace LIBC_NAMESPACE_DECL {
+namespace shared {
+
+using math::lroundbf16;
+
+} // namespace shared
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SHARED_MATH_LROUNDBF16_H
diff --git a/libc/shared/math/lroundf.h b/libc/shared/math/lroundf.h
new file mode 100644
index 0000000000000..0ae27220f668e
--- /dev/null
+++ b/libc/shared/math/lroundf.h
@@ -0,0 +1,23 @@
+//===-- Shared lroundf function ---------------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_SHARED_MATH_LROUNDF_H
+#define LLVM_LIBC_SHARED_MATH_LROUNDF_H
+
+#include "shared/libc_common.h"
+#include "src/__support/math/lroundf.h"
+
+namespace LIBC_NAMESPACE_DECL {
+namespace shared {
+
+using math::lroundf;
+
+} // namespace shared
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SHARED_MATH_LROUNDF_H
diff --git a/libc/shared/math/lroundf128.h b/libc/shared/math/lroundf128.h
new file mode 100644
index 0000000000000..2fe4b0b84b232
--- /dev/null
+++ b/libc/shared/math/lroundf128.h
@@ -0,0 +1,29 @@
+//===-- Shared lroundf128 function ------------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_SHARED_MATH_LROUNDF128_H
+#define LLVM_LIBC_SHARED_MATH_LROUNDF128_H
+
+#include "include/llvm-libc-types/float128.h"
+
+#ifdef LIBC_TYPES_HAS_FLOAT128
+
+#include "shared/libc_common.h"
+#include "src/__support/math/lroundf128.h"
+
+namespace LIBC_NAMESPACE_DECL {
+namespace shared {
+
+using math::lroundf128;
+
+} // namespace shared
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LIBC_TYPES_HAS_FLOAT128
+
+#endif // LLVM_LIBC_SHARED_MATH_LROUNDF128_H
diff --git a/libc/shared/math/lroundf16.h b/libc/shared/math/lroundf16.h
new file mode 100644
index 0000000000000..2b8b46fb933d3
--- /dev/null
+++ b/libc/shared/math/lroundf16.h
@@ -0,0 +1,29 @@
+//===-- Shared lroundf16 function -------------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_SHARED_MATH_LROUNDF16_H
+#define LLVM_LIBC_SHARED_MATH_LROUNDF16_H
+
+#include "include/llvm-libc-macros/float16-macros.h"
+
+#ifdef LIBC_TYPES_HAS_FLOAT16
+
+#include "shared/libc_common.h"
+#include "src/__support/math/lroundf16.h"
+
+namespace LIBC_NAMESPACE_DECL {
+namespace shared {
+
+using math::lroundf16;
+
+} // namespace shared
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LIBC_TYPES_HAS_FLOAT16
+
+#endif // LLVM_LIBC_SHARED_MATH_LROUNDF16_H
diff --git a/libc/shared/math/lroundl.h b/libc/shared/math/lroundl.h
new file mode 100644
index 0000000000000..2afb5553c20be
--- /dev/null
+++ b/libc/shared/math/lroundl.h
@@ -0,0 +1,23 @@
+//===-- Shared lroundl function ---------------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_SHARED_MATH_LROUNDL_H
+#define LLVM_LIBC_SHARED_MATH_LROUNDL_H
+
+#include "shared/libc_common.h"
+#include "src/__support/math/lroundl.h"
+
+namespace LIBC_NAMESPACE_DECL {
+namespace shared {
+
+using math::lroundl;
+
+} // namespace shared
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SHARED_MATH_LROUNDL_H
diff --git a/libc/src/__support/math/CMakeLists.txt b/libc/src/__support/math/CMakeLists.txt
index db689026d404f..2d509cf5676f1 100644
--- a/libc/src/__support/math/CMakeLists.txt
+++ b/libc/src/__support/math/CMakeLists.txt
@@ -1669,6 +1669,233 @@ add_header_library(
     libc.src.__support.macros.config
 )
 
+add_header_library(
+  llrint
+  HDRS
+    llrint.h
+  DEPENDS
+    libc.src.__support.FPUtil.nearest_integer_operations
+    libc.src.__support.macros.config
+)
+
+add_header_library(
+  llrintbf16
+  HDRS
+    llrintbf16.h
+  DEPENDS
+    libc.src.__support.FPUtil.nearest_integer_operations
+    libc.src.__support.macros.config
+)
+
+add_header_library(
+  llrintf
+  HDRS
+    llrintf.h
+  DEPENDS
+    libc.src.__support.FPUtil.nearest_integer_operations
+    libc.src.__support.macros.config
+)
+
+add_header_library(
+  llrintf128
+  HDRS
+    llrintf128.h
+  DEPENDS
+    libc.include.llvm-libc-types.float128
+    libc.src.__support.FPUtil.nearest_integer_operations
+    libc.src.__support.macros.config
+)
+
+add_header_library(
+  llrintf16
+  HDRS
+    llrintf16.h
+  DEPENDS
+    libc.include.llvm-libc-macros.float16_macros
+    libc.src.__support.FPUtil.nearest_integer_operations
+    libc.src.__support.macros.config
+)
+
+add_header_library(
+  llrintl
+  HDRS
+    llrintl.h
+  DEPENDS
+    libc.src.__support.FPUtil.nearest_integer_operations
+    libc.src.__support.macros.config
+)
+
+add_header_library(
+  llround
+  HDRS
+    llround.h
+  DEPENDS
+    libc.src.__support.FPUtil.nearest_integer_operations
+    libc.src.__support.macros.config
+)
+
+add_header_library(
+  llroundbf16
+  HDRS
+    llroundbf16.h
+  DEPENDS
+    libc.src.__support.FPUtil.bfloat16
+    libc.src.__support.FPUtil.nearest_integer_operations
+    libc.src.__support.macros.config
+)
+
+add_header_library(
+  llroundf
+  HDRS
+    llroundf.h
+  DEPENDS
+    libc.src.__support.FPUtil.nearest_integer_operations
+    libc.src.__support.macros.config
+)
+
+add_header_library(
+  llroundf128
+  HDRS
+    llroundf128.h
+  DEPENDS
+    libc.include.llvm-libc-types.float128
+    libc.src.__support.FPUtil.nearest_integer_operations
+    libc.src.__support.macros.config
+)
+
+add_header_library(
+  llroundf16
+  HDRS
+    llroundf16.h
+  DEPENDS
+    libc.include.llvm-libc-macros.float16_macros
+    libc.src.__support.FPUtil.nearest_integer_operations
+    libc.src.__support.macros.config
+)
+
+add_header_library(
+  llroundl
+  HDRS
+    llroundl.h
+  DEPENDS
+    libc.src.__support.FPUtil.nearest_integer_operations
+    libc.src.__support.macros.config
+)
+
+add_header_library(
+  lrint
+  HDRS
+    lrint.h
+  DEPENDS
+    libc.src.__support.FPUtil.nearest_integer_operations
+    libc.src.__support.macros.config
+)
+
+add_header_library(
+  lrintbf16
+  HDRS
+    lrintbf16.h
+  DEPENDS
+    libc.src.__support.FPUtil.bfloat16
+    libc.src.__support.FPUtil.nearest_integer_operations
+    libc.src.__support.macros.config
+)
+
+add_header_library(
+  lrintf
+  HDRS
+    lrintf.h
+  DEPENDS
+    libc.src.__support.FPUtil.nearest_integer_operations
+    libc.src.__support.macros.config
+)
+
+add_header_library(
+  lrintf128
+  HDRS
+    lrintf128.h
+  DEPENDS
+    libc.include.llvm-libc-types.float128
+    libc.src.__support.FPUtil.nearest_integer_operations
+    libc.src.__support.macros.config
+)
+
+add_header_library(
+  lrintf16
+  HDRS
+    lrintf16.h
+  DEPENDS
+    libc.include.llvm-libc-macros.float16_macros
+    libc.src.__support.FPUtil.nearest_integer_operations
+    libc.src.__support.macros.config
+)
+
+add_header_library(
+  lrintl
+  HDRS
+    lrintl.h
+  DEPENDS
+    libc.src.__support.FPUtil.nearest_integer_operations
+    libc.src.__support.macros.config
+)
+
+add_header_library(
+  lround
+  HDRS
+    lround.h
+  DEPENDS
+    libc.src.__support.FPUtil.nearest_integer_operations
+    libc.src.__support.macros.config
+)
+
+add_header_library(
+  lroundbf16
+  HDRS
+    lroundbf16.h
+  DEPENDS
+    libc.src.__support.FPUtil.bfloat16
+    libc.src.__support.FPUtil.nearest_integer_operations
+    libc.src.__support.macros.config
+)
+
+add_header_library(
+  lroundf
+  HDRS
+    lroundf.h
+  DEPENDS
+    libc.src.__support.FPUtil.nearest_integer_operations
+    libc.src.__support.macros.config
+)
+
+add_header_library(
+  lroundf128
+  HDRS
+    lroundf128.h
+  DEPENDS
+    libc.include.llvm-libc-types.float128
+    libc.src.__support.FPUtil.nearest_integer_operations
+    libc.src.__support.macros.config
+)
+
+add_header_library(
+  lroundf16
+  HDRS
+    lroundf16.h
+  DEPENDS
+    libc.include.llvm-libc-macros.float16_macros
+    libc.src.__support.FPUtil.nearest_integer_operations
+    libc.src.__support.macros.config
+)
+
+add_header_library(
+  lroundl
+  HDRS
+    lroundl.h
+  DEPENDS
+    libc.src.__support.FPUtil.nearest_integer_operations
+    libc.src.__support.macros.config
+)
+
 add_header_library(
   modf
   HDRS
diff --git a/libc/src/__support/math/llrint.h b/libc/src/__support/math/llrint.h
new file mode 100644
index 0000000000000..3559593e6b6fc
--- /dev/null
+++ b/libc/src/__support/math/llrint.h
@@ -0,0 +1,27 @@
+//===-- Implementation header for llrint ------------------------*- 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_MATH_LLRINT_H
+#define LLVM_LIBC_SRC___SUPPORT_MATH_LLRINT_H
+
+#include "src/__support/FPUtil/NearestIntegerOperations.h"
+#include "src/__support/macros/config.h"
+
+namespace LIBC_NAMESPACE_DECL {
+namespace math {
+
+LIBC_INLINE constexpr long long llrint(double x) {
+  return fputil::round_to_signed_integer_using_current_rounding_mode<double,
+                                                                     long long>(
+      x);
+}
+
+} // namespace math
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SRC___SUPPORT_MATH_LLRINT_H
diff --git a/libc/src/__support/math/llrintbf16.h b/libc/src/__support/math/llrintbf16.h
new file mode 100644
index 0000000000000..f7dd2d4032371
--- /dev/null
+++ b/libc/src/__support/math/llrintbf16.h
@@ -0,0 +1,28 @@
+//===-- Implementation header for llrintbf16 --------------------*- 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_MATH_LLRINTBF16_H
+#define LLVM_LIBC_SRC___SUPPORT_MATH_LLRINTBF16_H
+
+#include "src/__support/FPUtil/NearestIntegerOperations.h"
+#include "src/__support/FPUtil/bfloat16.h"
+#include "src/__support/macros/config.h"
+
+namespace LIBC_NAMESPACE_DECL {
+namespace math {
+
+LIBC_INLINE constexpr long long llrintbf16(bfloat16 x) {
+  return fputil::round_to_signed_integer_using_current_rounding_mode<bfloat16,
+                                                                     long long>(
+      x);
+}
+
+} // namespace math
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SRC___SUPPORT_MATH_LLRINTBF16_H
diff --git a/libc/src/__support/math/llrintf.h b/libc/src/__support/math/llrintf.h
new file mode 100644
index 0000000000000..afba495e5c701
--- /dev/null
+++ b/libc/src/__support/math/llrintf.h
@@ -0,0 +1,27 @@
+//===-- Implementation header for llrintf -----------------------*- 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_MATH_LLRINTF_H
+#define LLVM_LIBC_SRC___SUPPORT_MATH_LLRINTF_H
+
+#include "src/__support/FPUtil/NearestIntegerOperations.h"
+#include "src/__support/macros/config.h"
+
+namespace LIBC_NAMESPACE_DECL {
+namespace math {
+
+LIBC_INLINE constexpr long long llrintf(float x) {
+  return fputil::round_to_signed_integer_using_current_rounding_mode<float,
+                                                                     long long>(
+      x);
+}
+
+} // namespace math
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SRC___SUPPORT_MATH_LLRINTF_H
diff --git a/libc/src/__support/math/llrintf128.h b/libc/src/__support/math/llrintf128.h
new file mode 100644
index 0000000000000..fe2c5c99969c9
--- /dev/null
+++ b/libc/src/__support/math/llrintf128.h
@@ -0,0 +1,33 @@
+//===-- Implementation header for llrintf128 --------------------*- 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_MATH_LLRINTF128_H
+#define LLVM_LIBC_SRC___SUPPORT_MATH_LLRINTF128_H
+
+#include "include/llvm-libc-types/float128.h"
+
+#ifdef LIBC_TYPES_HAS_FLOAT128
+
+#include "src/__support/FPUtil/NearestIntegerOperations.h"
+#include "src/__support/macros/config.h"
+
+namespace LIBC_NAMESPACE_DECL {
+namespace math {
+
+LIBC_INLINE constexpr long long llrintf128(float128 x) {
+  return fputil::round_to_signed_integer_using_current_rounding_mode<float128,
+                                                                     long long>(
+      x);
+}
+
+} // namespace math
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LIBC_TYPES_HAS_FLOAT128
+
+#endif // LLVM_LIBC_SRC___SUPPORT_MATH_LLRINTF128_H
diff --git a/libc/src/__support/math/llrintf16.h b/libc/src/__support/math/llrintf16.h
new file mode 100644
index 0000000000000..e9e4d07e41e2c
--- /dev/null
+++ b/libc/src/__support/math/llrintf16.h
@@ -0,0 +1,33 @@
+//===-- Implementation header for llrintf16 ---------------------*- 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_MATH_LLRINTF16_H
+#define LLVM_LIBC_SRC___SUPPORT_MATH_LLRINTF16_H
+
+#include "include/llvm-libc-macros/float16-macros.h"
+
+#ifdef LIBC_TYPES_HAS_FLOAT16
+
+#include "src/__support/FPUtil/NearestIntegerOperations.h"
+#include "src/__support/macros/config.h"
+
+namespace LIBC_NAMESPACE_DECL {
+namespace math {
+
+LIBC_INLINE constexpr long long llrintf16(float16 x) {
+  return fputil::round_to_signed_integer_using_current_rounding_mode<float16,
+                                                                     long long>(
+      x);
+}
+
+} // namespace math
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LIBC_TYPES_HAS_FLOAT16
+
+#endif // LLVM_LIBC_SRC___SUPPORT_MATH_LLRINTF16_H
diff --git a/libc/src/__support/math/llrintl.h b/libc/src/__support/math/llrintl.h
new file mode 100644
index 0000000000000..7f33ecc2f60b8
--- /dev/null
+++ b/libc/src/__support/math/llrintl.h
@@ -0,0 +1,26 @@
+//===-- Implementation header for llrintl -----------------------*- 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_MATH_LLRINTL_H
+#define LLVM_LIBC_SRC___SUPPORT_MATH_LLRINTL_H
+
+#include "src/__support/FPUtil/NearestIntegerOperations.h"
+#include "src/__support/macros/config.h"
+
+namespace LIBC_NAMESPACE_DECL {
+namespace math {
+
+LIBC_INLINE constexpr long long llrintl(long double x) {
+  return fputil::round_to_signed_integer_using_current_rounding_mode<
+      long double, long long>(x);
+}
+
+} // namespace math
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SRC___SUPPORT_MATH_LLRINTL_H
diff --git a/libc/src/__support/math/llround.h b/libc/src/__support/math/llround.h
new file mode 100644
index 0000000000000..fe4a7884ac98f
--- /dev/null
+++ b/libc/src/__support/math/llround.h
@@ -0,0 +1,25 @@
+//===-- Implementation header for llround -----------------------*- 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_MATH_LLROUND_H
+#define LLVM_LIBC_SRC___SUPPORT_MATH_LLROUND_H
+
+#include "src/__support/FPUtil/NearestIntegerOperations.h"
+#include "src/__support/macros/config.h"
+
+namespace LIBC_NAMESPACE_DECL {
+namespace math {
+
+LIBC_INLINE constexpr long long llround(double x) {
+  return fputil::round_to_signed_integer<double, long long>(x);
+}
+
+} // namespace math
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SRC___SUPPORT_MATH_LLROUND_H
diff --git a/libc/src/__support/math/llroundbf16.h b/libc/src/__support/math/llroundbf16.h
new file mode 100644
index 0000000000000..4a19c5d5f22c7
--- /dev/null
+++ b/libc/src/__support/math/llroundbf16.h
@@ -0,0 +1,26 @@
+//===-- Implementation header for llroundbf16 -------------------*- 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_MATH_LLROUNDBF16_H
+#define LLVM_LIBC_SRC___SUPPORT_MATH_LLROUNDBF16_H
+
+#include "src/__support/FPUtil/NearestIntegerOperations.h"
+#include "src/__support/FPUtil/bfloat16.h"
+#include "src/__support/macros/config.h"
+
+namespace LIBC_NAMESPACE_DECL {
+namespace math {
+
+LIBC_INLINE constexpr long long llroundbf16(bfloat16 x) {
+  return fputil::round_to_signed_integer<bfloat16, long long>(x);
+}
+
+} // namespace math
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SRC___SUPPORT_MATH_LLROUNDBF16_H
diff --git a/libc/src/__support/math/llroundf.h b/libc/src/__support/math/llroundf.h
new file mode 100644
index 0000000000000..e53c431faf651
--- /dev/null
+++ b/libc/src/__support/math/llroundf.h
@@ -0,0 +1,25 @@
+//===-- Implementation header for llroundf ----------------------*- 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_MATH_LLROUNDF_H
+#define LLVM_LIBC_SRC___SUPPORT_MATH_LLROUNDF_H
+
+#include "src/__support/FPUtil/NearestIntegerOperations.h"
+#include "src/__support/macros/config.h"
+
+namespace LIBC_NAMESPACE_DECL {
+namespace math {
+
+LIBC_INLINE constexpr long long llroundf(float x) {
+  return fputil::round_to_signed_integer<float, long long>(x);
+}
+
+} // namespace math
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SRC___SUPPORT_MATH_LLROUNDF_H
diff --git a/libc/src/__support/math/llroundf128.h b/libc/src/__support/math/llroundf128.h
new file mode 100644
index 0000000000000..ece48eeb6a14b
--- /dev/null
+++ b/libc/src/__support/math/llroundf128.h
@@ -0,0 +1,31 @@
+//===-- Implementation header for llroundf128 -------------------*- 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_MATH_LLROUNDF128_H
+#define LLVM_LIBC_SRC___SUPPORT_MATH_LLROUNDF128_H
+
+#include "include/llvm-libc-types/float128.h"
+
+#ifdef LIBC_TYPES_HAS_FLOAT128
+
+#include "src/__support/FPUtil/NearestIntegerOperations.h"
+#include "src/__support/macros/config.h"
+
+namespace LIBC_NAMESPACE_DECL {
+namespace math {
+
+LIBC_INLINE constexpr long long llroundf128(float128 x) {
+  return fputil::round_to_signed_integer<float128, long long>(x);
+}
+
+} // namespace math
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LIBC_TYPES_HAS_FLOAT128
+
+#endif // LLVM_LIBC_SRC___SUPPORT_MATH_LLROUNDF128_H
diff --git a/libc/src/__support/math/llroundf16.h b/libc/src/__support/math/llroundf16.h
new file mode 100644
index 0000000000000..5e73e0252938c
--- /dev/null
+++ b/libc/src/__support/math/llroundf16.h
@@ -0,0 +1,31 @@
+//===-- Implementation header for llroundf16 --------------------*- 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_MATH_LLROUNDF16_H
+#define LLVM_LIBC_SRC___SUPPORT_MATH_LLROUNDF16_H
+
+#include "include/llvm-libc-macros/float16-macros.h"
+
+#ifdef LIBC_TYPES_HAS_FLOAT16
+
+#include "src/__support/FPUtil/NearestIntegerOperations.h"
+#include "src/__support/macros/config.h"
+
+namespace LIBC_NAMESPACE_DECL {
+namespace math {
+
+LIBC_INLINE constexpr long long llroundf16(float16 x) {
+  return fputil::round_to_signed_integer<float16, long long>(x);
+}
+
+} // namespace math
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LIBC_TYPES_HAS_FLOAT16
+
+#endif // LLVM_LIBC_SRC___SUPPORT_MATH_LLROUNDF16_H
diff --git a/libc/src/__support/math/llroundl.h b/libc/src/__support/math/llroundl.h
new file mode 100644
index 0000000000000..9bacaea55ac72
--- /dev/null
+++ b/libc/src/__support/math/llroundl.h
@@ -0,0 +1,25 @@
+//===-- Implementation header for llroundl ----------------------*- 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_MATH_LLROUNDL_H
+#define LLVM_LIBC_SRC___SUPPORT_MATH_LLROUNDL_H
+
+#include "src/__support/FPUtil/NearestIntegerOperations.h"
+#include "src/__support/macros/config.h"
+
+namespace LIBC_NAMESPACE_DECL {
+namespace math {
+
+LIBC_INLINE constexpr long long llroundl(long double x) {
+  return fputil::round_to_signed_integer<long double, long long>(x);
+}
+
+} // namespace math
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SRC___SUPPORT_MATH_LLROUNDL_H
diff --git a/libc/src/__support/math/lrint.h b/libc/src/__support/math/lrint.h
new file mode 100644
index 0000000000000..2ecfff7522613
--- /dev/null
+++ b/libc/src/__support/math/lrint.h
@@ -0,0 +1,26 @@
+//===-- Implementation header for lrint -------------------------*- 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_MATH_LRINT_H
+#define LLVM_LIBC_SRC___SUPPORT_MATH_LRINT_H
+
+#include "src/__support/FPUtil/NearestIntegerOperations.h"
+#include "src/__support/macros/config.h"
+
+namespace LIBC_NAMESPACE_DECL {
+namespace math {
+
+LIBC_INLINE constexpr long lrint(double x) {
+  return fputil::round_to_signed_integer_using_current_rounding_mode<double,
+                                                                     long>(x);
+}
+
+} // namespace math
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SRC___SUPPORT_MATH_LRINT_H
diff --git a/libc/src/__support/math/lrintbf16.h b/libc/src/__support/math/lrintbf16.h
new file mode 100644
index 0000000000000..ca016e7bb145e
--- /dev/null
+++ b/libc/src/__support/math/lrintbf16.h
@@ -0,0 +1,27 @@
+//===-- Implementation header for lrintbf16 ---------------------*- 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_MATH_LRINTBF16_H
+#define LLVM_LIBC_SRC___SUPPORT_MATH_LRINTBF16_H
+
+#include "src/__support/FPUtil/NearestIntegerOperations.h"
+#include "src/__support/FPUtil/bfloat16.h"
+#include "src/__support/macros/config.h"
+
+namespace LIBC_NAMESPACE_DECL {
+namespace math {
+
+LIBC_INLINE constexpr long lrintbf16(bfloat16 x) {
+  return fputil::round_to_signed_integer_using_current_rounding_mode<bfloat16,
+                                                                     long>(x);
+}
+
+} // namespace math
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SRC___SUPPORT_MATH_LRINTBF16_H
diff --git a/libc/src/__support/math/lrintf.h b/libc/src/__support/math/lrintf.h
new file mode 100644
index 0000000000000..75e3786f7a420
--- /dev/null
+++ b/libc/src/__support/math/lrintf.h
@@ -0,0 +1,26 @@
+//===-- Implementation header for lrintf ------------------------*- 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_MATH_LRINTF_H
+#define LLVM_LIBC_SRC___SUPPORT_MATH_LRINTF_H
+
+#include "src/__support/FPUtil/NearestIntegerOperations.h"
+#include "src/__support/macros/config.h"
+
+namespace LIBC_NAMESPACE_DECL {
+namespace math {
+
+LIBC_INLINE constexpr long lrintf(float x) {
+  return fputil::round_to_signed_integer_using_current_rounding_mode<float,
+                                                                     long>(x);
+}
+
+} // namespace math
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SRC___SUPPORT_MATH_LRINTF_H
diff --git a/libc/src/__support/math/lrintf128.h b/libc/src/__support/math/lrintf128.h
new file mode 100644
index 0000000000000..fa3c470d0eab1
--- /dev/null
+++ b/libc/src/__support/math/lrintf128.h
@@ -0,0 +1,32 @@
+//===-- Implementation header for lrintf128 ---------------------*- 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_MATH_LRINTF128_H
+#define LLVM_LIBC_SRC___SUPPORT_MATH_LRINTF128_H
+
+#include "include/llvm-libc-types/float128.h"
+
+#ifdef LIBC_TYPES_HAS_FLOAT128
+
+#include "src/__support/FPUtil/NearestIntegerOperations.h"
+#include "src/__support/macros/config.h"
+
+namespace LIBC_NAMESPACE_DECL {
+namespace math {
+
+LIBC_INLINE constexpr long lrintf128(float128 x) {
+  return fputil::round_to_signed_integer_using_current_rounding_mode<float128,
+                                                                     long>(x);
+}
+
+} // namespace math
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LIBC_TYPES_HAS_FLOAT128
+
+#endif // LLVM_LIBC_SRC___SUPPORT_MATH_LRINTF128_H
diff --git a/libc/src/__support/math/lrintf16.h b/libc/src/__support/math/lrintf16.h
new file mode 100644
index 0000000000000..4d101c17aede6
--- /dev/null
+++ b/libc/src/__support/math/lrintf16.h
@@ -0,0 +1,32 @@
+//===-- Implementation header for lrintf16 ----------------------*- 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_MATH_LRINTF16_H
+#define LLVM_LIBC_SRC___SUPPORT_MATH_LRINTF16_H
+
+#include "include/llvm-libc-macros/float16-macros.h"
+
+#ifdef LIBC_TYPES_HAS_FLOAT16
+
+#include "src/__support/FPUtil/NearestIntegerOperations.h"
+#include "src/__support/macros/config.h"
+
+namespace LIBC_NAMESPACE_DECL {
+namespace math {
+
+LIBC_INLINE constexpr long lrintf16(float16 x) {
+  return fputil::round_to_signed_integer_using_current_rounding_mode<float16,
+                                                                     long>(x);
+}
+
+} // namespace math
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LIBC_TYPES_HAS_FLOAT16
+
+#endif // LLVM_LIBC_SRC___SUPPORT_MATH_LRINTF16_H
diff --git a/libc/src/__support/math/lrintl.h b/libc/src/__support/math/lrintl.h
new file mode 100644
index 0000000000000..6b481ba77978e
--- /dev/null
+++ b/libc/src/__support/math/lrintl.h
@@ -0,0 +1,26 @@
+//===-- Implementation header for lrintl ------------------------*- 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_MATH_LRINTL_H
+#define LLVM_LIBC_SRC___SUPPORT_MATH_LRINTL_H
+
+#include "src/__support/FPUtil/NearestIntegerOperations.h"
+#include "src/__support/macros/config.h"
+
+namespace LIBC_NAMESPACE_DECL {
+namespace math {
+
+LIBC_INLINE constexpr long lrintl(long double x) {
+  return fputil::round_to_signed_integer_using_current_rounding_mode<
+      long double, long>(x);
+}
+
+} // namespace math
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SRC___SUPPORT_MATH_LRINTL_H
diff --git a/libc/src/__support/math/lround.h b/libc/src/__support/math/lround.h
new file mode 100644
index 0000000000000..17c19cdb20cf3
--- /dev/null
+++ b/libc/src/__support/math/lround.h
@@ -0,0 +1,25 @@
+//===-- Implementation header for lround ------------------------*- 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_MATH_LROUND_H
+#define LLVM_LIBC_SRC___SUPPORT_MATH_LROUND_H
+
+#include "src/__support/FPUtil/NearestIntegerOperations.h"
+#include "src/__support/macros/config.h"
+
+namespace LIBC_NAMESPACE_DECL {
+namespace math {
+
+LIBC_INLINE constexpr long lround(double x) {
+  return fputil::round_to_signed_integer<double, long>(x);
+}
+
+} // namespace math
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SRC___SUPPORT_MATH_LROUND_H
diff --git a/libc/src/__support/math/lroundbf16.h b/libc/src/__support/math/lroundbf16.h
new file mode 100644
index 0000000000000..4259d7db28fb8
--- /dev/null
+++ b/libc/src/__support/math/lroundbf16.h
@@ -0,0 +1,26 @@
+//===-- Implementation header for lroundbf16 --------------------*- 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_MATH_LROUNDBF16_H
+#define LLVM_LIBC_SRC___SUPPORT_MATH_LROUNDBF16_H
+
+#include "src/__support/FPUtil/NearestIntegerOperations.h"
+#include "src/__support/FPUtil/bfloat16.h"
+#include "src/__support/macros/config.h"
+
+namespace LIBC_NAMESPACE_DECL {
+namespace math {
+
+LIBC_INLINE constexpr long lroundbf16(bfloat16 x) {
+  return fputil::round_to_signed_integer<bfloat16, long>(x);
+}
+
+} // namespace math
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SRC___SUPPORT_MATH_LROUNDBF16_H
diff --git a/libc/src/__support/math/lroundf.h b/libc/src/__support/math/lroundf.h
new file mode 100644
index 0000000000000..faa2ee9398038
--- /dev/null
+++ b/libc/src/__support/math/lroundf.h
@@ -0,0 +1,25 @@
+//===-- Implementation header for lroundf -----------------------*- 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_MATH_LROUNDF_H
+#define LLVM_LIBC_SRC___SUPPORT_MATH_LROUNDF_H
+
+#include "src/__support/FPUtil/NearestIntegerOperations.h"
+#include "src/__support/macros/config.h"
+
+namespace LIBC_NAMESPACE_DECL {
+namespace math {
+
+LIBC_INLINE constexpr long lroundf(float x) {
+  return fputil::round_to_signed_integer<float, long>(x);
+}
+
+} // namespace math
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SRC___SUPPORT_MATH_LROUNDF_H
diff --git a/libc/src/__support/math/lroundf128.h b/libc/src/__support/math/lroundf128.h
new file mode 100644
index 0000000000000..7945c59702258
--- /dev/null
+++ b/libc/src/__support/math/lroundf128.h
@@ -0,0 +1,31 @@
+//===-- Implementation header for lroundf128 --------------------*- 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_MATH_LROUNDF128_H
+#define LLVM_LIBC_SRC___SUPPORT_MATH_LROUNDF128_H
+
+#include "include/llvm-libc-types/float128.h"
+
+#ifdef LIBC_TYPES_HAS_FLOAT128
+
+#include "src/__support/FPUtil/NearestIntegerOperations.h"
+#include "src/__support/macros/config.h"
+
+namespace LIBC_NAMESPACE_DECL {
+namespace math {
+
+LIBC_INLINE constexpr long lroundf128(float128 x) {
+  return fputil::round_to_signed_integer<float128, long>(x);
+}
+
+} // namespace math
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LIBC_TYPES_HAS_FLOAT128
+
+#endif // LLVM_LIBC_SRC___SUPPORT_MATH_LROUNDF128_H
diff --git a/libc/src/__support/math/lroundf16.h b/libc/src/__support/math/lroundf16.h
new file mode 100644
index 0000000000000..bbb1007bce3b5
--- /dev/null
+++ b/libc/src/__support/math/lroundf16.h
@@ -0,0 +1,31 @@
+//===-- Implementation header for lroundf16 ---------------------*- 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_MATH_LROUNDF16_H
+#define LLVM_LIBC_SRC___SUPPORT_MATH_LROUNDF16_H
+
+#include "include/llvm-libc-macros/float16-macros.h"
+
+#ifdef LIBC_TYPES_HAS_FLOAT16
+
+#include "src/__support/FPUtil/NearestIntegerOperations.h"
+#include "src/__support/macros/config.h"
+
+namespace LIBC_NAMESPACE_DECL {
+namespace math {
+
+LIBC_INLINE constexpr long lroundf16(float16 x) {
+  return fputil::round_to_signed_integer<float16, long>(x);
+}
+
+} // namespace math
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LIBC_TYPES_HAS_FLOAT16
+
+#endif // LLVM_LIBC_SRC___SUPPORT_MATH_LROUNDF16_H
diff --git a/libc/src/__support/math/lroundl.h b/libc/src/__support/math/lroundl.h
new file mode 100644
index 0000000000000..4d832f22cb527
--- /dev/null
+++ b/libc/src/__support/math/lroundl.h
@@ -0,0 +1,25 @@
+//===-- Implementation header for lroundl -----------------------*- 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_MATH_LROUNDL_H
+#define LLVM_LIBC_SRC___SUPPORT_MATH_LROUNDL_H
+
+#include "src/__support/FPUtil/NearestIntegerOperations.h"
+#include "src/__support/macros/config.h"
+
+namespace LIBC_NAMESPACE_DECL {
+namespace math {
+
+LIBC_INLINE constexpr long lroundl(long double x) {
+  return fputil::round_to_signed_integer<long double, long>(x);
+}
+
+} // namespace math
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SRC___SUPPORT_MATH_LROUNDL_H
diff --git a/libc/src/math/generic/CMakeLists.txt b/libc/src/math/generic/CMakeLists.txt
index 3e799a037f340..f7444158e05c6 100644
--- a/libc/src/math/generic/CMakeLists.txt
+++ b/libc/src/math/generic/CMakeLists.txt
@@ -866,7 +866,7 @@ add_entrypoint_object(
   HDRS
     ../lround.h
   DEPENDS
-    libc.src.__support.FPUtil.nearest_integer_operations
+    libc.src.__support.math.lround
 )
 
 add_entrypoint_object(
@@ -876,7 +876,7 @@ add_entrypoint_object(
   HDRS
     ../lroundf.h
   DEPENDS
-    libc.src.__support.FPUtil.nearest_integer_operations
+    libc.src.__support.math.lroundf
 )
 
 add_entrypoint_object(
@@ -886,7 +886,7 @@ add_entrypoint_object(
   HDRS
     ../lroundl.h
   DEPENDS
-    libc.src.__support.FPUtil.nearest_integer_operations
+    libc.src.__support.math.lroundl
 )
 
 add_entrypoint_object(
@@ -896,8 +896,7 @@ add_entrypoint_object(
   HDRS
     ../lroundf16.h
   DEPENDS
-    libc.src.__support.macros.properties.types
-    libc.src.__support.FPUtil.nearest_integer_operations
+    libc.src.__support.math.lroundf16
 )
 
 add_entrypoint_object(
@@ -907,8 +906,7 @@ add_entrypoint_object(
   HDRS
     ../lroundf128.h
   DEPENDS
-    libc.src.__support.macros.properties.types
-    libc.src.__support.FPUtil.nearest_integer_operations
+    libc.src.__support.math.lroundf128
 )
 
 add_entrypoint_object(
@@ -918,10 +916,7 @@ add_entrypoint_object(
   HDRS
     ../lroundf16.h
   DEPENDS
-    libc.src.__support.common
-    libc.src.__support.FPUtil.bfloat16
-    libc.src.__support.FPUtil.nearest_integer_operations
-    libc.src.__support.macros.config
+    libc.src.__support.math.lroundbf16
 )
 
 add_entrypoint_object(
@@ -931,7 +926,7 @@ add_entrypoint_object(
   HDRS
     ../llround.h
   DEPENDS
-    libc.src.__support.FPUtil.nearest_integer_operations
+    libc.src.__support.math.llround
 )
 
 add_entrypoint_object(
@@ -941,7 +936,7 @@ add_entrypoint_object(
   HDRS
     ../llroundf.h
   DEPENDS
-    libc.src.__support.FPUtil.nearest_integer_operations
+    libc.src.__support.math.llroundf
 )
 
 add_entrypoint_object(
@@ -951,7 +946,7 @@ add_entrypoint_object(
   HDRS
     ../llroundl.h
   DEPENDS
-    libc.src.__support.FPUtil.nearest_integer_operations
+    libc.src.__support.math.llroundl
 )
 
 add_entrypoint_object(
@@ -961,8 +956,7 @@ add_entrypoint_object(
   HDRS
     ../llroundf16.h
   DEPENDS
-    libc.src.__support.macros.properties.types
-    libc.src.__support.FPUtil.nearest_integer_operations
+    libc.src.__support.math.llroundf16
 )
 
 add_entrypoint_object(
@@ -972,8 +966,7 @@ add_entrypoint_object(
   HDRS
     ../llroundf128.h
   DEPENDS
-    libc.src.__support.macros.properties.types
-    libc.src.__support.FPUtil.nearest_integer_operations
+    libc.src.__support.math.llroundf128
 )
 
 add_entrypoint_object(
@@ -983,10 +976,7 @@ add_entrypoint_object(
   HDRS
     ../llroundf16.h
   DEPENDS
-    libc.src.__support.common
-    libc.src.__support.FPUtil.bfloat16
-    libc.src.__support.FPUtil.nearest_integer_operations
-    libc.src.__support.macros.config
+    libc.src.__support.math.llroundbf16
 )
 
 add_entrypoint_object(
@@ -1071,7 +1061,7 @@ add_entrypoint_object(
   HDRS
     ../lrint.h
   DEPENDS
-    libc.src.__support.FPUtil.nearest_integer_operations
+    libc.src.__support.math.lrint
 )
 
 add_entrypoint_object(
@@ -1081,7 +1071,7 @@ add_entrypoint_object(
   HDRS
     ../lrintf.h
   DEPENDS
-    libc.src.__support.FPUtil.nearest_integer_operations
+    libc.src.__support.math.lrintf
 )
 
 add_entrypoint_object(
@@ -1091,7 +1081,7 @@ add_entrypoint_object(
   HDRS
     ../lrintl.h
   DEPENDS
-    libc.src.__support.FPUtil.nearest_integer_operations
+    libc.src.__support.math.lrintl
 )
 
 add_entrypoint_object(
@@ -1101,8 +1091,7 @@ add_entrypoint_object(
   HDRS
     ../lrintf16.h
   DEPENDS
-    libc.src.__support.macros.properties.types
-    libc.src.__support.FPUtil.nearest_integer_operations
+    libc.src.__support.math.lrintf16
 )
 
 add_entrypoint_object(
@@ -1112,8 +1101,7 @@ add_entrypoint_object(
   HDRS
     ../lrintf128.h
   DEPENDS
-    libc.src.__support.macros.properties.types
-    libc.src.__support.FPUtil.nearest_integer_operations
+    libc.src.__support.math.lrintf128
 )
 
 add_entrypoint_object(
@@ -1123,10 +1111,7 @@ add_entrypoint_object(
   HDRS
     ../lrintbf16.h
   DEPENDS
-    libc.src.__support.common
-    libc.src.__support.FPUtil.bfloat16
-    libc.src.__support.FPUtil.nearest_integer_operations
-    libc.src.__support.macros.config
+    libc.src.__support.math.lrintbf16
 )
 
 add_entrypoint_object(
@@ -1136,7 +1121,7 @@ add_entrypoint_object(
   HDRS
     ../llrint.h
   DEPENDS
-    libc.src.__support.FPUtil.nearest_integer_operations
+    libc.src.__support.math.llrint
 )
 
 add_entrypoint_object(
@@ -1146,7 +1131,7 @@ add_entrypoint_object(
   HDRS
     ../llrintf.h
   DEPENDS
-    libc.src.__support.FPUtil.nearest_integer_operations
+    libc.src.__support.math.llrintf
 )
 
 add_entrypoint_object(
@@ -1156,7 +1141,7 @@ add_entrypoint_object(
   HDRS
     ../llrintl.h
   DEPENDS
-    libc.src.__support.FPUtil.nearest_integer_operations
+    libc.src.__support.math.llrintl
 )
 
 add_entrypoint_object(
@@ -1166,8 +1151,7 @@ add_entrypoint_object(
   HDRS
     ../llrintf16.h
   DEPENDS
-    libc.src.__support.macros.properties.types
-    libc.src.__support.FPUtil.nearest_integer_operations
+    libc.src.__support.math.llrintf16
 )
 
 add_entrypoint_object(
@@ -1177,8 +1161,7 @@ add_entrypoint_object(
   HDRS
     ../llrintf128.h
   DEPENDS
-    libc.src.__support.macros.properties.types
-    libc.src.__support.FPUtil.nearest_integer_operations
+    libc.src.__support.math.llrintf128
 )
 
 add_entrypoint_object(
@@ -1188,8 +1171,7 @@ add_entrypoint_object(
   HDRS
     ../llrintbf16.h
   DEPENDS
-    libc.src.__support.macros.properties.types
-    libc.src.__support.FPUtil.nearest_integer_operations
+    libc.src.__support.math.llrintbf16
 )
 
 add_entrypoint_object(
diff --git a/libc/src/math/generic/llrint.cpp b/libc/src/math/generic/llrint.cpp
index f6e8cab93ec39..dfe71eedbe994 100644
--- a/libc/src/math/generic/llrint.cpp
+++ b/libc/src/math/generic/llrint.cpp
@@ -7,16 +7,10 @@
 //===----------------------------------------------------------------------===//
 
 #include "src/math/llrint.h"
-#include "src/__support/FPUtil/NearestIntegerOperations.h"
-#include "src/__support/common.h"
-#include "src/__support/macros/config.h"
+#include "src/__support/math/llrint.h"
 
 namespace LIBC_NAMESPACE_DECL {
 
-LLVM_LIBC_FUNCTION(long long, llrint, (double x)) {
-  return fputil::round_to_signed_integer_using_current_rounding_mode<double,
-                                                                     long long>(
-      x);
-}
+LLVM_LIBC_FUNCTION(long long, llrint, (double x)) { return math::llrint(x); }
 
 } // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/math/generic/llrintbf16.cpp b/libc/src/math/generic/llrintbf16.cpp
index ec85454d788ff..5f00986b19dab 100644
--- a/libc/src/math/generic/llrintbf16.cpp
+++ b/libc/src/math/generic/llrintbf16.cpp
@@ -7,17 +7,12 @@
 //===----------------------------------------------------------------------===//
 
 #include "src/math/llrintbf16.h"
-#include "src/__support/FPUtil/NearestIntegerOperations.h"
-#include "src/__support/FPUtil/bfloat16.h"
-#include "src/__support/common.h"
-#include "src/__support/macros/config.h"
+#include "src/__support/math/llrintbf16.h"
 
 namespace LIBC_NAMESPACE_DECL {
 
 LLVM_LIBC_FUNCTION(long long, llrintbf16, (bfloat16 x)) {
-  return fputil::round_to_signed_integer_using_current_rounding_mode<bfloat16,
-                                                                     long long>(
-      x);
+  return math::llrintbf16(x);
 }
 
 } // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/math/generic/llrintf.cpp b/libc/src/math/generic/llrintf.cpp
index b5180de9a9bf9..3fe894c2bf859 100644
--- a/libc/src/math/generic/llrintf.cpp
+++ b/libc/src/math/generic/llrintf.cpp
@@ -7,16 +7,10 @@
 //===----------------------------------------------------------------------===//
 
 #include "src/math/llrintf.h"
-#include "src/__support/FPUtil/NearestIntegerOperations.h"
-#include "src/__support/common.h"
-#include "src/__support/macros/config.h"
+#include "src/__support/math/llrintf.h"
 
 namespace LIBC_NAMESPACE_DECL {
 
-LLVM_LIBC_FUNCTION(long long, llrintf, (float x)) {
-  return fputil::round_to_signed_integer_using_current_rounding_mode<float,
-                                                                     long long>(
-      x);
-}
+LLVM_LIBC_FUNCTION(long long, llrintf, (float x)) { return math::llrintf(x); }
 
 } // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/math/generic/llrintf128.cpp b/libc/src/math/generic/llrintf128.cpp
index af489852eb73f..dc1897fdc7b8a 100644
--- a/libc/src/math/generic/llrintf128.cpp
+++ b/libc/src/math/generic/llrintf128.cpp
@@ -7,16 +7,12 @@
 //===----------------------------------------------------------------------===//
 
 #include "src/math/llrintf128.h"
-#include "src/__support/FPUtil/NearestIntegerOperations.h"
-#include "src/__support/common.h"
-#include "src/__support/macros/config.h"
+#include "src/__support/math/llrintf128.h"
 
 namespace LIBC_NAMESPACE_DECL {
 
 LLVM_LIBC_FUNCTION(long long, llrintf128, (float128 x)) {
-  return fputil::round_to_signed_integer_using_current_rounding_mode<float128,
-                                                                     long long>(
-      x);
+  return math::llrintf128(x);
 }
 
 } // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/math/generic/llrintf16.cpp b/libc/src/math/generic/llrintf16.cpp
index c6b31c7352262..aff975a93f828 100644
--- a/libc/src/math/generic/llrintf16.cpp
+++ b/libc/src/math/generic/llrintf16.cpp
@@ -7,16 +7,12 @@
 //===----------------------------------------------------------------------===//
 
 #include "src/math/llrintf16.h"
-#include "src/__support/FPUtil/NearestIntegerOperations.h"
-#include "src/__support/common.h"
-#include "src/__support/macros/config.h"
+#include "src/__support/math/llrintf16.h"
 
 namespace LIBC_NAMESPACE_DECL {
 
 LLVM_LIBC_FUNCTION(long long, llrintf16, (float16 x)) {
-  return fputil::round_to_signed_integer_using_current_rounding_mode<float16,
-                                                                     long long>(
-      x);
+  return math::llrintf16(x);
 }
 
 } // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/math/generic/llrintl.cpp b/libc/src/math/generic/llrintl.cpp
index 35ae609d019fe..6cf6ff77b1d1c 100644
--- a/libc/src/math/generic/llrintl.cpp
+++ b/libc/src/math/generic/llrintl.cpp
@@ -7,15 +7,12 @@
 //===----------------------------------------------------------------------===//
 
 #include "src/math/llrintl.h"
-#include "src/__support/FPUtil/NearestIntegerOperations.h"
-#include "src/__support/common.h"
-#include "src/__support/macros/config.h"
+#include "src/__support/math/llrintl.h"
 
 namespace LIBC_NAMESPACE_DECL {
 
 LLVM_LIBC_FUNCTION(long long, llrintl, (long double x)) {
-  return fputil::round_to_signed_integer_using_current_rounding_mode<
-      long double, long long>(x);
+  return math::llrintl(x);
 }
 
 } // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/math/generic/llround.cpp b/libc/src/math/generic/llround.cpp
index 40b2614396618..c0abc1f5cf813 100644
--- a/libc/src/math/generic/llround.cpp
+++ b/libc/src/math/generic/llround.cpp
@@ -7,14 +7,10 @@
 //===----------------------------------------------------------------------===//
 
 #include "src/math/llround.h"
-#include "src/__support/FPUtil/NearestIntegerOperations.h"
-#include "src/__support/common.h"
-#include "src/__support/macros/config.h"
+#include "src/__support/math/llround.h"
 
 namespace LIBC_NAMESPACE_DECL {
 
-LLVM_LIBC_FUNCTION(long long, llround, (double x)) {
-  return fputil::round_to_signed_integer<double, long long>(x);
-}
+LLVM_LIBC_FUNCTION(long long, llround, (double x)) { return math::llround(x); }
 
 } // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/math/generic/llroundbf16.cpp b/libc/src/math/generic/llroundbf16.cpp
index 2497b6b4a7df3..b5a62637df8ff 100644
--- a/libc/src/math/generic/llroundbf16.cpp
+++ b/libc/src/math/generic/llroundbf16.cpp
@@ -7,15 +7,12 @@
 //===----------------------------------------------------------------------===//
 
 #include "src/math/llroundbf16.h"
-#include "src/__support/FPUtil/NearestIntegerOperations.h"
-#include "src/__support/FPUtil/bfloat16.h"
-#include "src/__support/common.h"
-#include "src/__support/macros/config.h"
+#include "src/__support/math/llroundbf16.h"
 
 namespace LIBC_NAMESPACE_DECL {
 
 LLVM_LIBC_FUNCTION(long long, llroundbf16, (bfloat16 x)) {
-  return fputil::round_to_signed_integer<bfloat16, long long>(x);
+  return math::llroundbf16(x);
 }
 
 } // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/math/generic/llroundf.cpp b/libc/src/math/generic/llroundf.cpp
index 259c769a49c9c..ec93b62f1d890 100644
--- a/libc/src/math/generic/llroundf.cpp
+++ b/libc/src/math/generic/llroundf.cpp
@@ -7,14 +7,10 @@
 //===----------------------------------------------------------------------===//
 
 #include "src/math/llroundf.h"
-#include "src/__support/FPUtil/NearestIntegerOperations.h"
-#include "src/__support/common.h"
-#include "src/__support/macros/config.h"
+#include "src/__support/math/llroundf.h"
 
 namespace LIBC_NAMESPACE_DECL {
 
-LLVM_LIBC_FUNCTION(long long, llroundf, (float x)) {
-  return fputil::round_to_signed_integer<float, long long>(x);
-}
+LLVM_LIBC_FUNCTION(long long, llroundf, (float x)) { return math::llroundf(x); }
 
 } // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/math/generic/llroundf128.cpp b/libc/src/math/generic/llroundf128.cpp
index 2df24f5221cc3..4ef2eb0032370 100644
--- a/libc/src/math/generic/llroundf128.cpp
+++ b/libc/src/math/generic/llroundf128.cpp
@@ -7,14 +7,12 @@
 //===----------------------------------------------------------------------===//
 
 #include "src/math/llroundf128.h"
-#include "src/__support/FPUtil/NearestIntegerOperations.h"
-#include "src/__support/common.h"
-#include "src/__support/macros/config.h"
+#include "src/__support/math/llroundf128.h"
 
 namespace LIBC_NAMESPACE_DECL {
 
 LLVM_LIBC_FUNCTION(long long, llroundf128, (float128 x)) {
-  return fputil::round_to_signed_integer<float128, long long>(x);
+  return math::llroundf128(x);
 }
 
 } // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/math/generic/llroundf16.cpp b/libc/src/math/generic/llroundf16.cpp
index d3f691ed0c6fd..fa2e023406d9c 100644
--- a/libc/src/math/generic/llroundf16.cpp
+++ b/libc/src/math/generic/llroundf16.cpp
@@ -7,14 +7,12 @@
 //===----------------------------------------------------------------------===//
 
 #include "src/math/llroundf16.h"
-#include "src/__support/FPUtil/NearestIntegerOperations.h"
-#include "src/__support/common.h"
-#include "src/__support/macros/config.h"
+#include "src/__support/math/llroundf16.h"
 
 namespace LIBC_NAMESPACE_DECL {
 
 LLVM_LIBC_FUNCTION(long long, llroundf16, (float16 x)) {
-  return fputil::round_to_signed_integer<float16, long long>(x);
+  return math::llroundf16(x);
 }
 
 } // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/math/generic/llroundl.cpp b/libc/src/math/generic/llroundl.cpp
index 49b41c810365e..ae1f27f90076c 100644
--- a/libc/src/math/generic/llroundl.cpp
+++ b/libc/src/math/generic/llroundl.cpp
@@ -7,14 +7,12 @@
 //===----------------------------------------------------------------------===//
 
 #include "src/math/llroundl.h"
-#include "src/__support/FPUtil/NearestIntegerOperations.h"
-#include "src/__support/common.h"
-#include "src/__support/macros/config.h"
+#include "src/__support/math/llroundl.h"
 
 namespace LIBC_NAMESPACE_DECL {
 
 LLVM_LIBC_FUNCTION(long long, llroundl, (long double x)) {
-  return fputil::round_to_signed_integer<long double, long long>(x);
+  return math::llroundl(x);
 }
 
 } // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/math/generic/lrint.cpp b/libc/src/math/generic/lrint.cpp
index eae9bc13d6311..2aaa8b76b5ef9 100644
--- a/libc/src/math/generic/lrint.cpp
+++ b/libc/src/math/generic/lrint.cpp
@@ -7,15 +7,10 @@
 //===----------------------------------------------------------------------===//
 
 #include "src/math/lrint.h"
-#include "src/__support/FPUtil/NearestIntegerOperations.h"
-#include "src/__support/common.h"
-#include "src/__support/macros/config.h"
+#include "src/__support/math/lrint.h"
 
 namespace LIBC_NAMESPACE_DECL {
 
-LLVM_LIBC_FUNCTION(long, lrint, (double x)) {
-  return fputil::round_to_signed_integer_using_current_rounding_mode<double,
-                                                                     long>(x);
-}
+LLVM_LIBC_FUNCTION(long, lrint, (double x)) { return math::lrint(x); }
 
 } // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/math/generic/lrintbf16.cpp b/libc/src/math/generic/lrintbf16.cpp
index 4b378909413d3..ec1fe1e61274b 100644
--- a/libc/src/math/generic/lrintbf16.cpp
+++ b/libc/src/math/generic/lrintbf16.cpp
@@ -7,16 +7,10 @@
 //===----------------------------------------------------------------------===//
 
 #include "src/math/lrintbf16.h"
-#include "src/__support/FPUtil/NearestIntegerOperations.h"
-#include "src/__support/FPUtil/bfloat16.h"
-#include "src/__support/common.h"
-#include "src/__support/macros/config.h"
+#include "src/__support/math/lrintbf16.h"
 
 namespace LIBC_NAMESPACE_DECL {
 
-LLVM_LIBC_FUNCTION(long, lrintbf16, (bfloat16 x)) {
-  return fputil::round_to_signed_integer_using_current_rounding_mode<bfloat16,
-                                                                     long>(x);
-}
+LLVM_LIBC_FUNCTION(long, lrintbf16, (bfloat16 x)) { return math::lrintbf16(x); }
 
 } // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/math/generic/lrintf.cpp b/libc/src/math/generic/lrintf.cpp
index e08c87c713e9e..bf15b941c5e3e 100644
--- a/libc/src/math/generic/lrintf.cpp
+++ b/libc/src/math/generic/lrintf.cpp
@@ -7,15 +7,10 @@
 //===----------------------------------------------------------------------===//
 
 #include "src/math/lrintf.h"
-#include "src/__support/FPUtil/NearestIntegerOperations.h"
-#include "src/__support/common.h"
-#include "src/__support/macros/config.h"
+#include "src/__support/math/lrintf.h"
 
 namespace LIBC_NAMESPACE_DECL {
 
-LLVM_LIBC_FUNCTION(long, lrintf, (float x)) {
-  return fputil::round_to_signed_integer_using_current_rounding_mode<float,
-                                                                     long>(x);
-}
+LLVM_LIBC_FUNCTION(long, lrintf, (float x)) { return math::lrintf(x); }
 
 } // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/math/generic/lrintf128.cpp b/libc/src/math/generic/lrintf128.cpp
index 15ecded1a3722..2fffbd3572f88 100644
--- a/libc/src/math/generic/lrintf128.cpp
+++ b/libc/src/math/generic/lrintf128.cpp
@@ -7,15 +7,10 @@
 //===----------------------------------------------------------------------===//
 
 #include "src/math/lrintf128.h"
-#include "src/__support/FPUtil/NearestIntegerOperations.h"
-#include "src/__support/common.h"
-#include "src/__support/macros/config.h"
+#include "src/__support/math/lrintf128.h"
 
 namespace LIBC_NAMESPACE_DECL {
 
-LLVM_LIBC_FUNCTION(long, lrintf128, (float128 x)) {
-  return fputil::round_to_signed_integer_using_current_rounding_mode<float128,
-                                                                     long>(x);
-}
+LLVM_LIBC_FUNCTION(long, lrintf128, (float128 x)) { return math::lrintf128(x); }
 
 } // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/math/generic/lrintf16.cpp b/libc/src/math/generic/lrintf16.cpp
index 92af687444446..bf621fc6fe2e9 100644
--- a/libc/src/math/generic/lrintf16.cpp
+++ b/libc/src/math/generic/lrintf16.cpp
@@ -7,15 +7,10 @@
 //===----------------------------------------------------------------------===//
 
 #include "src/math/lrintf16.h"
-#include "src/__support/FPUtil/NearestIntegerOperations.h"
-#include "src/__support/common.h"
-#include "src/__support/macros/config.h"
+#include "src/__support/math/lrintf16.h"
 
 namespace LIBC_NAMESPACE_DECL {
 
-LLVM_LIBC_FUNCTION(long, lrintf16, (float16 x)) {
-  return fputil::round_to_signed_integer_using_current_rounding_mode<float16,
-                                                                     long>(x);
-}
+LLVM_LIBC_FUNCTION(long, lrintf16, (float16 x)) { return math::lrintf16(x); }
 
 } // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/math/generic/lrintl.cpp b/libc/src/math/generic/lrintl.cpp
index d881aeea1727b..2e45dae341e79 100644
--- a/libc/src/math/generic/lrintl.cpp
+++ b/libc/src/math/generic/lrintl.cpp
@@ -7,15 +7,10 @@
 //===----------------------------------------------------------------------===//
 
 #include "src/math/lrintl.h"
-#include "src/__support/FPUtil/NearestIntegerOperations.h"
-#include "src/__support/common.h"
-#include "src/__support/macros/config.h"
+#include "src/__support/math/lrintl.h"
 
 namespace LIBC_NAMESPACE_DECL {
 
-LLVM_LIBC_FUNCTION(long, lrintl, (long double x)) {
-  return fputil::round_to_signed_integer_using_current_rounding_mode<
-      long double, long>(x);
-}
+LLVM_LIBC_FUNCTION(long, lrintl, (long double x)) { return math::lrintl(x); }
 
 } // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/math/generic/lround.cpp b/libc/src/math/generic/lround.cpp
index b208457000846..c0b0ce9abf2ef 100644
--- a/libc/src/math/generic/lround.cpp
+++ b/libc/src/math/generic/lround.cpp
@@ -7,14 +7,10 @@
 //===----------------------------------------------------------------------===//
 
 #include "src/math/lround.h"
-#include "src/__support/FPUtil/NearestIntegerOperations.h"
-#include "src/__support/common.h"
-#include "src/__support/macros/config.h"
+#include "src/__support/math/lround.h"
 
 namespace LIBC_NAMESPACE_DECL {
 
-LLVM_LIBC_FUNCTION(long, lround, (double x)) {
-  return fputil::round_to_signed_integer<double, long>(x);
-}
+LLVM_LIBC_FUNCTION(long, lround, (double x)) { return math::lround(x); }
 
 } // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/math/generic/lroundbf16.cpp b/libc/src/math/generic/lroundbf16.cpp
index 89095d1786f63..9aec4e98910f0 100644
--- a/libc/src/math/generic/lroundbf16.cpp
+++ b/libc/src/math/generic/lroundbf16.cpp
@@ -7,15 +7,12 @@
 //===----------------------------------------------------------------------===//
 
 #include "src/math/lroundbf16.h"
-#include "src/__support/FPUtil/NearestIntegerOperations.h"
-#include "src/__support/FPUtil/bfloat16.h"
-#include "src/__support/common.h"
-#include "src/__support/macros/config.h"
+#include "src/__support/math/lroundbf16.h"
 
 namespace LIBC_NAMESPACE_DECL {
 
 LLVM_LIBC_FUNCTION(long, lroundbf16, (bfloat16 x)) {
-  return fputil::round_to_signed_integer<bfloat16, long>(x);
+  return math::lroundbf16(x);
 }
 
 } // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/math/generic/lroundf.cpp b/libc/src/math/generic/lroundf.cpp
index 1e1a948ac7972..9bae285b6cdc4 100644
--- a/libc/src/math/generic/lroundf.cpp
+++ b/libc/src/math/generic/lroundf.cpp
@@ -7,14 +7,10 @@
 //===----------------------------------------------------------------------===//
 
 #include "src/math/lroundf.h"
-#include "src/__support/FPUtil/NearestIntegerOperations.h"
-#include "src/__support/common.h"
-#include "src/__support/macros/config.h"
+#include "src/__support/math/lroundf.h"
 
 namespace LIBC_NAMESPACE_DECL {
 
-LLVM_LIBC_FUNCTION(long, lroundf, (float x)) {
-  return fputil::round_to_signed_integer<float, long>(x);
-}
+LLVM_LIBC_FUNCTION(long, lroundf, (float x)) { return math::lroundf(x); }
 
 } // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/math/generic/lroundf128.cpp b/libc/src/math/generic/lroundf128.cpp
index 89b15f525f903..c6ea549d58253 100644
--- a/libc/src/math/generic/lroundf128.cpp
+++ b/libc/src/math/generic/lroundf128.cpp
@@ -7,14 +7,12 @@
 //===----------------------------------------------------------------------===//
 
 #include "src/math/lroundf128.h"
-#include "src/__support/FPUtil/NearestIntegerOperations.h"
-#include "src/__support/common.h"
-#include "src/__support/macros/config.h"
+#include "src/__support/math/lroundf128.h"
 
 namespace LIBC_NAMESPACE_DECL {
 
 LLVM_LIBC_FUNCTION(long, lroundf128, (float128 x)) {
-  return fputil::round_to_signed_integer<float128, long>(x);
+  return math::lroundf128(x);
 }
 
 } // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/math/generic/lroundf16.cpp b/libc/src/math/generic/lroundf16.cpp
index d25bc8467f061..58e84d4ae8e3c 100644
--- a/libc/src/math/generic/lroundf16.cpp
+++ b/libc/src/math/generic/lroundf16.cpp
@@ -7,14 +7,10 @@
 //===----------------------------------------------------------------------===//
 
 #include "src/math/lroundf16.h"
-#include "src/__support/FPUtil/NearestIntegerOperations.h"
-#include "src/__support/common.h"
-#include "src/__support/macros/config.h"
+#include "src/__support/math/lroundf16.h"
 
 namespace LIBC_NAMESPACE_DECL {
 
-LLVM_LIBC_FUNCTION(long, lroundf16, (float16 x)) {
-  return fputil::round_to_signed_integer<float16, long>(x);
-}
+LLVM_LIBC_FUNCTION(long, lroundf16, (float16 x)) { return math::lroundf16(x); }
 
 } // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/math/generic/lroundl.cpp b/libc/src/math/generic/lroundl.cpp
index efcf3da3ff15f..ca4ce5df6d668 100644
--- a/libc/src/math/generic/lroundl.cpp
+++ b/libc/src/math/generic/lroundl.cpp
@@ -7,14 +7,10 @@
 //===----------------------------------------------------------------------===//
 
 #include "src/math/lroundl.h"
-#include "src/__support/FPUtil/NearestIntegerOperations.h"
-#include "src/__support/common.h"
-#include "src/__support/macros/config.h"
+#include "src/__support/math/lroundl.h"
 
 namespace LIBC_NAMESPACE_DECL {
 
-LLVM_LIBC_FUNCTION(long, lroundl, (long double x)) {
-  return fputil::round_to_signed_integer<long double, long>(x);
-}
+LLVM_LIBC_FUNCTION(long, lroundl, (long double x)) { return math::lroundl(x); }
 
 } // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/test/shared/CMakeLists.txt b/libc/test/shared/CMakeLists.txt
index c5781cca1d16e..c64dad12391e9 100644
--- a/libc/test/shared/CMakeLists.txt
+++ b/libc/test/shared/CMakeLists.txt
@@ -284,6 +284,18 @@ add_fp_unittest(
     libc.src.__support.math.ldexpl
     libc.src.__support.math.llogb
     libc.src.__support.math.llogbbf16
+    libc.src.__support.math.llrint
+    libc.src.__support.math.llrintbf16
+    libc.src.__support.math.llrintf
+    libc.src.__support.math.llrintf128
+    libc.src.__support.math.llrintf16
+    libc.src.__support.math.llrintl
+    libc.src.__support.math.llround
+    libc.src.__support.math.llroundbf16
+    libc.src.__support.math.llroundf
+    libc.src.__support.math.llroundf128
+    libc.src.__support.math.llroundf16
+    libc.src.__support.math.llroundl
     libc.src.__support.math.log
     libc.src.__support.math.log10
     libc.src.__support.math.log10f16
@@ -311,6 +323,18 @@ add_fp_unittest(
     libc.src.__support.math.logbl
     libc.src.__support.math.logf16
     libc.src.__support.math.llogbl
+    libc.src.__support.math.lrint
+    libc.src.__support.math.lrintbf16
+    libc.src.__support.math.lrintf
+    libc.src.__support.math.lrintf128
+    libc.src.__support.math.lrintf16
+    libc.src.__support.math.lrintl
+    libc.src.__support.math.lround
+    libc.src.__support.math.lroundbf16
+    libc.src.__support.math.lroundf
+    libc.src.__support.math.lroundf128
+    libc.src.__support.math.lroundf16
+    libc.src.__support.math.lroundl
     libc.src.__support.math.modf
     libc.src.__support.math.modfbf16
     libc.src.__support.math.modff
@@ -567,9 +591,33 @@ add_fp_unittest(
     libc.src.__support.math.ldexpbf16
     libc.src.__support.math.ldexpl
     libc.src.__support.math.llogbbf16
+    libc.src.__support.math.llrint
+    libc.src.__support.math.llrintbf16
+    libc.src.__support.math.llrintf
+    libc.src.__support.math.llrintf128
+    libc.src.__support.math.llrintf16
+    libc.src.__support.math.llrintl
+    libc.src.__support.math.llround
+    libc.src.__support.math.llroundbf16
+    libc.src.__support.math.llroundf
+    libc.src.__support.math.llroundf128
+    libc.src.__support.math.llroundf16
+    libc.src.__support.math.llroundl
     libc.src.__support.math.log
     libc.src.__support.math.logbbf16
     libc.src.__support.math.ilogbbf16
+    libc.src.__support.math.lrint
+    libc.src.__support.math.lrintbf16
+    libc.src.__support.math.lrintf
+    libc.src.__support.math.lrintf128
+    libc.src.__support.math.lrintf16
+    libc.src.__support.math.lrintl
+    libc.src.__support.math.lround
+    libc.src.__support.math.lroundbf16
+    libc.src.__support.math.lroundf
+    libc.src.__support.math.lroundf128
+    libc.src.__support.math.lroundf16
+    libc.src.__support.math.lroundl
     libc.src.__support.math.modf
     libc.src.__support.math.modfbf16
     libc.src.__support.math.modff
diff --git a/libc/test/shared/shared_math_constexpr_test.cpp b/libc/test/shared/shared_math_constexpr_test.cpp
index 7422017f5d3ee..41f662ecb59b4 100644
--- a/libc/test/shared/shared_math_constexpr_test.cpp
+++ b/libc/test/shared/shared_math_constexpr_test.cpp
@@ -62,6 +62,8 @@ static_assert(0.0 == [] {
   int exp{};
   return LIBC_NAMESPACE::shared::frexp(0.0, &exp);
 }());
+static_assert(0L == LIBC_NAMESPACE::shared::lrint(0.0));
+static_assert(0L == LIBC_NAMESPACE::shared::lround(0.0));
 
 //===----------------------------------------------------------------------===//
 //                       Float Tests
@@ -110,6 +112,9 @@ static_assert(0.0f == LIBC_NAMESPACE::shared::scalblnf(0.0f, 0.0));
 static_assert(0.0f == LIBC_NAMESPACE::shared::scalbnf(0.0f, 0.0));
 static_assert(0.0f == LIBC_NAMESPACE::shared::fmul(0.0, 0.0));
 static_assert(0.0f == LIBC_NAMESPACE::shared::fsub(0.0, 0.0));
+static_assert(0.0L == LIBC_NAMESPACE::shared::lrintf(0.0f));
+static_assert(0.0L == LIBC_NAMESPACE::shared::lroundf(0.0f));
+
 //===----------------------------------------------------------------------===//
 //                       Float16 Tests
 //===----------------------------------------------------------------------===//
@@ -175,6 +180,8 @@ static_assert(0.0f16 == [] {
 }());
 static_assert(0.0f16 == LIBC_NAMESPACE::shared::scalblnf16(0.0f16, 0.0));
 static_assert(0.0f16 == LIBC_NAMESPACE::shared::scalbnf16(0.0f16, 0.0));
+static_assert(0L == LIBC_NAMESPACE::shared::lrintf16(0.0f16));
+static_assert(0L == LIBC_NAMESPACE::shared::lroundf16(0.0f16));
 #endif // LIBC_TYPES_HAS_FLOAT16
 
 //===----------------------------------------------------------------------===//
@@ -238,6 +245,20 @@ static_assert(0.0L == [] {
   int exp{};
   return LIBC_NAMESPACE::shared::frexpl(0.0L, &exp);
 }());
+static_assert(0L == LIBC_NAMESPACE::shared::lrintl(0.0L));
+static_assert(0L == LIBC_NAMESPACE::shared::lroundl(0.0L));
+static_assert(0.0L == LIBC_NAMESPACE::shared::llrint(0.0));
+static_assert(0.0L == LIBC_NAMESPACE::shared::llrintf16(0.0));
+static_assert(0.0L == LIBC_NAMESPACE::shared::llrintbf16(bfloat16(0.0)));
+static_assert(0.0L == LIBC_NAMESPACE::shared::llrintf(0.0f));
+static_assert(0.0L == LIBC_NAMESPACE::shared::llrintf128(float128(0.0)));
+static_assert(0.0L == LIBC_NAMESPACE::shared::llrintl(0.0L));
+static_assert(0.0L == LIBC_NAMESPACE::shared::llround(0.0));
+static_assert(0.0L == LIBC_NAMESPACE::shared::llroundbf16(bfloat16(0.0)));
+static_assert(0.0L == LIBC_NAMESPACE::shared::llroundf(0.0f));
+static_assert(0.0L == LIBC_NAMESPACE::shared::llroundf128(float128(0.0)));
+static_assert(0.0L == LIBC_NAMESPACE::shared::llroundl(0.0L));
+static_assert(0.0L == LIBC_NAMESPACE::shared::llroundf16(0.0f16));
 
 #endif
 
@@ -334,6 +355,8 @@ static_assert(0.0f ==
               LIBC_NAMESPACE::shared::fmulf128(float128(0.0), float128(0.0)));
 static_assert(0.0f ==
               LIBC_NAMESPACE::shared::fsubf128(float128(0.0), float128(0.0)));
+static_assert(0L == LIBC_NAMESPACE::shared::lrintf128(float128(0.0)));
+static_assert(0L == LIBC_NAMESPACE::shared::lroundf128(float128(0.0)));
 
 #endif // LIBC_TYPES_HAS_FLOAT128
 
@@ -425,5 +448,7 @@ static_assert(bfloat16(0.0) == [] {
   int exp{};
   return LIBC_NAMESPACE::shared::frexpbf16(bfloat16(0.0), &exp);
 }());
+static_assert(0L == LIBC_NAMESPACE::shared::lrintbf16(bfloat16(0.0)));
+static_assert(0L == LIBC_NAMESPACE::shared::lroundbf16(bfloat16(0.0)));
 
 TEST(LlvmLibcSharedMathTest, ConstantEvaluation) {}
diff --git a/libc/test/shared/shared_math_test.cpp b/libc/test/shared/shared_math_test.cpp
index c177adf8b46bc..a059d6947c617 100644
--- a/libc/test/shared/shared_math_test.cpp
+++ b/libc/test/shared/shared_math_test.cpp
@@ -142,6 +142,8 @@ TEST(LlvmLibcSharedMathTest, AllFloat16) {
   EXPECT_EQ(1, remquof16_exp);
   EXPECT_FP_EQ(0x0p+0f16, LIBC_NAMESPACE::shared::scalblnf16(0.0f16, 0L));
   EXPECT_FP_EQ(0x0p+0f16, LIBC_NAMESPACE::shared::scalbnf16(0.0f16, 0));
+  EXPECT_EQ(0L, LIBC_NAMESPACE::shared::lrintf16(0.0f16));
+  EXPECT_EQ(0L, LIBC_NAMESPACE::shared::lroundf16(0.0f16));
 }
 
 #endif // LIBC_TYPES_HAS_FLOAT16
@@ -288,6 +290,8 @@ TEST(LlvmLibcSharedMathTest, AllFloat) {
   EXPECT_FP_EQ(0x0p+0f, LIBC_NAMESPACE::shared::fmull(0.0L, 0.0L));
   EXPECT_FP_EQ(0x0p+0f, LIBC_NAMESPACE::shared::fsub(0.0, 0.0));
   EXPECT_FP_EQ(0x0p+0f, LIBC_NAMESPACE::shared::fsubl(0.0L, 0.0L));
+  EXPECT_EQ(0L, LIBC_NAMESPACE::shared::lrintf(0.0f));
+  EXPECT_EQ(0L, LIBC_NAMESPACE::shared::lroundf(0.0f));
 }
 
 TEST(LlvmLibcSharedMathTest, AllDouble) {
@@ -409,6 +413,9 @@ TEST(LlvmLibcSharedMathTest, AllDouble) {
   int frexp_exp = 0;
   EXPECT_FP_EQ(0.0, LIBC_NAMESPACE::shared::frexp(0.0, &frexp_exp));
   EXPECT_EQ(0, frexp_exp);
+
+  EXPECT_EQ(0L, LIBC_NAMESPACE::shared::lrint(0.0));
+  EXPECT_EQ(0L, LIBC_NAMESPACE::shared::lround(0.0));
 }
 
 // TODO: Enable the tests when double-double type is supported.
@@ -474,6 +481,8 @@ TEST(LlvmLibcSharedMathTest, AllLongDouble) {
   EXPECT_FP_EQ(0.0f16, LIBC_NAMESPACE::shared::f16subl(0.0L, 0.0L));
   EXPECT_FP_EQ(1.0f16, LIBC_NAMESPACE::shared::f16sqrtl(1.0L));
   EXPECT_FP_EQ(10.0f16, LIBC_NAMESPACE::shared::f16fmal(2.0L, 3.0L, 4.0L));
+  EXPECT_FP_EQ(0x0p+0L, LIBC_NAMESPACE::shared::llrintf16(0.0f16));
+  EXPECT_FP_EQ(0x0p+0L, LIBC_NAMESPACE::shared::llroundf16(0.0f16));
 #endif // LIBC_TYPES_HAS_FLOAT16
 
   EXPECT_FP_EQ(0.0L, LIBC_NAMESPACE::shared::sqrtl(0.0L));
@@ -513,6 +522,16 @@ TEST(LlvmLibcSharedMathTest, AllLongDouble) {
   int frexpl_exp = 0;
   EXPECT_FP_EQ(0x0p+0L, LIBC_NAMESPACE::shared::frexpl(0.0L, &frexpl_exp));
   EXPECT_EQ(0, frexpl_exp);
+  EXPECT_FP_EQ(0x0p+0L, LIBC_NAMESPACE::shared::llrintl(0.0L));
+  EXPECT_FP_EQ(0x0p+0L, LIBC_NAMESPACE::shared::llroundl(0.0L));
+  EXPECT_FP_EQ(0.0L, LIBC_NAMESPACE::shared::llrint(0.0));
+  EXPECT_FP_EQ(0.0L, LIBC_NAMESPACE::shared::llround(0.0));
+  EXPECT_FP_EQ(0x0p+0L, LIBC_NAMESPACE::shared::llrintf(0.0f));
+  EXPECT_FP_EQ(0x0p+0L, LIBC_NAMESPACE::shared::llroundf(0.0f));
+  EXPECT_FP_EQ(0x0p+0L, LIBC_NAMESPACE::shared::llrintbf16(bfloat16(0.0)));
+  EXPECT_FP_EQ(0x0p+0L, LIBC_NAMESPACE::shared::llroundbf16(bfloat16(0.0)));
+  EXPECT_EQ(0L, LIBC_NAMESPACE::shared::lrintl(0.0L));
+  EXPECT_EQ(0L, LIBC_NAMESPACE::shared::lroundl(0.0L));
 }
 
 #endif // LIBC_TYPES_LONG_DOUBLE_IS_DOUBLE_DOUBLE
@@ -675,6 +694,10 @@ TEST(LlvmLibcSharedMathTest, AllFloat128) {
                LIBC_NAMESPACE::shared::fsubf128(float128(0.0), float128(0.0)));
   EXPECT_FP_EQ(0x0p+0f,
                LIBC_NAMESPACE::shared::fmulf128(float128(0.0), float128(0.0)));
+  EXPECT_FP_EQ(0.0L, LIBC_NAMESPACE::shared::llrintf128(float128(0.0)));
+  EXPECT_FP_EQ(0.0L, LIBC_NAMESPACE::shared::llroundf128(float128(0.0)));
+  EXPECT_EQ(0L, LIBC_NAMESPACE::shared::lrintf128(float128(0.0)));
+  EXPECT_EQ(0L, LIBC_NAMESPACE::shared::lroundf128(float128(0.0)));
 }
 
 #endif // LIBC_TYPES_HAS_FLOAT128
@@ -800,4 +823,6 @@ TEST(LlvmLibcSharedMathTest, AllBFloat16) {
   EXPECT_FP_EQ(bfloat16(0.0), LIBC_NAMESPACE::shared::frexpbf16(
                                   bfloat16(0.0), &frexpbf16_exp));
   EXPECT_EQ(0, frexpbf16_exp);
+  EXPECT_EQ(0L, LIBC_NAMESPACE::shared::lrintbf16(bfloat16(0.0)));
+  EXPECT_EQ(0L, LIBC_NAMESPACE::shared::lroundbf16(bfloat16(0.0)));
 }
diff --git a/utils/bazel/llvm-project-overlay/libc/BUILD.bazel b/utils/bazel/llvm-project-overlay/libc/BUILD.bazel
index a71b2a04cc256..1f94c366ec8dc 100644
--- a/utils/bazel/llvm-project-overlay/libc/BUILD.bazel
+++ b/utils/bazel/llvm-project-overlay/libc/BUILD.bazel
@@ -4858,6 +4858,233 @@ libc_support_library(
     ],
 )
 
+libc_support_library(
+    name = "__support_math_llrint",
+    hdrs = ["src/__support/math/llrint.h"],
+    deps = [
+        ":__support_fputil_nearest_integer_operations",
+        ":__support_macros_config",
+    ],
+)
+
+libc_support_library(
+    name = "__support_math_llrintbf16",
+    hdrs = ["src/__support/math/llrintbf16.h"],
+    deps = [
+        ":__support_fputil_nearest_integer_operations",
+        ":__support_macros_config",
+    ],
+)
+
+libc_support_library(
+    name = "__support_math_llrintf",
+    hdrs = ["src/__support/math/llrintf.h"],
+    deps = [
+        ":__support_fputil_nearest_integer_operations",
+        ":__support_macros_config",
+    ],
+)
+
+libc_support_library(
+    name = "__support_math_llrintf128",
+    hdrs = ["src/__support/math/llrintf128.h"],
+    deps = [
+        ":__support_fputil_nearest_integer_operations",
+        ":__support_macros_config",
+        ":llvm_libc_types_float128",
+    ],
+)
+
+libc_support_library(
+    name = "__support_math_llrintf16",
+    hdrs = ["src/__support/math/llrintf16.h"],
+    deps = [
+        ":__support_fputil_nearest_integer_operations",
+        ":__support_macros_config",
+        ":llvm_libc_macros_float16_macros",
+    ],
+)
+
+libc_support_library(
+    name = "__support_math_llrintl",
+    hdrs = ["src/__support/math/llrintl.h"],
+    deps = [
+        ":__support_fputil_nearest_integer_operations",
+        ":__support_macros_config",
+    ],
+)
+
+libc_support_library(
+    name = "__support_math_llround",
+    hdrs = ["src/__support/math/llround.h"],
+    deps = [
+        ":__support_fputil_nearest_integer_operations",
+        ":__support_macros_config",
+    ],
+)
+
+libc_support_library(
+    name = "__support_math_llroundbf16",
+    hdrs = ["src/__support/math/llroundbf16.h"],
+    deps = [
+        ":__support_fputil_bfloat16",
+        ":__support_fputil_nearest_integer_operations",
+        ":__support_macros_config",
+    ],
+)
+
+libc_support_library(
+    name = "__support_math_llroundf",
+    hdrs = ["src/__support/math/llroundf.h"],
+    deps = [
+        ":__support_fputil_nearest_integer_operations",
+        ":__support_macros_config",
+    ],
+)
+
+libc_support_library(
+    name = "__support_math_llroundf128",
+    hdrs = ["src/__support/math/llroundf128.h"],
+    deps = [
+        ":__support_fputil_nearest_integer_operations",
+        ":__support_macros_config",
+        ":llvm_libc_types_float128",
+    ],
+)
+
+libc_support_library(
+    name = "__support_math_llroundf16",
+    hdrs = ["src/__support/math/llroundf16.h"],
+    deps = [
+        ":__support_fputil_nearest_integer_operations",
+        ":__support_macros_config",
+        ":llvm_libc_macros_float16_macros",
+    ],
+)
+
+libc_support_library(
+    name = "__support_math_llroundl",
+    hdrs = ["src/__support/math/llroundl.h"],
+    deps = [
+        ":__support_fputil_nearest_integer_operations",
+        ":__support_macros_config",
+    ],
+)
+
+libc_support_library(
+    name = "__support_math_lrint",
+    hdrs = ["src/__support/math/lrint.h"],
+    deps = [
+        ":__support_fputil_nearest_integer_operations",
+        ":__support_macros_config",
+    ],
+)
+
+libc_support_library(
+    name = "__support_math_lrintbf16",
+    hdrs = ["src/__support/math/lrintbf16.h"],
+    deps = [
+        ":__support_fputil_bfloat16",
+        ":__support_fputil_nearest_integer_operations",
+        ":__support_macros_config",
+    ],
+)
+
+libc_support_library(
+    name = "__support_math_lrintf",
+    hdrs = ["src/__support/math/lrintf.h"],
+    deps = [
+        ":__support_fputil_nearest_integer_operations",
+        ":__support_macros_config",
+    ],
+)
+
+libc_support_library(
+    name = "__support_math_lrintf128",
+    hdrs = ["src/__support/math/lrintf128.h"],
+    deps = [
+        ":__support_fputil_nearest_integer_operations",
+        ":__support_macros_config",
+        ":llvm_libc_types_float128",
+    ],
+)
+
+libc_support_library(
+    name = "__support_math_lrintf16",
+    hdrs = ["src/__support/math/lrintf16.h"],
+    deps = [
+        ":__support_fputil_nearest_integer_operations",
+        ":__support_macros_config",
+        ":llvm_libc_macros_float16_macros",
+    ],
+)
+
+libc_support_library(
+    name = "__support_math_lrintl",
+    hdrs = ["src/__support/math/lrintl.h"],
+    deps = [
+        ":__support_fputil_nearest_integer_operations",
+        ":__support_macros_config",
+    ],
+)
+
+libc_support_library(
+    name = "__support_math_lround",
+    hdrs = ["src/__support/math/lround.h"],
+    deps = [
+        ":__support_fputil_nearest_integer_operations",
+        ":__support_macros_config",
+    ],
+)
+
+libc_support_library(
+    name = "__support_math_lroundbf16",
+    hdrs = ["src/__support/math/lroundbf16.h"],
+    deps = [
+        ":__support_fputil_bfloat16",
+        ":__support_fputil_nearest_integer_operations",
+        ":__support_macros_config",
+    ],
+)
+
+libc_support_library(
+    name = "__support_math_lroundf",
+    hdrs = ["src/__support/math/lroundf.h"],
+    deps = [
+        ":__support_fputil_nearest_integer_operations",
+        ":__support_macros_config",
+    ],
+)
+
+libc_support_library(
+    name = "__support_math_lroundf128",
+    hdrs = ["src/__support/math/lroundf128.h"],
+    deps = [
+        ":__support_fputil_nearest_integer_operations",
+        ":__support_macros_config",
+        ":llvm_libc_types_float128",
+    ],
+)
+
+libc_support_library(
+    name = "__support_math_lroundf16",
+    hdrs = ["src/__support/math/lroundf16.h"],
+    deps = [
+        ":__support_fputil_nearest_integer_operations",
+        ":__support_macros_config",
+        ":llvm_libc_macros_float16_macros",
+    ],
+)
+
+libc_support_library(
+    name = "__support_math_lroundl",
+    hdrs = ["src/__support/math/lroundl.h"],
+    deps = [
+        ":__support_fputil_nearest_integer_operations",
+        ":__support_macros_config",
+    ],
+)
+
 libc_support_library(
     name = "__support_math_modf",
     hdrs = ["src/__support/math/modf.h"],
@@ -10228,32 +10455,88 @@ libc_math_function(
     ],
 )
 
-libc_math_function(name = "llrint")
+libc_math_function(
+    name = "llrint",
+    additional_deps = [
+        ":__support_math_llrint",
+    ],
+)
+
+libc_math_function(
+    name = "llrintbf16",
+    additional_deps = [
+        ":__support_math_llrintbf16",
+    ],
+)
 
-libc_math_function(name = "llrintf")
+libc_math_function(
+    name = "llrintf",
+    additional_deps = [
+        ":__support_math_llrintf",
+    ],
+)
 
-libc_math_function(name = "llrintl")
+libc_math_function(
+    name = "llrintl",
+    additional_deps = [
+        ":__support_math_llrintl",
+    ],
+)
 
 libc_math_function(
     name = "llrintf128",
+    additional_deps = [
+        ":__support_math_llrintf128",
+    ],
 )
 
 libc_math_function(
     name = "llrintf16",
+    additional_deps = [
+        ":__support_math_llrintf16",
+    ],
 )
 
-libc_math_function(name = "llround")
+libc_math_function(
+    name = "llround",
+    additional_deps = [
+        ":__support_math_llround",
+    ],
+)
 
-libc_math_function(name = "llroundf")
+libc_math_function(
+    name = "llroundbf16",
+    additional_deps = [
+        ":__support_math_llroundbf16",
+    ],
+)
 
-libc_math_function(name = "llroundl")
+libc_math_function(
+    name = "llroundf",
+    additional_deps = [
+        ":__support_math_llroundf",
+    ],
+)
+
+libc_math_function(
+    name = "llroundl",
+    additional_deps = [
+        ":__support_math_llroundl",
+    ],
+)
 
 libc_math_function(
     name = "llroundf128",
+    additional_deps = [
+        ":__support_math_llroundf128",
+    ],
 )
 
 libc_math_function(
     name = "llroundf16",
+    additional_deps = [
+        ":__support_math_llroundf16",
+    ],
 )
 
 libc_math_function(
@@ -10382,32 +10665,88 @@ libc_math_function(
     ],
 )
 
-libc_math_function(name = "lrint")
+libc_math_function(
+    name = "lrint",
+    additional_deps = [
+        ":__support_math_lrint",
+    ],
+)
 
-libc_math_function(name = "lrintf")
+libc_math_function(
+    name = "lrintbf16",
+    additional_deps = [
+        ":__support_math_lrintbf16",
+    ],
+)
 
-libc_math_function(name = "lrintl")
+libc_math_function(
+    name = "lrintf",
+    additional_deps = [
+        ":__support_math_lrintf",
+    ],
+)
+
+libc_math_function(
+    name = "lrintl",
+    additional_deps = [
+        ":__support_math_lrintl",
+    ],
+)
 
 libc_math_function(
     name = "lrintf128",
+    additional_deps = [
+        ":__support_math_lrintf128",
+    ],
 )
 
 libc_math_function(
     name = "lrintf16",
+    additional_deps = [
+        ":__support_math_lrintf16",
+    ],
+)
+
+libc_math_function(
+    name = "lround",
+    additional_deps = [
+        ":__support_math_lround",
+    ],
 )
 
-libc_math_function(name = "lround")
+libc_math_function(
+    name = "lroundbf16",
+    additional_deps = [
+        ":__support_math_lroundbf16",
+    ],
+)
 
-libc_math_function(name = "lroundf")
+libc_math_function(
+    name = "lroundf",
+    additional_deps = [
+        ":__support_math_lroundf",
+    ],
+)
 
-libc_math_function(name = "lroundl")
+libc_math_function(
+    name = "lroundl",
+    additional_deps = [
+        ":__support_math_lroundl",
+    ],
+)
 
 libc_math_function(
     name = "lroundf128",
+    additional_deps = [
+        ":__support_math_lroundf128",
+    ],
 )
 
 libc_math_function(
     name = "lroundf16",
+    additional_deps = [
+        ":__support_math_lroundf16",
+    ],
 )
 
 libc_math_function(



More information about the libc-commits mailing list