xref: /llvm-project/libc/src/stdfix/uksqrtui.cpp (revision 5ff3ff33ff930e4ec49da7910612d8a41eb068cb)
1ad33fe12Slntue //===-- Implementation of uksqrtui function -------------------------------===//
2ad33fe12Slntue //
3ad33fe12Slntue // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4ad33fe12Slntue // See https://llvm.org/LICENSE.txt for license information.
5ad33fe12Slntue // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6ad33fe12Slntue //
7ad33fe12Slntue //===----------------------------------------------------------------------===//
8ad33fe12Slntue 
9ad33fe12Slntue #include "uksqrtui.h"
10ad33fe12Slntue #include "src/__support/common.h"
11ad33fe12Slntue #include "src/__support/fixed_point/sqrt.h"
12*5ff3ff33SPetr Hosek #include "src/__support/macros/config.h"
13ad33fe12Slntue 
14*5ff3ff33SPetr Hosek namespace LIBC_NAMESPACE_DECL {
15ad33fe12Slntue 
16ad33fe12Slntue LLVM_LIBC_FUNCTION(unsigned accum, uksqrtui, (unsigned int x)) {
17ad33fe12Slntue #ifdef LIBC_FAST_MATH
18ad33fe12Slntue   return fixed_point::isqrt_fast(x);
19ad33fe12Slntue #else
20ad33fe12Slntue   return fixed_point::isqrt(x);
21ad33fe12Slntue #endif
22ad33fe12Slntue }
23ad33fe12Slntue 
24*5ff3ff33SPetr Hosek } // namespace LIBC_NAMESPACE_DECL
25