My Project
UDK 3.2.7 C/C++ API Reference
Main Page
Related Pages
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Pages
sal
mathconf.h
Go to the documentation of this file.
1
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2
/*************************************************************************
3
*
4
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5
*
6
* Copyright 2000, 2010 Oracle and/or its affiliates.
7
*
8
* OpenOffice.org - a multi-platform office productivity suite
9
*
10
* This file is part of OpenOffice.org.
11
*
12
* OpenOffice.org is free software: you can redistribute it and/or modify
13
* it under the terms of the GNU Lesser General Public License version 3
14
* only, as published by the Free Software Foundation.
15
*
16
* OpenOffice.org is distributed in the hope that it will be useful,
17
* but WITHOUT ANY WARRANTY; without even the implied warranty of
18
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19
* GNU Lesser General Public License version 3 for more details
20
* (a copy is included in the LICENSE file that accompanied this code).
21
*
22
* You should have received a copy of the GNU Lesser General Public License
23
* version 3 along with OpenOffice.org. If not, see
24
* <http://www.openoffice.org/license.html>
25
* for a copy of the LGPLv3 License.
26
*
27
************************************************************************/
28
29
#if !defined INCLUDED_SAL_MATHCONF_H
30
#define INCLUDED_SAL_MATHCONF_H
31
32
#include "
osl/endian.h
"
33
34
#include <float.h>
35
36
#if defined SOLARIS
37
#include <ieeefp.h>
38
#endif
/* SOLARIS */
39
40
#if defined(__cplusplus) && ( defined(__GXX_EXPERIMENTAL_CXX0X__) || __cplusplus >= 201103L )
41
#include <cmath>
42
#endif
43
44
#if defined __cplusplus
45
extern
"C"
{
46
#endif
/* __cplusplus */
47
48
49
/* Generally, the C standard guarantees that at program startup, "trapping or
50
stopping (if supported) is disabled on all [floating-point] exceptions"
51
(F.7.3/1 of the August 3, 1998 draft of C99), and that during program
52
execution, "a programmer can safely assume default modes (or be unaware of
53
them)" (7.6/2, footnote 161 of the August 3, 1998 draft of C99). Reportedly,
54
on Windows there are printer drivers that switch on exceptions. To avoid
55
problems, the SAL_MATH_FPEXCEPTIONS_OFF macro can be used to explicitly
56
switch off exceptions (on Windows).
57
*/
58
#if defined WNT
59
#define SAL_MATH_FPEXCEPTIONS_OFF() _control87( _MCW_EM, _MCW_EM )
60
#else
/* WNT */
61
#define SAL_MATH_FPEXCEPTIONS_OFF()
62
#endif
/* WNT */
63
64
65
/* SAL_MATH_FINITE(d): test double d on INFINITY, NaN et al. */
66
#if defined(__cplusplus) && ( defined(__GXX_EXPERIMENTAL_CXX0X__) || __cplusplus >= 201103L )
67
#define SAL_MATH_FINITE(d) std::isfinite(d)
68
#elif defined( WNT)
69
#define SAL_MATH_FINITE(d) _finite(d)
70
#elif defined IOS
71
/* C++ is so nice. This is the only way I could come up with making
72
* this actually work in all cases (?), even when <cmath> has been
73
* included which #undefs isfinite: copy the definition of isfinite()
74
* from <architecture/arm/math.h>
75
*/
76
#define SAL_MATH_FINITE(d) \
77
( sizeof (d) == sizeof(float ) ? __inline_isfinitef((float)(d)) \
78
: sizeof (d) == sizeof(double) ? __inline_isfinited((double)(d)) \
79
: __inline_isfinite ((long double)(d)))
80
#elif defined LINUX || defined UNX
81
#define SAL_MATH_FINITE(d) finite(d)
82
#else
/* WNT, LINUX, UNX */
83
#error "SAL_MATH_FINITE not defined"
84
#endif
/* WNT, LINUX, UNX */
85
86
87
/* This needs to be fixed for non--IEEE-754 platforms: */
88
#if 1
/* IEEE 754 supported */
89
#if defined OSL_BIGENDIAN
90
91
/* IEEE 754 double structures for BigEndian */
92
union
sal_math_Double
93
{
94
struct
95
{
96
unsigned
sign : 1;
97
unsigned
exponent :11;
98
unsigned
fraction_hi :20;
99
unsigned
fraction_lo :32;
100
} inf_parts;
101
struct
102
{
103
unsigned
sign : 1;
104
unsigned
exponent :11;
105
unsigned
qnan_bit : 1;
106
unsigned
bits :19;
107
unsigned
fraction_lo :32;
108
} nan_parts;
109
struct
110
{
111
unsigned
msw :32;
112
unsigned
lsw :32;
113
} w32_parts;
114
double
value;
115
};
116
117
#elif defined OSL_LITENDIAN
118
119
/* IEEE 754 double structures for LittleEndian */
120
union
sal_math_Double
121
{
122
struct
{
123
unsigned
fraction_lo :32;
124
unsigned
fraction_hi :20;
125
unsigned
exponent :11;
126
unsigned
sign : 1;
127
} inf_parts;
128
struct
{
129
unsigned
fraction_lo :32;
130
unsigned
bits :19;
131
unsigned
qnan_bit : 1;
132
unsigned
exponent :11;
133
unsigned
sign : 1;
134
} nan_parts;
135
struct
136
{
137
unsigned
lsw :32;
138
unsigned
msw :32;
139
} w32_parts;
140
double
value;
141
};
142
143
#else
/* OSL_BIGENDIAN, OSL_LITENDIAN */
144
145
#error "neither OSL_BIGENDIAN nor OSL_LITENDIAN"
146
147
#endif
/* OSL_BIGENDIAN, OSL_LITENDIAN */
148
#else
/* IEEE 754 supported */
149
150
#error "don't know how to handle IEEE 754"
151
152
#endif
/* IEEE 754 supported */
153
154
155
#if defined __cplusplus
156
}
157
#endif
/* __cplusplus */
158
159
#endif
/* INCLUDED_SAL_MATHCONF_H */
160
161
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Generated on Mon Oct 8 2012 00:36:42 for My Project by
1.8.1.2