VirtualBox

Changeset 8277 in vbox for trunk/include


Ignore:
Timestamp:
Apr 22, 2008 11:56:47 AM (17 years ago)
Author:
vboxsync
Message:

indent. put the remarks on the group definition.

File:
1 edited

Legend:

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

    r8275 r8277  
    3838 * Defined as 1 if we're using a _MSC_VER 1400.
    3939 * Otherwise defined as 0.
    40  */
    41 
    42 /** @note
    43  *
    44  * Some remarks about __volatile__: Without this keyword gcc is allowed to reorder
    45  * or even optimize assembler instructions away. For instance, in the following code
    46  * the second rdmsr instruction is optimized away because gcc treats that instruction
    47  * as deterministic:
    48  *
    49  *   @code
    50  *   static inline uint64_t rdmsr_low(idx)
    51  *   {
    52  *     uint32_t low;
    53  *     __asm__ ("rdmsr" : "=a"(low) : "c"(idx) : "edx");
    54  *   }
    55  *   ...
    56  *   uint32_t msr1 = rdmsr(1);
    57  *   foo(msr1);
    58  *   msr1 = rdmsr(1);
    59  *   bar(msr1);
    60  *   @endcode
    61  *
    62  * The input parameter of rdmsr_low is the same for both calls and therefore gcc will
    63  * use the result of the first call as input parameter for bar() as well. For rdmsr this
    64  * is not acceptable as this instruction is _not_ deterministic. This applies to reading
    65  * machine status information in general.
    6640 */
    6741
     
    141115 *          are unordered (note the Uo).
    142116 *
     117 * @remarks Some remarks about __volatile__: Without this keyword gcc is allowed to reorder
     118 *          or even optimize assembler instructions away. For instance, in the following code
     119 *          the second rdmsr instruction is optimized away because gcc treats that instruction
     120 *          as deterministic:
     121 *
     122 *            @code
     123 *            static inline uint64_t rdmsr_low(int idx)
     124 *            {
     125 *              uint32_t low;
     126 *              __asm__ ("rdmsr" : "=a"(low) : "c"(idx) : "edx");
     127 *            }
     128 *            ...
     129 *            uint32_t msr1 = rdmsr_low(1);
     130 *            foo(msr1);
     131 *            msr1 = rdmsr_low(1);
     132 *            bar(msr1);
     133 *            @endcode
     134 *
     135 *          The input parameter of rdmsr_low is the same for both calls and therefore gcc will
     136 *          use the result of the first call as input parameter for bar() as well. For rdmsr this
     137 *          is not acceptable as this instruction is _not_ deterministic. This applies to reading
     138 *          machine status information in general.
     139 *
    143140 * @{
    144141 */
     
    13881385    RTUINT64U u;
    13891386# if RT_INLINE_ASM_GNU_STYLE
    1390     __asm__ __volatile__ ("rdmsr\n\t"
    1391              : "=a" (u.s.Lo),
    1392                "=d" (u.s.Hi)
    1393              : "c" (uRegister));
     1387    __asm__ __volatile__("rdmsr\n\t"
     1388                         : "=a" (u.s.Lo),
     1389                           "=d" (u.s.Hi)
     1390                         : "c" (uRegister));
    13941391
    13951392# elif RT_INLINE_ASM_USES_INTRIN
     
    14621459# if RT_INLINE_ASM_GNU_STYLE
    14631460    __asm__ __volatile__("rdmsr\n\t"
    1464              : "=a" (u32)
    1465              : "c" (uRegister)
    1466              : "edx");
     1461                         : "=a" (u32)
     1462                         : "c" (uRegister)
     1463                         : "edx");
    14671464
    14681465# elif RT_INLINE_ASM_USES_INTRIN
     
    14971494# if RT_INLINE_ASM_GNU_STYLE
    14981495    __asm__ __volatile__("rdmsr\n\t"
    1499              : "=d" (u32)
    1500              : "c" (uRegister)
    1501              : "eax");
     1496                         : "=d" (u32)
     1497                         : "c" (uRegister)
     1498                         : "eax");
    15021499
    15031500# elif RT_INLINE_ASM_USES_INTRIN
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