1 /*
2   (c) Copyright 2019 Joel Sherrill <joel@rtems.org
3   (c) Copyright 2019 Craig Howlang <craig.howland@caci.com>
4   All rights reserved.
5 
6   Redistribution and use in source and binary forms, with or without
7   modification, are permitted provided that the following conditions
8   are met:
9 
10   1. Redistributions of source code must retain the above copyright
11      notice, this list of conditions and the following disclaimer.
12 
13   2. Redistributions in binary form must reproduce the above copyright
14      notice, this list of conditions and the following disclaimer in the
15      documentation and/or other materials provided with the distribution.
16 
17   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18   "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
20   A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
21   HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
22   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
23   LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24   DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25   THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 */
29 
30 #ifndef _SYS_FENV_H_
31 #define _SYS_FENV_H_
32 
33 /*******************************************************************************
34  * THIS FILE IS A TEMPLATE, INTENDED TO BE USED AS A STARTING POINT FOR
35  * TARGET-SPECIFIC FLOATING-POINT IMPLEMENTATIONS.  NOTES BELOW HIGHLIGHT THE
36  * BASICS OF WHAT NEEDS TO BE DEFINED.  THE DEFAULT IMPLEMTATION IS
37  * DEGENERATE, WITH ALL FUNCTIONS RETURNING ERROR AND NO EXCEPTIONS AND NO
38  * ROUNDING MODES DEFINED (SINCE NONE ARE SUPPORTED).
39  * THE MACRO VALUES ARE EXAMPLES ONLY, ALTHOUGH TAKEN FROM A WORKING
40  * IMPLEMENTATION.
41  * REMOVE THIS NOTICE WHEN COPYING TO A REAL IMPLEMENTATION, REPLACING IT WITH
42  * ANY TARGET-SPECIFIC NOTES OF INTEREST.  THE FENV FUNCTION MAN PAGES POINT TO
43  * THIS FILE AS A MEANS OF DETERMINING A FUNCTIONAL VS. NON-FUNCTIONAL
44  * IMPLEMENTATION.
45  ******************************************************************************/
46 /*
47  * The following macros are to be defined if the respective exception is
48  * supported by the implementation, each with a unique bit mask:
49  *
50  *	FE_DIVBYZERO
51  *	FE_INEXACT
52  *	FE_INVALID
53  *	FE_OVERFLOW
54  *	FE_UNDERFLOW
55  *
56  * Other implementation-specific exceptions may be defined, and must start
57  * with FE_ followed by a capital letter.
58  *
59  * FE_ALL_EXCEPT must be defined as the logical OR of all exceptions.
60  */
61 
62 /*
63 #define FE_DIVBYZERO 0x00000001
64 #define FE_INEXACT   0x00000002
65 #define FE_INVALID   0x00000004
66 #define FE_OVERFLOW  0x00000008
67 #define FE_UNDERFLOW 0x00000010
68 
69 #define FE_ALL_EXCEPT \
70           (FE_DIVBYZERO|FE_INEXACT|FE_INVALID|FE_OVERFLOW|FE_UNDERFLOW)
71 */
72 
73 /*
74  * The following macros are to be defined if the respective rounding
75  * direction is supported by the implementation via the fegetround() and
76  * fesetround() functions, each with a unique positive value.
77  *
78  *	FE_DOWNWARD
79  *	FE_TONEAREST
80  *	FE_TOWARDZERO
81  *	FE_UPWARD
82  *
83  * Other implementation-specific rounding modes may be defined, and must start
84  * with FE_ followed by a capital letter.
85  */
86 /*
87 #define FE_DOWNWARD   	1
88 #define FE_TONEAREST  	2
89 #define FE_TOWARDZERO 	3
90 #define FE_UPWARD     	4
91 */
92 
93 /*
94  * The following typedefs are required. These should be defined properly
95  * to support the architecture specific implementation. See the C and
96  * POSIX standards for details:
97  *
98  *	fenv_t
99  *	fexcept_t
100  */
101 typedef int fenv_t;
102 typedef int fexcept_t;
103 
104 #endif /* _SYS_FENV_H_ */
105