VirtualBox

Changeset 35003 in vbox for trunk/include


Ignore:
Timestamp:
Dec 13, 2010 1:09:17 PM (14 years ago)
Author:
vboxsync
Message:

ASM: use preprocessor instead of compiler optimizations

File:
1 edited

Legend:

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

    r33540 r35003  
    19221922 * @param   puRes   Where to store the result.
    19231923 */
    1924 #define ASMAtomicReadSize(pu, puRes) \
     1924#if HC_ARCH_BITS == 32
     1925# define ASMAtomicReadSize(pu, puRes) \
    19251926    do { \
    1926         switch (sizeof(*(pu))) { \
    1927             case 1: *(uint8_t  *)(puRes) = ASMAtomicReadU8( (volatile uint8_t  *)(void *)(pu)); break; \
    1928             case 2: *(uint16_t *)(puRes) = ASMAtomicReadU16((volatile uint16_t *)(void *)(pu)); break; \
    1929             case 4: *(uint32_t *)(puRes) = ASMAtomicReadU32((volatile uint32_t *)(void *)(pu)); break; \
    1930             case 8: *(uint64_t *)(puRes) = ASMAtomicReadU64((volatile uint64_t *)(void *)(pu)); break; \
    1931             default: AssertMsgFailed(("ASMAtomicReadSize: size %d is not supported\n", sizeof(*(pu)))); \
    1932         } \
     1927        *(uint32_t *)(puRes) = ASMAtomicReadU32((volatile uint32_t *)(void *)(pu)); \
    19331928    } while (0)
     1929#elif HC_ARCH_BITS == 64
     1930# define ASMAtomicReadSize(pu, puRes) \
     1931    do { \
     1932        *(uint64_t *)(puRes) = ASMAtomicReadU64((volatile uint64_t *)(void *)(pu)); \
     1933    } while (0)
     1934#else
     1935# error HC_ARCH_BITS
     1936#endif
    19341937
    19351938
     
    19411944 * @param   puRes   Where to store the result.
    19421945 */
    1943 #define ASMAtomicUoReadSize(pu, puRes) \
     1946#if HC_ARCH_BITS == 32
     1947# define ASMAtomicUoReadSize(pu, puRes) \
    19441948    do { \
    1945         switch (sizeof(*(pu))) { \
    1946             case 1: *(uint8_t  *)(puRes) = ASMAtomicUoReadU8( (volatile uint8_t  *)(void *)(pu)); break; \
    1947             case 2: *(uint16_t *)(puRes) = ASMAtomicUoReadU16((volatile uint16_t *)(void *)(pu)); break; \
    1948             case 4: *(uint32_t *)(puRes) = ASMAtomicUoReadU32((volatile uint32_t *)(void *)(pu)); break; \
    1949             case 8: *(uint64_t *)(puRes) = ASMAtomicUoReadU64((volatile uint64_t *)(void *)(pu)); break; \
    1950             default: AssertMsgFailed(("ASMAtomicReadSize: size %d is not supported\n", sizeof(*(pu)))); \
    1951         } \
     1949        *(uint32_t *)(puRes) = ASMAtomicUoReadU32((volatile uint32_t *)(void *)(pu)); \
    19521950    } while (0)
    1953 
     1951#elif HC_ARCH_BITS == 64
     1952# define ASMAtomicUoReadSize(pu, puRes) \
     1953    do { \
     1954        *(uint64_t *)(puRes) = ASMAtomicUoReadU64((volatile uint64_t *)(void *)(pu)); \
     1955    } while (0)
     1956#else
     1957# error HC_ARCH_BITS
     1958#endif
    19541959
    19551960/**
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