VirtualBox

Changeset 87185 in vbox for trunk/src/VBox/Runtime/common


Ignore:
Timestamp:
Jan 6, 2021 12:27:54 PM (4 years ago)
Author:
vboxsync
Message:

IPRT: Added generic ASMMemFill32, ASMMemZero32 and ASMMemFirstMismatchingU8 C implementations. bugref:9898

Location:
trunk/src/VBox/Runtime/common/asm
Files:
3 copied

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Runtime/common/asm/ASMMemFill32-generic.cpp

    r87184 r87185  
    3333
    3434#include <iprt/string.h>
     35#include <iprt/assert.h>
    3536
    3637
    37 RT_ASM_DECL_PRAGMA_WATCOM(void) ASMMemZeroPage(volatile void RT_FAR *pv) RT_NOTHROW_DEF
     38RT_ASM_DECL_PRAGMA_WATCOM(void) ASMMemFill32(volatile void RT_FAR *pv, size_t cb, uint32_t u32) RT_NOTHROW_DEF
    3839{
    39     memset((void *)pv, 0, RT_ASM_PAGE_SIZE);
     40    Assert(!(cb & 3));
     41    size_t cFills = cb / sizeof(uint32_t);
     42    uint32_t *pu32Dst = (uint32_t *)pv;
     43
     44    while (cFills >= 8)
     45    {
     46        pu32Dst[0] = u32;
     47        pu32Dst[1] = u32;
     48        pu32Dst[2] = u32;
     49        pu32Dst[3] = u32;
     50        pu32Dst[4] = u32;
     51        pu32Dst[5] = u32;
     52        pu32Dst[6] = u32;
     53        pu32Dst[7] = u32;
     54        pu32Dst += 8;
     55        cFills  -= 8;
     56    }
     57
     58    while (cFills > 0)
     59    {
     60        *pu32Dst++ = u32;
     61        cFills -= 1;
     62    }
    4063}
    4164
  • trunk/src/VBox/Runtime/common/asm/ASMMemFirstMismatchingU8-generic.cpp

    r87184 r87185  
    55
    66/*
    7  * Copyright (C) 2021 Oracle Corporation
     7 * Copyright (C) 2006-2021 Oracle Corporation
    88 *
    99 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    3232#include "internal/iprt.h"
    3333
    34 #include <iprt/string.h>
    3534
    36 
    37 RT_ASM_DECL_PRAGMA_WATCOM(void) ASMMemZeroPage(volatile void RT_FAR *pv) RT_NOTHROW_DEF
     35DECLASM(void *) ASMMemFirstMismatchingU8(void const RT_FAR *pv, size_t cb, uint8_t u8) RT_NOTHROW_DEF
    3836{
    39     memset((void *)pv, 0, RT_ASM_PAGE_SIZE);
     37    uint8_t const *pb = (uint8_t const RT_FAR *)pv;
     38    for (; cb; cb--, pb++)
     39        if (RT_LIKELY(*pb == u8))
     40        { /* likely */ }
     41        else
     42            return (void *)pb;
     43    return NULL;
    4044}
    4145
  • trunk/src/VBox/Runtime/common/asm/ASMMemZero32-generic.cpp

    r87184 r87185  
    11/* $Id$ */
    22/** @file
    3  * IPRT - ASMMemZeroPage - generic C implementation.
     3 * IPRT - ASMMemZero32 - generic C implementation.
    44 */
    55
     
    3535
    3636
    37 RT_ASM_DECL_PRAGMA_WATCOM(void) ASMMemZeroPage(volatile void RT_FAR *pv) RT_NOTHROW_DEF
     37RT_ASM_DECL_PRAGMA_WATCOM(void) ASMMemZero32(volatile void RT_FAR *pv, size_t cb) RT_NOTHROW_DEF
    3838{
    39     memset((void *)pv, 0, RT_ASM_PAGE_SIZE);
     39    memset((void *)pv, 0, cb);
    4040}
    4141
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