1 /* FPU control word bits.  Alpha-mapped-to-Intel version.
2    Copyright (C) 1996, 1998, 2000, 2002 Free Software Foundation, Inc.
3    This file is part of the GNU C Library.
4    Contributed by Olaf Flebbe.
5 
6    The GNU C Library is free software; you can redistribute it and/or
7    modify it under the terms of the GNU Lesser General Public
8    License as published by the Free Software Foundation; either
9    version 2.1 of the License, or (at your option) any later version.
10 
11    The GNU C Library is distributed in the hope that it will be useful,
12    but WITHOUT ANY WARRANTY; without even the implied warranty of
13    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14    Lesser General Public License for more details.
15 
16    You should have received a copy of the GNU Lesser General Public
17    License along with the GNU C Library; if not, see
18    <http://www.gnu.org/licenses/>.  */
19 
20 #ifndef _ALPHA_FPU_CONTROL_H
21 #define _ALPHA_FPU_CONTROL_H
22 
23 /*
24  * Since many programs seem to hardcode the values passed to __setfpucw()
25  * (rather than using the manifest constants) we emulate the x87 interface
26  * here (at least where this makes sense).
27  *
28  *     15-13    12  11-10  9-8     7-6     5    4    3    2    1    0
29  * | reserved | IC | RC  | PC | reserved | PM | UM | OM | ZM | DM | IM
30  *
31  * IM: Invalid operation mask
32  * DM: Denormalized operand mask
33  * ZM: Zero-divide mask
34  * OM: Overflow mask
35  * UM: Underflow mask
36  * PM: Precision (inexact result) mask
37  *
38  * Mask bit is 1 means no interrupt.
39  *
40  * PC: Precision control
41  * 11 - round to extended precision
42  * 10 - round to double precision
43  * 00 - round to single precision
44  *
45  * RC: Rounding control
46  * 00 - rounding to nearest
47  * 01 - rounding down (toward - infinity)
48  * 10 - rounding up (toward + infinity)
49  * 11 - rounding toward zero
50  *
51  * IC: Infinity control
52  * That is for 8087 and 80287 only.
53  *
54  * The hardware default is 0x037f. I choose 0x1372.
55  */
56 
57 #include <features.h>
58 
59 /* masking of interrupts */
60 #define _FPU_MASK_IM  0x01
61 #define _FPU_MASK_DM  0x02
62 #define _FPU_MASK_ZM  0x04
63 #define _FPU_MASK_OM  0x08
64 #define _FPU_MASK_UM  0x10
65 #define _FPU_MASK_PM  0x20
66 
67 /* precision control -- without effect on Alpha */
68 #define _FPU_EXTENDED 0x300   /* RECOMMENDED */
69 #define _FPU_DOUBLE   0x200
70 #define _FPU_SINGLE   0x0     /* DO NOT USE */
71 
72 /*
73  * rounding control---notice that on the Alpha this affects only
74  * instructions with the dynamic rounding mode qualifier (/d).
75  */
76 #define _FPU_RC_NEAREST 0x000 /* RECOMMENDED */
77 #define _FPU_RC_DOWN    0x400
78 #define _FPU_RC_UP      0x800
79 #define _FPU_RC_ZERO    0xC00
80 
81 #define _FPU_RESERVED 0xF0C0  /* Reserved bits in cw */
82 
83 
84 /* Now two recommended cw */
85 
86 /* Linux default:
87      - extended precision
88      - rounding to positive infinity.  There is no /p instruction
89        qualifier.  By setting the dynamic rounding mode to +infinity,
90        one can use /d to get round to +infinity with no extra overhead
91        (so long as the default isn't changed, of course...)
92      - no exceptions enabled.  */
93 
94 #define _FPU_DEFAULT  0x137f
95 
96 /* IEEE:  same as above. */
97 #define _FPU_IEEE     0x137f
98 
99 /* Type of the control word.  */
100 typedef unsigned int fpu_control_t;
101 
102 #if 0
103 /* Default control word set at startup.  */
104 extern fpu_control_t __fpu_control;
105 #endif
106 
107 #endif	/* _ALPHA_FPU_CONTROL */
108