xref: /llvm-project/libc/src/fenv/feholdexcept.cpp (revision 5ff3ff33ff930e4ec49da7910612d8a41eb068cb)
1b7e05c87SSiva Chandra Reddy //===-- Implementation of feholdexcept function ---------------------------===//
2b7e05c87SSiva Chandra Reddy //
3b7e05c87SSiva Chandra Reddy // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4b7e05c87SSiva Chandra Reddy // See https://llvm.org/LICENSE.txt for license information.
5b7e05c87SSiva Chandra Reddy // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6b7e05c87SSiva Chandra Reddy //
7b7e05c87SSiva Chandra Reddy //===----------------------------------------------------------------------===//
8b7e05c87SSiva Chandra Reddy 
9b7e05c87SSiva Chandra Reddy #include "src/fenv/feholdexcept.h"
1075bbf4ddSJob Henandez Lara #include "hdr/types/fenv_t.h"
1176ec69a9STue Ly #include "src/__support/FPUtil/FEnvImpl.h"
12b7e05c87SSiva Chandra Reddy #include "src/__support/common.h"
13*5ff3ff33SPetr Hosek #include "src/__support/macros/config.h"
14b7e05c87SSiva Chandra Reddy 
15*5ff3ff33SPetr Hosek namespace LIBC_NAMESPACE_DECL {
16b7e05c87SSiva Chandra Reddy 
17b7e05c87SSiva Chandra Reddy LLVM_LIBC_FUNCTION(int, feholdexcept, (fenv_t * envp)) {
181c92911eSMichael Jones   if (fputil::get_env(envp) != 0)
19b7e05c87SSiva Chandra Reddy     return -1;
201c92911eSMichael Jones   fputil::clear_except(FE_ALL_EXCEPT);
211c92911eSMichael Jones   fputil::disable_except(FE_ALL_EXCEPT);
22b7e05c87SSiva Chandra Reddy   return 0;
23b7e05c87SSiva Chandra Reddy }
24b7e05c87SSiva Chandra Reddy 
25*5ff3ff33SPetr Hosek } // namespace LIBC_NAMESPACE_DECL
26