xref: /llvm-project/libc/src/math/generic/ceil.cpp (revision 4531f82c1ad905614c1df9359a77d48e6397fd97)
126687147SSiva Chandra //===-- Implementation of ceil function -----------------------------------===//
226687147SSiva Chandra //
326687147SSiva Chandra // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
426687147SSiva Chandra // See https://llvm.org/LICENSE.txt for license information.
526687147SSiva Chandra // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
626687147SSiva Chandra //
726687147SSiva Chandra //===----------------------------------------------------------------------===//
826687147SSiva Chandra 
926687147SSiva Chandra #include "src/math/ceil.h"
10c120edc7SMichael Jones #include "src/__support/FPUtil/NearestIntegerOperations.h"
1126687147SSiva Chandra #include "src/__support/common.h"
125ff3ff33SPetr Hosek #include "src/__support/macros/config.h"
1326687147SSiva Chandra 
145ff3ff33SPetr Hosek namespace LIBC_NAMESPACE_DECL {
1526687147SSiva Chandra 
16*4531f82cSOverMighty LLVM_LIBC_FUNCTION(double, ceil, (double x)) {
17*4531f82cSOverMighty #ifdef __LIBC_USE_BUILTIN_CEIL_FLOOR_RINT_TRUNC
18*4531f82cSOverMighty   return __builtin_ceil(x);
19*4531f82cSOverMighty #else
20*4531f82cSOverMighty   return fputil::ceil(x);
21*4531f82cSOverMighty #endif
22*4531f82cSOverMighty }
2326687147SSiva Chandra 
245ff3ff33SPetr Hosek } // namespace LIBC_NAMESPACE_DECL
25