Changeset 44241 in vbox
- Timestamp:
- Jan 7, 2013 8:17:19 PM (12 years ago)
- svn:sync-xref-src-repo-rev:
- 83097
- Location:
- trunk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/iprt/mangling.h
r43291 r44241 1173 1173 # define RTSgBufCopyToBuf RT_MANGLER(RTSgBufCopyToBuf) 1174 1174 # define RTSgBufInit RT_MANGLER(RTSgBufInit) 1175 # define RTSgBufIsZero RT_MANGLER(RTSgBufIsZero) 1175 1176 # define RTSgBufReset RT_MANGLER(RTSgBufReset) 1176 1177 # define RTSgBufSegArrayCreate RT_MANGLER(RTSgBufSegArrayCreate) -
trunk/include/iprt/sg.h
r38539 r44241 220 220 */ 221 221 RTDECL(size_t) RTSgBufSegArrayCreate(PRTSGBUF pSgBuf, PRTSGSEG paSeg, unsigned *pcSeg, size_t cbData); 222 223 /** 224 * Returns whether the given S/G buffer is zeroed out from the current position 225 * upto the number of bytes to check. 226 * 227 * @returns true if the buffer has only zeros 228 * false otherwise. 229 * @param pSgBuf The S/G buffer. 230 * @param cbCheck Number of bytes to check. 231 */ 232 RTDECL(bool) RTSgBufIsZero(PRTSGBUF pSgBuf, size_t cbCheck); 222 233 223 234 /** -
trunk/src/VBox/Runtime/common/misc/sg.cpp
r44135 r44241 32 32 #include <iprt/string.h> 33 33 #include <iprt/assert.h> 34 #include <iprt/asm.h> 34 35 35 36 … … 422 423 } 423 424 425 RTDECL(bool) RTSgBufIsZero(PRTSGBUF pSgBuf, size_t cbCheck) 426 { 427 bool fIsZero = true; 428 size_t cbLeft = cbCheck; 429 RTSGBUF SgBufTmp; 430 431 RTSgBufClone(&SgBufTmp, pSgBuf); 432 433 while (cbLeft) 434 { 435 size_t cbThisCheck = cbLeft; 436 void *pvBuf = sgBufGet(&SgBufTmp, &cbThisCheck); 437 438 if (!cbThisCheck) 439 break; 440 441 /* Use optimized inline assembler if possible. */ 442 if ( !(cbThisCheck % 4) 443 && (cbThisCheck * 8 <= UINT32_MAX)) 444 { 445 if (ASMBitFirstSet((volatile void *)pvBuf, cbThisCheck * 8) != -1) 446 { 447 fIsZero = false; 448 break; 449 } 450 } 451 else 452 { 453 for (unsigned i = 0; i < cbThisCheck; i++) 454 { 455 char *pbBuf = (char *)pvBuf; 456 if (*pbBuf) 457 { 458 fIsZero = false; 459 break; 460 } 461 pvBuf = pbBuf + 1; 462 } 463 464 if (!fIsZero) 465 break; 466 } 467 468 cbLeft -= cbThisCheck; 469 } 470 471 return fIsZero; 472 } 473
Note:
See TracChangeset
for help on using the changeset viewer.