comparison druntime/import/core/stdc/fenv.d @ 1458:e0b2d67cfe7c

Added druntime (this should be removed once it works).
author Robert Clipsham <robert@octarineparrot.com>
date Tue, 02 Jun 2009 17:43:06 +0100
parents
children
comparison
equal deleted inserted replaced
1456:7b218ec1044f 1458:e0b2d67cfe7c
1 /**
2 * D header file for C99.
3 *
4 * Copyright: Copyright Sean Kelly 2005 - 2009.
5 * License: <a href="http://www.boost.org/LICENSE_1_0.txt>Boost License 1.0</a>.
6 * Authors: Sean Kelly
7 * Standards: ISO/IEC 9899:1999 (E)
8 *
9 * Copyright Sean Kelly 2005 - 2009.
10 * Distributed under the Boost Software License, Version 1.0.
11 * (See accompanying file LICENSE_1_0.txt or copy at
12 * http://www.boost.org/LICENSE_1_0.txt)
13 */
14 module core.stdc.fenv;
15
16 extern (C):
17
18 version( Windows )
19 {
20 struct fenv_t
21 {
22 ushort status;
23 ushort control;
24 ushort round;
25 ushort[2] reserved;
26 }
27
28 alias int fexcept_t;
29 }
30 else version( linux )
31 {
32 struct fenv_t
33 {
34 ushort __control_word;
35 ushort __unused1;
36 ushort __status_word;
37 ushort __unused2;
38 ushort __tags;
39 ushort __unused3;
40 uint __eip;
41 ushort __cs_selector;
42 ushort __opcode;
43 uint __data_offset;
44 ushort __data_selector;
45 ushort __unused5;
46 }
47
48 alias int fexcept_t;
49 }
50 else version ( OSX )
51 {
52 version ( BigEndian )
53 {
54 alias uint fenv_t;
55 alias uint fexcept_t;
56 }
57 version ( LittleEndian )
58 {
59 struct fenv_t
60 {
61 ushort __control;
62 ushort __status;
63 uint __mxcsr;
64 byte[8] __reserved;
65 }
66
67 alias ushort fexcept_t;
68 }
69 }
70 else version ( freebsd )
71 {
72 struct fenv_t
73 {
74 ushort __control;
75 ushort __mxcsr_hi;
76 ushort __status;
77 ushort __mxcsr_lo;
78 uint __tag;
79 byte[16] __other;
80 }
81
82 alias ushort fexcept_t;
83 }
84 else
85 {
86 static assert( false );
87 }
88
89 enum
90 {
91 FE_INVALID = 1,
92 FE_DENORMAL = 2, // non-standard
93 FE_DIVBYZERO = 4,
94 FE_OVERFLOW = 8,
95 FE_UNDERFLOW = 0x10,
96 FE_INEXACT = 0x20,
97 FE_ALL_EXCEPT = 0x3F,
98 FE_TONEAREST = 0,
99 FE_UPWARD = 0x800,
100 FE_DOWNWARD = 0x400,
101 FE_TOWARDZERO = 0xC00,
102 }
103
104 version( Windows )
105 {
106 private extern fenv_t _FE_DFL_ENV;
107 fenv_t* FE_DFL_ENV = &_FE_DFL_ENV;
108 }
109 else version( linux )
110 {
111 fenv_t* FE_DFL_ENV = cast(fenv_t*)(-1);
112 }
113 else version( OSX )
114 {
115 private extern fenv_t _FE_DFL_ENV;
116 fenv_t* FE_DFL_ENV = &_FE_DFL_ENV;
117 }
118 else version( freebsd )
119 {
120 private extern fenv_t __fe_dfl_env;
121 fenv_t* FE_DFL_ENV = &__fe_dfl_env;
122 }
123 else
124 {
125 static assert( false );
126 }
127
128 void feraiseexcept(int excepts);
129 void feclearexcept(int excepts);
130
131 int fetestexcept(int excepts);
132 int feholdexcept(fenv_t* envp);
133
134 void fegetexceptflag(fexcept_t* flagp, int excepts);
135 void fesetexceptflag(in fexcept_t* flagp, int excepts);
136
137 int fegetround();
138 int fesetround(int round);
139
140 void fegetenv(fenv_t* envp);
141 void fesetenv(in fenv_t* envp);
142 void feupdateenv(in fenv_t* envp);