ホーム › Networking.Clustering › ResUtilPaxosComparer
ResUtilPaxosComparer
関数二つのPaxosタグが等しいか比較する。
シグネチャ
// RESUTILS.dll
#include <windows.h>
BOOL ResUtilPaxosComparer(
const PaxosTagCStruct* left,
const PaxosTagCStruct* right
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| left | PaxosTagCStruct* | in | 比較する一方のPaxosタグ構造体(PaxosTagCStruct)へのポインター。 |
| right | PaxosTagCStruct* | in | 比較するもう一方のPaxosタグ構造体へのポインター。等しければ真。 |
戻り値の型: BOOL
各言語での呼び出し定義
// RESUTILS.dll
#include <windows.h>
BOOL ResUtilPaxosComparer(
const PaxosTagCStruct* left,
const PaxosTagCStruct* right
);[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("RESUTILS.dll", ExactSpelling = true)]
static extern bool ResUtilPaxosComparer(
IntPtr left, // PaxosTagCStruct*
IntPtr right // PaxosTagCStruct*
);<DllImport("RESUTILS.dll", ExactSpelling:=True)>
Public Shared Function ResUtilPaxosComparer(
left As IntPtr, ' PaxosTagCStruct*
right As IntPtr ' PaxosTagCStruct*
) As <MarshalAs(UnmanagedType.Bool)> Boolean
End Function' left : PaxosTagCStruct*
' right : PaxosTagCStruct*
Declare PtrSafe Function ResUtilPaxosComparer Lib "resutils" ( _
ByVal left As LongPtr, _
ByVal right As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
ResUtilPaxosComparer = ctypes.windll.resutils.ResUtilPaxosComparer
ResUtilPaxosComparer.restype = wintypes.BOOL
ResUtilPaxosComparer.argtypes = [
ctypes.c_void_p, # left : PaxosTagCStruct*
ctypes.c_void_p, # right : PaxosTagCStruct*
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('RESUTILS.dll')
ResUtilPaxosComparer = Fiddle::Function.new(
lib['ResUtilPaxosComparer'],
[
Fiddle::TYPE_VOIDP, # left : PaxosTagCStruct*
Fiddle::TYPE_VOIDP, # right : PaxosTagCStruct*
],
Fiddle::TYPE_INT)#[link(name = "resutils")]
extern "system" {
fn ResUtilPaxosComparer(
left: *const PaxosTagCStruct, // PaxosTagCStruct*
right: *const PaxosTagCStruct // PaxosTagCStruct*
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("RESUTILS.dll")]
public static extern bool ResUtilPaxosComparer(IntPtr left, IntPtr right);
"@
$api = Add-Type -MemberDefinition $sig -Name 'RESUTILS_ResUtilPaxosComparer' -Namespace Win32 -PassThru
# $api::ResUtilPaxosComparer(left, right)#uselib "RESUTILS.dll"
#func global ResUtilPaxosComparer "ResUtilPaxosComparer" sptr, sptr
; ResUtilPaxosComparer varptr(left), varptr(right) ; 戻り値は stat
; left : PaxosTagCStruct* -> "sptr"
; right : PaxosTagCStruct* -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "RESUTILS.dll" #cfunc global ResUtilPaxosComparer "ResUtilPaxosComparer" var, var ; res = ResUtilPaxosComparer(left, right) ; left : PaxosTagCStruct* -> "var" ; right : PaxosTagCStruct* -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "RESUTILS.dll" #cfunc global ResUtilPaxosComparer "ResUtilPaxosComparer" sptr, sptr ; res = ResUtilPaxosComparer(varptr(left), varptr(right)) ; left : PaxosTagCStruct* -> "sptr" ; right : PaxosTagCStruct* -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; BOOL ResUtilPaxosComparer(PaxosTagCStruct* left, PaxosTagCStruct* right) #uselib "RESUTILS.dll" #cfunc global ResUtilPaxosComparer "ResUtilPaxosComparer" var, var ; res = ResUtilPaxosComparer(left, right) ; left : PaxosTagCStruct* -> "var" ; right : PaxosTagCStruct* -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; BOOL ResUtilPaxosComparer(PaxosTagCStruct* left, PaxosTagCStruct* right) #uselib "RESUTILS.dll" #cfunc global ResUtilPaxosComparer "ResUtilPaxosComparer" intptr, intptr ; res = ResUtilPaxosComparer(varptr(left), varptr(right)) ; left : PaxosTagCStruct* -> "intptr" ; right : PaxosTagCStruct* -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
resutils = windows.NewLazySystemDLL("RESUTILS.dll")
procResUtilPaxosComparer = resutils.NewProc("ResUtilPaxosComparer")
)
// left (PaxosTagCStruct*), right (PaxosTagCStruct*)
r1, _, err := procResUtilPaxosComparer.Call(
uintptr(left),
uintptr(right),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // BOOLfunction ResUtilPaxosComparer(
left: Pointer; // PaxosTagCStruct*
right: Pointer // PaxosTagCStruct*
): BOOL; stdcall;
external 'RESUTILS.dll' name 'ResUtilPaxosComparer';result := DllCall("RESUTILS\ResUtilPaxosComparer"
, "Ptr", left ; PaxosTagCStruct*
, "Ptr", right ; PaxosTagCStruct*
, "Int") ; return: BOOL●ResUtilPaxosComparer(left, right) = DLL("RESUTILS.dll", "bool ResUtilPaxosComparer(void*, void*)")
# 呼び出し: ResUtilPaxosComparer(left, right)
# left : PaxosTagCStruct* -> "void*"
# right : PaxosTagCStruct* -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "resutils" fn ResUtilPaxosComparer(
left: [*c]PaxosTagCStruct, // PaxosTagCStruct*
right: [*c]PaxosTagCStruct // PaxosTagCStruct*
) callconv(std.os.windows.WINAPI) i32;proc ResUtilPaxosComparer(
left: ptr PaxosTagCStruct, # PaxosTagCStruct*
right: ptr PaxosTagCStruct # PaxosTagCStruct*
): int32 {.importc: "ResUtilPaxosComparer", stdcall, dynlib: "RESUTILS.dll".}pragma(lib, "resutils");
extern(Windows)
int ResUtilPaxosComparer(
PaxosTagCStruct* left, // PaxosTagCStruct*
PaxosTagCStruct* right // PaxosTagCStruct*
);ccall((:ResUtilPaxosComparer, "RESUTILS.dll"), stdcall, Int32,
(Ptr{PaxosTagCStruct}, Ptr{PaxosTagCStruct}),
left, right)
# left : PaxosTagCStruct* -> Ptr{PaxosTagCStruct}
# right : PaxosTagCStruct* -> Ptr{PaxosTagCStruct}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
int32_t ResUtilPaxosComparer(
void* left,
void* right);
]]
local resutils = ffi.load("resutils")
-- resutils.ResUtilPaxosComparer(left, right)
-- left : PaxosTagCStruct*
-- right : PaxosTagCStruct*
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('RESUTILS.dll');
const ResUtilPaxosComparer = lib.func('__stdcall', 'ResUtilPaxosComparer', 'int32_t', ['void *', 'void *']);
// ResUtilPaxosComparer(left, right)
// left : PaxosTagCStruct* -> 'void *'
// right : PaxosTagCStruct* -> 'void *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("RESUTILS.dll", {
ResUtilPaxosComparer: { parameters: ["pointer", "pointer"], result: "i32" },
});
// lib.symbols.ResUtilPaxosComparer(left, right)
// left : PaxosTagCStruct* -> "pointer"
// right : PaxosTagCStruct* -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int32_t ResUtilPaxosComparer(
void* left,
void* right);
C, "RESUTILS.dll");
// $ffi->ResUtilPaxosComparer(left, right);
// left : PaxosTagCStruct*
// right : PaxosTagCStruct*
// 構造体/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 Resutils extends StdCallLibrary {
Resutils INSTANCE = Native.load("resutils", Resutils.class);
boolean ResUtilPaxosComparer(
Pointer left, // PaxosTagCStruct*
Pointer right // PaxosTagCStruct*
);
}@[Link("resutils")]
lib LibRESUTILS
fun ResUtilPaxosComparer = ResUtilPaxosComparer(
left : PaxosTagCStruct*, # PaxosTagCStruct*
right : PaxosTagCStruct* # PaxosTagCStruct*
) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef ResUtilPaxosComparerNative = Int32 Function(Pointer<Void>, Pointer<Void>);
typedef ResUtilPaxosComparerDart = int Function(Pointer<Void>, Pointer<Void>);
final ResUtilPaxosComparer = DynamicLibrary.open('RESUTILS.dll')
.lookupFunction<ResUtilPaxosComparerNative, ResUtilPaxosComparerDart>('ResUtilPaxosComparer');
// left : PaxosTagCStruct* -> Pointer<Void>
// right : PaxosTagCStruct* -> Pointer<Void>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function ResUtilPaxosComparer(
left: Pointer; // PaxosTagCStruct*
right: Pointer // PaxosTagCStruct*
): BOOL; stdcall;
external 'RESUTILS.dll' name 'ResUtilPaxosComparer';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "ResUtilPaxosComparer"
c_ResUtilPaxosComparer :: Ptr () -> Ptr () -> IO CInt
-- left : PaxosTagCStruct* -> Ptr ()
-- right : PaxosTagCStruct* -> Ptr ()
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let resutilpaxoscomparer =
foreign "ResUtilPaxosComparer"
((ptr void) @-> (ptr void) @-> returning int32_t)
(* left : PaxosTagCStruct* -> (ptr void) *)
(* right : PaxosTagCStruct* -> (ptr void) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library resutils (t "RESUTILS.dll"))
(cffi:use-foreign-library resutils)
(cffi:defcfun ("ResUtilPaxosComparer" res-util-paxos-comparer :convention :stdcall) :int32
(left :pointer) ; PaxosTagCStruct*
(right :pointer)) ; PaxosTagCStruct*
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $ResUtilPaxosComparer = Win32::API::More->new('RESUTILS',
'BOOL ResUtilPaxosComparer(LPVOID left, LPVOID right)');
# my $ret = $ResUtilPaxosComparer->Call($left, $right);
# left : PaxosTagCStruct* -> LPVOID
# right : PaxosTagCStruct* -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。関連項目
使用する型