Subversion Repositories Kolibri OS

Rev

Rev 4872 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
4349 Serge 1
#ifndef _FENV_H_
2
#define _FENV_H_
3
 
4
/* FPU status word exception flags */
5
#define FE_INVALID	0x01
6
#define FE_DENORMAL	0x02
7
#define FE_DIVBYZERO	0x04
8
#define FE_OVERFLOW	0x08
9
#define FE_UNDERFLOW	0x10
10
#define FE_INEXACT	0x20
11
#define FE_ALL_EXCEPT (FE_INVALID | FE_DENORMAL | FE_DIVBYZERO \
12
		       | FE_OVERFLOW | FE_UNDERFLOW | FE_INEXACT)
13
 
14
/* FPU control word rounding flags */
15
#define FE_TONEAREST	0x0000
16
#define FE_DOWNWARD	0x0400
17
#define FE_UPWARD	0x0800
18
#define FE_TOWARDZERO	0x0c00
19
 
20
/* The MXCSR exception flags are the same as the
21
   FE flags. */
22
#define __MXCSR_EXCEPT_FLAG_SHIFT 0
23
 
24
/* How much to shift FE status word exception flags
25
   to get the MXCSR exeptions masks,  */
26
#define __MXCSR_EXCEPT_MASK_SHIFT 7
27
 
28
/* How much to shift FE control word rounding flags
29
   to get MXCSR rounding flags,  */
30
#define __MXCSR_ROUND_FLAG_SHIFT 3
31
 
32
#ifndef RC_INVOKED
33
/*
34
  For now, support only for the basic abstraction of flags that are
35
  either set or clear. fexcept_t could be  structure that holds more
36
  info about the fp environment.
37
*/
38
typedef unsigned short fexcept_t;
39
 
40
/* This 32-byte struct represents the entire floating point
41
   environment as stored by fnstenv or fstenv, augmented by
42
   the  contents of the MXCSR register, as stored by stmxcsr
43
   (if CPU supports it). */
44
typedef struct
45
{
46
  unsigned short __control_word;
47
  unsigned short __unused0;
48
  unsigned short __status_word;
49
  unsigned short __unused1;
50
  unsigned short __tag_word;
51
  unsigned short __unused2;
52
  unsigned int	 __ip_offset;    /* instruction pointer offset */
53
  unsigned short __ip_selector;
54
  unsigned short __opcode;
55
  unsigned int	 __data_offset;
56
  unsigned short __data_selector;
57
  unsigned short  __unused3;
58
  unsigned int __mxcsr; /* contents of the MXCSR register  */
59
} fenv_t;
60
 
61
 
62
/*The C99 standard (7.6.9) allows us to define implementation-specific macros for
63
  different fp environments */
64
 
65
/* The default Intel x87 floating point environment (64-bit mantissa) */
66
#define FE_PC64_ENV ((const fenv_t *)-1)
67
 
68
/* The floating point environment set by MSVCRT _fpreset (53-bit mantissa) */
69
#define FE_PC53_ENV ((const fenv_t *)-2)
70
 
71
/* The FE_DFL_ENV macro is required by standard.
72
  fesetenv will use the environment set at app startup.*/
73
#define FE_DFL_ENV ((const fenv_t *) 0)
74
 
75
#ifdef __cplusplus
76
extern "C" {
77
#endif
78
 
79
/*TODO: Some of these could be inlined */
80
/* 7.6.2 Exception */
81
 
82
extern int __cdecl  feclearexcept (int);
83
extern int __cdecl  fegetexceptflag (fexcept_t * flagp, int excepts);
84
extern int __cdecl  feraiseexcept (int excepts );
85
extern int __cdecl  fesetexceptflag (const fexcept_t *, int);
86
extern int __cdecl  fetestexcept (int excepts);
87
 
88
/* 7.6.3 Rounding */
89
 
90
extern int __cdecl  fegetround (void);
91
extern int __cdecl  fesetround (int mode);
92
 
93
/* 7.6.4 Environment */
94
 
95
extern int __cdecl  fegetenv (fenv_t * envp);
96
extern int __cdecl  fesetenv (const fenv_t * );
97
extern int __cdecl  feupdateenv (const fenv_t *);
98
extern int __cdecl  feholdexcept (fenv_t *);
99
 
100
#ifdef __cplusplus
101
}
102
#endif
103
#endif	/* Not RC_INVOKED */
104
 
105
#endif /* ndef _FENV_H */