blob: 79a4120d9ae2f546a4b8fdb8f62354893b64c1d1 [file] [log] [blame]
Calin Juravle2d367902014-02-25 14:49:41 +00001/*-
2 * Copyright (c) 2004-2005 David Schultz <das (at) FreeBSD.ORG>
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 *
14 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
25 */
26
27#ifndef _AMD64_FENV_H_
28#define _AMD64_FENV_H_
29
30#include <sys/types.h>
31
32__BEGIN_DECLS
33
34/*
35 * Each symbol representing a floating point exception expands to an integer
36 * constant expression with values, such that bitwise-inclusive ORs of _all
37 * combinations_ of the constants result in distinct values.
38 *
39 * We use such values that allow direct bitwise operations on FPU/SSE registers.
40 */
41#define FE_INVALID 0x01
42#define FE_DENORMAL 0x02
43#define FE_DIVBYZERO 0x04
44#define FE_OVERFLOW 0x08
45#define FE_UNDERFLOW 0x10
46#define FE_INEXACT 0x20
47
48/*
49 * The following symbol is simply the bitwise-inclusive OR of all floating-point
50 * exception constants defined above.
51 */
52#define FE_ALL_EXCEPT (FE_INVALID | FE_DENORMAL | FE_DIVBYZERO | \
53 FE_OVERFLOW | FE_UNDERFLOW | FE_INEXACT)
54#define _SSE_MASK_SHIFT 7
55
56/*
57 * Each symbol representing the rounding direction, expands to an integer
58 * constant expression whose value is distinct non-negative value.
59 *
60 * We use such values that allow direct bitwise operations on FPU/SSE registers.
61 */
62#define FE_TONEAREST 0x000
63#define FE_DOWNWARD 0x400
64#define FE_UPWARD 0x800
65#define FE_TOWARDZERO 0xc00
66
67/*
68 * The following symbol is simply the bitwise-inclusive OR of all floating-point
69 * rounding direction constants defined above.
70 */
71#define _X87_ROUND_MASK (FE_TONEAREST | FE_DOWNWARD | FE_UPWARD | \
72 FE_TOWARDZERO)
73#define _SSE_ROUND_SHIFT 3
74
75/*
76 * fenv_t represents the entire floating-point environment.
77 */
78typedef struct {
79 struct {
80 __uint32_t __control; /* Control word register */
81 __uint32_t __status; /* Status word register */
82 __uint32_t __tag; /* Tag word register */
83 __uint32_t __others[4]; /* EIP, Pointer Selector, etc */
84 } __x87;
85 __uint32_t __mxcsr; /* Control, status register */
86} fenv_t;
87
88/*
89 * fexcept_t represents the floating-point status flags collectively, including
90 * any status the implementation associates with the flags.
91 *
92 * A floating-point status flag is a system variable whose value is set (but
93 * never cleared) when a floating-point exception is raised, which occurs as a
94 * side effect of exceptional floating-point arithmetic to provide auxiliary
95 * information.
96 *
97 * A floating-point control mode is a system variable whose value may be set by
98 * the user to affect the subsequent behavior of floating-point arithmetic.
99 */
Pavel Chupin7ba84d32014-02-28 00:36:10 +0400100typedef __uint32_t fexcept_t;
Calin Juravle2d367902014-02-25 14:49:41 +0000101
102__END_DECLS
103
104#endif /* !_AMD64_FENV_H_ */