Changeset 94537 in vbox
- Timestamp:
- Apr 10, 2022 2:14:38 PM (3 years ago)
- Location:
- trunk/include/iprt
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/iprt/cdefs.h
r93836 r94537 86 86 # define RT_COMPILER_GROKS_64BIT_BITFIELDS 87 87 # define RT_COMPILER_WITH_80BIT_LONG_DOUBLE 88 # define RT_COMPILER_WITH_128BIT_LONG_DOUBLE 88 89 # define RT_COMPILER_WITH_128BIT_INT_TYPES 89 90 # define RT_NO_VISIBILITY_HIDDEN … … 1115 1116 #if (defined(RT_ARCH_AMD64) || defined(RT_ARCH_X86)) && !defined(RT_OS_WINDOWS) 1116 1117 # define RT_COMPILER_WITH_80BIT_LONG_DOUBLE 1118 #endif 1119 1120 /** @def RT_COMPILER_WITH_128BIT_LONG_DOUBLE 1121 * Macro that is defined if the compiler implements long double as the 1122 * IEEE quadruple precision floating (128-bit). 1123 * @note Currently not able to detect this, so must be explicitly defined. */ 1124 #if 0 1125 # define RT_COMPILER_WITH_128BIT_LONG_DOUBLE 1117 1126 #endif 1118 1127 -
trunk/include/iprt/types.h
r94446 r94537 956 956 /** The max exponent value for the RTFLOAT32U format. */ 957 957 #define RTFLOAT32U_EXP_MAX (255) 958 /** The exponent bias underflow adjust for the RTFLOAT32U format. 959 * @note 754-1985 sec 7.4, not mentioned in later standard versions. */ 960 #define RTFLOAT32U_EXP_BIAS_UNDERFLOW_ADJUST (192) 958 961 /** Fraction width (in bits) for the RTFLOAT32U format. */ 959 962 #define RTFLOAT32U_FRACTION_BITS (23) … … 1057 1060 /** The max exponent value for the RTFLOAT64U format. */ 1058 1061 #define RTFLOAT64U_EXP_MAX (2047) 1062 /** The exponent bias underflow adjust for the RTFLOAT64U format. 1063 * @note 754-1985 sec 7.4, not mentioned in later standard versions. */ 1064 #define RTFLOAT64U_EXP_BIAS_UNDERFLOW_ADJUST (1536) 1059 1065 /** Fraction width (in bits) for the RTFLOAT64U format. */ 1060 1066 #define RTFLOAT64U_FRACTION_BITS (52) … … 1107 1113 # endif 1108 1114 } s; 1115 1116 /** Format for accessing it as two separate components. */ 1117 RT_GCC_EXTENSION struct 1118 { 1119 # ifdef RT_BIG_ENDIAN /** @todo big endian mapping is wrong. */ 1120 /** The sign bit and exponent. */ 1121 uint16_t uSignAndExponent; 1122 /** The mantissa. */ 1123 uint64_t uMantissa; 1124 # else 1125 /** The mantissa. */ 1126 uint64_t uMantissa; 1127 /** The sign bit and exponent. */ 1128 uint16_t uSignAndExponent; 1129 # endif 1130 } s2; 1109 1131 1110 1132 # ifdef RT_COMPILER_GROKS_64BIT_BITFIELDS … … 1155 1177 # endif 1156 1178 # define RTFLOAT80U_INIT_C(a_fSign, a_uMantissa, a_uExponent) RTFLOAT80U_INIT((a_fSign), UINT64_C(a_uMantissa), (a_uExponent)) 1179 # define RTFLOAT80U_INIT_ZERO(a_fSign) RTFLOAT80U_INIT((a_fSign), 0, 0) 1180 # define RTFLOAT80U_INIT_INF(a_fSign) RTFLOAT80U_INIT((a_fSign), RT_BIT_64(63), 0x7fff) 1181 # define RTFLOAT80U_INIT_SIGNALLING_NAN(a_fSign) RTFLOAT80U_INIT((a_fSign), RT_BIT_64(63) | 1, 0x7fff) 1182 # define RTFLOAT80U_INIT_SNAN(a_fSign) RTFLOAT80U_INIT_SIGNALLING_NAN(a_fSign) 1183 # define RTFLOAT80U_INIT_QUIET_NAN(a_fSign) RTFLOAT80U_INIT((a_fSign), RT_BIT_64(63) | RT_BIT_64(62) | 1, 0x7fff) 1184 # define RTFLOAT80U_INIT_QNAN(a_fSign) RTFLOAT80U_INIT_QUIET_NAN(a_fSign) 1185 # define RTFLOAT80U_INIT_INDEFINITE(a_fSign) RTFLOAT80U_INIT((a_fSign), RT_BIT_64(63) | RT_BIT_64(62), 0x7fff) 1186 # define RTFLOAT80U_INIT_IND(a_fSign) RTFLOAT80U_INIT_INDEFINITE(a_fSign) 1157 1187 /** The exponent bias for the RTFLOAT80U format. */ 1158 1188 # define RTFLOAT80U_EXP_BIAS (16383) 1159 1189 /** The max exponent value for the RTFLOAT80U format. */ 1160 1190 # define RTFLOAT80U_EXP_MAX (32767) 1191 /** The exponent bias underflow adjust for the RTFLOAT80U format. 1192 * @note 754-1985 sec 7.4, not mentioned in later standard versions. */ 1193 # define RTFLOAT80U_EXP_BIAS_UNDERFLOW_ADJUST (24576) 1161 1194 /** Fraction width (in bits) for the RTFLOAT80U format. */ 1162 1195 # define RTFLOAT80U_FRACTION_BITS (63) … … 1233 1266 } s; 1234 1267 1268 /** Format for accessing it as two separate components. */ 1269 RT_GCC_EXTENSION struct 1270 { 1271 # ifdef RT_BIG_ENDIAN /** @todo big endian mapping is wrong. */ 1272 /** The sign bit and exponent. */ 1273 uint16_t uSignAndExponent; 1274 /** The mantissa. */ 1275 uint64_t uMantissa; 1276 # else 1277 /** The mantissa. */ 1278 uint64_t uMantissa; 1279 /** The sign bit and exponent. */ 1280 uint16_t uSignAndExponent; 1281 # endif 1282 } s2; 1283 1235 1284 /** Bitfield exposing the J bit and the fraction. */ 1236 1285 RT_GCC_EXTENSION struct … … 1309 1358 1310 1359 #endif /* uint16_t bitfields doesn't work */ 1360 1361 1362 /** 1363 * Quadruple precision floating point format (128-bit). 1364 */ 1365 typedef union RTFLOAT128U 1366 { 1367 /** Format using regular bitfields. */ 1368 struct 1369 { 1370 # ifdef RT_BIG_ENDIAN 1371 /** The sign indicator. */ 1372 uint32_t fSign : 1; 1373 /** The exponent (offseted by 16383). */ 1374 uint32_t uExponent : 15; 1375 /** The fraction, bits 96 thru 111. */ 1376 uint32_t uFractionHigh : 16; 1377 /** The fraction, bits 64 thru 95. */ 1378 uint32_t uFractionMid; 1379 /** The fraction, bits 0 thru 63. */ 1380 uint64_t uFractionLow; 1381 # else 1382 /** The fraction, bits 0 thru 63. */ 1383 uint64_t uFractionLow; 1384 /** The fraction, bits 64 thru 95. */ 1385 uint32_t uFractionMid; 1386 /** The fraction, bits 96 thru 111. */ 1387 uint32_t uFractionHigh : 16; 1388 /** The exponent (offseted by 16383). */ 1389 uint32_t uExponent : 15; 1390 /** The sign indicator. */ 1391 uint32_t fSign : 1; 1392 # endif 1393 } s; 1394 1395 /** Format for accessing it as two separate components. */ 1396 struct 1397 { 1398 # ifdef RT_BIG_ENDIAN 1399 /** The sign bit and exponent. */ 1400 uint16_t uSignAndExponent; 1401 /** The fraction, bits 96 thru 111. */ 1402 uint16_t uFractionHigh; 1403 /** The fraction, bits 64 thru 95. */ 1404 uint32_t uFractionMid; 1405 /** The fraction, bits 0 thru 63. */ 1406 uint64_t uFractionLow; 1407 # else 1408 /** The fraction, bits 0 thru 63. */ 1409 uint64_t uFractionLow; 1410 /** The fraction, bits 64 thru 95. */ 1411 uint32_t uFractionMid; 1412 /** The fraction, bits 96 thru 111. */ 1413 uint16_t uFractionHigh; 1414 /** The sign bit and exponent. */ 1415 uint16_t uSignAndExponent; 1416 # endif 1417 } s2; 1418 1419 #ifdef RT_COMPILER_GROKS_64BIT_BITFIELDS 1420 /** Format using 64-bit bitfields. */ 1421 RT_GCC_EXTENSION struct 1422 { 1423 # ifdef RT_BIG_ENDIAN 1424 /** The sign indicator. */ 1425 RT_GCC_EXTENSION uint64_t fSign : 1; 1426 /** The exponent (offseted by 16383). */ 1427 RT_GCC_EXTENSION uint64_t uExponent : 15; 1428 /** The fraction, bits 64 thru 111. */ 1429 RT_GCC_EXTENSION uint64_t uFractionHi : 48; 1430 /** The fraction, bits 0 thru 63. */ 1431 uint64_t uFractionLo; 1432 # else 1433 /** The fraction, bits 0 thru 63. */ 1434 uint64_t uFractionLo; 1435 /** The fraction, bits 64 thru 111. */ 1436 RT_GCC_EXTENSION uint64_t uFractionHi : 48; 1437 /** The exponent (offseted by 16383). */ 1438 RT_GCC_EXTENSION uint64_t uExponent : 15; 1439 /** The sign indicator. */ 1440 RT_GCC_EXTENSION uint64_t fSign : 1; 1441 # endif 1442 } s64; 1443 #endif 1444 1445 #ifdef RT_COMPILER_WITH_128BIT_LONG_DOUBLE 1446 /** Long double view. */ 1447 long double lrd; 1448 #endif 1449 /** 128-bit view. */ 1450 RTUINT128U u128; 1451 /** 64-bit view. */ 1452 uint64_t au64[2]; 1453 /** 32-bit view. */ 1454 uint32_t au32[4]; 1455 /** 16-bit view. */ 1456 uint16_t au16[8]; 1457 /** 8-bit view. */ 1458 uint8_t au8[16]; 1459 } RTFLOAT128U; 1460 /** Pointer to a quadruple precision floating point format union. */ 1461 typedef RTFLOAT128U RT_FAR *PRTFLOAT128U; 1462 /** Pointer to a const quadruple precision floating point format union. */ 1463 typedef const RTFLOAT128U RT_FAR *PCRTFLOAT128U; 1464 /** RTFLOAT128U initializer. */ 1465 #ifdef RT_BIG_ENDIAN 1466 # define RTFLOAT128U_INIT(a_fSign, a_uFractionHi, a_uFractionLo, a_uExponent) \ 1467 { { (a_fSign), (a_uExponent), (uint32_t)((a_uFractionHi) >> 32), (uint32_t)((a_uFractionHi) & UINT32_MAX), (a_uFractionLo) } } 1468 #else 1469 # define RTFLOAT128U_INIT(a_fSign, a_uFractionHi, a_uFractionLo, a_uExponent) \ 1470 { { (a_uFractionLo), (uint32_t)((a_uFractionHi) & UINT32_MAX), (uint32_t)((a_uFractionHi) >> 32), (a_uExponent), (a_fSign) } } 1471 #endif 1472 #define RTFLOAT128U_INIT_C(a_fSign, a_uFractionHi, a_uFractionLo, a_uExponent) \ 1473 RTFLOAT128U_INIT((a_fSign), UINT64_C(a_uFractionHi), UINT64_C(a_uFractionLo), (a_uExponent)) 1474 /** The exponent bias for the RTFLOAT128U format. */ 1475 #define RTFLOAT128U_EXP_BIAS (16383) 1476 /** The max exponent value for the RTFLOAT128U format. */ 1477 #define RTFLOAT128U_EXP_MAX (32767) 1478 /** The exponent bias underflow adjust for the RTFLOAT128U format. 1479 * @note This is stipulated based on RTFLOAT80U, it doesn't appear in any 1480 * standard text as far as we know. */ 1481 #define RTFLOAT128U_EXP_BIAS_UNDERFLOW_ADJUST (24576) 1482 /** Fraction width (in bits) for the RTFLOAT128U format. */ 1483 #define RTFLOAT128U_FRACTION_BITS (112) 1484 /** Check if two 128-bit floating values are identical (memcmp, not 1485 * numerically). */ 1486 #define RTFLOAT128U_ARE_IDENTICAL(a_pLeft, a_pRight) \ 1487 ( (a_pLeft)->au64[0] == (a_pRight)->au64[0] && (a_pLeft)->au64[1] == (a_pRight)->au64[1] ) 1488 /** @name RTFLOAT128U classification macros 1489 * @{ */ 1490 #define RTFLOAT128U_IS_ZERO(a_pr128) ( (a_pr128)->u128.s.Lo == 0 \ 1491 && ((a_pr128)->u128.s.Hi & (RT_BIT_64(63) - 1)) == 0) 1492 #define RTFLOAT128U_IS_SUBNORMAL(a_pr128) ( (a_pr128)->s.uExponent == 0 \ 1493 && ( (a_pr128)->s.uFractionLow != 0 \ 1494 || (a_pr128)->s.uFractionMid != 0 \ 1495 || (a_pr128)->s.uFractionHigh != 0 ) ) 1496 #define RTFLOAT128U_IS_INF(a_pr128) ( (a_pr128)->s.uExponent == RTFLOAT128U_EXP_MAX \ 1497 && (a_pr128)->s.uFractionHigh == 0 \ 1498 && (a_pr128)->s.uFractionMid == 0 \ 1499 && (a_pr128)->s.uFractionLow == 0 ) 1500 #define RTFLOAT128U_IS_SIGNALLING_NAN(a_pr128) ( (a_pr128)->s.uExponent == RTFLOAT128U_EXP_MAX \ 1501 && !((a_pr128)->s.uFractionHigh & RT_BIT_32(15)) \ 1502 && ( (a_pr128)->s.uFractionHigh != 0 \ 1503 || (a_pr128)->s.uFractionMid != 0 \ 1504 || (a_pr128)->s.uFractionLow != 0) ) 1505 #define RTFLOAT128U_IS_QUIET_NAN(a_pr128) ( (a_pr128)->s.uExponent == RTFLOAT128U_EXP_MAX \ 1506 && ((a_pr128)->s.uFractionHigh & RT_BIT_32(15))) 1507 #define RTFLOAT128U_IS_NAN(a_pr128) ( (a_pr128)->s.uExponent == RTFLOAT128U_EXP_MAX \ 1508 && ( (a_pr128)->s.uFractionLow != 0 \ 1509 || (a_pr128)->s.uFractionMid != 0 \ 1510 || (a_pr128)->s.uFractionHigh != 0) ) 1511 #define RTFLOAT128U_IS_NORMAL(a_pr128) ((a_pr128)->s.uExponent > 0 && (a_pr128)->s.uExponent < RTFLOAT128U_EXP_MAX) 1512 /** @} */ 1311 1513 1312 1514
Note:
See TracChangeset
for help on using the changeset viewer.