VirtualBox

Changeset 2304

Show
Ignore:
Timestamp:
04/21/07 03:23:53 (2 years ago)
Author:
vboxsync
Message:

ASMMemoryClobber -> ASMCompilerBarrier + MSC (untested)

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/include/iprt/asm.h

    r2252 r2304  
    3131 
    3232#ifdef _MSC_VER 
     33# pragma intrinsic(_ReadWriteBarrier) 
    3334# if _MSC_VER >= 1400 
    3435#  define RT_INLINE_ASM_USES_INTRIN 1 
     
    15061507 
    15071508/** 
    1508  * Ensure that gcc does not use any register value before this instruction. This function is used 
    1509  * for assembler instructions with side-effects, e.g. port writes to magical guest ports causing 
    1510  * guest memory changes by the host 
    1511  * 
    1512  * @todo r=bird: There are two things I don't like there, 1) the name and 2) what about msc? 
    1513  * 
    1514  *      Unless I'm not much mistaken this construct is what is 'barrier' or 'mb' in the linux  
    1515  *      kernel. The ASMMem is used as prefix elsewhere in this file, so ASMMemory* is a confusing 
    1516  *      way to name a new function. I think a more fitting name would be ASMCompilerBarrier,  
    1517  *      ASMCompilerMemoryBarrier, or perhaps ASMMemBarrier. 
    1518  * 
    1519  *      For MSC I guess _ReadWriteBarrier is what we're looking for.  
    1520  *      See http://msdn2.microsoft.com/en-us/library/f20w0x5e(VS.80).aspx 
    1521  * 
    1522  *      We should also add a little note about considering using 'volatile' similar to the one found  
    1523  *      with the _ReadWriteBarrier docs. 
    1524  */ 
     1509 * Compiler memory barrier. 
     1510 *  
     1511 * Ensure that the compiler does not use any cached (register/tmp stack) memory  
     1512 * values or any outstanding writes when returning from this function. 
     1513 *  
     1514 * This function must be used if non-volatile data is modified by a  
     1515 * device or the VMM. Typical cases are port access, MMIO access,  
     1516 * trapping instruction, etc. 
     1517 */ 
     1518DECLINLINE(void) ASMCompilerBarrier(void) 
     1519
    15251520#if RT_INLINE_ASM_GNU_STYLE 
    1526 DECLINLINE(void) ASMMemoryClobber(void) 
    1527 { 
    15281521    __asm__ __volatile__ ("" : : : "memory"); 
    1529 
    1530 #else 
    1531 DECLINLINE(void) ASMMemoryClobber(void) 
    1532 
    1533 
    1534 #endif 
     1522#else 
     1523    _ReadWriteBarrier(); 
     1524#endif  
     1525
     1526 
    15351527 
    15361528/** 
  • trunk/src/VBox/Additions/common/VBoxGuestLib/GenericRequest.cpp

    r2197 r2304  
    8686        ASMOutU32(g_vbgldata.portVMMDev + PORT_VMMDEV_REQUEST_OFFSET, (uint32_t)physaddr); 
    8787        /* Make the compiler aware that the host has changed memory. */ 
    88         ASMMemoryClobber(); 
     88        ASMCompilerBarrier(); 
    8989        rc = pReq->rc; 
    9090    } 

© 2008 Sun Microsystems, Inc.
ContactPrivacy policy