mirror of
https://github.com/reactos/reactos.git
synced 2024-12-28 10:04:49 +00:00
[NDK] Add Affinity helper inline functions
This commit is contained in:
parent
57e7f0b321
commit
d87b45bee7
3 changed files with 47 additions and 10 deletions
|
@ -7,15 +7,6 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#define AFFINITY_MASK(Id) ((KAFFINITY)1 << (Id))
|
|
||||||
|
|
||||||
/* Helper to find the lowest CPU in a KAFFINITY */
|
|
||||||
#ifdef _WIN64
|
|
||||||
#define BitScanForwardAffinity BitScanForward64
|
|
||||||
#else
|
|
||||||
#define BitScanForwardAffinity BitScanForward
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* This table is filled for each physical processor on system */
|
/* This table is filled for each physical processor on system */
|
||||||
typedef struct _PROCESSOR_IDENTITY
|
typedef struct _PROCESSOR_IDENTITY
|
||||||
{
|
{
|
||||||
|
|
|
@ -155,7 +155,6 @@ extern VOID __cdecl KiInterruptTemplate(VOID);
|
||||||
|
|
||||||
/* MACROS *************************************************************************/
|
/* MACROS *************************************************************************/
|
||||||
|
|
||||||
#define AFFINITY_MASK(ProcessorIndex) ((KAFFINITY)1 << (ProcessorIndex))
|
|
||||||
#define PRIORITY_MASK(Priority) (1UL << (Priority))
|
#define PRIORITY_MASK(Priority) (1UL << (Priority))
|
||||||
|
|
||||||
/* Tells us if the Timer or Event is a Syncronization or Notification Object */
|
/* Tells us if the Timer or Event is a Syncronization or Notification Object */
|
||||||
|
|
|
@ -33,6 +33,53 @@ extern "C"
|
||||||
|
|
||||||
#ifndef NTOS_MODE_USER
|
#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
|
// APC Functions
|
||||||
//
|
//
|
||||||
|
|
Loading…
Reference in a new issue