Changeset 9986 for trunk/src/NTDLL/rtlbitmap.c
- Timestamp:
- Apr 7, 2003, 8:40:53 PM (22 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/NTDLL/rtlbitmap.c
r9733 r9986 28 28 * Note that to avoid unexpected behaviour, the size of a bitmap should be set 29 29 * to a multiple of 32. 30 31 */ 32 #include <winbase.h> 30 */ 31 #include <stdlib.h> 32 #include <string.h> 33 #include "windef.h" 33 34 #include "winternl.h" 34 35 #include "wine/debug.h" … … 50 51 51 52 /* Last set bit in a nibble; used for determining most significant bit */ 52 static const BYTENTDLL_mostSignificant[16] = {53 0, 0, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 353 static const signed char NTDLL_mostSignificant[16] = { 54 -1, 0, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3 54 55 }; 55 56 … … 568 569 * Find the most significant bit in a 64 bit integer. 569 570 * 570 * PARAMS571 * lpBits [I] Bitmap pointer572 * ulStart [I] First bit to search from573 *574 571 * RETURNS 575 572 * The position of the most significant bit. … … 577 574 CCHAR WINAPI RtlFindMostSignificantBit(ULONGLONG ulLong) 578 575 { 579 LONG lCount = 64; 580 LPBYTE lpOut = (LPBYTE)&ulLong + 7; 581 582 TRACE("(%lld)\n", ulLong); 583 584 if (!(ulLong & 0xffffffff00000000ul)) 585 { 586 lpOut -= 4; 587 lCount -= 32; 588 } 589 590 for (; lCount > 0; lCount -= 8) 591 { 592 if (*lpOut) 593 { 594 if (*lpOut & 0x0f) 595 return lCount - 8 + NTDLL_mostSignificant[*lpOut & 0x0f]; 596 return lCount - 4 + NTDLL_mostSignificant[*lpOut >> 4]; 597 } 598 lpOut--; 599 } 600 return -1; 576 signed char ret = 32; 577 DWORD dw; 578 579 if (!(dw = (ulLong >> 32))) 580 { 581 ret = 0; 582 dw = (DWORD)ulLong; 583 } 584 if (dw & 0xffff0000) 585 { 586 dw >>= 16; 587 ret += 16; 588 } 589 if (dw & 0xff00) 590 { 591 dw >>= 8; 592 ret += 8; 593 } 594 if (dw & 0xf0) 595 { 596 dw >>= 4; 597 ret += 4; 598 } 599 return ret + NTDLL_mostSignificant[dw]; 601 600 } 602 601 … … 606 605 * Find the least significant bit in a 64 bit integer. 607 606 * 608 * PARAMS609 * lpBits [I] Bitmap pointer610 * ulStart [I] First bit to search from611 *612 607 * RETURNS 613 608 * The position of the least significant bit. … … 615 610 CCHAR WINAPI RtlFindLeastSignificantBit(ULONGLONG ulLong) 616 611 { 617 ULONG ulCount = 0; 618 LPBYTE lpOut = (LPBYTE)&ulLong; 619 620 TRACE("(%lld)\n", ulLong); 621 622 if (!(ulLong & 0xffffffff)) 623 { 624 lpOut += 4; 625 ulCount = 32; 626 } 627 628 for (; ulCount < 64; ulCount += 8) 629 { 630 if (*lpOut) 631 { 632 if (*lpOut & 0x0f) 633 return ulCount + NTDLL_leastSignificant[*lpOut & 0x0f]; 634 return ulCount + 4 + NTDLL_leastSignificant[*lpOut >> 4]; 635 } 636 lpOut++; 637 } 638 return -1; 612 signed char ret = 0; 613 DWORD dw; 614 615 if (!(dw = (DWORD)ulLong)) 616 { 617 ret = 32; 618 if (!(dw = ulLong >> 32)) return -1; 619 } 620 if (!(dw & 0xffff)) 621 { 622 dw >>= 16; 623 ret += 16; 624 } 625 if (!(dw & 0xff)) 626 { 627 dw >>= 8; 628 ret += 8; 629 } 630 if (!(dw & 0x0f)) 631 { 632 dw >>= 4; 633 ret += 4; 634 } 635 return ret + NTDLL_leastSignificant[dw & 0x0f]; 639 636 } 640 637 … … 642 639 * NTDLL_RunSortFn 643 640 * 644 * Internal helper: qsort compar ason function for RTL_BITMAP_RUN arrays641 * Internal helper: qsort comparison function for RTL_BITMAP_RUN arrays 645 642 */ 646 643 static int NTDLL_RunSortFn(const void *lhs, const void *rhs)
Note:
See TracChangeset
for help on using the changeset viewer.