source: svn/trunk/newcon3bcm2_21bu/toolchain/mipsel-linux-uclibc/include/bits/uClibc_fpmax.h

Last change on this file was 2, checked in by jglee, 11 years ago

first commit

  • Property svn:executable set to *
File size: 4.1 KB
Line 
1/*  Copyright (C) 2003     Manuel Novoa III
2 *
3 *  This library is free software; you can redistribute it and/or
4 *  modify it under the terms of the GNU Library General Public
5 *  License as published by the Free Software Foundation; either
6 *  version 2 of the License, or (at your option) any later version.
7 *
8 *  This library is distributed in the hope that it will be useful,
9 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
10 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 *  Library General Public License for more details.
12 *
13 *  You should have received a copy of the GNU Library General Public
14 *  License along with this library; if not, write to the Free
15 *  Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
16 */
17
18/* Define a maximal floating point type, and the associated constants
19 * that are defined for the floating point types in float.h.
20 *
21 * This is to support archs that are missing long double, or even double.
22 */
23
24#ifndef _UCLIBC_FPMAX_H
25#define _UCLIBC_FPMAX_H
26
27#ifndef _ISOC99_SOURCE
28#define _ISOC99_SOURCE 1
29#endif
30
31#include <features.h>
32#include <float.h>
33
34#ifdef __UCLIBC_HAS_FLOATS__
35
36#if defined(LDBL_MANT_DIG)
37
38typedef long double __fpmax_t;
39#define FPMAX_TYPE           3
40
41#define FPMAX_MANT_DIG       LDBL_MANT_DIG
42#define FPMAX_DIG            LDBL_DIG
43#define FPMAX_EPSILON        LDBL_EPSILON
44#define FPMAX_MIN_EXP        LDBL_MIN_EXP
45#define FPMAX_MIN            LDBL_MIN
46#define FPMAX_MIN_10_EXP     LDBL_MIN_10_EXP
47#define FPMAX_MAX_EXP        LDBL_MAX_EXP
48#define FPMAX_MAX            LDBL_MAX
49#define FPMAX_MAX_10_EXP     LDBL_MAX_10_EXP
50
51#elif defined(DBL_MANT_DIG)
52
53typedef double __fpmax_t;
54#define FPMAX_TYPE           2
55
56#define FPMAX_MANT_DIG       DBL_MANT_DIG
57#define FPMAX_DIG            DBL_DIG
58#define FPMAX_EPSILON        DBL_EPSILON
59#define FPMAX_MIN_EXP        DBL_MIN_EXP
60#define FPMAX_MIN            DBL_MIN
61#define FPMAX_MIN_10_EXP     DBL_MIN_10_EXP
62#define FPMAX_MAX_EXP        DBL_MAX_EXP
63#define FPMAX_MAX            DBL_MAX
64#define FPMAX_MAX_10_EXP     DBL_MAX_10_EXP
65
66#elif defined(FLT_MANT_DIG)
67
68typedef float __fpmax_t;
69#define FPMAX_TYPE           1
70
71#define FPMAX_MANT_DIG       FLT_MANT_DIG
72#define FPMAX_DIG            FLT_DIG
73#define FPMAX_EPSILON        FLT_EPSILON
74#define FPMAX_MIN_EXP        FLT_MIN_EXP
75#define FPMAX_MIN            FLT_MIN
76#define FPMAX_MIN_10_EXP     FLT_MIN_10_EXP
77#define FPMAX_MAX_EXP        FLT_MAX_EXP
78#define FPMAX_MAX            FLT_MAX
79#define FPMAX_MAX_10_EXP     FLT_MAX_10_EXP
80
81#else
82#error unable to determine appropriate type for __fpmax_t!
83#endif
84
85#ifndef DECIMAL_DIG
86
87#ifdef L___strtofpmax
88/* Emit warning only once. */
89#warning DECIMAL_DIG is not defined! If you are using gcc, it may not be defining __STDC_VERSION__ as it should.
90#endif
91#if !defined(FLT_RADIX) || (FLT_RADIX != 2)
92#error unable to compensate for missing DECIMAL_DIG!
93#endif
94
95/*  ceil (1 + #mantissa * log10 (FLT_RADIX)) */
96#define DECIMAL_DIG   (1 + (((FPMAX_MANT_DIG * 100) + 331) / 332))
97
98#endif /* DECIMAL_DIG */
99
100extern __fpmax_t __strtofpmax(const char *str, char **endptr, int exp_adjust);
101
102#ifdef __UCLIBC_HAS_XLOCALE__
103extern __fpmax_t __strtofpmax_l(const char *str, char **endptr, int exp_adjust,
104                                                                __locale_t locale_arg);
105#endif
106
107#ifdef __UCLIBC_HAS_WCHAR__
108extern __fpmax_t __wcstofpmax(const wchar_t *wcs, wchar_t **endptr,
109                                                          int exp_adjust);
110
111#ifdef __UCLIBC_HAS_XLOCALE__
112extern __fpmax_t __wcstofpmax_l(const wchar_t *wcs, wchar_t **endptr,
113                                                                int exp_adjust, __locale_t locale_arg);
114#endif
115#endif /* __UCLIBC_HAS_WCHAR__ */
116
117/* The following checks in an __fpmax_t is either 0 or +/- infinity.
118 *
119 * WARNING!!!   WARNING!!!   WARNING!!!   WARNING!!!   WARNING!!!   WARNING!!!
120 *
121 * This only works if __fpmax_t is the actual maximal floating point type used
122 * in intermediate calculations.  Otherwise, excess precision in the
123 * intermediate values can cause the test to fail.
124 *
125 * WARNING!!!   WARNING!!!   WARNING!!!   WARNING!!!   WARNING!!!   WARNING!!!
126 */
127
128#define __FPMAX_ZERO_OR_INF_CHECK(x)  ((x) == ((x)/4) )
129
130#endif /* __UCLIBC_HAS_FLOATS__ */
131
132#endif /* _UCLIBC_FPMAX_H */
Note: See TracBrowser for help on using the repository browser.