VirtualBox

Changeset 103017 in vbox for trunk


Ignore:
Timestamp:
Jan 24, 2024 1:05:51 AM (8 months ago)
Author:
vboxsync
Message:

iprt/asm-mem.h: Eliminated the unused ASMProbeReadBuffer.

Location:
trunk
Files:
2 edited

Legend:

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

    r103014 r103017  
    7272 * @{
    7373 */
    74 
    75 #if defined(DOXYGEN_RUNNING) || defined(RT_ASM_INCLUDE_PAGE_SIZE)
    76 /** @def RT_ASM_PAGE_SIZE
    77  * We try avoid dragging in iprt/param.h here.
    78  * @internal
    79  */
    80 # if defined(RT_ARCH_SPARC64)
    81 #  define RT_ASM_PAGE_SIZE   0x2000
    82 #  if defined(PAGE_SIZE) && !defined(NT_INCLUDED)
    83 #   if PAGE_SIZE != 0x2000
    84 #    error "PAGE_SIZE is not 0x2000!"
    85 #   endif
    86 #  endif
    87 # elif defined(RT_ARCH_ARM64) && defined(RT_OS_DARWIN)
    88 #  define RT_ASM_PAGE_SIZE   0x4000
    89 #  if defined(PAGE_SIZE) && !defined(NT_INCLUDED) && !defined(_MACH_ARM_VM_PARAM_H_)
    90 #   if PAGE_SIZE != 0x4000
    91 #    error "PAGE_SIZE is not 0x4000!"
    92 #   endif
    93 #  endif
    94 # else
    95 #  define RT_ASM_PAGE_SIZE   0x1000
    96 #  if defined(PAGE_SIZE) && !defined(NT_INCLUDED) && !defined(RT_OS_LINUX) && !defined(RT_ARCH_ARM64)
    97 #   if PAGE_SIZE != 0x1000
    98 #    error "PAGE_SIZE is not 0x1000!"
    99 #   endif
    100 #  endif
    101 # endif
    102 #endif
    103 
    10474
    10575/**
     
    371341#endif
    372342
    373 #ifdef RT_ASM_PAGE_SIZE
    374 /**
    375  * Probes a buffer for read access page by page.
    376  *
    377  * While the function will fault if the buffer is not fully read
    378  * accessible, the idea is to do this in a safe place like before
    379  * acquiring locks and such like.
    380  *
    381  * Also, this functions guarantees that an eager compiler is not going
    382  * to optimize the probing away.
    383  *
    384  * @param   pvBuf       Pointer to the buffer.
    385  * @param   cbBuf       The size of the buffer in bytes. Must be >= 1.
    386  */
    387 DECLINLINE(void) ASMProbeReadBuffer(const void RT_FAR *pvBuf, size_t cbBuf) RT_NOTHROW_DEF
    388 {
    389     /** @todo verify that the compiler actually doesn't optimize this away. (intel & gcc) */
    390     /* the first byte */
    391     const uint8_t RT_FAR *pu8 = (const uint8_t RT_FAR *)pvBuf;
    392     ASMProbeReadByte(pu8);
    393 
    394     /* the pages in between pages. */
    395     while (cbBuf > RT_ASM_PAGE_SIZE)
    396     {
    397         ASMProbeReadByte(pu8);
    398         cbBuf -= RT_ASM_PAGE_SIZE;
    399         pu8   += RT_ASM_PAGE_SIZE;
    400     }
    401 
    402     /* the last byte */
    403     ASMProbeReadByte(pu8 + cbBuf - 1);
    404 }
    405 #endif
    406 
    407343/** @} */
    408344
  • trunk/src/VBox/Runtime/testcase/tstRTInlineAsm.cpp

    r103014 r103017  
    3939*   Header Files                                                                                                                 *
    4040*********************************************************************************************************************************/
    41 #define RT_ASM_INCLUDE_PAGE_SIZE
    4241#include <iprt/asm-mem.h>
    4342#include <iprt/asm.h>
     
    26522651static void tstASMProbe(RTTEST hTest)
    26532652{
    2654     RTTestSub(hTest, "ASMProbeReadByte/Buffer");
     2653    RTTestSub(hTest, "ASMProbeReadByte");
    26552654
    26562655    uint8_t b = 42;
    26572656    RTTESTI_CHECK(ASMProbeReadByte(&b) == 42);
    2658     ASMProbeReadBuffer(&b, sizeof(b));
    26592657
    26602658    for (uint32_t cPages = 1; cPages < 16; cPages++)
     
    26712669        RTTESTI_CHECK(ASMProbeReadByte(&pbBuf1[0]) == 0xf6);
    26722670        RTTESTI_CHECK(ASMProbeReadByte(&pbBuf2[0]) == 0x42);
    2673 
    2674         ASMProbeReadBuffer(pbBuf1, cPages * PAGE_SIZE);
    2675         ASMProbeReadBuffer(pbBuf2, cPages * PAGE_SIZE);
    26762671    }
    26772672}
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