VirtualBox

Changeset 40988 in vbox


Ignore:
Timestamp:
Apr 19, 2012 1:25:45 PM (13 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
77546
Message:

Runtime/Uuid: Treat UUIDs the same on little and big endian architectures

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

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Runtime/common/string/strformatrt.cpp

    r40938 r40988  
    4949#include <iprt/net.h>
    5050#include <iprt/path.h>
     51#include <iprt/asm.h>
    5152#define STRFORMAT_WITH_X86
    5253#ifdef STRFORMAT_WITH_X86
     
    517518                            return RTStrFormat(pfnOutput, pvArgOutput, NULL, 0,
    518519                                               "%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x",
    519                                                u.pUuid->Gen.u32TimeLow,
    520                                                u.pUuid->Gen.u16TimeMid,
    521                                                u.pUuid->Gen.u16TimeHiAndVersion,
     520                                               RT_H2LE_U32(u.pUuid->Gen.u32TimeLow),
     521                                               RT_H2LE_U16(u.pUuid->Gen.u16TimeMid),
     522                                               RT_H2LE_U16(u.pUuid->Gen.u16TimeHiAndVersion),
    522523                                               u.pUuid->Gen.u8ClockSeqHiAndReserved,
    523524                                               u.pUuid->Gen.u8ClockSeqLow,
  • trunk/src/VBox/Runtime/generic/uuid-generic.cpp

    r32995 r40988  
    3434#include <iprt/assert.h>
    3535#include <iprt/err.h>
     36#include <iprt/asm.h>
    3637
    3738
     
    201202     *             pUuid->Gen.au8Node[5]);
    202203     */
    203     u32TimeLow = pUuid->Gen.u32TimeLow;
     204    u32TimeLow = RT_H2LE_U32(pUuid->Gen.u32TimeLow);
    204205    pszString[ 0] = g_achDigits[(u32TimeLow >> 28)/*& 0xf*/];
    205206    pszString[ 1] = g_achDigits[(u32TimeLow >> 24) & 0xf];
     
    211212    pszString[ 7] = g_achDigits[(u32TimeLow/*>>0*/)& 0xf];
    212213    pszString[ 8] = '-';
    213     u = pUuid->Gen.u16TimeMid;
     214    u = RT_H2LE_U16(pUuid->Gen.u16TimeMid);
    214215    pszString[ 9] = g_achDigits[(u >> 12)/*& 0xf*/];
    215216    pszString[10] = g_achDigits[(u >>  8) & 0xf];
     
    217218    pszString[12] = g_achDigits[(u/*>>0*/)& 0xf];
    218219    pszString[13] = '-';
    219     u = pUuid->Gen.u16TimeHiAndVersion;
     220    u = RT_H2LE_U16(pUuid->Gen.u16TimeHiAndVersion);
    220221    pszString[14] = g_achDigits[(u >> 12)/*& 0xf*/];
    221222    pszString[15] = g_achDigits[(u >>  8) & 0xf];
     
    308309     */
    309310#define MY_TONUM(ch) (g_au8Digits[(ch) & 0xff])
    310     pUuid->Gen.u32TimeLow = (uint32_t)MY_TONUM(pszString[ 0]) << 28
     311    pUuid->Gen.u32TimeLow = RT_LE2H_U32((uint32_t)MY_TONUM(pszString[ 0]) << 28
    311312                          | (uint32_t)MY_TONUM(pszString[ 1]) << 24
    312313                          | (uint32_t)MY_TONUM(pszString[ 2]) << 20
     
    315316                          | (uint32_t)MY_TONUM(pszString[ 5]) <<  8
    316317                          | (uint32_t)MY_TONUM(pszString[ 6]) <<  4
    317                           | (uint32_t)MY_TONUM(pszString[ 7]);
    318     pUuid->Gen.u16TimeMid = (uint16_t)MY_TONUM(pszString[ 9]) << 12
     318                          | (uint32_t)MY_TONUM(pszString[ 7]));
     319    pUuid->Gen.u16TimeMid = RT_LE2H_U16((uint16_t)MY_TONUM(pszString[ 9]) << 12
    319320                          | (uint16_t)MY_TONUM(pszString[10]) << 8
    320321                          | (uint16_t)MY_TONUM(pszString[11]) << 4
    321                           | (uint16_t)MY_TONUM(pszString[12]);
    322     pUuid->Gen.u16TimeHiAndVersion =
     322                          | (uint16_t)MY_TONUM(pszString[12]));
     323    pUuid->Gen.u16TimeHiAndVersion = RT_LE2H_U16(
    323324                            (uint16_t)MY_TONUM(pszString[14]) << 12
    324325                          | (uint16_t)MY_TONUM(pszString[15]) << 8
    325326                          | (uint16_t)MY_TONUM(pszString[16]) << 4
    326                           | (uint16_t)MY_TONUM(pszString[17]);
     327                          | (uint16_t)MY_TONUM(pszString[17]));
    327328    pUuid->Gen.u8ClockSeqHiAndReserved =
    328329                            (uint16_t)MY_TONUM(pszString[19]) << 4
     
    373374     *             pUuid->Gen.au8Node[5]);
    374375     */
    375     u32TimeLow = pUuid->Gen.u32TimeLow;
     376    u32TimeLow = RT_H2LE_U32(pUuid->Gen.u32TimeLow);
    376377    pwszString[ 0] = g_achDigits[(u32TimeLow >> 28)/*& 0xf*/];
    377378    pwszString[ 1] = g_achDigits[(u32TimeLow >> 24) & 0xf];
     
    383384    pwszString[ 7] = g_achDigits[(u32TimeLow/*>>0*/)& 0xf];
    384385    pwszString[ 8] = '-';
    385     u = pUuid->Gen.u16TimeMid;
     386    u = RT_H2LE_U16(pUuid->Gen.u16TimeMid);
    386387    pwszString[ 9] = g_achDigits[(u >> 12)/*& 0xf*/];
    387388    pwszString[10] = g_achDigits[(u >>  8) & 0xf];
     
    389390    pwszString[12] = g_achDigits[(u/*>>0*/)& 0xf];
    390391    pwszString[13] = '-';
    391     u = pUuid->Gen.u16TimeHiAndVersion;
     392    u = RT_H2LE_U16(pUuid->Gen.u16TimeHiAndVersion);
    392393    pwszString[14] = g_achDigits[(u >> 12)/*& 0xf*/];
    393394    pwszString[15] = g_achDigits[(u >>  8) & 0xf];
     
    480481     */
    481482#define MY_TONUM(ch) (g_au8Digits[(ch) & 0xff])
    482     pUuid->Gen.u32TimeLow = (uint32_t)MY_TONUM(pwszString[ 0]) << 28
     483    pUuid->Gen.u32TimeLow = RT_LE2H_U32((uint32_t)MY_TONUM(pwszString[ 0]) << 28
    483484                          | (uint32_t)MY_TONUM(pwszString[ 1]) << 24
    484485                          | (uint32_t)MY_TONUM(pwszString[ 2]) << 20
     
    487488                          | (uint32_t)MY_TONUM(pwszString[ 5]) <<  8
    488489                          | (uint32_t)MY_TONUM(pwszString[ 6]) <<  4
    489                           | (uint32_t)MY_TONUM(pwszString[ 7]);
    490     pUuid->Gen.u16TimeMid = (uint16_t)MY_TONUM(pwszString[ 9]) << 12
     490                          | (uint32_t)MY_TONUM(pwszString[ 7]));
     491    pUuid->Gen.u16TimeMid = RT_LE2H_U16((uint16_t)MY_TONUM(pwszString[ 9]) << 12
    491492                          | (uint16_t)MY_TONUM(pwszString[10]) << 8
    492493                          | (uint16_t)MY_TONUM(pwszString[11]) << 4
    493                           | (uint16_t)MY_TONUM(pwszString[12]);
    494     pUuid->Gen.u16TimeHiAndVersion =
     494                          | (uint16_t)MY_TONUM(pwszString[12]));
     495    pUuid->Gen.u16TimeHiAndVersion = RT_LE2H_U16(
    495496                            (uint16_t)MY_TONUM(pwszString[14]) << 12
    496497                          | (uint16_t)MY_TONUM(pwszString[15]) << 8
    497498                          | (uint16_t)MY_TONUM(pwszString[16]) << 4
    498                           | (uint16_t)MY_TONUM(pwszString[17]);
     499                          | (uint16_t)MY_TONUM(pwszString[17]));
    499500    pUuid->Gen.u8ClockSeqHiAndReserved =
    500501                            (uint16_t)MY_TONUM(pwszString[19]) << 4
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