VirtualBox

儲存庫 vbox 的更動 87186


忽略:
時間撮記:
2021-1-6 下午12:47:49 (4 年 以前)
作者:
vboxsync
svn:sync-xref-src-repo-rev:
142117
訊息:

IPRT: Added generic ASMMemFirstNonZero C implementations. bugref:9898

位置:
trunk/src/VBox/Runtime
檔案:
修改 1 筆資料
複製 1 筆資料

圖例:

未更動
新增
刪除
  • trunk/src/VBox/Runtime/Makefile.kmk

    r87185 r87186  
    772772        common/asm/ASMMemFill32-generic.cpp \
    773773        common/asm/ASMMemFirstMismatchingU8-generic.cpp \
     774        common/asm/ASMMemFirstNonZero-generic.cpp \
    774775        common/misc/zero-alt.S
    775776RuntimeR3_SOURCES.arm64 := \
     
    778779        common/asm/ASMMemFill32-generic.cpp \
    779780        common/asm/ASMMemFirstMismatchingU8-generic.cpp \
     781        common/asm/ASMMemFirstNonZero-generic.cpp \
    780782        common/misc/zero-alt.S
    781783RuntimeR3_SOURCES.sparc32 += \
  • trunk/src/VBox/Runtime/common/asm/ASMMemFirstNonZero-generic.cpp

    r87185 r87186  
    3333
    3434
    35 DECLASM(void *) ASMMemFirstMismatchingU8(void const RT_FAR *pv, size_t cb, uint8_t u8) RT_NOTHROW_DEF
     35DECLASM(void RT_FAR *) ASMMemFirstNonZero(void const RT_FAR *pv, size_t cb) RT_NOTHROW_DEF
    3636{
    3737    uint8_t const *pb = (uint8_t const RT_FAR *)pv;
     38
     39    /*
     40     * If we've got a large buffer to search, do it in larger units.
     41     */
     42    if (cb >= sizeof(size_t) * 2)
     43    {
     44        /* Align the pointer: */
     45        while ((uintptr_t)pb & (sizeof(size_t) - 1))
     46        {
     47            if (RT_LIKELY(*pb == 0))
     48            { /* likely */ }
     49            else
     50                return (void RT_FAR *)pb;
     51            cb--;
     52            pb++;
     53        }
     54
     55        /* Scan in size_t sized words: */
     56        while (   cb >= sizeof(size_t)
     57               && *(size_t *)pb == 0)
     58        {
     59            pb += sizeof(size_t);
     60            cb -= sizeof(size_t);
     61        }
     62    }
     63
     64    /*
     65     * Search byte by byte.
     66     */
    3867    for (; cb; cb--, pb++)
    39         if (RT_LIKELY(*pb == u8))
     68        if (RT_LIKELY(*pb == 0))
    4069        { /* likely */ }
    4170        else
    42             return (void *)pb;
     71            return (void RT_FAR *)pb;
     72
    4373    return NULL;
    4474}
注意: 瀏覽 TracChangeset 來幫助您使用更動檢視器

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette