VirtualBox

Changeset 85755 in vbox for trunk/src/VBox


Ignore:
Timestamp:
Aug 14, 2020 8:34:17 AM (5 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
139904
Message:

Devices/EFI/FirmwarNew/VBoxPkg: Fix compilation on MSVC, bugref:4643

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/EFI/FirmwareNew/VBoxPkg/Library/VBoxDebugLib/VBoxPrintHex.c

    r82968 r85755  
    6060    switch (cbType)
    6161    {
     62/*
     63 * We have to cast the result to UINTN before indexing into the array
     64 * or cl.exe insists on generating a call to __allmul for unoptimized 32bit builds,
     65 * see: https://patchew.org/EDK2/[email protected]/
     66 */
     67#define VAL_NIBBLE_EXTRACT(a_uValue, a_iNibbleStart) (s_szHex[(UINTN)(RShiftU64((a_uValue), (a_iNibbleStart)) & 0xf)])
    6268        case 8:
    63             vboxPrintHexChar(s_szHex[RShiftU64(uValue, 60) & 0xf]);
    64             vboxPrintHexChar(s_szHex[RShiftU64(uValue, 56) & 0xf]);
    65             vboxPrintHexChar(s_szHex[RShiftU64(uValue, 52) & 0xf]);
    66             vboxPrintHexChar(s_szHex[RShiftU64(uValue, 48) & 0xf]);
    67             vboxPrintHexChar(s_szHex[RShiftU64(uValue, 44) & 0xf]);
    68             vboxPrintHexChar(s_szHex[RShiftU64(uValue, 40) & 0xf]);
    69             vboxPrintHexChar(s_szHex[RShiftU64(uValue, 36) & 0xf]);
    70             vboxPrintHexChar(s_szHex[RShiftU64(uValue, 32) & 0xf]);
     69            vboxPrintHexChar(VAL_NIBBLE_EXTRACT(uValue, 60));
     70            vboxPrintHexChar(VAL_NIBBLE_EXTRACT(uValue, 56));
     71            vboxPrintHexChar(VAL_NIBBLE_EXTRACT(uValue, 52));
     72            vboxPrintHexChar(VAL_NIBBLE_EXTRACT(uValue, 48));
     73            vboxPrintHexChar(VAL_NIBBLE_EXTRACT(uValue, 44));
     74            vboxPrintHexChar(VAL_NIBBLE_EXTRACT(uValue, 40));
     75            vboxPrintHexChar(VAL_NIBBLE_EXTRACT(uValue, 36));
     76            vboxPrintHexChar(VAL_NIBBLE_EXTRACT(uValue, 32));
    7177        case 4:
    72             vboxPrintHexChar(s_szHex[RShiftU64(uValue, 28) & 0xf]);
    73             vboxPrintHexChar(s_szHex[RShiftU64(uValue, 24) & 0xf]);
    74             vboxPrintHexChar(s_szHex[RShiftU64(uValue, 20) & 0xf]);
    75             vboxPrintHexChar(s_szHex[RShiftU64(uValue, 16) & 0xf]);
     78            vboxPrintHexChar(VAL_NIBBLE_EXTRACT(uValue, 28));
     79            vboxPrintHexChar(VAL_NIBBLE_EXTRACT(uValue, 24));
     80            vboxPrintHexChar(VAL_NIBBLE_EXTRACT(uValue, 20));
     81            vboxPrintHexChar(VAL_NIBBLE_EXTRACT(uValue, 16));
    7682        case 2:
    77             vboxPrintHexChar(s_szHex[RShiftU64(uValue, 12) & 0xf]);
    78             vboxPrintHexChar(s_szHex[RShiftU64(uValue,  8) & 0xf]);
     83            vboxPrintHexChar(VAL_NIBBLE_EXTRACT(uValue, 12));
     84            vboxPrintHexChar(VAL_NIBBLE_EXTRACT(uValue,  8));
    7985        case 1:
    80             vboxPrintHexChar(s_szHex[RShiftU64(uValue,  4) & 0xf]);
    81             vboxPrintHexChar(s_szHex[         (uValue    ) & 0xf]);
     86            vboxPrintHexChar(VAL_NIBBLE_EXTRACT(uValue,  4));
     87            vboxPrintHexChar(VAL_NIBBLE_EXTRACT(uValue,  0));
    8288            break;
     89#undef VAL_NIBBLE_EXTRACT
    8390    }
    84     return cbType * 2;
     91
     92#if 0 /* There is no MultU32x32 for 32bit and cl insists on emitting __allmul otherwise so we just hardcode everything here... */
     93    return cbType * 2;
     94#else
     95    static size_t s_acbPrinted[9] = { 0, 2, 4, 0, 8, 0, 0, 0, 16};
     96    if (cbType < RT_ELEMENTS(s_acbPrinted))
     97        return s_acbPrinted[cbType];
     98    return 0;
     99#endif
    85100}
    86 
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