Back to index

glibc  2.9
fpu_control.h
Go to the documentation of this file.
00001 /* FPU control word bits.  Alpha-mapped-to-Intel version.
00002    Copyright (C) 1996, 1998, 2000, 2002 Free Software Foundation, Inc.
00003    This file is part of the GNU C Library.
00004    Contributed by Olaf Flebbe.
00005 
00006    The GNU C Library is free software; you can redistribute it and/or
00007    modify it under the terms of the GNU Lesser General Public
00008    License as published by the Free Software Foundation; either
00009    version 2.1 of the License, or (at your option) any later version.
00010 
00011    The GNU C Library is distributed in the hope that it will be useful,
00012    but WITHOUT ANY WARRANTY; without even the implied warranty of
00013    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014    Lesser General Public License for more details.
00015 
00016    You should have received a copy of the GNU Lesser General Public
00017    License along with the GNU C Library; if not, write to the Free
00018    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
00019    02111-1307 USA.  */
00020 
00021 #ifndef _ALPHA_FPU_CONTROL_H
00022 #define _ALPHA_FPU_CONTROL_H
00023 
00024 /*
00025  * Since many programs seem to hardcode the values passed to __setfpucw()
00026  * (rather than using the manifest constants) we emulate the x87 interface
00027  * here (at least where this makes sense).
00028  *
00029  *     15-13    12  11-10  9-8     7-6     5    4    3    2    1    0
00030  * | reserved | IC | RC  | PC | reserved | PM | UM | OM | ZM | DM | IM
00031  *
00032  * IM: Invalid operation mask
00033  * DM: Denormalized operand mask
00034  * ZM: Zero-divide mask
00035  * OM: Overflow mask
00036  * UM: Underflow mask
00037  * PM: Precision (inexact result) mask
00038  *
00039  * Mask bit is 1 means no interrupt.
00040  *
00041  * PC: Precision control
00042  * 11 - round to extended precision
00043  * 10 - round to double precision
00044  * 00 - round to single precision
00045  *
00046  * RC: Rounding control
00047  * 00 - rounding to nearest
00048  * 01 - rounding down (toward - infinity)
00049  * 10 - rounding up (toward + infinity)
00050  * 11 - rounding toward zero
00051  *
00052  * IC: Infinity control
00053  * That is for 8087 and 80287 only.
00054  *
00055  * The hardware default is 0x037f. I choose 0x1372.
00056  */
00057 
00058 #include <features.h>
00059 
00060 /* masking of interrupts */
00061 #define _FPU_MASK_IM  0x01
00062 #define _FPU_MASK_DM  0x02
00063 #define _FPU_MASK_ZM  0x04
00064 #define _FPU_MASK_OM  0x08
00065 #define _FPU_MASK_UM  0x10
00066 #define _FPU_MASK_PM  0x20
00067 
00068 /* precision control -- without effect on Alpha */
00069 #define _FPU_EXTENDED 0x300   /* RECOMMENDED */
00070 #define _FPU_DOUBLE   0x200
00071 #define _FPU_SINGLE   0x0     /* DO NOT USE */
00072 
00073 /*
00074  * rounding control---notice that on the Alpha this affects only
00075  * instructions with the dynamic rounding mode qualifier (/d).
00076  */
00077 #define _FPU_RC_NEAREST 0x000 /* RECOMMENDED */
00078 #define _FPU_RC_DOWN    0x400
00079 #define _FPU_RC_UP      0x800
00080 #define _FPU_RC_ZERO    0xC00
00081 
00082 #define _FPU_RESERVED 0xF0C0  /* Reserved bits in cw */
00083 
00084 
00085 /* Now two recommended cw */
00086 
00087 /* Linux default:
00088      - extended precision
00089      - rounding to positive infinity.  There is no /p instruction
00090        qualifier.  By setting the dynamic rounding mode to +infinity,
00091        one can use /d to get round to +infinity with no extra overhead
00092        (so long as the default isn't changed, of course...)
00093      - no exceptions enabled.  */
00094 
00095 #define _FPU_DEFAULT  0x137f
00096 
00097 /* IEEE:  same as above. */
00098 #define _FPU_IEEE     0x137f
00099 
00100 /* Type of the control word.  */
00101 typedef unsigned int fpu_control_t;
00102 
00103 /* Default control word set at startup.  */
00104 extern fpu_control_t __fpu_control;
00105 
00106 #endif /* _ALPHA_FPU_CONTROL */