ホーム › System.Threading › InterlockedPushListSListEx
InterlockedPushListSListEx
関数単方向リストへ複数項目をアトミックにまとめて追加する。
シグネチャ
// KERNEL32.dll
#include <windows.h>
SLIST_ENTRY* InterlockedPushListSListEx(
SLIST_HEADER* ListHead,
SLIST_ENTRY* List,
SLIST_ENTRY* ListEnd,
DWORD Count
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| ListHead | SLIST_HEADER* | inout | 単方向リンクリストの先頭を表す SLIST_HEADER 構造体へのポインターです。List および ListEnd パラメーターで指定されたリストが、このリストの先頭に挿入されます。 |
| List | SLIST_ENTRY* | inout | 挿入するリストの最初の項目を表す SLIST_ENTRY 構造体へのポインターです。 |
| ListEnd | SLIST_ENTRY* | inout | 挿入するリストの最後の項目を表す SLIST_ENTRY 構造体へのポインターです。 |
| Count | DWORD | in | 挿入するリスト内の項目数です。 |
戻り値の型: SLIST_ENTRY*
公式ドキュメント
単方向リンクリストを、別の単方向リンクリストの先頭に挿入します。マルチプロセッサシステムでは、リストへのアクセスは同期されます。このバージョンのメソッドは、__fastcall 呼び出し規約を使用しません。
戻り値
戻り値は、ListHead パラメーターで指定されたリストの直前の先頭項目です。リストが以前は空であった場合、戻り値は NULL です。
解説(Remarks)
すべてのリスト項目は MEMORY_ALLOCATION_ALIGNMENT 境界に揃えられている必要があります。そうでない場合、この関数の動作は予測できません。_aligned_malloc を参照してください。
出典・ライセンス: 上記「公式ドキュメント」の内容は Microsoft の Win32 API ドキュメント(MicrosoftDocs/sdk-api)を日本語に翻訳・改変したものです。© Microsoft Corporation. CC BY 4.0 で提供。
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)
各言語での呼び出し定義
// KERNEL32.dll
#include <windows.h>
SLIST_ENTRY* InterlockedPushListSListEx(
SLIST_HEADER* ListHead,
SLIST_ENTRY* List,
SLIST_ENTRY* ListEnd,
DWORD Count
);[DllImport("KERNEL32.dll", ExactSpelling = true)]
static extern IntPtr InterlockedPushListSListEx(
IntPtr ListHead, // SLIST_HEADER* in/out
IntPtr List, // SLIST_ENTRY* in/out
IntPtr ListEnd, // SLIST_ENTRY* in/out
uint Count // DWORD
);<DllImport("KERNEL32.dll", ExactSpelling:=True)>
Public Shared Function InterlockedPushListSListEx(
ListHead As IntPtr, ' SLIST_HEADER* in/out
List As IntPtr, ' SLIST_ENTRY* in/out
ListEnd As IntPtr, ' SLIST_ENTRY* in/out
Count As UInteger ' DWORD
) As IntPtr
End Function' ListHead : SLIST_HEADER* in/out
' List : SLIST_ENTRY* in/out
' ListEnd : SLIST_ENTRY* in/out
' Count : DWORD
Declare PtrSafe Function InterlockedPushListSListEx Lib "kernel32" ( _
ByVal ListHead As LongPtr, _
ByVal List As LongPtr, _
ByVal ListEnd As LongPtr, _
ByVal Count As Long) As LongPtr
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
InterlockedPushListSListEx = ctypes.windll.kernel32.InterlockedPushListSListEx
InterlockedPushListSListEx.restype = ctypes.c_void_p
InterlockedPushListSListEx.argtypes = [
ctypes.c_void_p, # ListHead : SLIST_HEADER* in/out
ctypes.c_void_p, # List : SLIST_ENTRY* in/out
ctypes.c_void_p, # ListEnd : SLIST_ENTRY* in/out
wintypes.DWORD, # Count : DWORD
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('KERNEL32.dll')
InterlockedPushListSListEx = Fiddle::Function.new(
lib['InterlockedPushListSListEx'],
[
Fiddle::TYPE_VOIDP, # ListHead : SLIST_HEADER* in/out
Fiddle::TYPE_VOIDP, # List : SLIST_ENTRY* in/out
Fiddle::TYPE_VOIDP, # ListEnd : SLIST_ENTRY* in/out
-Fiddle::TYPE_INT, # Count : DWORD
],
Fiddle::TYPE_VOIDP)#[link(name = "kernel32")]
extern "system" {
fn InterlockedPushListSListEx(
ListHead: *mut SLIST_HEADER, // SLIST_HEADER* in/out
List: *mut SLIST_ENTRY, // SLIST_ENTRY* in/out
ListEnd: *mut SLIST_ENTRY, // SLIST_ENTRY* in/out
Count: u32 // DWORD
) -> *mut SLIST_ENTRY;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("KERNEL32.dll")]
public static extern IntPtr InterlockedPushListSListEx(IntPtr ListHead, IntPtr List, IntPtr ListEnd, uint Count);
"@
$api = Add-Type -MemberDefinition $sig -Name 'KERNEL32_InterlockedPushListSListEx' -Namespace Win32 -PassThru
# $api::InterlockedPushListSListEx(ListHead, List, ListEnd, Count)#uselib "KERNEL32.dll"
#func global InterlockedPushListSListEx "InterlockedPushListSListEx" sptr, sptr, sptr, sptr
; InterlockedPushListSListEx varptr(ListHead), varptr(List), varptr(ListEnd), Count ; 戻り値は stat
; ListHead : SLIST_HEADER* in/out -> "sptr"
; List : SLIST_ENTRY* in/out -> "sptr"
; ListEnd : SLIST_ENTRY* in/out -> "sptr"
; Count : DWORD -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "KERNEL32.dll" #cfunc global InterlockedPushListSListEx "InterlockedPushListSListEx" var, var, var, int ; res = InterlockedPushListSListEx(ListHead, List, ListEnd, Count) ; ListHead : SLIST_HEADER* in/out -> "var" ; List : SLIST_ENTRY* in/out -> "var" ; ListEnd : SLIST_ENTRY* in/out -> "var" ; Count : DWORD -> "int" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "KERNEL32.dll" #cfunc global InterlockedPushListSListEx "InterlockedPushListSListEx" sptr, sptr, sptr, int ; res = InterlockedPushListSListEx(varptr(ListHead), varptr(List), varptr(ListEnd), Count) ; ListHead : SLIST_HEADER* in/out -> "sptr" ; List : SLIST_ENTRY* in/out -> "sptr" ; ListEnd : SLIST_ENTRY* in/out -> "sptr" ; Count : DWORD -> "int" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; SLIST_ENTRY* InterlockedPushListSListEx(SLIST_HEADER* ListHead, SLIST_ENTRY* List, SLIST_ENTRY* ListEnd, DWORD Count) #uselib "KERNEL32.dll" #cfunc global InterlockedPushListSListEx "InterlockedPushListSListEx" var, var, var, int ; res = InterlockedPushListSListEx(ListHead, List, ListEnd, Count) ; ListHead : SLIST_HEADER* in/out -> "var" ; List : SLIST_ENTRY* in/out -> "var" ; ListEnd : SLIST_ENTRY* in/out -> "var" ; Count : DWORD -> "int" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; SLIST_ENTRY* InterlockedPushListSListEx(SLIST_HEADER* ListHead, SLIST_ENTRY* List, SLIST_ENTRY* ListEnd, DWORD Count) #uselib "KERNEL32.dll" #cfunc global InterlockedPushListSListEx "InterlockedPushListSListEx" intptr, intptr, intptr, int ; res = InterlockedPushListSListEx(varptr(ListHead), varptr(List), varptr(ListEnd), Count) ; ListHead : SLIST_HEADER* in/out -> "intptr" ; List : SLIST_ENTRY* in/out -> "intptr" ; ListEnd : SLIST_ENTRY* in/out -> "intptr" ; Count : DWORD -> "int" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
kernel32 = windows.NewLazySystemDLL("KERNEL32.dll")
procInterlockedPushListSListEx = kernel32.NewProc("InterlockedPushListSListEx")
)
// ListHead (SLIST_HEADER* in/out), List (SLIST_ENTRY* in/out), ListEnd (SLIST_ENTRY* in/out), Count (DWORD)
r1, _, err := procInterlockedPushListSListEx.Call(
uintptr(ListHead),
uintptr(List),
uintptr(ListEnd),
uintptr(Count),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // SLIST_ENTRY*function InterlockedPushListSListEx(
ListHead: Pointer; // SLIST_HEADER* in/out
List: Pointer; // SLIST_ENTRY* in/out
ListEnd: Pointer; // SLIST_ENTRY* in/out
Count: DWORD // DWORD
): Pointer; stdcall;
external 'KERNEL32.dll' name 'InterlockedPushListSListEx';result := DllCall("KERNEL32\InterlockedPushListSListEx"
, "Ptr", ListHead ; SLIST_HEADER* in/out
, "Ptr", List ; SLIST_ENTRY* in/out
, "Ptr", ListEnd ; SLIST_ENTRY* in/out
, "UInt", Count ; DWORD
, "Ptr") ; return: SLIST_ENTRY*●InterlockedPushListSListEx(ListHead, List, ListEnd, Count) = DLL("KERNEL32.dll", "void* InterlockedPushListSListEx(void*, void*, void*, dword)")
# 呼び出し: InterlockedPushListSListEx(ListHead, List, ListEnd, Count)
# ListHead : SLIST_HEADER* in/out -> "void*"
# List : SLIST_ENTRY* in/out -> "void*"
# ListEnd : SLIST_ENTRY* in/out -> "void*"
# Count : DWORD -> "dword"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "kernel32" fn InterlockedPushListSListEx(
ListHead: [*c]SLIST_HEADER, // SLIST_HEADER* in/out
List: [*c]SLIST_ENTRY, // SLIST_ENTRY* in/out
ListEnd: [*c]SLIST_ENTRY, // SLIST_ENTRY* in/out
Count: u32 // DWORD
) callconv(std.os.windows.WINAPI) [*c]SLIST_ENTRY;proc InterlockedPushListSListEx(
ListHead: ptr SLIST_HEADER, # SLIST_HEADER* in/out
List: ptr SLIST_ENTRY, # SLIST_ENTRY* in/out
ListEnd: ptr SLIST_ENTRY, # SLIST_ENTRY* in/out
Count: uint32 # DWORD
): ptr SLIST_ENTRY {.importc: "InterlockedPushListSListEx", stdcall, dynlib: "KERNEL32.dll".}pragma(lib, "kernel32");
extern(Windows)
SLIST_ENTRY* InterlockedPushListSListEx(
SLIST_HEADER* ListHead, // SLIST_HEADER* in/out
SLIST_ENTRY* List, // SLIST_ENTRY* in/out
SLIST_ENTRY* ListEnd, // SLIST_ENTRY* in/out
uint Count // DWORD
);ccall((:InterlockedPushListSListEx, "KERNEL32.dll"), stdcall, Ptr{SLIST_ENTRY},
(Ptr{SLIST_HEADER}, Ptr{SLIST_ENTRY}, Ptr{SLIST_ENTRY}, UInt32),
ListHead, List, ListEnd, Count)
# ListHead : SLIST_HEADER* in/out -> Ptr{SLIST_HEADER}
# List : SLIST_ENTRY* in/out -> Ptr{SLIST_ENTRY}
# ListEnd : SLIST_ENTRY* in/out -> Ptr{SLIST_ENTRY}
# Count : DWORD -> UInt32
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
void* InterlockedPushListSListEx(
void* ListHead,
void* List,
void* ListEnd,
uint32_t Count);
]]
local kernel32 = ffi.load("kernel32")
-- kernel32.InterlockedPushListSListEx(ListHead, List, ListEnd, Count)
-- ListHead : SLIST_HEADER* in/out
-- List : SLIST_ENTRY* in/out
-- ListEnd : SLIST_ENTRY* in/out
-- Count : DWORD
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('KERNEL32.dll');
const InterlockedPushListSListEx = lib.func('__stdcall', 'InterlockedPushListSListEx', 'void *', ['void *', 'void *', 'void *', 'uint32_t']);
// InterlockedPushListSListEx(ListHead, List, ListEnd, Count)
// ListHead : SLIST_HEADER* in/out -> 'void *'
// List : SLIST_ENTRY* in/out -> 'void *'
// ListEnd : SLIST_ENTRY* in/out -> 'void *'
// Count : DWORD -> 'uint32_t'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("KERNEL32.dll", {
InterlockedPushListSListEx: { parameters: ["pointer", "pointer", "pointer", "u32"], result: "pointer" },
});
// lib.symbols.InterlockedPushListSListEx(ListHead, List, ListEnd, Count)
// ListHead : SLIST_HEADER* in/out -> "pointer"
// List : SLIST_ENTRY* in/out -> "pointer"
// ListEnd : SLIST_ENTRY* in/out -> "pointer"
// Count : DWORD -> "u32"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
void* InterlockedPushListSListEx(
void* ListHead,
void* List,
void* ListEnd,
uint32_t Count);
C, "KERNEL32.dll");
// $ffi->InterlockedPushListSListEx(ListHead, List, ListEnd, Count);
// ListHead : SLIST_HEADER* in/out
// List : SLIST_ENTRY* in/out
// ListEnd : SLIST_ENTRY* in/out
// Count : DWORD
// 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
// WINAPI(stdcall): x64 では呼出規約が統一されるため問題なし。x86 では __stdcall 対応のラッパが必要な場合あり。import com.sun.jna.*;
import com.sun.jna.ptr.*;
import com.sun.jna.win32.StdCallLibrary;
import com.sun.jna.win32.W32APIOptions;
public interface Kernel32 extends StdCallLibrary {
Kernel32 INSTANCE = Native.load("kernel32", Kernel32.class);
Pointer InterlockedPushListSListEx(
Pointer ListHead, // SLIST_HEADER* in/out
Pointer List, // SLIST_ENTRY* in/out
Pointer ListEnd, // SLIST_ENTRY* in/out
int Count // DWORD
);
}@[Link("kernel32")]
lib LibKERNEL32
fun InterlockedPushListSListEx = InterlockedPushListSListEx(
ListHead : SLIST_HEADER*, # SLIST_HEADER* in/out
List : SLIST_ENTRY*, # SLIST_ENTRY* in/out
ListEnd : SLIST_ENTRY*, # SLIST_ENTRY* in/out
Count : UInt32 # DWORD
) : SLIST_ENTRY*
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef InterlockedPushListSListExNative = Pointer<Void> Function(Pointer<Void>, Pointer<Void>, Pointer<Void>, Uint32);
typedef InterlockedPushListSListExDart = Pointer<Void> Function(Pointer<Void>, Pointer<Void>, Pointer<Void>, int);
final InterlockedPushListSListEx = DynamicLibrary.open('KERNEL32.dll')
.lookupFunction<InterlockedPushListSListExNative, InterlockedPushListSListExDart>('InterlockedPushListSListEx');
// ListHead : SLIST_HEADER* in/out -> Pointer<Void>
// List : SLIST_ENTRY* in/out -> Pointer<Void>
// ListEnd : SLIST_ENTRY* in/out -> Pointer<Void>
// Count : DWORD -> Uint32
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function InterlockedPushListSListEx(
ListHead: Pointer; // SLIST_HEADER* in/out
List: Pointer; // SLIST_ENTRY* in/out
ListEnd: Pointer; // SLIST_ENTRY* in/out
Count: DWORD // DWORD
): Pointer; stdcall;
external 'KERNEL32.dll' name 'InterlockedPushListSListEx';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "InterlockedPushListSListEx"
c_InterlockedPushListSListEx :: Ptr () -> Ptr () -> Ptr () -> Word32 -> IO (Ptr ())
-- ListHead : SLIST_HEADER* in/out -> Ptr ()
-- List : SLIST_ENTRY* in/out -> Ptr ()
-- ListEnd : SLIST_ENTRY* in/out -> Ptr ()
-- Count : DWORD -> Word32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let interlockedpushlistslistex =
foreign "InterlockedPushListSListEx"
((ptr void) @-> (ptr void) @-> (ptr void) @-> uint32_t @-> returning (ptr void))
(* ListHead : SLIST_HEADER* in/out -> (ptr void) *)
(* List : SLIST_ENTRY* in/out -> (ptr void) *)
(* ListEnd : SLIST_ENTRY* in/out -> (ptr void) *)
(* Count : DWORD -> uint32_t *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library kernel32 (t "KERNEL32.dll"))
(cffi:use-foreign-library kernel32)
(cffi:defcfun ("InterlockedPushListSListEx" interlocked-push-list-slist-ex :convention :stdcall) :pointer
(list-head :pointer) ; SLIST_HEADER* in/out
(list :pointer) ; SLIST_ENTRY* in/out
(list-end :pointer) ; SLIST_ENTRY* in/out
(count :uint32)) ; DWORD
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $InterlockedPushListSListEx = Win32::API::More->new('KERNEL32',
'LPVOID InterlockedPushListSListEx(LPVOID ListHead, LPVOID List, LPVOID ListEnd, DWORD Count)');
# my $ret = $InterlockedPushListSListEx->Call($ListHead, $List, $ListEnd, $Count);
# ListHead : SLIST_HEADER* in/out -> LPVOID
# List : SLIST_ENTRY* in/out -> LPVOID
# ListEnd : SLIST_ENTRY* in/out -> LPVOID
# Count : DWORD -> DWORD
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。