Changes in uspace/lib/softfloat/conversion.c [440f57f:c0c38c7c] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/softfloat/conversion.c
r440f57f rc0c38c7c 34 34 */ 35 35 36 #include "sftypes.h"37 36 #include "conversion.h" 38 37 #include "comparison.h" … … 1037 1036 } 1038 1037 1038 #ifdef float32_t 1039 1040 float32_t __floatsisf(int32_t i) 1041 { 1042 float32_u res; 1043 res.data = int32_to_float32(i); 1044 1045 return res.val; 1046 } 1047 1048 float32_t __floatdisf(int64_t i) 1049 { 1050 float32_u res; 1051 res.data = int64_to_float32(i); 1052 1053 return res.val; 1054 } 1055 1056 float32_t __floatunsisf(uint32_t i) 1057 { 1058 float32_u res; 1059 res.data = uint32_to_float32(i); 1060 1061 return res.val; 1062 } 1063 1064 float32_t __floatundisf(uint64_t i) 1065 { 1066 float32_u res; 1067 res.data = uint64_to_float32(i); 1068 1069 return res.val; 1070 } 1071 1072 int32_t __fixsfsi(float32_t a) 1073 { 1074 float32_u ua; 1075 ua.val = a; 1076 1077 return float32_to_int32(ua.data); 1078 } 1079 1080 int64_t __fixsfdi(float32_t a) 1081 { 1082 float32_u ua; 1083 ua.val = a; 1084 1085 return float32_to_int64(ua.data); 1086 } 1087 1088 uint32_t __fixunssfsi(float32_t a) 1089 { 1090 float32_u ua; 1091 ua.val = a; 1092 1093 return float32_to_uint32(ua.data); 1094 } 1095 1096 uint64_t __fixunssfdi(float32_t a) 1097 { 1098 float32_u ua; 1099 ua.val = a; 1100 1101 return float32_to_uint64(ua.data); 1102 } 1103 1104 int32_t __aeabi_f2iz(float32_t a) 1105 { 1106 float32_u ua; 1107 ua.val = a; 1108 1109 return float32_to_int32(ua.data); 1110 } 1111 1112 uint32_t __aeabi_f2uiz(float32_t a) 1113 { 1114 float32_u ua; 1115 ua.val = a; 1116 1117 return float32_to_uint32(ua.data); 1118 } 1119 1120 float32_t __aeabi_i2f(int32_t i) 1121 { 1122 float32_u res; 1123 res.data = int32_to_float32(i); 1124 1125 return res.val; 1126 } 1127 1128 float32_t __aeabi_l2f(int64_t i) 1129 { 1130 float32_u res; 1131 res.data = int64_to_float32(i); 1132 1133 return res.val; 1134 } 1135 1136 float32_t __aeabi_ui2f(uint32_t i) 1137 { 1138 float32_u res; 1139 res.data = uint32_to_float32(i); 1140 1141 return res.val; 1142 } 1143 1144 float32_t __aeabi_ul2f(uint64_t i) 1145 { 1146 float32_u res; 1147 res.data = uint64_to_float32(i); 1148 1149 return res.val; 1150 } 1151 1152 #endif 1153 1154 #ifdef float64_t 1155 1156 float64_t __floatsidf(int32_t i) 1157 { 1158 float64_u res; 1159 res.data = int32_to_float64(i); 1160 1161 return res.val; 1162 } 1163 1164 float64_t __floatdidf(int64_t i) 1165 { 1166 float64_u res; 1167 res.data = int64_to_float64(i); 1168 1169 return res.val; 1170 } 1171 1172 float64_t __floatunsidf(uint32_t i) 1173 { 1174 float64_u res; 1175 res.data = uint32_to_float64(i); 1176 1177 return res.val; 1178 } 1179 1180 float64_t __floatundidf(uint64_t i) 1181 { 1182 float64_u res; 1183 res.data = uint64_to_float64(i); 1184 1185 return res.val; 1186 } 1187 1188 uint32_t __fixunsdfsi(float64_t a) 1189 { 1190 float64_u ua; 1191 ua.val = a; 1192 1193 return float64_to_uint32(ua.data); 1194 } 1195 1196 uint64_t __fixunsdfdi(float64_t a) 1197 { 1198 float64_u ua; 1199 ua.val = a; 1200 1201 return float64_to_uint64(ua.data); 1202 } 1203 1204 int32_t __fixdfsi(float64_t a) 1205 { 1206 float64_u ua; 1207 ua.val = a; 1208 1209 return float64_to_int32(ua.data); 1210 } 1211 1212 int64_t __fixdfdi(float64_t a) 1213 { 1214 float64_u ua; 1215 ua.val = a; 1216 1217 return float64_to_int64(ua.data); 1218 } 1219 1220 float64_t __aeabi_i2d(int32_t i) 1221 { 1222 float64_u res; 1223 res.data = int32_to_float64(i); 1224 1225 return res.val; 1226 } 1227 1228 float64_t __aeabi_ui2d(uint32_t i) 1229 { 1230 float64_u res; 1231 res.data = uint32_to_float64(i); 1232 1233 return res.val; 1234 } 1235 1236 float64_t __aeabi_l2d(int64_t i) 1237 { 1238 float64_u res; 1239 res.data = int64_to_float64(i); 1240 1241 return res.val; 1242 } 1243 1244 int32_t __aeabi_d2iz(float64_t a) 1245 { 1246 float64_u ua; 1247 ua.val = a; 1248 1249 return float64_to_int32(ua.data); 1250 } 1251 1252 int64_t __aeabi_d2lz(float64_t a) 1253 { 1254 float64_u ua; 1255 ua.val = a; 1256 1257 return float64_to_int64(ua.data); 1258 } 1259 1260 uint32_t __aeabi_d2uiz(float64_t a) 1261 { 1262 float64_u ua; 1263 ua.val = a; 1264 1265 return float64_to_uint32(ua.data); 1266 } 1267 1268 #endif 1269 1270 #ifdef float128_t 1271 1272 float128_t __floatsitf(int32_t i) 1273 { 1274 float128_u res; 1275 res.data = int32_to_float128(i); 1276 1277 return res.val; 1278 } 1279 1280 float128_t __floatditf(int64_t i) 1281 { 1282 float128_u res; 1283 res.data = int64_to_float128(i); 1284 1285 return res.val; 1286 } 1287 1288 float128_t __floatunsitf(uint32_t i) 1289 { 1290 float128_u res; 1291 res.data = uint32_to_float128(i); 1292 1293 return res.val; 1294 } 1295 1296 float128_t __floatunditf(uint64_t i) 1297 { 1298 float128_u res; 1299 res.data = uint64_to_float128(i); 1300 1301 return res.val; 1302 } 1303 1304 int32_t __fixtfsi(float128_t a) 1305 { 1306 float128_u ua; 1307 ua.val = a; 1308 1309 return float128_to_int32(ua.data); 1310 } 1311 1312 int64_t __fixtfdi(float128_t a) 1313 { 1314 float128_u ua; 1315 ua.val = a; 1316 1317 return float128_to_uint64(ua.data); 1318 } 1319 1320 uint32_t __fixunstfsi(float128_t a) 1321 { 1322 float128_u ua; 1323 ua.val = a; 1324 1325 return float128_to_uint32(ua.data); 1326 } 1327 1328 uint64_t __fixunstfdi(float128_t a) 1329 { 1330 float128_u ua; 1331 ua.val = a; 1332 1333 return float128_to_uint64(ua.data); 1334 } 1335 1336 int32_t _Qp_qtoi(float128_t *a) 1337 { 1338 return __fixtfsi(*a); 1339 } 1340 1341 int64_t _Qp_qtox(float128_t *a) 1342 { 1343 return __fixunstfdi(*a); 1344 } 1345 1346 uint32_t _Qp_qtoui(float128_t *a) 1347 { 1348 return __fixunstfsi(*a); 1349 } 1350 1351 uint64_t _Qp_qtoux(float128_t *a) 1352 { 1353 return __fixunstfdi(*a); 1354 } 1355 1356 void _Qp_itoq(float128_t *c, int32_t a) 1357 { 1358 *c = __floatsitf(a); 1359 } 1360 1361 void _Qp_xtoq(float128_t *c, int64_t a) 1362 { 1363 *c = __floatditf(a); 1364 } 1365 1366 void _Qp_uitoq(float128_t *c, uint32_t a) 1367 { 1368 *c = __floatunsitf(a); 1369 } 1370 1371 void _Qp_uxtoq(float128_t *c, uint64_t a) 1372 { 1373 *c = __floatunditf(a); 1374 } 1375 1376 #endif 1377 1378 #if (defined(float32_t) && defined(float64_t)) 1379 1380 float32_t __truncdfsf2(float64_t a) 1381 { 1382 float64_u ua; 1383 ua.val = a; 1384 1385 float32_u res; 1386 res.data = float64_to_float32(ua.data); 1387 1388 return res.val; 1389 } 1390 1391 float64_t __extendsfdf2(float32_t a) 1392 { 1393 float32_u ua; 1394 ua.val = a; 1395 1396 float64_u res; 1397 res.data = float32_to_float64(ua.data); 1398 1399 return res.val; 1400 } 1401 1402 float64_t __aeabi_f2d(float32_t a) 1403 { 1404 float32_u ua; 1405 ua.val = a; 1406 1407 float64_u res; 1408 res.data = float32_to_float64(ua.data); 1409 1410 return res.val; 1411 } 1412 1413 float32_t __aeabi_d2f(float64_t a) 1414 { 1415 float64_u ua; 1416 ua.val = a; 1417 1418 float32_u res; 1419 res.data = float64_to_float32(ua.data); 1420 1421 return res.val; 1422 } 1423 1424 #endif 1425 1426 #if (defined(float32_t) && defined(float128_t)) 1427 1428 float32_t __trunctfsf2(float128_t a) 1429 { 1430 float128_u ua; 1431 ua.val = a; 1432 1433 float32_u res; 1434 res.data = float128_to_float32(ua.data); 1435 1436 return res.val; 1437 } 1438 1439 float128_t __extendsftf2(float32_t a) 1440 { 1441 float32_u ua; 1442 ua.val = a; 1443 1444 float128_u res; 1445 res.data = float32_to_float128(ua.data); 1446 1447 return res.val; 1448 } 1449 1450 void _Qp_stoq(float128_t *c, float32_t a) 1451 { 1452 *c = __extendsftf2(a); 1453 } 1454 1455 float32_t _Qp_qtos(float128_t *a) 1456 { 1457 return __trunctfsf2(*a); 1458 } 1459 1460 #endif 1461 1462 #if (defined(float64_t) && defined(float128_t)) 1463 1464 float64_t __trunctfdf2(float128_t a) 1465 { 1466 float128_u ua; 1467 ua.val = a; 1468 1469 float64_u res; 1470 res.data = float128_to_float64(ua.data); 1471 1472 return res.val; 1473 } 1474 1475 float128_t __extenddftf2(float64_t a) 1476 { 1477 float64_u ua; 1478 ua.val = a; 1479 1480 float128_u res; 1481 res.data = float64_to_float128(ua.data); 1482 1483 return res.val; 1484 } 1485 1486 void _Qp_dtoq(float128_t *c, float64_t a) 1487 { 1488 *c = __extenddftf2(a); 1489 } 1490 1491 float64_t _Qp_qtod(float128_t *a) 1492 { 1493 return __trunctfdf2(*a); 1494 } 1495 1496 #endif 1497 1039 1498 /** @} 1040 1499 */
Note:
See TracChangeset
for help on using the changeset viewer.