Changeset 8b863a62 in mainline for uspace/lib/softfloat
- Timestamp:
- 2014-04-16T17:14:06Z (12 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- f857e8b
- Parents:
- dba3e2c (diff), 70b570c (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)links above to see all the changes relative to each parent. - Location:
- uspace/lib/softfloat
- Files:
-
- 5 edited
-
Makefile (modified) (2 diffs)
-
conversion.c (modified) (2 diffs)
-
sftypes.h (modified) (2 diffs)
-
softfloat.c (modified) (6 diffs)
-
softfloat.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/softfloat/Makefile
rdba3e2c r8b863a62 30 30 USPACE_PREFIX = ../.. 31 31 LIBRARY = libsoftfloat 32 MATH = y 32 33 33 34 SOURCES = \ … … 39 40 mul.c \ 40 41 comparison.c \ 41 conversion.c \ 42 other.c 42 conversion.c 43 43 44 44 include $(USPACE_PREFIX)/Makefile.common -
uspace/lib/softfloat/conversion.c
rdba3e2c r8b863a62 217 217 result.parts.exp = 0; 218 218 219 exp *= -1; 219 exp *= -1; 220 220 if (exp > FLOAT32_FRACTION_SIZE) { 221 221 /* FIXME: underflow */ … … 891 891 } 892 892 893 894 893 float64 uint64_to_float64(uint64_t i) 895 894 { -
uspace/lib/softfloat/sftypes.h
rdba3e2c r8b863a62 34 34 */ 35 35 36 #ifndef __SFTYPES_H__ 37 #define __SFTYPES_H__ 38 39 #include <byteorder.h> 40 #include <stdint.h> 41 42 /* 43 * For recognizing NaNs or infinity use specialized comparison 44 * functions, comparing with these constants is not sufficient. 45 */ 46 47 #define FLOAT32_NAN UINT32_C(0x7FC00001) 48 #define FLOAT32_SIGNAN UINT32_C(0x7F800001) 49 #define FLOAT32_INF UINT32_C(0x7F800000) 50 51 #define FLOAT64_NAN UINT64_C(0x7FF8000000000001) 52 #define FLOAT64_SIGNAN UINT64_C(0x7FF0000000000001) 53 #define FLOAT64_INF UINT64_C(0x7FF0000000000000) 54 55 #define FLOAT96_NAN_HI UINT64_C(0x7FFF80000000) 56 #define FLOAT96_NAN_LO UINT32_C(0x00010000) 57 #define FLOAT96_SIGNAN_HI UINT64_C(0x7FFF00000000) 58 #define FLOAT96_SIGNAN_LO UINT32_C(0x00010000) 59 60 #define FLOAT128_NAN_HI UINT64_C(0x7FFF800000000000) 61 #define FLOAT128_NAN_LO UINT64_C(0x0000000000000001) 62 #define FLOAT128_SIGNAN_HI UINT64_C(0x7FFF000000000000) 63 #define FLOAT128_SIGNAN_LO UINT64_C(0x0000000000000001) 64 #define FLOAT128_INF_HI UINT64_C(0x7FFF000000000000) 65 #define FLOAT128_INF_LO UINT64_C(0x0000000000000000) 66 67 #define FLOAT32_FRACTION_SIZE 23 68 #define FLOAT64_FRACTION_SIZE 52 69 #define FLOAT96_FRACTION_SIZE 64 70 #define FLOAT128_FRACTION_SIZE 112 71 #define FLOAT128_FRAC_HI_SIZE 48 72 #define FLOAT128_FRAC_LO_SIZE 64 73 74 #define FLOAT32_HIDDEN_BIT_MASK UINT32_C(0x800000) 75 #define FLOAT64_HIDDEN_BIT_MASK UINT64_C(0x10000000000000) 76 #define FLOAT128_HIDDEN_BIT_MASK_HI UINT64_C(0x1000000000000) 77 #define FLOAT128_HIDDEN_BIT_MASK_LO UINT64_C(0x0000000000000000) 78 79 #define FLOAT32_MAX_EXPONENT 0xFF 80 #define FLOAT64_MAX_EXPONENT 0x7FF 81 #define FLOAT96_MAX_EXPONENT 0x7FFF 82 #define FLOAT128_MAX_EXPONENT 0x7FFF 83 84 #define FLOAT32_BIAS 0x7F 85 #define FLOAT64_BIAS 0x3FF 86 #define FLOAT96_BIAS 0x3FFF 87 #define FLOAT128_BIAS 0x3FFF 88 89 #if defined(__BE__) 90 91 typedef union { 92 uint32_t bin; 93 94 struct { 95 uint32_t sign : 1; 96 uint32_t exp : 8; 97 uint32_t fraction : 23; 98 } parts __attribute__((packed)); 99 } float32; 100 101 typedef union { 102 uint64_t bin; 103 104 struct { 105 uint64_t sign : 1; 106 uint64_t exp : 11; 107 uint64_t fraction : 52; 108 } parts __attribute__((packed)); 109 } float64; 110 111 typedef union { 112 struct { 113 uint64_t hi; 114 uint32_t lo; 115 } bin __attribute__((packed)); 116 117 struct { 118 uint64_t padding : 16; 119 uint64_t sign : 1; 120 uint64_t exp : 15; 121 uint64_t fraction : 64; 122 } parts __attribute__((packed)); 123 } float96; 124 125 typedef union { 126 struct { 127 uint64_t hi; 128 uint64_t lo; 129 } bin __attribute__((packed)); 130 131 struct { 132 uint64_t sign : 1; 133 uint64_t exp : 15; 134 uint64_t frac_hi : 48; 135 uint64_t frac_lo : 64; 136 } parts __attribute__((packed)); 137 } float128; 138 139 #elif defined(__LE__) 140 141 typedef union { 142 uint32_t bin; 143 144 struct { 145 uint32_t fraction : 23; 146 uint32_t exp : 8; 147 uint32_t sign : 1; 148 } parts __attribute__((packed)); 149 } float32; 150 151 typedef union { 152 uint64_t bin; 153 154 struct { 155 uint64_t fraction : 52; 156 uint64_t exp : 11; 157 uint64_t sign : 1; 158 } parts __attribute__((packed)); 159 } float64; 160 161 typedef union { 162 struct { 163 uint32_t lo; 164 uint64_t hi; 165 } bin __attribute__((packed)); 166 167 struct { 168 uint64_t fraction : 64; 169 uint64_t exp : 15; 170 uint64_t sign : 1; 171 uint64_t padding : 16; 172 } parts __attribute__((packed)); 173 } float96; 174 175 typedef union { 176 struct { 177 uint64_t lo; 178 uint64_t hi; 179 } bin __attribute__((packed)); 180 181 struct { 182 uint64_t frac_lo : 64; 183 uint64_t frac_hi : 48; 184 uint64_t exp : 15; 185 uint64_t sign : 1; 186 } parts __attribute__((packed)); 187 } float128; 188 189 #else 190 #error Unknown endianess 191 #endif 192 193 typedef union { 194 float val; 195 196 #if defined(FLOAT_SIZE_32) 197 float32 data; 198 #elif defined(FLOAT_SIZE_64) 199 float64 data; 200 #elif defined(FLOAT_SIZE_96) 201 float96 data; 202 #elif defined(FLOAT_SIZE_128) 203 float128 data; 204 #else 205 #error Unsupported float size 206 #endif 207 } float_t; 208 209 typedef union { 210 double val; 211 212 #if defined(DOUBLE_SIZE_32) 213 float32 data; 214 #elif defined(DOUBLE_SIZE_64) 215 float64 data; 216 #elif defined(DOUBLE_SIZE_96) 217 float96 data; 218 #elif defined(DOUBLE_SIZE_128) 219 float128 data; 220 #else 221 #error Unsupported double size 222 #endif 223 } double_t; 224 225 typedef union { 226 long double val; 227 228 #if defined(LONG_DOUBLE_SIZE_32) 229 float32 data; 230 #elif defined(LONG_DOUBLE_SIZE_64) 231 float64 data; 232 #elif defined(LONG_DOUBLE_SIZE_96) 233 float96 data; 234 #elif defined(LONG_DOUBLE_SIZE_128) 235 float128 data; 236 #else 237 #error Unsupported long double size 238 #endif 239 } long_double_t; 240 36 #ifndef SOFTFLOAT_SFTYPES_H__ 37 #define SOFTFLOAT_SFTYPES_H__ 38 39 #include <mathtypes.h> 241 40 242 41 #if defined(INT_SIZE_8) … … 602 401 #define ullong_to_long_double CONCAT(from_ullong, _to_long_double) 603 402 604 605 403 #endif 606 404 -
uspace/lib/softfloat/softfloat.c
rdba3e2c r8b863a62 44 44 #include "conversion.h" 45 45 #include "comparison.h" 46 #include "other.h"47 46 48 47 /* Arithmetic functions */ … … 1265 1264 } 1266 1265 1266 float __aeabi_d2f(double a) 1267 { 1268 return __truncdfsf2(a); 1269 } 1270 1271 double __aeabi_f2d(float a) 1272 { 1273 return __extendsfdf2(a); 1274 } 1275 1276 1277 float __aeabi_i2f(int i) 1278 { 1279 return __floatsisf(i); 1280 } 1281 1282 float __aeabi_ui2f(int i) 1283 { 1284 return __floatunsisf(i); 1285 } 1286 1267 1287 double __aeabi_i2d(int i) 1268 1288 { … … 1275 1295 } 1276 1296 1297 double __aeabi_l2d(long long i) 1298 { 1299 return __floattidf(i); 1300 } 1301 1302 float __aeabi_l2f(long long i) 1303 { 1304 return __floattisf(i); 1305 } 1306 1307 float __aeabi_ul2f(unsigned long long u) 1308 { 1309 return __floatuntisf(u); 1310 } 1311 1277 1312 int __aeabi_f2iz(float a) 1278 1313 { … … 1280 1315 } 1281 1316 1317 int __aeabi_f2uiz(float a) 1318 { 1319 return __fixunssfsi(a); 1320 } 1321 1282 1322 int __aeabi_d2iz(double a) 1283 1323 { … … 1290 1330 } 1291 1331 1332 long long __aeabi_d2lz(double a) 1333 { 1334 return __fixdfti(a); 1335 } 1336 1337 int __aeabi_fcmpge(float a, float b) 1338 { 1339 return __gesf2(a, b); 1340 } 1341 1342 int __aeabi_fcmpgt(float a, float b) 1343 { 1344 return __gtsf2(a, b); 1345 } 1346 1347 int __aeabi_fcmplt(float a, float b) 1348 { 1349 return __ltsf2(a, b); 1350 } 1351 1352 int __aeabi_fcmpeq(float a, float b) 1353 { 1354 return __eqsf2(a, b); 1355 } 1356 1292 1357 int __aeabi_dcmpge(double a, double b) 1293 1358 { … … 1303 1368 { 1304 1369 return __ltdf2(a, b); 1370 } 1371 1372 int __aeabi_dcmple(double a, double b) 1373 { 1374 return __ledf2(a, b); 1305 1375 } 1306 1376 -
uspace/lib/softfloat/softfloat.h
rdba3e2c r8b863a62 204 204 205 205 /* ARM EABI */ 206 extern float __aeabi_d2f(double); 207 extern double __aeabi_f2d(float); 208 extern float __aeabi_i2f(int); 209 extern float __aeabi_ui2f(int); 206 210 extern double __aeabi_i2d(int); 207 211 extern double __aeabi_ui2d(unsigned int); 212 extern double __aeabi_l2d(long long); 213 extern float __aeabi_l2f(long long); 214 extern float __aeabi_ul2f(unsigned long long); 208 215 extern unsigned int __aeabi_d2uiz(double); 216 extern long long __aeabi_d2lz(double); 209 217 210 218 extern int __aeabi_f2iz(float); 219 extern int __aeabi_f2uiz(float); 211 220 extern int __aeabi_d2iz(double); 221 222 extern int __aeabi_fcmpge(float, float); 223 extern int __aeabi_fcmpgt(float, float); 224 extern int __aeabi_fcmplt(float, float); 225 extern int __aeabi_fcmpeq(float, float); 212 226 213 227 extern int __aeabi_dcmpge(double, double); 214 228 extern int __aeabi_dcmpgt(double, double); 215 229 extern int __aeabi_dcmplt(double, double); 230 extern int __aeabi_dcmple(double, double); 216 231 extern int __aeabi_dcmpeq(double, double); 217 232
Note:
See TracChangeset
for help on using the changeset viewer.
