Dr Andrew Scott G7VAV

My photo
 
June 2025
Mo Tu We Th Fr Sa Su
26 27 28 29 30 31 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 1 2 3 4 5 6


fenv.h
001: /* Copyright (C) 1997-2001,2004,2011 Free Software Foundation, Inc.
002:    This file is part of the GNU C Library.
003: 
004:    The GNU C Library is free software; you can redistribute it and/or
005:    modify it under the terms of the GNU Lesser General Public
006:    License as published by the Free Software Foundation; either
007:    version 2.1 of the License, or (at your option) any later version.
008: 
009:    The GNU C Library is distributed in the hope that it will be useful,
010:    but WITHOUT ANY WARRANTY; without even the implied warranty of
011:    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
012:    Lesser General Public License for more details.
013: 
014:    You should have received a copy of the GNU Lesser General Public
015:    License along with the GNU C Library; if not, write to the Free
016:    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
017:    02111-1307 USA.  */
018: 
019: #ifndef _FENV_H
020: # error "Never use <bits/fenv.h> directly; include <fenv.h> instead."
021: #endif
022: 
023: #include <bits/wordsize.h>
024: 
025: 
026: /* Define bits representing the exception.  We use the bit positions
027:    of the appropriate bits in the FPU control word.  */
028: enum
029:   {
030:     FE_INVALID = 0x01,
031: #define FE_INVALID      FE_INVALID
032:     __FE_DENORM = 0x02,
033:     FE_DIVBYZERO = 0x04,
034: #define FE_DIVBYZERO    FE_DIVBYZERO
035:     FE_OVERFLOW = 0x08,
036: #define FE_OVERFLOW     FE_OVERFLOW
037:     FE_UNDERFLOW = 0x10,
038: #define FE_UNDERFLOW    FE_UNDERFLOW
039:     FE_INEXACT = 0x20
040: #define FE_INEXACT      FE_INEXACT
041:   };
042: 
043: #define FE_ALL_EXCEPT \
044:         (FE_INEXACT | FE_DIVBYZERO | FE_UNDERFLOW | FE_OVERFLOW | FE_INVALID)
045: 
046: /* The ix87 FPU supports all of the four defined rounding modes.  We
047:    use again the bit positions in the FPU control word as the values
048:    for the appropriate macros.  */
049: enum
050:   {
051:     FE_TONEAREST = 0,
052: #define FE_TONEAREST    FE_TONEAREST
053:     FE_DOWNWARD = 0x400,
054: #define FE_DOWNWARD     FE_DOWNWARD
055:     FE_UPWARD = 0x800,
056: #define FE_UPWARD       FE_UPWARD
057:     FE_TOWARDZERO = 0xc00
058: #define FE_TOWARDZERO   FE_TOWARDZERO
059:   };
060: 
061: 
062: /* Type representing exception flags.  */
063: typedef unsigned short int fexcept_t;
064: 
065: 
066: /* Type representing floating-point environment.  This structure
067:    corresponds to the layout of the block written by the `fstenv'
068:    instruction and has additional fields for the contents of the MXCSR
069:    register as written by the `stmxcsr' instruction.  */
070: typedef struct
071:   {
072:     unsigned short int __control_word;
073:     unsigned short int __unused1;
074:     unsigned short int __status_word;
075:     unsigned short int __unused2;
076:     unsigned short int __tags;
077:     unsigned short int __unused3;
078:     unsigned int __eip;
079:     unsigned short int __cs_selector;
080:     unsigned int __opcode:11;
081:     unsigned int __unused4:5;
082:     unsigned int __data_offset;
083:     unsigned short int __data_selector;
084:     unsigned short int __unused5;
085: #if __WORDSIZE == 64
086:     unsigned int __mxcsr;
087: #endif
088:   }
089: fenv_t;
090: 
091: /* If the default argument is used we use this value.  */
092: #define FE_DFL_ENV      ((__const fenv_t *) -1)
093: 
094: #ifdef __USE_GNU
095: /* Floating-point environment where none of the exception is masked.  */
096: # define FE_NOMASK_ENV  ((__const fenv_t *) -2)
097: #endif
098: 
099: 
100: #ifdef __USE_EXTERN_INLINES
101: __BEGIN_DECLS
102: 
103: /* Optimized versions.  */
104: extern int __REDIRECT_NTH (__feraiseexcept_renamed, (int), feraiseexcept);
105: __extern_inline int
106: __NTH (feraiseexcept (int __excepts))
107: {
108:   if (__builtin_constant_p (__excepts)
109:       && (__excepts & ~(FE_INVALID | FE_DIVBYZERO)) == 0)
110:     {
111:       if ((FE_INVALID & __excepts) != 0)
112:         {
113:           /* One example of a invalid operation is 0.0 / 0.0.  */
114:           float __f = 0.0;
115: 
116:           __asm__ __volatile__ ("divss %0, %0 " : : "x" (__f));
117:           (void) &__f;
118:         }
119:       if ((FE_DIVBYZERO & __excepts) != 0)
120:         {
121:           float __f = 1.0;
122:           float __g = 0.0;
123: 
124:           __asm__ __volatile__ ("divss %1, %0" : : "x" (__f), "x" (__g));
125:           (void) &__f;
126:         }
127: 
128:       return 0;
129:     }
130: 
131:   return __feraiseexcept_renamed (__excepts);
132: }
133: 
134: __END_DECLS
135: #endif
136: 


for client (none)
© Andrew Scott 2006 - 2025,
All Rights Reserved
http://www.andrew-scott.uk/
Andrew Scott
http://www.andrew-scott.co.uk/