OpenCores
URL https://opencores.org/ocsvn/c0or1k/c0or1k/trunk

Subversion Repositories c0or1k

[/] [c0or1k/] [trunk/] [conts/] [posix/] [libposix/] [include/] [posix/] [bits/] [uClibc_fpmax.h] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 drasko
/*
2
 * Copyright (C) 2003-2006     Manuel Novoa III
3
 *
4
 * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
5
 */
6
/* Define a maximal floating point type, and the associated constants
7
 * that are defined for the floating point types in float.h.
8
 *
9
 * This is to support archs that are missing long double, or even double.
10
 */
11
 
12
#ifndef _UCLIBC_FPMAX_H
13
#define _UCLIBC_FPMAX_H
14
 
15
#ifndef _ISOC99_SOURCE
16
#define _ISOC99_SOURCE 1
17
#endif
18
 
19
#include <features.h>
20
#include <float.h>
21
 
22
#ifdef __UCLIBC_HAS_FLOATS__
23
 
24
#if defined(LDBL_MANT_DIG)
25
 
26
typedef long double __fpmax_t;
27
#define FPMAX_TYPE           3
28
 
29
#define FPMAX_MANT_DIG       LDBL_MANT_DIG
30
#define FPMAX_DIG            LDBL_DIG
31
#define FPMAX_EPSILON        LDBL_EPSILON
32
#define FPMAX_MIN_EXP        LDBL_MIN_EXP
33
#define FPMAX_MIN            LDBL_MIN
34
#define FPMAX_MIN_10_EXP     LDBL_MIN_10_EXP
35
#define FPMAX_MAX_EXP        LDBL_MAX_EXP
36
#define FPMAX_MAX            LDBL_MAX
37
#define FPMAX_MAX_10_EXP     LDBL_MAX_10_EXP
38
 
39
#elif defined(DBL_MANT_DIG)
40
 
41
typedef double __fpmax_t;
42
#define FPMAX_TYPE           2
43
 
44
#define FPMAX_MANT_DIG       DBL_MANT_DIG
45
#define FPMAX_DIG            DBL_DIG
46
#define FPMAX_EPSILON        DBL_EPSILON
47
#define FPMAX_MIN_EXP        DBL_MIN_EXP
48
#define FPMAX_MIN            DBL_MIN
49
#define FPMAX_MIN_10_EXP     DBL_MIN_10_EXP
50
#define FPMAX_MAX_EXP        DBL_MAX_EXP
51
#define FPMAX_MAX            DBL_MAX
52
#define FPMAX_MAX_10_EXP     DBL_MAX_10_EXP
53
 
54
#elif defined(FLT_MANT_DIG)
55
 
56
typedef float __fpmax_t;
57
#define FPMAX_TYPE           1
58
 
59
#define FPMAX_MANT_DIG       FLT_MANT_DIG
60
#define FPMAX_DIG            FLT_DIG
61
#define FPMAX_EPSILON        FLT_EPSILON
62
#define FPMAX_MIN_EXP        FLT_MIN_EXP
63
#define FPMAX_MIN            FLT_MIN
64
#define FPMAX_MIN_10_EXP     FLT_MIN_10_EXP
65
#define FPMAX_MAX_EXP        FLT_MAX_EXP
66
#define FPMAX_MAX            FLT_MAX
67
#define FPMAX_MAX_10_EXP     FLT_MAX_10_EXP
68
 
69
#else
70
#error unable to determine appropriate type for __fpmax_t!
71
#endif
72
 
73
#ifndef DECIMAL_DIG
74
 
75
#ifdef L___strtofpmax
76
/* Emit warning only once. */
77
#warning DECIMAL_DIG is not defined! If you are using gcc, it may not be defining __STDC_VERSION__ as it should.
78
#endif
79
#if !defined(FLT_RADIX) || (FLT_RADIX != 2)
80
#error unable to compensate for missing DECIMAL_DIG!
81
#endif
82
 
83
/*  ceil (1 + #mantissa * log10 (FLT_RADIX)) */
84
#define DECIMAL_DIG   (1 + (((FPMAX_MANT_DIG * 100) + 331) / 332))
85
 
86
#endif /* DECIMAL_DIG */
87
 
88
#if defined _LIBC && defined IS_IN_libc
89
extern __fpmax_t __strtofpmax(const char *str, char **endptr, int exp_adjust) attribute_hidden;
90
 
91
#ifdef __UCLIBC_HAS_XLOCALE__
92
extern __fpmax_t __strtofpmax_l(const char *str, char **endptr, int exp_adjust,
93
                                                                __locale_t locale_arg) attribute_hidden;
94
#endif
95
 
96
#ifdef __UCLIBC_HAS_WCHAR__
97
extern __fpmax_t __wcstofpmax(const wchar_t *wcs, wchar_t **endptr,
98
                                                          int exp_adjust) attribute_hidden;
99
 
100
#ifdef __UCLIBC_HAS_XLOCALE__
101
extern __fpmax_t __wcstofpmax_l(const wchar_t *wcs, wchar_t **endptr,
102
                                                                int exp_adjust, __locale_t locale_arg) attribute_hidden;
103
#endif
104
#endif /* __UCLIBC_HAS_WCHAR__ */
105
#endif /* _LIBC */
106
 
107
/* The following checks in an __fpmax_t is either 0 or +/- infinity.
108
 *
109
 * WARNING!!!   WARNING!!!   WARNING!!!   WARNING!!!   WARNING!!!   WARNING!!!
110
 *
111
 * This only works if __fpmax_t is the actual maximal floating point type used
112
 * in intermediate calculations.  Otherwise, excess precision in the
113
 * intermediate values can cause the test to fail.
114
 *
115
 * WARNING!!!   WARNING!!!   WARNING!!!   WARNING!!!   WARNING!!!   WARNING!!!
116
 */
117
 
118
#define __FPMAX_ZERO_OR_INF_CHECK(x)  ((x) == ((x)/4) )
119
 
120
#endif /* __UCLIBC_HAS_FLOATS__ */
121
 
122
#endif /* _UCLIBC_FPMAX_H */

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.