using System;
using System.Runtime.InteropServices;
namespace Vanara.PInvoke
{
public static partial class Kernel32
{
/// Retrieves the node that currently has the highest number.
/// The number of the highest node.
///
/// If the function succeeds, the return value is nonzero.
/// If the function fails, the return value is zero. To get extended error information, call GetLastError.
///
// BOOL WINAPI GetNumaHighestNodeNumber( _Out_ PULONG HighestNodeNumber); https://msdn.microsoft.com/en-us/library/windows/desktop/ms683203(v=vs.85).aspx
[DllImport(Lib.Kernel32, SetLastError = true, ExactSpelling = true)]
[PInvokeData("systemtopology.h", MSDNShortId = "ms683203")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool GetNumaHighestNodeNumber(out uint HighestNodeNumber);
/// Retrieves the processor mask for a node regardless of the processor group the node belongs to.
/// The node number.
///
///
/// A pointer to a GROUP_AFFINITY structure that receives the processor mask for the specified node. A processor mask is a bit
/// vector in which each bit represents a processor and whether it is in the node.
///
/// If the specified node has no processors configured, the Mask member is zero and the Group member is undefined.
///
///
/// If the function succeeds, the return value is nonzero.
/// If the function fails, the return value is zero.
///
// BOOL GetNumaNodeProcessorMaskEx( _In_ USHORT Node, _Out_ PGROUP_AFFINITY ProcessorMask); https://msdn.microsoft.com/en-us/library/windows/desktop/dd405493(v=vs.85).aspx
[DllImport(Lib.Kernel32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("systemtopology.h", MSDNShortId = "dd405493")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool GetNumaNodeProcessorMaskEx(ushort Node, out GROUP_AFFINITY ProcessorMask);
/// Retrieves the NUMA node number that corresponds to the specified proximity identifier as a USHORT value.
/// The proximity identifier of the node.
/// Points to a variable to receive the node number for the specified proximity identifier.
///
/// If the function succeeds, the return value is nonzero.
/// If the function fails, the return value is zero.
///
// BOOL GetNumaProximityNodeEx( _In_ ULONG ProximityId, _Out_ PUSHORT NodeNumber); https://msdn.microsoft.com/en-us/library/windows/desktop/dd405495(v=vs.85).aspx
[DllImport(Lib.Kernel32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("systemtopology.h", MSDNShortId = "dd405495")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool GetNumaProximityNodeEx(uint ProximityId, out ushort NodeNumber);
/// Represents a processor group-specific affinity, such as the affinity of a thread.
// typedef struct _GROUP_AFFINITY { KAFFINITY Mask; WORD Group; WORD Reserved[3];} GROUP_AFFINITY, *PGROUP_AFFINITY; https://msdn.microsoft.com/en-us/library/windows/desktop/dd405500(v=vs.85).aspx
[PInvokeData("WinNT.h", MSDNShortId = "dd405500")]
[StructLayout(LayoutKind.Sequential, Pack = 4)]
public struct GROUP_AFFINITY
{
/// A bitmap that specifies the affinity for zero or more processors within the specified group.
public UIntPtr Mask;
/// The processor group number.
public ushort Group;
/// This member is reserved.
private ushort Reserved1;
/// This member is reserved.
private ushort Reserved2;
/// This member is reserved.
private ushort Reserved3;
}
}
}