1bbb75554SSiva Chandra //===-- Implementation of rint function -----------------------------------===// 2bbb75554SSiva Chandra // 3bbb75554SSiva Chandra // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4bbb75554SSiva Chandra // See https://llvm.org/LICENSE.txt for license information. 5bbb75554SSiva Chandra // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6bbb75554SSiva Chandra // 7bbb75554SSiva Chandra //===----------------------------------------------------------------------===// 8bbb75554SSiva Chandra 9bbb75554SSiva Chandra #include "src/math/rint.h" 10c120edc7SMichael Jones #include "src/__support/FPUtil/NearestIntegerOperations.h" 11bbb75554SSiva Chandra #include "src/__support/common.h" 125ff3ff33SPetr Hosek #include "src/__support/macros/config.h" 13bbb75554SSiva Chandra 145ff3ff33SPetr Hosek namespace LIBC_NAMESPACE_DECL { 15bbb75554SSiva Chandra 16bbb75554SSiva Chandra LLVM_LIBC_FUNCTION(double, rint, (double x)) { 17*4531f82cSOverMighty #ifdef __LIBC_USE_BUILTIN_CEIL_FLOOR_RINT_TRUNC 18*4531f82cSOverMighty return __builtin_rint(x); 19*4531f82cSOverMighty #else 201c92911eSMichael Jones return fputil::round_using_current_rounding_mode(x); 21*4531f82cSOverMighty #endif 22bbb75554SSiva Chandra } 23bbb75554SSiva Chandra 245ff3ff33SPetr Hosek } // namespace LIBC_NAMESPACE_DECL 25