132
|
1 /**
|
|
2 * D header file for C99.
|
|
3 *
|
|
4 * Copyright: Public Domain
|
|
5 * License: Public Domain
|
|
6 * Authors: Sean Kelly, Walter Bright
|
|
7 * Standards: ISO/IEC 9899:1999 (E)
|
|
8 */
|
|
9 module tango.stdc.fenv;
|
|
10
|
|
11 extern (C):
|
|
12
|
|
13 version( Win32 )
|
|
14 {
|
|
15 struct fenv_t
|
|
16 {
|
|
17 ushort status;
|
|
18 ushort control;
|
|
19 ushort round;
|
|
20 ushort[2] reserved;
|
|
21 }
|
|
22
|
|
23 alias int fexcept_t;
|
|
24 }
|
|
25 else version( linux )
|
|
26 {
|
|
27 struct fenv_t
|
|
28 {
|
|
29 ushort __control_word;
|
|
30 ushort __unused1;
|
|
31 ushort __status_word;
|
|
32 ushort __unused2;
|
|
33 ushort __tags;
|
|
34 ushort __unused3;
|
|
35 uint __eip;
|
|
36 ushort __cs_selector;
|
|
37 ushort __opcode;
|
|
38 uint __data_offset;
|
|
39 ushort __data_selector;
|
|
40 ushort __unused5;
|
|
41 }
|
|
42
|
|
43 alias int fexcept_t;
|
|
44 }
|
|
45 else version ( darwin )
|
|
46 {
|
|
47 version ( BigEndian )
|
|
48 {
|
|
49 alias uint fenv_t;
|
|
50 alias uint fexcept_t;
|
|
51 }
|
|
52 version ( LittleEndian )
|
|
53 {
|
|
54 struct fenv_t
|
|
55 {
|
|
56 ushort __control;
|
|
57 ushort __status;
|
|
58 uint __mxcsr;
|
|
59 byte[8] __reserved;
|
|
60 }
|
|
61
|
|
62 alias ushort fexcept_t;
|
|
63 }
|
|
64 }
|
|
65 else
|
|
66 {
|
|
67 static assert( false );
|
|
68 }
|
|
69
|
|
70 enum
|
|
71 {
|
|
72 FE_INVALID = 1,
|
|
73 FE_DENORMAL = 2, // non-standard
|
|
74 FE_DIVBYZERO = 4,
|
|
75 FE_OVERFLOW = 8,
|
|
76 FE_UNDERFLOW = 0x10,
|
|
77 FE_INEXACT = 0x20,
|
|
78 FE_ALL_EXCEPT = 0x3F,
|
|
79 FE_TONEAREST = 0,
|
|
80 FE_UPWARD = 0x800,
|
|
81 FE_DOWNWARD = 0x400,
|
|
82 FE_TOWARDZERO = 0xC00,
|
|
83 }
|
|
84
|
|
85 version( Win32 )
|
|
86 {
|
|
87 private extern fenv_t _FE_DFL_ENV;
|
|
88 fenv_t* FE_DFL_ENV = &_FE_DFL_ENV;
|
|
89 }
|
|
90 else version( linux )
|
|
91 {
|
|
92 fenv_t* FE_DFL_ENV = cast(fenv_t*)(-1);
|
|
93 }
|
|
94 else version( darwin )
|
|
95 {
|
|
96 private extern fenv_t _FE_DFL_ENV;
|
|
97 fenv_t* FE_DFL_ENV = &_FE_DFL_ENV;
|
|
98 }
|
|
99 else
|
|
100 {
|
|
101 static assert( false );
|
|
102 }
|
|
103
|
|
104 void feraiseexcept(int excepts);
|
|
105 void feclearexcept(int excepts);
|
|
106
|
|
107 int fetestexcept(int excepts);
|
|
108 int feholdexcept(fenv_t* envp);
|
|
109
|
|
110 void fegetexceptflag(fexcept_t* flagp, int excepts);
|
|
111 void fesetexceptflag(fexcept_t* flagp, int excepts);
|
|
112
|
|
113 int fegetround();
|
|
114 int fesetround(int round);
|
|
115
|
|
116 void fegetenv(fenv_t* envp);
|
|
117 void fesetenv(fenv_t* envp);
|
|
118 void feupdateenv(fenv_t* envp);
|