Changeset 44241 in vbox for trunk/src/VBox/Runtime
- Timestamp:
- Jan 7, 2013 8:17:19 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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.