Changeset 87186 in vbox for trunk/src/VBox/Runtime/common/asm
- Timestamp:
- Jan 6, 2021 12:47:49 PM (4 years ago)
- svn:sync-xref-src-repo-rev:
- 142117
- File:
-
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/common/asm/ASMMemFirstNonZero-generic.cpp
r87185 r87186 33 33 34 34 35 DECLASM(void *) ASMMemFirstMismatchingU8(void const RT_FAR *pv, size_t cb, uint8_t u8) RT_NOTHROW_DEF35 DECLASM(void RT_FAR *) ASMMemFirstNonZero(void const RT_FAR *pv, size_t cb) RT_NOTHROW_DEF 36 36 { 37 37 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 */ 38 67 for (; cb; cb--, pb++) 39 if (RT_LIKELY(*pb == u8))68 if (RT_LIKELY(*pb == 0)) 40 69 { /* likely */ } 41 70 else 42 return (void *)pb; 71 return (void RT_FAR *)pb; 72 43 73 return NULL; 44 74 }
Note:
See TracChangeset
for help on using the changeset viewer.