Dr Andrew Scott G7VAV

My photo
 
May 2024
Mo Tu We Th Fr Sa Su
29 30 1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30 31 1 2
3 4 5 6 7 8 9


fpu_control.h
001: /* FPU control word bits.  x86-64 version.
002:    Copyright (C) 1993,1995,1996,1997,1998,2000,2001,2002 Free Software Foundation, Inc.
003:    This file is part of the GNU C Library.
004:    Contributed by Olaf Flebbe.
005: 
006:    The GNU C Library is free software; you can redistribute it and/or
007:    modify it under the terms of the GNU Lesser General Public
008:    License as published by the Free Software Foundation; either
009:    version 2.1 of the License, or (at your option) any later version.
010: 
011:    The GNU C Library is distributed in the hope that it will be useful,
012:    but WITHOUT ANY WARRANTY; without even the implied warranty of
013:    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
014:    Lesser General Public License for more details.
015: 
016:    You should have received a copy of the GNU Lesser General Public
017:    License along with the GNU C Library; if not, write to the Free
018:    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
019:    02111-1307 USA.  */
020: 
021: #ifndef _FPU_CONTROL_H
022: #define _FPU_CONTROL_H  1
023: 
024: /* Note that this file sets on x86-64 only the x87 FPU, it does not
025:    touch the SSE unit.  */
026: 
027: /* Here is the dirty part. Set up your 387 through the control word
028:  * (cw) register.
029:  *
030:  *     15-13    12  11-10  9-8     7-6     5    4    3    2    1    0
031:  * | reserved | IC | RC  | PC | reserved | PM | UM | OM | ZM | DM | IM
032:  *
033:  * IM: Invalid operation mask
034:  * DM: Denormalized operand mask
035:  * ZM: Zero-divide mask
036:  * OM: Overflow mask
037:  * UM: Underflow mask
038:  * PM: Precision (inexact result) mask
039:  *
040:  * Mask bit is 1 means no interrupt.
041:  *
042:  * PC: Precision control
043:  * 11 - round to extended precision
044:  * 10 - round to double precision
045:  * 00 - round to single precision
046:  *
047:  * RC: Rounding control
048:  * 00 - rounding to nearest
049:  * 01 - rounding down (toward - infinity)
050:  * 10 - rounding up (toward + infinity)
051:  * 11 - rounding toward zero
052:  *
053:  * IC: Infinity control
054:  * That is for 8087 and 80287 only.
055:  *
056:  * The hardware default is 0x037f which we use.
057:  */
058: 
059: #include <features.h>
060: 
061: /* masking of interrupts */
062: #define _FPU_MASK_IM  0x01
063: #define _FPU_MASK_DM  0x02
064: #define _FPU_MASK_ZM  0x04
065: #define _FPU_MASK_OM  0x08
066: #define _FPU_MASK_UM  0x10
067: #define _FPU_MASK_PM  0x20
068: 
069: /* precision control */
070: #define _FPU_EXTENDED 0x300     /* libm requires double extended precision.  */
071: #define _FPU_DOUBLE   0x200
072: #define _FPU_SINGLE   0x0
073: 
074: /* rounding control */
075: #define _FPU_RC_NEAREST 0x0    /* RECOMMENDED */
076: #define _FPU_RC_DOWN    0x400
077: #define _FPU_RC_UP      0x800
078: #define _FPU_RC_ZERO    0xC00
079: 
080: #define _FPU_RESERVED 0xF0C0  /* Reserved bits in cw */
081: 
082: 
083: /* The fdlibm code requires strict IEEE double precision arithmetic,
084:    and no interrupts for exceptions, rounding to nearest.  */
085: 
086: #define _FPU_DEFAULT  0x037f
087: 
088: /* IEEE:  same as above.  */
089: #define _FPU_IEEE     0x037f
090: 
091: /* Type of the control word.  */
092: typedef unsigned int fpu_control_t __attribute__ ((__mode__ (__HI__)));
093: 
094: /* Macros for accessing the hardware control word.  */
095: #define _FPU_GETCW(cw) __asm__ ("fnstcw %0" : "=m" (*&cw))
096: #define _FPU_SETCW(cw) __asm__ ("fldcw %0" : : "m" (*&cw))
097: 
098: /* Default control word set at startup.  */
099: extern fpu_control_t __fpu_control;
100: 
101: #endif  /* fpu_control.h */
102: 


for client 18.221.239.148
© Andrew Scott 2006 - 2024,
All Rights Reserved
http://www.andrew-scott.uk/
Andrew Scott
http://www.andrew-scott.co.uk/