VirtualBox

Changeset 94253 in vbox for trunk/include/iprt/types.h


Ignore:
Timestamp:
Mar 15, 2022 10:32:54 PM (3 years ago)
Author:
vboxsync
Message:

iprt/types.h: Added a sj64 member to RTFLOAT80U as well as RTFLOAT80U_INIT and RTFLOAT80U_INIT_C for initializers and RTFLOAT80U_ARE_IDENTICAL for comparing. Moved the optional 'long double' member of RTFLOAT80U2 down so we can use initializers with the union. bugref:9898

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/iprt/types.h

    r93906 r94253  
    978978 * Extended Double precision floating point format (80-bit).
    979979 */
    980 #pragma pack(1)
     980# pragma pack(1)
    981981typedef union RTFLOAT80U
    982982{
     
    10011001    } s;
    10021002
     1003# ifdef RT_COMPILER_GROKS_64BIT_BITFIELDS
     1004    /** 64-bit bitfields exposing the J bit and the fraction.  */
     1005    RT_GCC_EXTENSION struct
     1006    {
     1007#  ifdef RT_BIG_ENDIAN
     1008        /** The sign indicator. */
     1009        RT_GCC_EXTENSION uint16_t   fSign : 1;
     1010        /** The exponent (offseted by 16383). */
     1011        RT_GCC_EXTENSION uint16_t   uExponent : 15;
     1012        /** The J bit, aka the integer bit. */
     1013        RT_GCC_EXTENSION uint64_t   fInteger : 1;
     1014        /** The fraction. */
     1015        RT_GCC_EXTENSION uint64_t   u63Fraction : 63;
     1016#  else
     1017        /** The fraction. */
     1018        RT_GCC_EXTENSION uint64_t   u63Fraction : 63;
     1019        /** The J bit, aka the integer bit. */
     1020        RT_GCC_EXTENSION uint64_t   fInteger : 1;
     1021        /** The exponent (offseted by 16383). */
     1022        RT_GCC_EXTENSION uint16_t   uExponent : 15;
     1023        /** The sign indicator. */
     1024        RT_GCC_EXTENSION uint16_t   fSign : 1;
     1025#  endif
     1026    } sj64;
     1027# endif
     1028
    10031029    /** 64-bit view. */
    10041030    uint64_t    au64[1];
     
    10101036    uint8_t     au8[10];
    10111037} RTFLOAT80U;
    1012 #pragma pack()
     1038# pragma pack()
    10131039/** Pointer to a extended precision floating point format union. */
    10141040typedef RTFLOAT80U RT_FAR *PRTFLOAT80U;
    10151041/** Pointer to a const extended precision floating point format union. */
    10161042typedef const RTFLOAT80U RT_FAR *PCRTFLOAT80U;
     1043/** RTFLOAT80U initializer. */
     1044# ifdef RT_BIG_ENDIAN
     1045#  define RTFLOAT80U_INIT(a_fSign, a_uMantissa, a_uExponent)  { { (a_fSign), (a_uExponent), (a_uMantissa) } }
     1046# else
     1047#  define RTFLOAT80U_INIT(a_fSign, a_uMantissa, a_uExponent)  { { (a_uMantissa), (a_uExponent), (a_fSign) } }
     1048# endif
     1049# define RTFLOAT80U_INIT_C(a_fSign, a_uMantissa, a_uExponent) RTFLOAT80U_INIT((a_fSign), (a_uExponent), UINT64_C(a_uMantissa))
     1050
     1051/** Check if two 80-bit floating values are identical (memcmp, not
     1052 *  numberically). */
     1053# define RTFLOAT80U_ARE_IDENTICAL(a_pLeft, a_pRight) \
     1054    (   (a_pLeft)->au64[0] == (a_pRight)->au64[0] \
     1055     && (a_pLeft)->au16[4] == (a_pRight)->au16[4] )
    10171056
    10181057
     
    10201059 * A variant of RTFLOAT80U that may be larger than 80-bits depending on how the
    10211060 * compiler implements long double.
    1022  */
    1023 #pragma pack(1)
     1061 *
     1062 * @note On AMD64 systems implementing the System V ABI, this will be 16 bytes!
     1063 *       The last 6 bytes are unused padding taken up by the long double view.
     1064 */
     1065# pragma pack(1)
    10241066typedef union RTFLOAT80U2
    10251067{
    1026 #ifdef RT_COMPILER_WITH_80BIT_LONG_DOUBLE
    1027     /** Long double view. */
    1028     long double     lrd;
    1029 #endif
    10301068    /** Format using bitfields.  */
    10311069    RT_GCC_EXTENSION struct
    10321070    {
    1033 #ifdef RT_BIG_ENDIAN
     1071# ifdef RT_BIG_ENDIAN
    10341072        /** The sign indicator. */
    10351073        RT_GCC_EXTENSION uint16_t   fSign : 1;
     
    10381076        /** The mantissa. */
    10391077        uint64_t                    u64Mantissa;
    1040 #else
     1078# else
    10411079        /** The mantissa. */
    10421080        uint64_t                    u64Mantissa;
     
    10451083        /** The sign indicator. */
    10461084        RT_GCC_EXTENSION uint16_t   fSign : 1;
    1047 #endif
     1085# endif
    10481086    } s;
    10491087
    10501088    /** Bitfield exposing the J bit and the fraction.  */
    1051     RT_GCC_EXTENSION struct
    1052     {
    1053 #ifdef RT_BIG_ENDIAN
    1054         /** The sign indicator. */
    1055         RT_GCC_EXTENSION uint16_t   fSign : 1;
    1056         /** The exponent (offseted by 16383). */
    1057         RT_GCC_EXTENSION uint16_t   uExponent : 15;
    1058         /** The J bit, aka the integer bit. */
    1059         uint32_t                    fInteger;
    1060         /** The fraction, bits 32 thru 62. */
    1061         uint32_t                    u31FractionHigh : 31;
    1062         /** The fraction, bits 0 thru 31. */
    1063         uint32_t                    u32FractionLow : 32;
    1064 #else
    1065         /** The fraction, bits 0 thru 31. */
    1066         uint32_t                    u32FractionLow : 32;
    1067         /** The fraction, bits 32 thru 62. */
    1068         uint32_t                    u31FractionHigh : 31;
    1069         /** The J bit, aka the integer bit. */
    1070         uint32_t                    fInteger;
    1071         /** The exponent (offseted by 16383). */
    1072         RT_GCC_EXTENSION uint16_t   uExponent : 15;
    1073         /** The sign indicator. */
    1074         RT_GCC_EXTENSION uint16_t   fSign : 1;
    1075 #endif
    1076     } sj;
    1077 
    1078 #ifdef RT_COMPILER_GROKS_64BIT_BITFIELDS
    1079     /** 64-bit bitfields exposing the J bit and the fraction.  */
    10801089    RT_GCC_EXTENSION struct
    10811090    {
     
    10861095        RT_GCC_EXTENSION uint16_t   uExponent : 15;
    10871096        /** The J bit, aka the integer bit. */
     1097        uint32_t                    fInteger : 1;
     1098        /** The fraction, bits 32 thru 62. */
     1099        uint32_t                    u31FractionHigh : 31;
     1100        /** The fraction, bits 0 thru 31. */
     1101        uint32_t                    u32FractionLow : 32;
     1102# else
     1103        /** The fraction, bits 0 thru 31. */
     1104        uint32_t                    u32FractionLow : 32;
     1105        /** The fraction, bits 32 thru 62. */
     1106        uint32_t                    u31FractionHigh : 31;
     1107        /** The J bit, aka the integer bit. */
     1108        uint32_t                    fInteger : 1;
     1109        /** The exponent (offseted by 16383). */
     1110        RT_GCC_EXTENSION uint16_t   uExponent : 15;
     1111        /** The sign indicator. */
     1112        RT_GCC_EXTENSION uint16_t   fSign : 1;
     1113# endif
     1114    } sj;
     1115
     1116# ifdef RT_COMPILER_GROKS_64BIT_BITFIELDS
     1117    /** 64-bit bitfields exposing the J bit and the fraction.  */
     1118    RT_GCC_EXTENSION struct
     1119    {
     1120#  ifdef RT_BIG_ENDIAN
     1121        /** The sign indicator. */
     1122        RT_GCC_EXTENSION uint16_t   fSign : 1;
     1123        /** The exponent (offseted by 16383). */
     1124        RT_GCC_EXTENSION uint16_t   uExponent : 15;
     1125        /** The J bit, aka the integer bit. */
    10881126        RT_GCC_EXTENSION uint64_t   fInteger : 1;
    10891127        /** The fraction. */
    10901128        RT_GCC_EXTENSION uint64_t   u63Fraction : 63;
    1091 # else
     1129#  else
    10921130        /** The fraction. */
    10931131        RT_GCC_EXTENSION uint64_t   u63Fraction : 63;
     
    10981136        /** The sign indicator. */
    10991137        RT_GCC_EXTENSION uint16_t   fSign : 1;
     1138#  endif
     1139    } sj64;
    11001140# endif
    1101     } sj64;
    1102 #endif
    1103 
     1141
     1142# ifdef RT_COMPILER_WITH_80BIT_LONG_DOUBLE
     1143    /** Long double view. */
     1144    long double lrd;
     1145# endif
    11041146    /** 64-bit view. */
    11051147    uint64_t    au64[1];
     
    11111153    uint8_t     au8[10];
    11121154} RTFLOAT80U2;
    1113 #pragma pack()
     1155# pragma pack()
    11141156/** Pointer to a extended precision floating point format union, 2nd
    11151157 * variant. */
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette