FLANG
exceptions.h
1//===-- include/flang/Runtime/exceptions.h ----------------*- C++ -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9// Support for floating point exceptions and related floating point environment
10// functionality.
11
12#ifndef FORTRAN_RUNTIME_EXCEPTIONS_H_
13#define FORTRAN_RUNTIME_EXCEPTIONS_H_
14
15#include "flang/Runtime/entry-names.h"
16#include <cinttypes>
17#include <cstddef>
18
19namespace Fortran::runtime {
20
21class Descriptor;
22
23extern "C" {
24
25// Map a set of IEEE_FLAG_TYPE exception values to a libm fenv.h excepts value.
26// This mapping is done at runtime to support cross compilation.
27std::uint32_t RTNAME(MapException)(std::uint32_t excepts);
28
29// Exception processing functions that call the corresponding libm functions,
30// and also include support for denormal exceptions where available.
31void RTNAME(feclearexcept)(std::uint32_t excepts);
32void RTNAME(feraiseexcept)(std::uint32_t excepts);
33std::uint32_t RTNAME(fetestexcept)(std::uint32_t excepts);
34void RTNAME(fedisableexcept)(std::uint32_t excepts);
35void RTNAME(feenableexcept)(std::uint32_t excepts);
36std::uint32_t RTNAME(fegetexcept)(void);
37
38// Check if the processor has the ability to control whether to halt
39// or continue exeuction when a given exception is raised.
40bool RTNAME(SupportHalting)(uint32_t except);
41
42// Get and set the ieee underflow mode if supported; otherwise nops.
43bool RTNAME(GetUnderflowMode)(void);
44void RTNAME(SetUnderflowMode)(bool flag);
45
46// Get the byte size of ieee_modes_type and ieee_status_type data.
47std::size_t RTNAME(GetModesTypeSize)(void);
48std::size_t RTNAME(GetStatusTypeSize)(void);
49
50} // extern "C"
51} // namespace Fortran::runtime
52#endif // FORTRAN_RUNTIME_EXCEPTIONS_H_