source: trunk/libs/newlib/src/newlib/libc/machine/riscv/sys/fenv.h @ 444

Last change on this file since 444 was 444, checked in by satin@…, 6 years ago

add newlib,libalmos-mkh, restructure shared_syscalls.h and mini-libc

File size: 2.7 KB
Line 
1/* Copyright (c) 2017  SiFive Inc. All rights reserved.
2
3   This copyrighted material is made available to anyone wishing to use,
4   modify, copy, or redistribute it subject to the terms and conditions
5   of the FreeBSD License.   This program is distributed in the hope that
6   it will be useful, but WITHOUT ANY WARRANTY expressed or implied,
7   including the implied warranties of MERCHANTABILITY or FITNESS FOR
8   A PARTICULAR PURPOSE.  A copy of this license is available at
9   http://www.opensource.org/licenses.
10*/
11
12#ifndef _FENV_H_
13#define _FENV_H_
14
15#include <stddef.h>
16
17/* Per "The RISC-V Instruction Set Manual: Volume I: User-Level ISA:
18 * Version 2.1", Section 8.2, "Floating-Point Control and Status
19 * Register":
20 *
21 * Flag Mnemonic Flag Meaning
22 * ------------- -----------------
23 * NV            Invalid Operation
24 * DZ            Divide by Zero
25 * OF            Overflow
26 * UF            Underflow
27 * NX            Inexact
28 */
29
30#define FE_INVALID   0x00000010
31#define FE_DIVBYZERO 0x00000008
32#define FE_OVERFLOW  0x00000004
33#define FE_UNDERFLOW 0x00000002
34#define FE_INEXACT   0x00000001
35
36#define FE_ALL_EXCEPT (FE_INVALID|FE_DIVBYZERO|FE_OVERFLOW|FE_UNDERFLOW|FE_INEXACT)
37
38/* Per "The RISC-V Instruction Set Manual: Volume I: User-Level ISA:
39 * Version 2.1", Section 8.2, "Floating-Point Control and Status
40 * Register":
41 *
42 * Rounding Mode  Mnemonic Meaning  Meaning
43 * -------------  ----------------  -------
44 * 000            RNE               Round to Nearest, ties to Even
45 * 001            RTZ               Round towards Zero
46 * 010            RDN               Round Down (towards −∞)
47 * 011            RUP               Round Up (towards +∞)
48 * 100            RMM               Round to Nearest, ties to Max Magnitude
49 * 101                              Invalid. Reserved for future use.
50 * 110                              Invalid. Reserved for future use.
51 * 111                              In instruction’s rm field, selects dynamic rounding mode;
52 *                                  In Rounding Mode register, Invalid
53 */
54
55#define FE_TONEAREST_MM 0x00000004
56#define FE_UPWARD       0x00000003
57#define FE_DOWNWARD     0x00000002
58#define FE_TOWARDZERO   0x00000001
59#define FE_TONEAREST    0x00000000
60
61#define FE_RMODE_MASK   0x7
62
63/* Per "The RISC-V Instruction Set Manual: Volume I: User-Level ISA:
64 * Version 2.1":
65 *
66 * "The F extension adds 32 floating-point registers, f0–f31, each 32
67 * bits wide, and a floating-point control and status register fcsr,
68 * which contains the operating mode and exception status of the
69 * floating-point unit."
70 */
71
72typedef size_t fenv_t;
73typedef size_t fexcept_t;
74extern const fenv_t fe_dfl_env;
75#define FE_DFL_ENV fe_dfl_env_p
76
77#endif /* _FENV_H_ */
Note: See TracBrowser for help on using the repository browser.