VirtualBox

Changeset 11413 in vbox for trunk/src/VBox/Runtime/generic


Ignore:
Timestamp:
Aug 14, 2008 8:03:03 AM (17 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
34729
Message:

Runtime: small fix to the UUID code, splitting the ClockSeq field and put the UUID variant in the right place. Rest is cleanup and documenting that the IPRT UUIDs are little endian.

Location:
trunk/src/VBox/Runtime/generic
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Runtime/generic/RTUuidCreate-generic.cpp

    r9744 r11413  
    3939
    4040
    41 /* WARNING: This implementation ASSUMES little endian. Needs testing on big endian! */
     41/* WARNING: This implementation ASSUMES little endian. Does not work on big endian! */
     42
     43/* Remember, the time fields in the UUID must be little endian. */
    4244
    4345
     
    4850
    4951    RTRandBytes(pUuid, sizeof(*pUuid));
    50     pUuid->Gen.u16ClockSeq = (pUuid->Gen.u16ClockSeq & 0x3fff) | 0x8000;
     52    pUuid->Gen.u8ClockSeqHiAndReserved = (pUuid->Gen.u8ClockSeqHiAndReserved & 0x3f) | 0x80;
    5153    pUuid->Gen.u16TimeHiAndVersion = (pUuid->Gen.u16TimeHiAndVersion & 0x0fff) | 0x4000;
    5254
  • trunk/src/VBox/Runtime/generic/uuid-generic.cpp

    r9743 r11413  
    3838
    3939
    40 /* WARNING: This implementation ASSUMES little endian. Needs testing on big endian! */
     40/* WARNING: This implementation ASSUMES little endian. Does not work on big endian! */
     41
     42/* Remember, the time fields in the UUID must be little endian. */
    4143
    4244
     
    8183    if (pUuid1->Gen.u16TimeHiAndVersion != pUuid2->Gen.u16TimeHiAndVersion)
    8284        return pUuid1->Gen.u16TimeHiAndVersion < pUuid2->Gen.u16TimeHiAndVersion ? -1 : 1;
    83     if (pUuid1->Gen.u16ClockSeq != pUuid2->Gen.u16ClockSeq)
    84         return pUuid1->Gen.u16ClockSeq < pUuid2->Gen.u16ClockSeq ? -1 : 1;
     85    if (pUuid1->Gen.u8ClockSeqHiAndReserved != pUuid2->Gen.u8ClockSeqHiAndReserved)
     86        return pUuid1->Gen.u8ClockSeqHiAndReserved < pUuid2->Gen.u8ClockSeqHiAndReserved ? -1 : 1;
     87    if (pUuid1->Gen.u8ClockSeqLow != pUuid2->Gen.u8ClockSeqLow)
     88        return pUuid1->Gen.u8ClockSeqLow < pUuid2->Gen.u8ClockSeqLow ? -1 : 1;
    8589    if (pUuid1->Gen.au8Node[0] != pUuid2->Gen.au8Node[0])
    8690        return pUuid1->Gen.au8Node[0] < pUuid2->Gen.au8Node[0] ? -1 : 1;
     
    160164    pszString[17] = s_achDigits[(u/*>>0*/)& 0xf];
    161165    pszString[18] = '-';
    162     u = pUuid->Gen.u16ClockSeq;
    163     pszString[19] = s_achDigits[(u >>  4) & 0xf];
    164     pszString[20] = s_achDigits[(u/*>>0*/)& 0xf];
    165     pszString[21] = s_achDigits[(u >> 12)/*& 0xf*/];
    166     pszString[22] = s_achDigits[(u >>  8) & 0xf];
     166    pszString[19] = s_achDigits[pUuid->Gen.u8ClockSeqHiAndReserved >> 4];
     167    pszString[20] = s_achDigits[pUuid->Gen.u8ClockSeqHiAndReserved & 0xf];
     168    pszString[21] = s_achDigits[pUuid->Gen.u8ClockSeqLow >> 4];
     169    pszString[22] = s_achDigits[pUuid->Gen.u8ClockSeqLow & 0xf];
    167170    pszString[23] = '-';
    168171    pszString[24] = s_achDigits[pUuid->Gen.au8Node[0] >> 4];
     
    276279                          | (uint16_t)MY_TONUM(pszString[16]) << 4
    277280                          | (uint16_t)MY_TONUM(pszString[17]);
    278     pUuid->Gen.u16ClockSeq =(uint16_t)MY_TONUM(pszString[19]) << 4
    279                           | (uint16_t)MY_TONUM(pszString[20])
    280                           | (uint16_t)MY_TONUM(pszString[21]) << 12
    281                           | (uint16_t)MY_TONUM(pszString[22]) << 8;
     281    pUuid->Gen.u8ClockSeqHiAndReserved =
     282                            (uint16_t)MY_TONUM(pszString[19]) << 4
     283                          | (uint16_t)MY_TONUM(pszString[20]);
     284    pUuid->Gen.u8ClockSeqLow =
     285                            (uint16_t)MY_TONUM(pszString[21]) << 4
     286                          | (uint16_t)MY_TONUM(pszString[22]);
    282287    pUuid->Gen.au8Node[0] = (uint8_t)MY_TONUM(pszString[24]) << 4
    283288                          | (uint8_t)MY_TONUM(pszString[25]);
Note: See TracChangeset for help on using the changeset viewer.

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