Ignore:
Timestamp:
Apr 7, 2003, 8:40:53 PM (22 years ago)
Author:
sandervl
Message:

PF: NTDLL update for GCC 3.2.1 + resync with Wine

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/NTDLL/rtlbitmap.c

    r9733 r9986  
    2828 *  Note that to avoid unexpected behaviour, the size of a bitmap should be set
    2929 *  to a multiple of 32.
    30 
    31  */
    32 #include <winbase.h>
     30 */
     31#include <stdlib.h>
     32#include <string.h>
     33#include "windef.h"
    3334#include "winternl.h"
    3435#include "wine/debug.h"
     
    5051
    5152/* Last set bit in a nibble; used for determining most significant bit */
    52 static const BYTE NTDLL_mostSignificant[16] = {
    53   0, 0, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3
     53static const signed char NTDLL_mostSignificant[16] = {
     54  -1, 0, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3
    5455};
    5556
     
    568569 * Find the most significant bit in a 64 bit integer.
    569570 *
    570  * PARAMS
    571  *  lpBits  [I] Bitmap pointer
    572  *  ulStart [I] First bit to search from
    573  *
    574571 * RETURNS
    575572 *  The position of the most significant bit.
     
    577574CCHAR WINAPI RtlFindMostSignificantBit(ULONGLONG ulLong)
    578575{
    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];
    601600}
    602601
     
    606605 * Find the least significant bit in a 64 bit integer.
    607606 *
    608  * PARAMS
    609  *  lpBits  [I] Bitmap pointer
    610  *  ulStart [I] First bit to search from
    611  *
    612607 * RETURNS
    613608 *  The position of the least significant bit.
     
    615610CCHAR WINAPI RtlFindLeastSignificantBit(ULONGLONG ulLong)
    616611{
    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];
    639636}
    640637
     
    642639 * NTDLL_RunSortFn
    643640 *
    644  * Internal helper: qsort comparason function for RTL_BITMAP_RUN arrays
     641 * Internal helper: qsort comparison function for RTL_BITMAP_RUN arrays
    645642 */
    646643static int NTDLL_RunSortFn(const void *lhs, const void *rhs)
Note: See TracChangeset for help on using the changeset viewer.