[NDK] Add Affinity helper inline functions

This commit is contained in:
Timo Kreuzer 2023-11-26 17:32:27 +02:00
parent 57e7f0b321
commit d87b45bee7
3 changed files with 47 additions and 10 deletions

View file

@ -33,6 +33,53 @@ extern "C"
#ifndef NTOS_MODE_USER
//
// Affinity helpers
//
FORCEINLINE KAFFINITY AFFINITY_MASK(ULONG Index)
{
ASSERT(Index < sizeof(KAFFINITY) * 8);
return (KAFFINITY)1 << Index;
}
FORCEINLINE BOOLEAN BitScanForwardAffinity(PULONG Index, KAFFINITY Mask)
{
#ifdef _WIN64
return BitScanForward64(Index, Mask);
#else
return BitScanForward(Index, Mask);
#endif
}
FORCEINLINE BOOLEAN BitScanReverseAffinity(PULONG Index, KAFFINITY Mask)
{
#ifdef _WIN64
return BitScanReverse64(Index, Mask);
#else
return BitScanReverse(Index, Mask);
#endif
}
FORCEINLINE BOOLEAN InterlockedBitTestAndSetAffinity(volatile KAFFINITY *Affinity, ULONG Index)
{
ASSERT(Index < sizeof(KAFFINITY) * 8);
#ifdef _WIN64
return InterlockedBitTestAndSet64((PLONG64)Affinity, Index);
#else
return InterlockedBitTestAndSet((PLONG)Affinity, Index);
#endif
}
FORCEINLINE BOOLEAN InterlockedBitTestAndResetAffinity(volatile KAFFINITY *Affinity, ULONG Index)
{
ASSERT(Index < sizeof(KAFFINITY) * 8);
#ifdef _WIN64
return InterlockedBitTestAndReset64((PLONG64)Affinity, Index);
#else
return InterlockedBitTestAndReset((PLONG)Affinity, Index);
#endif
}
//
// APC Functions
//