Chameleon

Chameleon Svn Source Tree

Root/branches/ErmaC/Trunk/i386/include/architecture/ppc/fenv.h

1/*
2 * Copyright (c) 2002 Apple Computer, Inc. All rights reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
6 * The contents of this file constitute Original Code as defined in and
7 * are subject to the Apple Public Source License Version 1.1 (the
8 * "License"). You may not use this file except in compliance with the
9 * License. Please obtain a copy of the License at
10 * http://www.apple.com/publicsource and read it before using this file.
11 *
12 * This Original Code and all software distributed under the License are
13 * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
14 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
15 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
17 * License for the specific language governing rights and limitations
18 * under the License.
19 *
20 * @APPLE_LICENSE_HEADER_END@
21 */
22
23/*******************************************************************************
24* *
25* File: fenv.h *
26* *
27* Contains: typedefs and prototypes for C99 floating point environment. *
28* *
29*******************************************************************************/
30
31#ifndef __FENV__
32#define __FENV__
33
34#if defined( __i386__ ) || defined( __x86_64__ )
35 #error Wrong arch. This is PowerPC only.
36#endif
37
38#if defined(__GNUC__) && (__GNUC__ >= 4)
39#pragma GCC fenv
40#endif
41
42#ifdef __cplusplus
43extern "C" {
44#endif
45
46/*
47 A collection of functions designed to provide access to the floating
48 point environment for numerical programming. It is modeled after
49 the floating-point requirements in C9X.
50
51 The file <fenv.h> declares many functions in support of numerical
52 programming. Programs that test flags or run under
53 non-default modes must do so under the effect of an enabling
54 "fenv_access" pragma.
55*/
56
57/********************************************************************************
58* *
59* fenv_t is a type for representing the entire floating-point *
60* environment in a single object. *
61* *
62* fexcept_t is a type for representing the floating-point *
63* exception flag state collectively. *
64* *
65********************************************************************************/
66typedef unsigned intfenv_t;
67typedef unsigned intfexcept_t;
68
69/* Definitions of floating-point exception macros */
70#define FE_INEXACT 0x02000000
71#define FE_DIVBYZERO 0x04000000
72#define FE_UNDERFLOW 0x08000000
73#define FE_OVERFLOW 0x10000000
74#define FE_INVALID 0x20000000
75#define FE_ALL_EXCEPT 0x3E000000
76
77/* Definitions of rounding direction macros */
78#define FE_TONEAREST 0x00000000
79#define FE_TOWARDZERO 0x00000001
80#define FE_UPWARD 0x00000002
81#define FE_DOWNWARD 0x00000003
82
83/* default environment object */
84extern const fenv_t _FE_DFL_ENV;
85#define FE_DFL_ENV &_FE_DFL_ENV /* pointer to default environment */
86
87/*******************************************************************************
88* The following functions provide access to the exception flags. The *
89* "int" input argument can be constructed by bitwise ORs of the exception *
90* macros: for example: FE_OVERFLOW | FE_INEXACT. *
91*******************************************************************************/
92
93/*******************************************************************************
94* The function "feclearexcept" clears the supported exceptions represented *
95* by its argument. *
96*******************************************************************************/
97
98extern int feclearexcept(int);
99
100
101/*******************************************************************************
102* The function "fegetexceptflag" stores a representation of the exception *
103* flags indicated by its integer argument through the fexcept_t pointer *
104* argument. *
105*******************************************************************************/
106
107extern int fegetexceptflag(fexcept_t *, int);
108
109
110/*******************************************************************************
111* The function "feraiseexcept" raises the supported exceptions *
112* represented by its argument. *
113*******************************************************************************/
114
115extern int feraiseexcept(int);
116
117
118/*******************************************************************************
119* The function "fesetexceptflag" sets or clears the exception flags indicated *
120* by the its integer argument according to the representation in the *
121* object pointed to by the fexcept_t pointer argument. The value of the *
122* object must have been set by a previous call to "fegetexceptflag". *
123* This function does not raise exceptions; it just sets the state of *
124* the flags. *
125*******************************************************************************/
126
127extern int fesetexceptflag(const fexcept_t *, int);
128
129
130/*******************************************************************************
131* The function "fetestexcept" determines which of the specified subset of *
132* the exception flags are currently set. The integer argument specifies *
133* the exception flags to be queried as a bitwise OR of the exception *
134* macros. This function returns the bitwise OR of the exception macros *
135* corresponding to the currently set exceptions included in "excepts". *
136*******************************************************************************/
137
138extern int fetestexcept(int);
139
140
141/*******************************************************************************
142* The following functions provide control of rounding direction modes. *
143*******************************************************************************/
144
145/*******************************************************************************
146* The function "fegetround" returns the value of the rounding direction *
147* macro which represents the current rounding direction. *
148*******************************************************************************/
149
150extern int fegetround(void);
151
152
153/*******************************************************************************
154* The function "fesetround" establishes the rounding direction represented *
155* by its argument. It returns zero if and only if the argument matches *
156* a rounding direction macro. If not, the rounding direction is not *
157* changed. *
158*******************************************************************************/
159
160extern int fesetround(int);
161
162
163/*******************************************************************************
164* The following functions manage the floating-point environment, exception *
165* flags and dynamic modes, as one entity. *
166*******************************************************************************/
167
168extern int fegetenv(fenv_t *);
169extern int feholdexcept(fenv_t *);
170extern int fesetenv(const fenv_t *);
171extern int feupdateenv(const fenv_t *);
172
173
174#ifdef __cplusplus
175}
176#endif
177
178#endif /* __FENV__ */
179
180

Archive Download this file

Revision: 1622