Win32 API 日本語リファレンス
ホームSystem.Memory › AllocateUserPhysicalPagesNuma

AllocateUserPhysicalPagesNuma

関数
指定NUMAノードからAWE用物理メモリページを割り当てる。
DLLKERNEL32.dll呼出規約winapiSetLastErrorあり対応OSWindows Vista 以降

シグネチャ

// KERNEL32.dll
#include <windows.h>

BOOL AllocateUserPhysicalPagesNuma(
    HANDLE hProcess,
    UINT_PTR* NumberOfPages,
    UINT_PTR* PageArray,
    DWORD nndPreferred
);

パラメーター

名前方向
hProcessHANDLEin
NumberOfPagesUINT_PTR*inout
PageArrayUINT_PTR*out
nndPreferredDWORDin

戻り値の型: BOOL

各言語での呼び出し定義

// KERNEL32.dll
#include <windows.h>

BOOL AllocateUserPhysicalPagesNuma(
    HANDLE hProcess,
    UINT_PTR* NumberOfPages,
    UINT_PTR* PageArray,
    DWORD nndPreferred
);
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("KERNEL32.dll", SetLastError = true, ExactSpelling = true)]
static extern bool AllocateUserPhysicalPagesNuma(
    IntPtr hProcess,   // HANDLE
    ref UIntPtr NumberOfPages,   // UINT_PTR* in/out
    out UIntPtr PageArray,   // UINT_PTR* out
    uint nndPreferred   // DWORD
);
<DllImport("KERNEL32.dll", SetLastError:=True, ExactSpelling:=True)>
Public Shared Function AllocateUserPhysicalPagesNuma(
    hProcess As IntPtr,   ' HANDLE
    ByRef NumberOfPages As UIntPtr,   ' UINT_PTR* in/out
    <Out> ByRef PageArray As UIntPtr,   ' UINT_PTR* out
    nndPreferred As UInteger   ' DWORD
) As Boolean
End Function
' hProcess : HANDLE
' NumberOfPages : UINT_PTR* in/out
' PageArray : UINT_PTR* out
' nndPreferred : DWORD
Declare PtrSafe Function AllocateUserPhysicalPagesNuma Lib "kernel32" ( _
    ByVal hProcess As LongPtr, _
    ByRef NumberOfPages As LongPtr, _
    ByRef PageArray As LongPtr, _
    ByVal nndPreferred As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

AllocateUserPhysicalPagesNuma = ctypes.windll.kernel32.AllocateUserPhysicalPagesNuma
AllocateUserPhysicalPagesNuma.restype = wintypes.BOOL
AllocateUserPhysicalPagesNuma.argtypes = [
    wintypes.HANDLE,  # hProcess : HANDLE
    ctypes.POINTER(ctypes.c_size_t),  # NumberOfPages : UINT_PTR* in/out
    ctypes.POINTER(ctypes.c_size_t),  # PageArray : UINT_PTR* out
    wintypes.DWORD,  # nndPreferred : DWORD
]
# GetLastError: use ctypes.GetLastError() (or ctypes.WinDLL(use_last_error=True))
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('KERNEL32.dll')
AllocateUserPhysicalPagesNuma = Fiddle::Function.new(
  lib['AllocateUserPhysicalPagesNuma'],
  [
    Fiddle::TYPE_VOIDP,  # hProcess : HANDLE
    Fiddle::TYPE_VOIDP,  # NumberOfPages : UINT_PTR* in/out
    Fiddle::TYPE_VOIDP,  # PageArray : UINT_PTR* out
    -Fiddle::TYPE_INT,  # nndPreferred : DWORD
  ],
  Fiddle::TYPE_INT)
#[link(name = "kernel32")]
extern "system" {
    fn AllocateUserPhysicalPagesNuma(
        hProcess: *mut core::ffi::c_void,  // HANDLE
        NumberOfPages: *mut usize,  // UINT_PTR* in/out
        PageArray: *mut usize,  // UINT_PTR* out
        nndPreferred: u32  // DWORD
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("KERNEL32.dll", SetLastError = true)]
public static extern bool AllocateUserPhysicalPagesNuma(IntPtr hProcess, ref UIntPtr NumberOfPages, out UIntPtr PageArray, uint nndPreferred);
"@
$api = Add-Type -MemberDefinition $sig -Name 'KERNEL32_AllocateUserPhysicalPagesNuma' -Namespace Win32 -PassThru
# $api::AllocateUserPhysicalPagesNuma(hProcess, NumberOfPages, PageArray, nndPreferred)
#uselib "KERNEL32.dll"
#func global AllocateUserPhysicalPagesNuma "AllocateUserPhysicalPagesNuma" sptr, sptr, sptr, sptr
; AllocateUserPhysicalPagesNuma hProcess, varptr(NumberOfPages), varptr(PageArray), nndPreferred   ; 戻り値は stat
; hProcess : HANDLE -> "sptr"
; NumberOfPages : UINT_PTR* in/out -> "sptr"
; PageArray : UINT_PTR* out -> "sptr"
; nndPreferred : DWORD -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "KERNEL32.dll"
#cfunc global AllocateUserPhysicalPagesNuma "AllocateUserPhysicalPagesNuma" sptr, var, var, int
; res = AllocateUserPhysicalPagesNuma(hProcess, NumberOfPages, PageArray, nndPreferred)
; hProcess : HANDLE -> "sptr"
; NumberOfPages : UINT_PTR* in/out -> "var"
; PageArray : UINT_PTR* out -> "var"
; nndPreferred : DWORD -> "int"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; BOOL AllocateUserPhysicalPagesNuma(HANDLE hProcess, UINT_PTR* NumberOfPages, UINT_PTR* PageArray, DWORD nndPreferred)
#uselib "KERNEL32.dll"
#cfunc global AllocateUserPhysicalPagesNuma "AllocateUserPhysicalPagesNuma" intptr, var, var, int
; res = AllocateUserPhysicalPagesNuma(hProcess, NumberOfPages, PageArray, nndPreferred)
; hProcess : HANDLE -> "intptr"
; NumberOfPages : UINT_PTR* in/out -> "var"
; PageArray : UINT_PTR* out -> "var"
; nndPreferred : DWORD -> "int"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	kernel32 = windows.NewLazySystemDLL("KERNEL32.dll")
	procAllocateUserPhysicalPagesNuma = kernel32.NewProc("AllocateUserPhysicalPagesNuma")
)

// hProcess (HANDLE), NumberOfPages (UINT_PTR* in/out), PageArray (UINT_PTR* out), nndPreferred (DWORD)
r1, _, err := procAllocateUserPhysicalPagesNuma.Call(
	uintptr(hProcess),
	uintptr(NumberOfPages),
	uintptr(PageArray),
	uintptr(nndPreferred),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // BOOL
function AllocateUserPhysicalPagesNuma(
  hProcess: THandle;   // HANDLE
  NumberOfPages: Pointer;   // UINT_PTR* in/out
  PageArray: Pointer;   // UINT_PTR* out
  nndPreferred: DWORD   // DWORD
): BOOL; stdcall;
  external 'KERNEL32.dll' name 'AllocateUserPhysicalPagesNuma';
result := DllCall("KERNEL32\AllocateUserPhysicalPagesNuma"
    , "Ptr", hProcess   ; HANDLE
    , "Ptr", NumberOfPages   ; UINT_PTR* in/out
    , "Ptr", PageArray   ; UINT_PTR* out
    , "UInt", nndPreferred   ; DWORD
    , "Int")   ; return: BOOL
●AllocateUserPhysicalPagesNuma(hProcess, NumberOfPages, PageArray, nndPreferred) = DLL("KERNEL32.dll", "bool AllocateUserPhysicalPagesNuma(void*, void*, void*, dword)")
# 呼び出し: AllocateUserPhysicalPagesNuma(hProcess, NumberOfPages, PageArray, nndPreferred)
# hProcess : HANDLE -> "void*"
# NumberOfPages : UINT_PTR* in/out -> "void*"
# PageArray : UINT_PTR* out -> "void*"
# nndPreferred : DWORD -> "dword"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。