1 | /*
|
---|
2 | * Copyright (c) 2005 Josef Cejka
|
---|
3 | * Copyright (c) 2011 Petr Koupy
|
---|
4 | * All rights reserved.
|
---|
5 | *
|
---|
6 | * Redistribution and use in source and binary forms, with or without
|
---|
7 | * modification, are permitted provided that the following conditions
|
---|
8 | * are met:
|
---|
9 | *
|
---|
10 | * - Redistributions of source code must retain the above copyright
|
---|
11 | * notice, this list of conditions and the following disclaimer.
|
---|
12 | * - Redistributions in binary form must reproduce the above copyright
|
---|
13 | * notice, this list of conditions and the following disclaimer in the
|
---|
14 | * documentation and/or other materials provided with the distribution.
|
---|
15 | * - The name of the author may not be used to endorse or promote products
|
---|
16 | * derived from this software without specific prior written permission.
|
---|
17 | *
|
---|
18 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
---|
19 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
---|
20 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
---|
21 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
---|
22 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
---|
23 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
---|
24 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
---|
25 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
---|
26 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
---|
27 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
---|
28 | */
|
---|
29 |
|
---|
30 | /** @addtogroup softfloat
|
---|
31 | * @{
|
---|
32 | */
|
---|
33 | /** @file Conversion of precision and conversion between integers and floats.
|
---|
34 | */
|
---|
35 |
|
---|
36 | #ifndef __CONVERSION_H__
|
---|
37 | #define __CONVERSION_H__
|
---|
38 |
|
---|
39 | #include <mathtypes.h>
|
---|
40 |
|
---|
41 | extern float64 float32_to_float64(float32);
|
---|
42 | extern float96 float32_to_float96(float32);
|
---|
43 | extern float128 float32_to_float128(float32);
|
---|
44 | extern float96 float64_to_float96(float64);
|
---|
45 | extern float128 float64_to_float128(float64);
|
---|
46 | extern float128 float96_to_float128(float96);
|
---|
47 |
|
---|
48 | extern float32 float64_to_float32(float64);
|
---|
49 | extern float32 float96_to_float32(float96);
|
---|
50 | extern float64 float96_to_float64(float96);
|
---|
51 | extern float32 float128_to_float32(float128);
|
---|
52 | extern float64 float128_to_float64(float128);
|
---|
53 | extern float96 float128_to_float96(float128);
|
---|
54 |
|
---|
55 | extern uint32_t float32_to_uint32(float32);
|
---|
56 | extern int32_t float32_to_int32(float32);
|
---|
57 |
|
---|
58 | extern uint64_t float32_to_uint64(float32);
|
---|
59 | extern int64_t float32_to_int64(float32);
|
---|
60 |
|
---|
61 | extern uint32_t float64_to_uint32(float64);
|
---|
62 | extern int32_t float64_to_int32(float64);
|
---|
63 |
|
---|
64 | extern uint64_t float64_to_uint64(float64);
|
---|
65 | extern int64_t float64_to_int64(float64);
|
---|
66 |
|
---|
67 | extern uint32_t float96_to_uint32(float96);
|
---|
68 | extern int32_t float96_to_int32(float96);
|
---|
69 |
|
---|
70 | extern uint64_t float96_to_uint64(float96);
|
---|
71 | extern int64_t float96_to_int64(float96);
|
---|
72 |
|
---|
73 | extern uint32_t float128_to_uint32(float128);
|
---|
74 | extern int32_t float128_to_int32(float128);
|
---|
75 |
|
---|
76 | extern uint64_t float128_to_uint64(float128);
|
---|
77 | extern int64_t float128_to_int64(float128);
|
---|
78 |
|
---|
79 | extern float32 uint32_to_float32(uint32_t);
|
---|
80 | extern float32 int32_to_float32(int32_t);
|
---|
81 |
|
---|
82 | extern float32 uint64_to_float32(uint64_t);
|
---|
83 | extern float32 int64_to_float32(int64_t);
|
---|
84 |
|
---|
85 | extern float64 uint32_to_float64(uint32_t);
|
---|
86 | extern float64 int32_to_float64(int32_t);
|
---|
87 |
|
---|
88 | extern float64 uint64_to_float64(uint64_t);
|
---|
89 | extern float64 int64_to_float64(int64_t);
|
---|
90 |
|
---|
91 | extern float96 uint32_to_float96(uint32_t);
|
---|
92 | extern float96 int32_to_float96(int32_t);
|
---|
93 |
|
---|
94 | extern float96 uint64_to_float96(uint64_t);
|
---|
95 | extern float96 int64_to_float96(int64_t);
|
---|
96 |
|
---|
97 | extern float128 uint32_to_float128(uint32_t);
|
---|
98 | extern float128 int32_to_float128(int32_t);
|
---|
99 |
|
---|
100 | extern float128 uint64_to_float128(uint64_t);
|
---|
101 | extern float128 int64_to_float128(int64_t);
|
---|
102 |
|
---|
103 | #ifdef float32_t
|
---|
104 | extern float32_t __floatsisf(int32_t);
|
---|
105 | extern float32_t __floatdisf(int64_t);
|
---|
106 | extern float32_t __floatunsisf(uint32_t);
|
---|
107 | extern float32_t __floatundisf(uint64_t);
|
---|
108 | extern int32_t __fixsfsi(float32_t);
|
---|
109 | extern int64_t __fixsfdi(float32_t);
|
---|
110 | extern uint32_t __fixunssfsi(float32_t);
|
---|
111 | extern uint64_t __fixunssfdi(float32_t);
|
---|
112 | extern int32_t __aeabi_f2iz(float32_t);
|
---|
113 | extern uint32_t __aeabi_f2uiz(float32_t);
|
---|
114 | extern float32_t __aeabi_i2f(int32_t);
|
---|
115 | extern float32_t __aeabi_l2f(int64_t);
|
---|
116 | extern float32_t __aeabi_ui2f(uint32_t);
|
---|
117 | extern float32_t __aeabi_ul2f(uint64_t);
|
---|
118 | #endif
|
---|
119 |
|
---|
120 | #ifdef float64_t
|
---|
121 | extern float64_t __floatsidf(int32_t);
|
---|
122 | extern float64_t __floatdidf(int64_t);
|
---|
123 | extern float64_t __floatunsidf(uint32_t);
|
---|
124 | extern float64_t __floatundidf(uint64_t);
|
---|
125 | extern int32_t __fixdfsi(float64_t);
|
---|
126 | extern int64_t __fixdfdi(float64_t);
|
---|
127 | extern uint32_t __fixunsdfsi(float64_t);
|
---|
128 | extern uint64_t __fixunsdfdi(float64_t);
|
---|
129 | extern float64_t __aeabi_i2d(int32_t);
|
---|
130 | extern float64_t __aeabi_ui2d(uint32_t);
|
---|
131 | extern float64_t __aeabi_l2d(int64_t);
|
---|
132 | extern int32_t __aeabi_d2iz(float64_t);
|
---|
133 | extern int64_t __aeabi_d2lz(float64_t);
|
---|
134 | extern uint32_t __aeabi_d2uiz(float64_t);
|
---|
135 | #endif
|
---|
136 |
|
---|
137 | #ifdef float128_t
|
---|
138 | extern float128_t __floatsitf(int32_t);
|
---|
139 | extern float128_t __floatditf(int64_t);
|
---|
140 | extern float128_t __floatunsitf(uint32_t);
|
---|
141 | extern float128_t __floatunditf(uint64_t);
|
---|
142 | extern int32_t __fixtfsi(float128_t);
|
---|
143 | extern int64_t __fixtfdi(float128_t);
|
---|
144 | extern uint32_t __fixunstfsi(float128_t);
|
---|
145 | extern uint64_t __fixunstfdi(float128_t);
|
---|
146 | extern int32_t _Qp_qtoi(float128_t *);
|
---|
147 | extern int64_t _Qp_qtox(float128_t *);
|
---|
148 | extern uint32_t _Qp_qtoui(float128_t *);
|
---|
149 | extern uint64_t _Qp_qtoux(float128_t *);
|
---|
150 | extern void _Qp_itoq(float128_t *, int32_t);
|
---|
151 | extern void _Qp_xtoq(float128_t *, int64_t);
|
---|
152 | extern void _Qp_uitoq(float128_t *, uint32_t);
|
---|
153 | extern void _Qp_uxtoq(float128_t *, uint64_t);
|
---|
154 | #endif
|
---|
155 |
|
---|
156 | #if (defined(float32_t) && defined(float64_t))
|
---|
157 | extern float32_t __truncdfsf2(float64_t);
|
---|
158 | extern float64_t __extendsfdf2(float32_t);
|
---|
159 | extern float64_t __aeabi_f2d(float32_t);
|
---|
160 | extern float32_t __aeabi_d2f(float64_t);
|
---|
161 | #endif
|
---|
162 |
|
---|
163 | #if (defined(float32_t) && defined(float128_t))
|
---|
164 | extern float32_t __trunctfsf2(float128_t);
|
---|
165 | extern float128_t __extendsftf2(float32_t);
|
---|
166 | extern void _Qp_stoq(float128_t *, float32_t);
|
---|
167 | extern float32_t _Qp_qtos(float128_t *);
|
---|
168 | #endif
|
---|
169 |
|
---|
170 | #if (defined(float64_t) && defined(float128_t))
|
---|
171 | extern float64_t __trunctfdf2(float128_t);
|
---|
172 | extern float128_t __extenddftf2(float64_t);
|
---|
173 | extern void _Qp_dtoq(float128_t *, float64_t);
|
---|
174 | extern float64_t _Qp_qtod(float128_t *);
|
---|
175 | #endif
|
---|
176 |
|
---|
177 | #endif
|
---|
178 |
|
---|
179 | /** @}
|
---|
180 | */
|
---|