static GLint
TransferTexturePitch( GLint dwPitch )
{
   GLint dwRet, i;

   i = BitScanForward( (GLshort)dwPitch );
   dwRet = dwPitch >> i;
   dwRet |= i << 9;
   return dwRet;
}
Beispiel #2
0
BOOLEAN DecodeNextBit(PUCHAR pBitmap, PUCHAR pValue)
{
    ULONG Index;
    BOOLEAN bResult = BitScanForward(&Index, *pBitmap);
    if (bResult)
    {
        *pValue = (unsigned char)Index;
        *pBitmap &= ~(1 << Index);
    }
    return bResult;
}
ULONG ParaNdis_GetIndexFromAffinity(KAFFINITY affinity)
{
    DWORD index = 0;
    BOOLEAN result;
#ifdef _WIN64
    result = BitScanForward64(&index, affinity);
#else
    result = BitScanForward(&index, affinity);
#endif
    if (result && ((KAFFINITY)1 << index) == affinity)
    {
        return index;
    }
    return INVALID_PROCESSOR_INDEX;
}
Beispiel #4
0
HRESULT SoraAllocateVStream(PSORA_RADIO radio, PULONG Mask)
{
    KIRQL OldIrql;
    HRESULT hr = E_FAIL;
    
    KeAcquireSpinLock(&radio->__rx_queue.VStreamFreeBitmapLock, &OldIrql);
    if (radio->__rx_queue.VStreamFreeBitmap != 0)
    {
        ULONG FreeBitIndex;
        hr = S_OK;
        BitScanForward(&FreeBitIndex, radio->__rx_queue.VStreamFreeBitmap);
        *Mask = 0x1 << FreeBitIndex;
        radio->__rx_queue.VStreamFreeBitmap &= ~(*Mask);
    }
    KeReleaseSpinLock(&radio->__rx_queue.VStreamFreeBitmapLock, OldIrql);
    return hr;
}
// param: PWCHAR, new volume's disk letter will be stored there.
static DWORD WINAPI DevNotifyThread(void *param)
{
    HWND hWnd;
    DWORD diskIndex = 0;

    g_NewVolumeBitmask = 0;

    if (!InitWindowClass())
        return 1;

    hWnd = CreateWindowEx(
        WS_EX_CLIENTEDGE | WS_EX_APPWINDOW,
        WND_CLASS_NAME,
        L"QDevNotify",
        WS_OVERLAPPEDWINDOW,
        CW_USEDEFAULT, 0,
        640, 480,
        NULL, NULL,
        GetModuleHandle(NULL),
        NULL);

    if (hWnd == NULL)
    {
        perror("CreateWindowEx: main appwindow hWnd");
        return 2;
    }

    MessagePump();

    if (g_NewVolumeBitmask == 0) // failed?
        return 3;

    // Translate bitmask into disk letter.
    BitScanForward(&diskIndex, g_NewVolumeBitmask);
    *(WCHAR *) param = L'A' + (WCHAR) diskIndex;

    return 0;
}