1b7e05c87SSiva Chandra Reddy //===-- Implementation of fegetexceptflag 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/fegetexceptflag.h"
10*76ec69a9STue Ly #include "src/__support/FPUtil/FEnvImpl.h"
11b7e05c87SSiva Chandra Reddy #include "src/__support/common.h"
12b7e05c87SSiva Chandra Reddy 
13b7e05c87SSiva Chandra Reddy #include <fenv.h>
14b7e05c87SSiva Chandra Reddy 
15b7e05c87SSiva Chandra Reddy namespace __llvm_libc {
16b7e05c87SSiva Chandra Reddy 
17b7e05c87SSiva Chandra Reddy LLVM_LIBC_FUNCTION(int, fegetexceptflag, (fexcept_t * flagp, int excepts)) {
189550f8baSSiva Chandra Reddy   // TODO: Add a compile time check to see if the excepts actually fit in flagp.
191c92911eSMichael Jones   *flagp = static_cast<fexcept_t>(fputil::test_except(FE_ALL_EXCEPT) & excepts);
20b7e05c87SSiva Chandra Reddy   return 0;
21b7e05c87SSiva Chandra Reddy }
22b7e05c87SSiva Chandra Reddy 
23b7e05c87SSiva Chandra Reddy } // namespace __llvm_libc
24