Merge pull request #21843 from alexrp/callconv-followup

Some follow-up work for #21697
This commit is contained in:
Alex Rønne Petersen 2024-11-03 14:27:09 +01:00 committed by GitHub
commit 3054486d1d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
24 changed files with 420 additions and 334 deletions

View File

@ -376,7 +376,7 @@ set(ZIG_STAGE2_SOURCES
lib/std/Target.zig lib/std/Target.zig
lib/std/Target/Query.zig lib/std/Target/Query.zig
lib/std/Target/aarch64.zig lib/std/Target/aarch64.zig
lib/std/Target/amdgpu.zig lib/std/Target/amdgcn.zig
lib/std/Target/arm.zig lib/std/Target/arm.zig
lib/std/Target/avr.zig lib/std/Target/avr.zig
lib/std/Target/bpf.zig lib/std/Target/bpf.zig

View File

@ -42,7 +42,7 @@ const largest_atomic_size = switch (arch) {
// Objects smaller than this threshold are implemented in terms of compare-exchange // Objects smaller than this threshold are implemented in terms of compare-exchange
// of a larger value. // of a larger value.
const smallest_atomic_fetch_exch_size = switch (arch) { const smallest_atomic_fetch_exch_size = switch (arch) {
// On AMDGPU, there are no instructions for atomic operations other than load and store // On AMDGCN, there are no instructions for atomic operations other than load and store
// (as of LLVM 15), and so these need to be implemented in terms of atomic CAS. // (as of LLVM 15), and so these need to be implemented in terms of atomic CAS.
.amdgcn => @sizeOf(u32), .amdgcn => @sizeOf(u32),
else => @sizeOf(u8), else => @sizeOf(u8),

View File

@ -719,7 +719,7 @@ pub const Os = struct {
pub const aarch64 = @import("Target/aarch64.zig"); pub const aarch64 = @import("Target/aarch64.zig");
pub const arc = @import("Target/arc.zig"); pub const arc = @import("Target/arc.zig");
pub const amdgpu = @import("Target/amdgpu.zig"); pub const amdgcn = @import("Target/amdgcn.zig");
pub const arm = @import("Target/arm.zig"); pub const arm = @import("Target/arm.zig");
pub const avr = @import("Target/avr.zig"); pub const avr = @import("Target/avr.zig");
pub const bpf = @import("Target/bpf.zig"); pub const bpf = @import("Target/bpf.zig");
@ -1592,7 +1592,6 @@ pub const Cpu = struct {
.loongarch32, .loongarch64 => "loongarch", .loongarch32, .loongarch64 => "loongarch",
.mips, .mipsel, .mips64, .mips64el => "mips", .mips, .mipsel, .mips64, .mips64el => "mips",
.powerpc, .powerpcle, .powerpc64, .powerpc64le => "powerpc", .powerpc, .powerpcle, .powerpc64, .powerpc64le => "powerpc",
.amdgcn => "amdgpu",
.riscv32, .riscv64 => "riscv", .riscv32, .riscv64 => "riscv",
.sparc, .sparc64 => "sparc", .sparc, .sparc64 => "sparc",
.s390x => "s390x", .s390x => "s390x",
@ -1621,7 +1620,7 @@ pub const Cpu = struct {
.mips, .mipsel, .mips64, .mips64el => &mips.all_features, .mips, .mipsel, .mips64, .mips64el => &mips.all_features,
.msp430 => &msp430.all_features, .msp430 => &msp430.all_features,
.powerpc, .powerpcle, .powerpc64, .powerpc64le => &powerpc.all_features, .powerpc, .powerpcle, .powerpc64, .powerpc64le => &powerpc.all_features,
.amdgcn => &amdgpu.all_features, .amdgcn => &amdgcn.all_features,
.riscv32, .riscv64 => &riscv.all_features, .riscv32, .riscv64 => &riscv.all_features,
.sparc, .sparc64 => &sparc.all_features, .sparc, .sparc64 => &sparc.all_features,
.spirv, .spirv32, .spirv64 => &spirv.all_features, .spirv, .spirv32, .spirv64 => &spirv.all_features,
@ -1653,7 +1652,7 @@ pub const Cpu = struct {
.mips, .mipsel, .mips64, .mips64el => comptime allCpusFromDecls(mips.cpu), .mips, .mipsel, .mips64, .mips64el => comptime allCpusFromDecls(mips.cpu),
.msp430 => comptime allCpusFromDecls(msp430.cpu), .msp430 => comptime allCpusFromDecls(msp430.cpu),
.powerpc, .powerpcle, .powerpc64, .powerpc64le => comptime allCpusFromDecls(powerpc.cpu), .powerpc, .powerpcle, .powerpc64, .powerpc64le => comptime allCpusFromDecls(powerpc.cpu),
.amdgcn => comptime allCpusFromDecls(amdgpu.cpu), .amdgcn => comptime allCpusFromDecls(amdgcn.cpu),
.riscv32, .riscv64 => comptime allCpusFromDecls(riscv.cpu), .riscv32, .riscv64 => comptime allCpusFromDecls(riscv.cpu),
.sparc, .sparc64 => comptime allCpusFromDecls(sparc.cpu), .sparc, .sparc64 => comptime allCpusFromDecls(sparc.cpu),
.spirv, .spirv32, .spirv64 => comptime allCpusFromDecls(spirv.cpu), .spirv, .spirv32, .spirv64 => comptime allCpusFromDecls(spirv.cpu),
@ -1891,7 +1890,7 @@ pub const Cpu = struct {
}; };
}; };
return switch (arch) { return switch (arch) {
.amdgcn => &amdgpu.cpu.gfx600, .amdgcn => &amdgcn.cpu.gfx600,
.arc => &arc.cpu.generic, .arc => &arc.cpu.generic,
.arm, .armeb, .thumb, .thumbeb => &arm.cpu.generic, .arm, .armeb, .thumb, .thumbeb => &arm.cpu.generic,
.aarch64, .aarch64_be => &aarch64.cpu.generic, .aarch64, .aarch64_be => &aarch64.cpu.generic,
@ -1940,7 +1939,7 @@ pub const Cpu = struct {
/// `Os.Tag.freestanding`. /// `Os.Tag.freestanding`.
pub fn baseline(arch: Arch, os: Os) *const Model { pub fn baseline(arch: Arch, os: Os) *const Model {
return switch (arch) { return switch (arch) {
.amdgcn => &amdgpu.cpu.gfx906, .amdgcn => &amdgcn.cpu.gfx906,
.arm, .armeb, .thumb, .thumbeb => &arm.cpu.baseline, .arm, .armeb, .thumb, .thumbeb => &arm.cpu.baseline,
.aarch64 => switch (os.tag) { .aarch64 => switch (os.tag) {
.bridgeos, .driverkit, .macos => &aarch64.cpu.apple_m1, .bridgeos, .driverkit, .macos => &aarch64.cpu.apple_m1,
@ -3308,6 +3307,7 @@ pub fn cCallingConvention(target: Target) ?std.builtin.CallingConvention {
}, },
.arm, .armeb, .thumb, .thumbeb => switch (target.os.tag) { .arm, .armeb, .thumb, .thumbeb => switch (target.os.tag) {
.netbsd => .{ .arm_apcs = .{} }, .netbsd => .{ .arm_apcs = .{} },
.watchos => .{ .arm_aapcs16_vfp = .{} },
else => switch (target.abi.floatAbi()) { else => switch (target.abi.floatAbi()) {
.soft => .{ .arm_aapcs = .{} }, .soft => .{ .arm_aapcs = .{} },
.hard => .{ .arm_aapcs_vfp = .{} }, .hard => .{ .arm_aapcs_vfp = .{} },

View File

@ -589,7 +589,7 @@ const WindowsThreadImpl = struct {
fn_args: Args, fn_args: Args,
thread: ThreadCompletion, thread: ThreadCompletion,
fn entryFn(raw_ptr: windows.PVOID) callconv(.C) windows.DWORD { fn entryFn(raw_ptr: windows.PVOID) callconv(.winapi) windows.DWORD {
const self: *@This() = @ptrCast(@alignCast(raw_ptr)); const self: *@This() = @ptrCast(@alignCast(raw_ptr));
defer switch (self.thread.completion.swap(.completed, .seq_cst)) { defer switch (self.thread.completion.swap(.completed, .seq_cst)) {
.running => {}, .running => {},
@ -749,7 +749,7 @@ const PosixThreadImpl = struct {
const allocator = std.heap.c_allocator; const allocator = std.heap.c_allocator;
const Instance = struct { const Instance = struct {
fn entryFn(raw_arg: ?*anyopaque) callconv(.C) ?*anyopaque { fn entryFn(raw_arg: ?*anyopaque) callconv(.c) ?*anyopaque {
const args_ptr: *Args = @ptrCast(@alignCast(raw_arg)); const args_ptr: *Args = @ptrCast(@alignCast(raw_arg));
defer allocator.destroy(args_ptr); defer allocator.destroy(args_ptr);
return callFn(f, args_ptr.*); return callFn(f, args_ptr.*);
@ -1363,7 +1363,7 @@ const LinuxThreadImpl = struct {
fn_args: Args, fn_args: Args,
thread: ThreadCompletion, thread: ThreadCompletion,
fn entryFn(raw_arg: usize) callconv(.C) u8 { fn entryFn(raw_arg: usize) callconv(.c) u8 {
const self = @as(*@This(), @ptrFromInt(raw_arg)); const self = @as(*@This(), @ptrFromInt(raw_arg));
defer switch (self.thread.completion.swap(.completed, .seq_cst)) { defer switch (self.thread.completion.swap(.completed, .seq_cst)) {
.running => {}, .running => {},

View File

@ -293,12 +293,12 @@ pub const CallingConvention = union(enum(u8)) {
arm_aapcs16_vfp: CommonOptions, arm_aapcs16_vfp: CommonOptions,
arm_interrupt: ArmInterruptOptions, arm_interrupt: ArmInterruptOptions,
// Calling conventions for the `mips64` architecture. // Calling conventions for the `mips64` and `mips64el` architectures.
mips64_n64: CommonOptions, mips64_n64: CommonOptions,
mips64_n32: CommonOptions, mips64_n32: CommonOptions,
mips64_interrupt: MipsInterruptOptions, mips64_interrupt: MipsInterruptOptions,
// Calling conventions for the `mips` architecture. // Calling conventions for the `mips` and `mipsel` architectures.
mips_o32: CommonOptions, mips_o32: CommonOptions,
mips_interrupt: MipsInterruptOptions, mips_interrupt: MipsInterruptOptions,
@ -329,7 +329,7 @@ pub const CallingConvention = union(enum(u8)) {
powerpc_aix: CommonOptions, powerpc_aix: CommonOptions,
powerpc_aix_altivec: CommonOptions, powerpc_aix_altivec: CommonOptions,
/// The standard `wasm32`/`wasm64` calling convention, as specified in the WebAssembly Tool Conventions. /// The standard `wasm32` and `wasm64` calling convention, as specified in the WebAssembly Tool Conventions.
wasm_watc: CommonOptions, wasm_watc: CommonOptions,
/// The standard `arc` calling convention. /// The standard `arc` calling convention.
@ -396,7 +396,7 @@ pub const CallingConvention = union(enum(u8)) {
amdgcn_kernel, amdgcn_kernel,
amdgcn_cs: CommonOptions, amdgcn_cs: CommonOptions,
// Calling conventions for the `nvptx` architecture. // Calling conventions for the `nvptx` and `nvptx64` architectures.
nvptx_device, nvptx_device,
nvptx_kernel, nvptx_kernel,

View File

@ -1344,7 +1344,7 @@ fn dumpSegfaultInfoPosix(sig: i32, code: i32, addr: usize, ctx_ptr: ?*anyopaque)
} }
} }
fn handleSegfaultWindows(info: *windows.EXCEPTION_POINTERS) callconv(windows.WINAPI) c_long { fn handleSegfaultWindows(info: *windows.EXCEPTION_POINTERS) callconv(.winapi) c_long {
switch (info.ExceptionRecord.ExceptionCode) { switch (info.ExceptionRecord.ExceptionCode) {
windows.EXCEPTION_DATATYPE_MISALIGNMENT => handleSegfaultWindowsExtra(info, 0, "Unaligned Memory Access"), windows.EXCEPTION_DATATYPE_MISALIGNMENT => handleSegfaultWindowsExtra(info, 0, "Unaligned Memory Access"),
windows.EXCEPTION_ACCESS_VIOLATION => handleSegfaultWindowsExtra(info, 1, null), windows.EXCEPTION_ACCESS_VIOLATION => handleSegfaultWindowsExtra(info, 1, null),

View File

@ -2101,8 +2101,8 @@ pub fn UnlockFile(
/// This is a workaround for the C backend until zig has the ability to put /// This is a workaround for the C backend until zig has the ability to put
/// C code in inline assembly. /// C code in inline assembly.
extern fn zig_x86_windows_teb() callconv(.C) *anyopaque; extern fn zig_x86_windows_teb() callconv(.c) *anyopaque;
extern fn zig_x86_64_windows_teb() callconv(.C) *anyopaque; extern fn zig_x86_64_windows_teb() callconv(.c) *anyopaque;
pub fn teb() *TEB { pub fn teb() *TEB {
return switch (native_arch) { return switch (native_arch) {
@ -2824,6 +2824,7 @@ pub const STD_OUTPUT_HANDLE = maxInt(DWORD) - 11 + 1;
/// The standard error device. Initially, this is the active console screen buffer, CONOUT$. /// The standard error device. Initially, this is the active console screen buffer, CONOUT$.
pub const STD_ERROR_HANDLE = maxInt(DWORD) - 12 + 1; pub const STD_ERROR_HANDLE = maxInt(DWORD) - 12 + 1;
/// Deprecated; use `std.builtin.CallingConvention.winapi` instead.
pub const WINAPI: std.builtin.CallingConvention = .winapi; pub const WINAPI: std.builtin.CallingConvention = .winapi;
pub const BOOL = c_int; pub const BOOL = c_int;
@ -3567,7 +3568,7 @@ pub const MEM_RESERVE_PLACEHOLDERS = 0x2;
pub const MEM_DECOMMIT = 0x4000; pub const MEM_DECOMMIT = 0x4000;
pub const MEM_RELEASE = 0x8000; pub const MEM_RELEASE = 0x8000;
pub const PTHREAD_START_ROUTINE = *const fn (LPVOID) callconv(.C) DWORD; pub const PTHREAD_START_ROUTINE = *const fn (LPVOID) callconv(.winapi) DWORD;
pub const LPTHREAD_START_ROUTINE = PTHREAD_START_ROUTINE; pub const LPTHREAD_START_ROUTINE = PTHREAD_START_ROUTINE;
pub const WIN32_FIND_DATAW = extern struct { pub const WIN32_FIND_DATAW = extern struct {
@ -3745,7 +3746,7 @@ pub const IMAGE_TLS_DIRECTORY = extern struct {
pub const IMAGE_TLS_DIRECTORY64 = IMAGE_TLS_DIRECTORY; pub const IMAGE_TLS_DIRECTORY64 = IMAGE_TLS_DIRECTORY;
pub const IMAGE_TLS_DIRECTORY32 = IMAGE_TLS_DIRECTORY; pub const IMAGE_TLS_DIRECTORY32 = IMAGE_TLS_DIRECTORY;
pub const PIMAGE_TLS_CALLBACK = ?*const fn (PVOID, DWORD, PVOID) callconv(.C) void; pub const PIMAGE_TLS_CALLBACK = ?*const fn (PVOID, DWORD, PVOID) callconv(.winapi) void;
pub const PROV_RSA_FULL = 1; pub const PROV_RSA_FULL = 1;
@ -3843,7 +3844,7 @@ pub const RTL_QUERY_REGISTRY_ROUTINE = ?*const fn (
ULONG, ULONG,
?*anyopaque, ?*anyopaque,
?*anyopaque, ?*anyopaque,
) callconv(WINAPI) NTSTATUS; ) callconv(.winapi) NTSTATUS;
/// Path is a full path /// Path is a full path
pub const RTL_REGISTRY_ABSOLUTE = 0; pub const RTL_REGISTRY_ABSOLUTE = 0;
@ -3940,7 +3941,7 @@ pub const FILE_ACTION_MODIFIED = 0x00000003;
pub const FILE_ACTION_RENAMED_OLD_NAME = 0x00000004; pub const FILE_ACTION_RENAMED_OLD_NAME = 0x00000004;
pub const FILE_ACTION_RENAMED_NEW_NAME = 0x00000005; pub const FILE_ACTION_RENAMED_NEW_NAME = 0x00000005;
pub const LPOVERLAPPED_COMPLETION_ROUTINE = ?*const fn (DWORD, DWORD, *OVERLAPPED) callconv(.C) void; pub const LPOVERLAPPED_COMPLETION_ROUTINE = ?*const fn (DWORD, DWORD, *OVERLAPPED) callconv(.winapi) void;
pub const FileNotifyChangeFilter = packed struct(DWORD) { pub const FileNotifyChangeFilter = packed struct(DWORD) {
file_name: bool = false, file_name: bool = false,
@ -4003,7 +4004,7 @@ pub const RTL_CRITICAL_SECTION = extern struct {
pub const CRITICAL_SECTION = RTL_CRITICAL_SECTION; pub const CRITICAL_SECTION = RTL_CRITICAL_SECTION;
pub const INIT_ONCE = RTL_RUN_ONCE; pub const INIT_ONCE = RTL_RUN_ONCE;
pub const INIT_ONCE_STATIC_INIT = RTL_RUN_ONCE_INIT; pub const INIT_ONCE_STATIC_INIT = RTL_RUN_ONCE_INIT;
pub const INIT_ONCE_FN = *const fn (InitOnce: *INIT_ONCE, Parameter: ?*anyopaque, Context: ?*anyopaque) callconv(.C) BOOL; pub const INIT_ONCE_FN = *const fn (InitOnce: *INIT_ONCE, Parameter: ?*anyopaque, Context: ?*anyopaque) callconv(.winapi) BOOL;
pub const RTL_RUN_ONCE = extern struct { pub const RTL_RUN_ONCE = extern struct {
Ptr: ?*anyopaque, Ptr: ?*anyopaque,
@ -4467,7 +4468,7 @@ pub const EXCEPTION_POINTERS = extern struct {
ContextRecord: *CONTEXT, ContextRecord: *CONTEXT,
}; };
pub const VECTORED_EXCEPTION_HANDLER = *const fn (ExceptionInfo: *EXCEPTION_POINTERS) callconv(WINAPI) c_long; pub const VECTORED_EXCEPTION_HANDLER = *const fn (ExceptionInfo: *EXCEPTION_POINTERS) callconv(.winapi) c_long;
pub const EXCEPTION_DISPOSITION = i32; pub const EXCEPTION_DISPOSITION = i32;
pub const EXCEPTION_ROUTINE = *const fn ( pub const EXCEPTION_ROUTINE = *const fn (
@ -4475,7 +4476,7 @@ pub const EXCEPTION_ROUTINE = *const fn (
EstablisherFrame: PVOID, EstablisherFrame: PVOID,
ContextRecord: *(Self.CONTEXT), ContextRecord: *(Self.CONTEXT),
DispatcherContext: PVOID, DispatcherContext: PVOID,
) callconv(WINAPI) EXCEPTION_DISPOSITION; ) callconv(.winapi) EXCEPTION_DISPOSITION;
pub const UNWIND_HISTORY_TABLE_SIZE = 12; pub const UNWIND_HISTORY_TABLE_SIZE = 12;
pub const UNWIND_HISTORY_TABLE_ENTRY = extern struct { pub const UNWIND_HISTORY_TABLE_ENTRY = extern struct {
@ -4851,7 +4852,7 @@ pub const RTL_DRIVE_LETTER_CURDIR = extern struct {
DosPath: UNICODE_STRING, DosPath: UNICODE_STRING,
}; };
pub const PPS_POST_PROCESS_INIT_ROUTINE = ?*const fn () callconv(.C) void; pub const PPS_POST_PROCESS_INIT_ROUTINE = ?*const fn () callconv(.winapi) void;
pub const FILE_DIRECTORY_INFORMATION = extern struct { pub const FILE_DIRECTORY_INFORMATION = extern struct {
NextEntryOffset: ULONG, NextEntryOffset: ULONG,
@ -4905,7 +4906,7 @@ pub fn FileInformationIterator(comptime FileInformationType: type) type {
}; };
} }
pub const IO_APC_ROUTINE = *const fn (PVOID, *IO_STATUS_BLOCK, ULONG) callconv(.C) void; pub const IO_APC_ROUTINE = *const fn (PVOID, *IO_STATUS_BLOCK, ULONG) callconv(.winapi) void;
pub const CURDIR = extern struct { pub const CURDIR = extern struct {
DosPath: UNICODE_STRING, DosPath: UNICODE_STRING,
@ -5009,8 +5010,8 @@ pub const ENUM_PAGE_FILE_INFORMATION = extern struct {
PeakUsage: SIZE_T, PeakUsage: SIZE_T,
}; };
pub const PENUM_PAGE_FILE_CALLBACKW = ?*const fn (?LPVOID, *ENUM_PAGE_FILE_INFORMATION, LPCWSTR) callconv(.C) BOOL; pub const PENUM_PAGE_FILE_CALLBACKW = ?*const fn (?LPVOID, *ENUM_PAGE_FILE_INFORMATION, LPCWSTR) callconv(.winapi) BOOL;
pub const PENUM_PAGE_FILE_CALLBACKA = ?*const fn (?LPVOID, *ENUM_PAGE_FILE_INFORMATION, LPCSTR) callconv(.C) BOOL; pub const PENUM_PAGE_FILE_CALLBACKA = ?*const fn (?LPVOID, *ENUM_PAGE_FILE_INFORMATION, LPCSTR) callconv(.winapi) BOOL;
pub const PSAPI_WS_WATCH_INFORMATION_EX = extern struct { pub const PSAPI_WS_WATCH_INFORMATION_EX = extern struct {
BasicInfo: PSAPI_WS_WATCH_INFORMATION, BasicInfo: PSAPI_WS_WATCH_INFORMATION,
@ -5122,7 +5123,7 @@ pub const CTRL_CLOSE_EVENT: DWORD = 2;
pub const CTRL_LOGOFF_EVENT: DWORD = 5; pub const CTRL_LOGOFF_EVENT: DWORD = 5;
pub const CTRL_SHUTDOWN_EVENT: DWORD = 6; pub const CTRL_SHUTDOWN_EVENT: DWORD = 6;
pub const HANDLER_ROUTINE = *const fn (dwCtrlType: DWORD) callconv(WINAPI) BOOL; pub const HANDLER_ROUTINE = *const fn (dwCtrlType: DWORD) callconv(.winapi) BOOL;
/// Processor feature enumeration. /// Processor feature enumeration.
pub const PF = enum(DWORD) { pub const PF = enum(DWORD) {

View File

@ -8,7 +8,6 @@ const LPCWSTR = windows.LPCWSTR;
const LSTATUS = windows.LSTATUS; const LSTATUS = windows.LSTATUS;
const REGSAM = windows.REGSAM; const REGSAM = windows.REGSAM;
const ULONG = windows.ULONG; const ULONG = windows.ULONG;
const WINAPI = windows.WINAPI;
pub extern "advapi32" fn RegOpenKeyExW( pub extern "advapi32" fn RegOpenKeyExW(
hKey: HKEY, hKey: HKEY,
@ -16,7 +15,7 @@ pub extern "advapi32" fn RegOpenKeyExW(
ulOptions: DWORD, ulOptions: DWORD,
samDesired: REGSAM, samDesired: REGSAM,
phkResult: *HKEY, phkResult: *HKEY,
) callconv(WINAPI) LSTATUS; ) callconv(.winapi) LSTATUS;
pub extern "advapi32" fn RegQueryValueExW( pub extern "advapi32" fn RegQueryValueExW(
hKey: HKEY, hKey: HKEY,
@ -25,13 +24,13 @@ pub extern "advapi32" fn RegQueryValueExW(
lpType: ?*DWORD, lpType: ?*DWORD,
lpData: ?*BYTE, lpData: ?*BYTE,
lpcbData: ?*DWORD, lpcbData: ?*DWORD,
) callconv(WINAPI) LSTATUS; ) callconv(.winapi) LSTATUS;
pub extern "advapi32" fn RegCloseKey(hKey: HKEY) callconv(WINAPI) LSTATUS; pub extern "advapi32" fn RegCloseKey(hKey: HKEY) callconv(.winapi) LSTATUS;
// RtlGenRandom is known as SystemFunction036 under advapi32 // RtlGenRandom is known as SystemFunction036 under advapi32
// http://msdn.microsoft.com/en-us/library/windows/desktop/aa387694.aspx */ // http://msdn.microsoft.com/en-us/library/windows/desktop/aa387694.aspx */
pub extern "advapi32" fn SystemFunction036(output: [*]u8, length: ULONG) callconv(WINAPI) BOOL; pub extern "advapi32" fn SystemFunction036(output: [*]u8, length: ULONG) callconv(.winapi) BOOL;
pub const RtlGenRandom = SystemFunction036; pub const RtlGenRandom = SystemFunction036;
pub const RRF = struct { pub const RRF = struct {
@ -62,7 +61,7 @@ pub extern "advapi32" fn RegGetValueW(
pdwType: ?*DWORD, pdwType: ?*DWORD,
pvData: ?*anyopaque, pvData: ?*anyopaque,
pcbData: ?*DWORD, pcbData: ?*DWORD,
) callconv(WINAPI) LSTATUS; ) callconv(.winapi) LSTATUS;
pub extern "advapi32" fn RegLoadAppKeyW( pub extern "advapi32" fn RegLoadAppKeyW(
lpFile: LPCWSTR, lpFile: LPCWSTR,
@ -70,4 +69,4 @@ pub extern "advapi32" fn RegLoadAppKeyW(
samDesired: REGSAM, samDesired: REGSAM,
dwOptions: DWORD, dwOptions: DWORD,
reserved: DWORD, reserved: DWORD,
) callconv(WINAPI) LSTATUS; ) callconv(.winapi) LSTATUS;

View File

@ -4,7 +4,6 @@ const BOOL = windows.BOOL;
const DWORD = windows.DWORD; const DWORD = windows.DWORD;
const BYTE = windows.BYTE; const BYTE = windows.BYTE;
const LPCWSTR = windows.LPCWSTR; const LPCWSTR = windows.LPCWSTR;
const WINAPI = windows.WINAPI;
pub const CERT_INFO = *opaque {}; pub const CERT_INFO = *opaque {};
pub const HCERTSTORE = *opaque {}; pub const HCERTSTORE = *opaque {};
@ -19,14 +18,14 @@ pub const CERT_CONTEXT = extern struct {
pub extern "crypt32" fn CertOpenSystemStoreW( pub extern "crypt32" fn CertOpenSystemStoreW(
_: ?*const anyopaque, _: ?*const anyopaque,
szSubsystemProtocol: LPCWSTR, szSubsystemProtocol: LPCWSTR,
) callconv(WINAPI) ?HCERTSTORE; ) callconv(.winapi) ?HCERTSTORE;
pub extern "crypt32" fn CertCloseStore( pub extern "crypt32" fn CertCloseStore(
hCertStore: HCERTSTORE, hCertStore: HCERTSTORE,
dwFlags: DWORD, dwFlags: DWORD,
) callconv(WINAPI) BOOL; ) callconv(.winapi) BOOL;
pub extern "crypt32" fn CertEnumCertificatesInStore( pub extern "crypt32" fn CertEnumCertificatesInStore(
hCertStore: HCERTSTORE, hCertStore: HCERTSTORE,
pPrevCertContext: ?*CERT_CONTEXT, pPrevCertContext: ?*CERT_CONTEXT,
) callconv(WINAPI) ?*CERT_CONTEXT; ) callconv(.winapi) ?*CERT_CONTEXT;

View File

@ -41,7 +41,6 @@ const VECTORED_EXCEPTION_HANDLER = windows.VECTORED_EXCEPTION_HANDLER;
const WCHAR = windows.WCHAR; const WCHAR = windows.WCHAR;
const WIN32_FIND_DATAW = windows.WIN32_FIND_DATAW; const WIN32_FIND_DATAW = windows.WIN32_FIND_DATAW;
const Win32Error = windows.Win32Error; const Win32Error = windows.Win32Error;
const WINAPI = windows.WINAPI;
const WORD = windows.WORD; const WORD = windows.WORD;
// I/O - Filesystem // I/O - Filesystem
@ -55,18 +54,18 @@ pub extern "kernel32" fn ReadDirectoryChangesW(
lpBytesReturned: ?*windows.DWORD, lpBytesReturned: ?*windows.DWORD,
lpOverlapped: ?*windows.OVERLAPPED, lpOverlapped: ?*windows.OVERLAPPED,
lpCompletionRoutine: windows.LPOVERLAPPED_COMPLETION_ROUTINE, lpCompletionRoutine: windows.LPOVERLAPPED_COMPLETION_ROUTINE,
) callconv(windows.WINAPI) windows.BOOL; ) callconv(.winapi) windows.BOOL;
// TODO: Wrapper around NtCancelIoFile. // TODO: Wrapper around NtCancelIoFile.
pub extern "kernel32" fn CancelIo( pub extern "kernel32" fn CancelIo(
hFile: HANDLE, hFile: HANDLE,
) callconv(WINAPI) BOOL; ) callconv(.winapi) BOOL;
// TODO: Wrapper around NtCancelIoFileEx. // TODO: Wrapper around NtCancelIoFileEx.
pub extern "kernel32" fn CancelIoEx( pub extern "kernel32" fn CancelIoEx(
hFile: HANDLE, hFile: HANDLE,
lpOverlapped: ?*OVERLAPPED, lpOverlapped: ?*OVERLAPPED,
) callconv(WINAPI) BOOL; ) callconv(.winapi) BOOL;
pub extern "kernel32" fn CreateFileW( pub extern "kernel32" fn CreateFileW(
lpFileName: LPCWSTR, lpFileName: LPCWSTR,
@ -76,7 +75,7 @@ pub extern "kernel32" fn CreateFileW(
dwCreationDisposition: DWORD, dwCreationDisposition: DWORD,
dwFlagsAndAttributes: DWORD, dwFlagsAndAttributes: DWORD,
hTemplateFile: ?HANDLE, hTemplateFile: ?HANDLE,
) callconv(WINAPI) HANDLE; ) callconv(.winapi) HANDLE;
// TODO A bunch of logic around NtCreateNamedPipe // TODO A bunch of logic around NtCreateNamedPipe
pub extern "kernel32" fn CreateNamedPipeW( pub extern "kernel32" fn CreateNamedPipeW(
@ -88,16 +87,16 @@ pub extern "kernel32" fn CreateNamedPipeW(
nInBufferSize: DWORD, nInBufferSize: DWORD,
nDefaultTimeOut: DWORD, nDefaultTimeOut: DWORD,
lpSecurityAttributes: ?*const SECURITY_ATTRIBUTES, lpSecurityAttributes: ?*const SECURITY_ATTRIBUTES,
) callconv(WINAPI) HANDLE; ) callconv(.winapi) HANDLE;
pub extern "kernel32" fn FindFirstFileW( pub extern "kernel32" fn FindFirstFileW(
lpFileName: LPCWSTR, lpFileName: LPCWSTR,
lpFindFileData: *WIN32_FIND_DATAW, lpFindFileData: *WIN32_FIND_DATAW,
) callconv(WINAPI) HANDLE; ) callconv(.winapi) HANDLE;
pub extern "kernel32" fn FindClose( pub extern "kernel32" fn FindClose(
hFindFile: HANDLE, hFindFile: HANDLE,
) callconv(WINAPI) BOOL; ) callconv(.winapi) BOOL;
// TODO: Wrapper around RtlGetFullPathName_UEx // TODO: Wrapper around RtlGetFullPathName_UEx
pub extern "kernel32" fn GetFullPathNameW( pub extern "kernel32" fn GetFullPathNameW(
@ -105,18 +104,18 @@ pub extern "kernel32" fn GetFullPathNameW(
nBufferLength: DWORD, nBufferLength: DWORD,
lpBuffer: LPWSTR, lpBuffer: LPWSTR,
lpFilePart: ?*?LPWSTR, lpFilePart: ?*?LPWSTR,
) callconv(WINAPI) DWORD; ) callconv(.winapi) DWORD;
// TODO: Matches `STD_*_HANDLE` to peb().ProcessParameters.Standard* // TODO: Matches `STD_*_HANDLE` to peb().ProcessParameters.Standard*
pub extern "kernel32" fn GetStdHandle( pub extern "kernel32" fn GetStdHandle(
nStdHandle: DWORD, nStdHandle: DWORD,
) callconv(WINAPI) ?HANDLE; ) callconv(.winapi) ?HANDLE;
pub extern "kernel32" fn MoveFileExW( pub extern "kernel32" fn MoveFileExW(
lpExistingFileName: LPCWSTR, lpExistingFileName: LPCWSTR,
lpNewFileName: LPCWSTR, lpNewFileName: LPCWSTR,
dwFlags: DWORD, dwFlags: DWORD,
) callconv(WINAPI) BOOL; ) callconv(.winapi) BOOL;
// TODO: Wrapper around NtSetInformationFile + `FILE_POSITION_INFORMATION`. // TODO: Wrapper around NtSetInformationFile + `FILE_POSITION_INFORMATION`.
// `FILE_STANDARD_INFORMATION` is also used if dwMoveMethod is `FILE_END` // `FILE_STANDARD_INFORMATION` is also used if dwMoveMethod is `FILE_END`
@ -125,7 +124,7 @@ pub extern "kernel32" fn SetFilePointerEx(
liDistanceToMove: LARGE_INTEGER, liDistanceToMove: LARGE_INTEGER,
lpNewFilePointer: ?*LARGE_INTEGER, lpNewFilePointer: ?*LARGE_INTEGER,
dwMoveMethod: DWORD, dwMoveMethod: DWORD,
) callconv(WINAPI) BOOL; ) callconv(.winapi) BOOL;
// TODO: Wrapper around NtSetInformationFile + `FILE_BASIC_INFORMATION` // TODO: Wrapper around NtSetInformationFile + `FILE_BASIC_INFORMATION`
pub extern "kernel32" fn SetFileTime( pub extern "kernel32" fn SetFileTime(
@ -133,7 +132,7 @@ pub extern "kernel32" fn SetFileTime(
lpCreationTime: ?*const FILETIME, lpCreationTime: ?*const FILETIME,
lpLastAccessTime: ?*const FILETIME, lpLastAccessTime: ?*const FILETIME,
lpLastWriteTime: ?*const FILETIME, lpLastWriteTime: ?*const FILETIME,
) callconv(WINAPI) BOOL; ) callconv(.winapi) BOOL;
pub extern "kernel32" fn WriteFile( pub extern "kernel32" fn WriteFile(
in_hFile: HANDLE, in_hFile: HANDLE,
@ -141,35 +140,35 @@ pub extern "kernel32" fn WriteFile(
in_nNumberOfBytesToWrite: DWORD, in_nNumberOfBytesToWrite: DWORD,
out_lpNumberOfBytesWritten: ?*DWORD, out_lpNumberOfBytesWritten: ?*DWORD,
in_out_lpOverlapped: ?*OVERLAPPED, in_out_lpOverlapped: ?*OVERLAPPED,
) callconv(WINAPI) BOOL; ) callconv(.winapi) BOOL;
// TODO: wrapper for NtQueryInformationFile + `FILE_STANDARD_INFORMATION` // TODO: wrapper for NtQueryInformationFile + `FILE_STANDARD_INFORMATION`
pub extern "kernel32" fn GetFileSizeEx( pub extern "kernel32" fn GetFileSizeEx(
hFile: HANDLE, hFile: HANDLE,
lpFileSize: *LARGE_INTEGER, lpFileSize: *LARGE_INTEGER,
) callconv(WINAPI) BOOL; ) callconv(.winapi) BOOL;
// TODO: Wrapper around GetStdHandle + NtFlushBuffersFile. // TODO: Wrapper around GetStdHandle + NtFlushBuffersFile.
pub extern "kernel32" fn FlushFileBuffers( pub extern "kernel32" fn FlushFileBuffers(
hFile: HANDLE, hFile: HANDLE,
) callconv(WINAPI) BOOL; ) callconv(.winapi) BOOL;
// TODO: Wrapper around NtSetInformationFile + `FILE_IO_COMPLETION_NOTIFICATION_INFORMATION`. // TODO: Wrapper around NtSetInformationFile + `FILE_IO_COMPLETION_NOTIFICATION_INFORMATION`.
pub extern "kernel32" fn SetFileCompletionNotificationModes( pub extern "kernel32" fn SetFileCompletionNotificationModes(
FileHandle: HANDLE, FileHandle: HANDLE,
Flags: UCHAR, Flags: UCHAR,
) callconv(WINAPI) BOOL; ) callconv(.winapi) BOOL;
// TODO: `RtlGetCurrentDirectory_U(nBufferLength * 2, lpBuffer)` // TODO: `RtlGetCurrentDirectory_U(nBufferLength * 2, lpBuffer)`
pub extern "kernel32" fn GetCurrentDirectoryW( pub extern "kernel32" fn GetCurrentDirectoryW(
nBufferLength: DWORD, nBufferLength: DWORD,
lpBuffer: ?[*]WCHAR, lpBuffer: ?[*]WCHAR,
) callconv(WINAPI) DWORD; ) callconv(.winapi) DWORD;
// TODO: RtlDosPathNameToNtPathNameU_WithStatus + NtQueryAttributesFile. // TODO: RtlDosPathNameToNtPathNameU_WithStatus + NtQueryAttributesFile.
pub extern "kernel32" fn GetFileAttributesW( pub extern "kernel32" fn GetFileAttributesW(
lpFileName: LPCWSTR, lpFileName: LPCWSTR,
) callconv(WINAPI) DWORD; ) callconv(.winapi) DWORD;
pub extern "kernel32" fn ReadFile( pub extern "kernel32" fn ReadFile(
hFile: HANDLE, hFile: HANDLE,
@ -177,12 +176,12 @@ pub extern "kernel32" fn ReadFile(
nNumberOfBytesToRead: DWORD, nNumberOfBytesToRead: DWORD,
lpNumberOfBytesRead: ?*DWORD, lpNumberOfBytesRead: ?*DWORD,
lpOverlapped: ?*OVERLAPPED, lpOverlapped: ?*OVERLAPPED,
) callconv(WINAPI) BOOL; ) callconv(.winapi) BOOL;
pub extern "kernel32" fn GetSystemDirectoryW( pub extern "kernel32" fn GetSystemDirectoryW(
lpBuffer: LPWSTR, lpBuffer: LPWSTR,
uSize: UINT, uSize: UINT,
) callconv(WINAPI) UINT; ) callconv(.winapi) UINT;
// I/O - Kernel Objects // I/O - Kernel Objects
@ -192,7 +191,7 @@ pub extern "kernel32" fn CreateEventExW(
lpName: ?LPCWSTR, lpName: ?LPCWSTR,
dwFlags: DWORD, dwFlags: DWORD,
dwDesiredAccess: DWORD, dwDesiredAccess: DWORD,
) callconv(WINAPI) ?HANDLE; ) callconv(.winapi) ?HANDLE;
// TODO: Wrapper around GetStdHandle + NtDuplicateObject. // TODO: Wrapper around GetStdHandle + NtDuplicateObject.
pub extern "kernel32" fn DuplicateHandle( pub extern "kernel32" fn DuplicateHandle(
@ -203,14 +202,14 @@ pub extern "kernel32" fn DuplicateHandle(
dwDesiredAccess: DWORD, dwDesiredAccess: DWORD,
bInheritHandle: BOOL, bInheritHandle: BOOL,
dwOptions: DWORD, dwOptions: DWORD,
) callconv(WINAPI) BOOL; ) callconv(.winapi) BOOL;
// TODO: Wrapper around GetStdHandle + NtQueryObject + NtSetInformationObject with .ObjectHandleFlagInformation. // TODO: Wrapper around GetStdHandle + NtQueryObject + NtSetInformationObject with .ObjectHandleFlagInformation.
pub extern "kernel32" fn SetHandleInformation( pub extern "kernel32" fn SetHandleInformation(
hObject: HANDLE, hObject: HANDLE,
dwMask: DWORD, dwMask: DWORD,
dwFlags: DWORD, dwFlags: DWORD,
) callconv(WINAPI) BOOL; ) callconv(.winapi) BOOL;
// TODO: Wrapper around NtRemoveIoCompletion. // TODO: Wrapper around NtRemoveIoCompletion.
pub extern "kernel32" fn GetQueuedCompletionStatus( pub extern "kernel32" fn GetQueuedCompletionStatus(
@ -219,7 +218,7 @@ pub extern "kernel32" fn GetQueuedCompletionStatus(
lpCompletionKey: *ULONG_PTR, lpCompletionKey: *ULONG_PTR,
lpOverlapped: *?*OVERLAPPED, lpOverlapped: *?*OVERLAPPED,
dwMilliseconds: DWORD, dwMilliseconds: DWORD,
) callconv(WINAPI) BOOL; ) callconv(.winapi) BOOL;
// TODO: Wrapper around NtRemoveIoCompletionEx. // TODO: Wrapper around NtRemoveIoCompletionEx.
pub extern "kernel32" fn GetQueuedCompletionStatusEx( pub extern "kernel32" fn GetQueuedCompletionStatusEx(
@ -229,7 +228,7 @@ pub extern "kernel32" fn GetQueuedCompletionStatusEx(
ulNumEntriesRemoved: *ULONG, ulNumEntriesRemoved: *ULONG,
dwMilliseconds: DWORD, dwMilliseconds: DWORD,
fAlertable: BOOL, fAlertable: BOOL,
) callconv(WINAPI) BOOL; ) callconv(.winapi) BOOL;
// TODO: Wrapper around NtSetIoCompletion with `IoStatus = .SUCCESS`. // TODO: Wrapper around NtSetIoCompletion with `IoStatus = .SUCCESS`.
pub extern "kernel32" fn PostQueuedCompletionStatus( pub extern "kernel32" fn PostQueuedCompletionStatus(
@ -237,7 +236,7 @@ pub extern "kernel32" fn PostQueuedCompletionStatus(
dwNumberOfBytesTransferred: DWORD, dwNumberOfBytesTransferred: DWORD,
dwCompletionKey: ULONG_PTR, dwCompletionKey: ULONG_PTR,
lpOverlapped: ?*OVERLAPPED, lpOverlapped: ?*OVERLAPPED,
) callconv(WINAPI) BOOL; ) callconv(.winapi) BOOL;
// TODO: // TODO:
// GetOverlappedResultEx with bAlertable=false, which calls: GetStdHandle + WaitForSingleObjectEx. // GetOverlappedResultEx with bAlertable=false, which calls: GetStdHandle + WaitForSingleObjectEx.
@ -247,7 +246,7 @@ pub extern "kernel32" fn GetOverlappedResult(
lpOverlapped: *OVERLAPPED, lpOverlapped: *OVERLAPPED,
lpNumberOfBytesTransferred: *DWORD, lpNumberOfBytesTransferred: *DWORD,
bWait: BOOL, bWait: BOOL,
) callconv(WINAPI) BOOL; ) callconv(.winapi) BOOL;
// TODO: Wrapper around NtCreateIoCompletion + NtSetInformationFile with FILE_COMPLETION_INFORMATION. // TODO: Wrapper around NtCreateIoCompletion + NtSetInformationFile with FILE_COMPLETION_INFORMATION.
// This would be better splitting into two functions. // This would be better splitting into two functions.
@ -256,30 +255,30 @@ pub extern "kernel32" fn CreateIoCompletionPort(
ExistingCompletionPort: ?HANDLE, ExistingCompletionPort: ?HANDLE,
CompletionKey: ULONG_PTR, CompletionKey: ULONG_PTR,
NumberOfConcurrentThreads: DWORD, NumberOfConcurrentThreads: DWORD,
) callconv(WINAPI) ?HANDLE; ) callconv(.winapi) ?HANDLE;
// TODO: Forwarder to NtAddVectoredExceptionHandler. // TODO: Forwarder to NtAddVectoredExceptionHandler.
pub extern "kernel32" fn AddVectoredExceptionHandler( pub extern "kernel32" fn AddVectoredExceptionHandler(
First: ULONG, First: ULONG,
Handler: ?VECTORED_EXCEPTION_HANDLER, Handler: ?VECTORED_EXCEPTION_HANDLER,
) callconv(WINAPI) ?LPVOID; ) callconv(.winapi) ?LPVOID;
// TODO: Forwarder to NtRemoveVectoredExceptionHandler. // TODO: Forwarder to NtRemoveVectoredExceptionHandler.
pub extern "kernel32" fn RemoveVectoredExceptionHandler( pub extern "kernel32" fn RemoveVectoredExceptionHandler(
Handle: HANDLE, Handle: HANDLE,
) callconv(WINAPI) ULONG; ) callconv(.winapi) ULONG;
// TODO: Wrapper around RtlReportSilentProcessExit + NtTerminateProcess. // TODO: Wrapper around RtlReportSilentProcessExit + NtTerminateProcess.
pub extern "kernel32" fn TerminateProcess( pub extern "kernel32" fn TerminateProcess(
hProcess: HANDLE, hProcess: HANDLE,
uExitCode: UINT, uExitCode: UINT,
) callconv(WINAPI) BOOL; ) callconv(.winapi) BOOL;
// TODO: WaitForSingleObjectEx with bAlertable=false. // TODO: WaitForSingleObjectEx with bAlertable=false.
pub extern "kernel32" fn WaitForSingleObject( pub extern "kernel32" fn WaitForSingleObject(
hHandle: HANDLE, hHandle: HANDLE,
dwMilliseconds: DWORD, dwMilliseconds: DWORD,
) callconv(WINAPI) DWORD; ) callconv(.winapi) DWORD;
// TODO: Wrapper for GetStdHandle + NtWaitForSingleObject. // TODO: Wrapper for GetStdHandle + NtWaitForSingleObject.
// Sets up an activation context before calling NtWaitForSingleObject. // Sets up an activation context before calling NtWaitForSingleObject.
@ -287,7 +286,7 @@ pub extern "kernel32" fn WaitForSingleObjectEx(
hHandle: HANDLE, hHandle: HANDLE,
dwMilliseconds: DWORD, dwMilliseconds: DWORD,
bAlertable: BOOL, bAlertable: BOOL,
) callconv(WINAPI) DWORD; ) callconv(.winapi) DWORD;
// TODO: WaitForMultipleObjectsEx with alertable=false // TODO: WaitForMultipleObjectsEx with alertable=false
pub extern "kernel32" fn WaitForMultipleObjects( pub extern "kernel32" fn WaitForMultipleObjects(
@ -295,7 +294,7 @@ pub extern "kernel32" fn WaitForMultipleObjects(
lpHandle: [*]const HANDLE, lpHandle: [*]const HANDLE,
bWaitAll: BOOL, bWaitAll: BOOL,
dwMilliseconds: DWORD, dwMilliseconds: DWORD,
) callconv(WINAPI) DWORD; ) callconv(.winapi) DWORD;
// TODO: Wrapper around NtWaitForMultipleObjects. // TODO: Wrapper around NtWaitForMultipleObjects.
pub extern "kernel32" fn WaitForMultipleObjectsEx( pub extern "kernel32" fn WaitForMultipleObjectsEx(
@ -304,7 +303,7 @@ pub extern "kernel32" fn WaitForMultipleObjectsEx(
bWaitAll: BOOL, bWaitAll: BOOL,
dwMilliseconds: DWORD, dwMilliseconds: DWORD,
bAlertable: BOOL, bAlertable: BOOL,
) callconv(WINAPI) DWORD; ) callconv(.winapi) DWORD;
// Process Management // Process Management
@ -319,57 +318,57 @@ pub extern "kernel32" fn CreateProcessW(
lpCurrentDirectory: ?LPCWSTR, lpCurrentDirectory: ?LPCWSTR,
lpStartupInfo: *STARTUPINFOW, lpStartupInfo: *STARTUPINFOW,
lpProcessInformation: *PROCESS_INFORMATION, lpProcessInformation: *PROCESS_INFORMATION,
) callconv(WINAPI) BOOL; ) callconv(.winapi) BOOL;
// TODO: Fowarder to RtlExitUserProcess. // TODO: Fowarder to RtlExitUserProcess.
pub extern "kernel32" fn ExitProcess( pub extern "kernel32" fn ExitProcess(
exit_code: UINT, exit_code: UINT,
) callconv(WINAPI) noreturn; ) callconv(.winapi) noreturn;
// TODO: SleepEx with bAlertable=false. // TODO: SleepEx with bAlertable=false.
pub extern "kernel32" fn Sleep( pub extern "kernel32" fn Sleep(
dwMilliseconds: DWORD, dwMilliseconds: DWORD,
) callconv(WINAPI) void; ) callconv(.winapi) void;
// TODO: Wrapper around NtQueryInformationProcess with `PROCESS_BASIC_INFORMATION`. // TODO: Wrapper around NtQueryInformationProcess with `PROCESS_BASIC_INFORMATION`.
pub extern "kernel32" fn GetExitCodeProcess( pub extern "kernel32" fn GetExitCodeProcess(
hProcess: HANDLE, hProcess: HANDLE,
lpExitCode: *DWORD, lpExitCode: *DWORD,
) callconv(WINAPI) BOOL; ) callconv(.winapi) BOOL;
// TODO: Already a wrapper for this, see `windows.GetCurrentProcess`. // TODO: Already a wrapper for this, see `windows.GetCurrentProcess`.
pub extern "kernel32" fn GetCurrentProcess() callconv(WINAPI) HANDLE; pub extern "kernel32" fn GetCurrentProcess() callconv(.winapi) HANDLE;
// TODO: memcpy peb().ProcessParameters.Environment, mem.span(0). Requires locking the PEB. // TODO: memcpy peb().ProcessParameters.Environment, mem.span(0). Requires locking the PEB.
pub extern "kernel32" fn GetEnvironmentStringsW() callconv(WINAPI) ?LPWSTR; pub extern "kernel32" fn GetEnvironmentStringsW() callconv(.winapi) ?LPWSTR;
// TODO: RtlFreeHeap on the output of GetEnvironmentStringsW. // TODO: RtlFreeHeap on the output of GetEnvironmentStringsW.
pub extern "kernel32" fn FreeEnvironmentStringsW( pub extern "kernel32" fn FreeEnvironmentStringsW(
penv: LPWSTR, penv: LPWSTR,
) callconv(WINAPI) BOOL; ) callconv(.winapi) BOOL;
// TODO: Wrapper around RtlQueryEnvironmentVariable. // TODO: Wrapper around RtlQueryEnvironmentVariable.
pub extern "kernel32" fn GetEnvironmentVariableW( pub extern "kernel32" fn GetEnvironmentVariableW(
lpName: ?LPCWSTR, lpName: ?LPCWSTR,
lpBuffer: ?[*]WCHAR, lpBuffer: ?[*]WCHAR,
nSize: DWORD, nSize: DWORD,
) callconv(WINAPI) DWORD; ) callconv(.winapi) DWORD;
// TODO: Wrapper around RtlSetEnvironmentVar. // TODO: Wrapper around RtlSetEnvironmentVar.
pub extern "kernel32" fn SetEnvironmentVariableW( pub extern "kernel32" fn SetEnvironmentVariableW(
lpName: LPCWSTR, lpName: LPCWSTR,
lpValue: ?LPCWSTR, lpValue: ?LPCWSTR,
) callconv(WINAPI) BOOL; ) callconv(.winapi) BOOL;
pub extern "kernel32" fn CreateToolhelp32Snapshot( pub extern "kernel32" fn CreateToolhelp32Snapshot(
dwFlags: DWORD, dwFlags: DWORD,
th32ProcessID: DWORD, th32ProcessID: DWORD,
) callconv(WINAPI) HANDLE; ) callconv(.winapi) HANDLE;
// Threading // Threading
// TODO: Already a wrapper for this, see `windows.GetCurrentThreadId`. // TODO: Already a wrapper for this, see `windows.GetCurrentThreadId`.
pub extern "kernel32" fn GetCurrentThreadId() callconv(WINAPI) DWORD; pub extern "kernel32" fn GetCurrentThreadId() callconv(.winapi) DWORD;
// TODO: CreateRemoteThread with hProcess=NtCurrentProcess(). // TODO: CreateRemoteThread with hProcess=NtCurrentProcess().
pub extern "kernel32" fn CreateThread( pub extern "kernel32" fn CreateThread(
@ -379,64 +378,64 @@ pub extern "kernel32" fn CreateThread(
lpParameter: ?LPVOID, lpParameter: ?LPVOID,
dwCreationFlags: DWORD, dwCreationFlags: DWORD,
lpThreadId: ?*DWORD, lpThreadId: ?*DWORD,
) callconv(WINAPI) ?HANDLE; ) callconv(.winapi) ?HANDLE;
// TODO: Wrapper around RtlDelayExecution. // TODO: Wrapper around RtlDelayExecution.
pub extern "kernel32" fn SwitchToThread() callconv(WINAPI) BOOL; pub extern "kernel32" fn SwitchToThread() callconv(.winapi) BOOL;
// Locks, critical sections, initializers // Locks, critical sections, initializers
// TODO: Forwarder to RtlInitializeCriticalSection // TODO: Forwarder to RtlInitializeCriticalSection
pub extern "kernel32" fn InitializeCriticalSection( pub extern "kernel32" fn InitializeCriticalSection(
lpCriticalSection: *CRITICAL_SECTION, lpCriticalSection: *CRITICAL_SECTION,
) callconv(WINAPI) void; ) callconv(.winapi) void;
// TODO: Forwarder to RtlEnterCriticalSection // TODO: Forwarder to RtlEnterCriticalSection
pub extern "kernel32" fn EnterCriticalSection( pub extern "kernel32" fn EnterCriticalSection(
lpCriticalSection: *CRITICAL_SECTION, lpCriticalSection: *CRITICAL_SECTION,
) callconv(WINAPI) void; ) callconv(.winapi) void;
// TODO: Forwarder to RtlLeaveCriticalSection // TODO: Forwarder to RtlLeaveCriticalSection
pub extern "kernel32" fn LeaveCriticalSection( pub extern "kernel32" fn LeaveCriticalSection(
lpCriticalSection: *CRITICAL_SECTION, lpCriticalSection: *CRITICAL_SECTION,
) callconv(WINAPI) void; ) callconv(.winapi) void;
// TODO: Forwarder to RtlDeleteCriticalSection // TODO: Forwarder to RtlDeleteCriticalSection
pub extern "kernel32" fn DeleteCriticalSection( pub extern "kernel32" fn DeleteCriticalSection(
lpCriticalSection: *CRITICAL_SECTION, lpCriticalSection: *CRITICAL_SECTION,
) callconv(WINAPI) void; ) callconv(.winapi) void;
// TODO: Forwarder to RtlTryAcquireSRWLockExclusive // TODO: Forwarder to RtlTryAcquireSRWLockExclusive
pub extern "kernel32" fn TryAcquireSRWLockExclusive( pub extern "kernel32" fn TryAcquireSRWLockExclusive(
SRWLock: *SRWLOCK, SRWLock: *SRWLOCK,
) callconv(WINAPI) BOOLEAN; ) callconv(.winapi) BOOLEAN;
// TODO: Forwarder to RtlAcquireSRWLockExclusive // TODO: Forwarder to RtlAcquireSRWLockExclusive
pub extern "kernel32" fn AcquireSRWLockExclusive( pub extern "kernel32" fn AcquireSRWLockExclusive(
SRWLock: *SRWLOCK, SRWLock: *SRWLOCK,
) callconv(WINAPI) void; ) callconv(.winapi) void;
// TODO: Forwarder to RtlReleaseSRWLockExclusive // TODO: Forwarder to RtlReleaseSRWLockExclusive
pub extern "kernel32" fn ReleaseSRWLockExclusive( pub extern "kernel32" fn ReleaseSRWLockExclusive(
SRWLock: *SRWLOCK, SRWLock: *SRWLOCK,
) callconv(WINAPI) void; ) callconv(.winapi) void;
pub extern "kernel32" fn InitOnceExecuteOnce( pub extern "kernel32" fn InitOnceExecuteOnce(
InitOnce: *INIT_ONCE, InitOnce: *INIT_ONCE,
InitFn: INIT_ONCE_FN, InitFn: INIT_ONCE_FN,
Parameter: ?*anyopaque, Parameter: ?*anyopaque,
Context: ?*anyopaque, Context: ?*anyopaque,
) callconv(WINAPI) BOOL; ) callconv(.winapi) BOOL;
// TODO: Forwarder to RtlWakeConditionVariable // TODO: Forwarder to RtlWakeConditionVariable
pub extern "kernel32" fn WakeConditionVariable( pub extern "kernel32" fn WakeConditionVariable(
ConditionVariable: *CONDITION_VARIABLE, ConditionVariable: *CONDITION_VARIABLE,
) callconv(WINAPI) void; ) callconv(.winapi) void;
// TODO: Forwarder to RtlWakeAllConditionVariable // TODO: Forwarder to RtlWakeAllConditionVariable
pub extern "kernel32" fn WakeAllConditionVariable( pub extern "kernel32" fn WakeAllConditionVariable(
ConditionVariable: *CONDITION_VARIABLE, ConditionVariable: *CONDITION_VARIABLE,
) callconv(WINAPI) void; ) callconv(.winapi) void;
// TODO: // TODO:
// - dwMilliseconds -> LARGE_INTEGER. // - dwMilliseconds -> LARGE_INTEGER.
@ -447,40 +446,40 @@ pub extern "kernel32" fn SleepConditionVariableSRW(
SRWLock: *SRWLOCK, SRWLock: *SRWLOCK,
dwMilliseconds: DWORD, dwMilliseconds: DWORD,
Flags: ULONG, Flags: ULONG,
) callconv(WINAPI) BOOL; ) callconv(.winapi) BOOL;
// Console management // Console management
pub extern "kernel32" fn GetConsoleMode( pub extern "kernel32" fn GetConsoleMode(
hConsoleHandle: HANDLE, hConsoleHandle: HANDLE,
lpMode: *DWORD, lpMode: *DWORD,
) callconv(WINAPI) BOOL; ) callconv(.winapi) BOOL;
pub extern "kernel32" fn SetConsoleMode( pub extern "kernel32" fn SetConsoleMode(
hConsoleHandle: HANDLE, hConsoleHandle: HANDLE,
dwMode: DWORD, dwMode: DWORD,
) callconv(WINAPI) BOOL; ) callconv(.winapi) BOOL;
pub extern "kernel32" fn GetConsoleScreenBufferInfo( pub extern "kernel32" fn GetConsoleScreenBufferInfo(
hConsoleOutput: HANDLE, hConsoleOutput: HANDLE,
lpConsoleScreenBufferInfo: *CONSOLE_SCREEN_BUFFER_INFO, lpConsoleScreenBufferInfo: *CONSOLE_SCREEN_BUFFER_INFO,
) callconv(WINAPI) BOOL; ) callconv(.winapi) BOOL;
pub extern "kernel32" fn SetConsoleTextAttribute( pub extern "kernel32" fn SetConsoleTextAttribute(
hConsoleOutput: HANDLE, hConsoleOutput: HANDLE,
wAttributes: WORD, wAttributes: WORD,
) callconv(WINAPI) BOOL; ) callconv(.winapi) BOOL;
pub extern "kernel32" fn SetConsoleCtrlHandler( pub extern "kernel32" fn SetConsoleCtrlHandler(
HandlerRoutine: ?HANDLER_ROUTINE, HandlerRoutine: ?HANDLER_ROUTINE,
Add: BOOL, Add: BOOL,
) callconv(WINAPI) BOOL; ) callconv(.winapi) BOOL;
pub extern "kernel32" fn SetConsoleOutputCP( pub extern "kernel32" fn SetConsoleOutputCP(
wCodePageID: UINT, wCodePageID: UINT,
) callconv(WINAPI) BOOL; ) callconv(.winapi) BOOL;
pub extern "kernel32" fn GetConsoleOutputCP() callconv(WINAPI) UINT; pub extern "kernel32" fn GetConsoleOutputCP() callconv(.winapi) UINT;
pub extern "kernel32" fn FillConsoleOutputAttribute( pub extern "kernel32" fn FillConsoleOutputAttribute(
hConsoleOutput: HANDLE, hConsoleOutput: HANDLE,
@ -488,7 +487,7 @@ pub extern "kernel32" fn FillConsoleOutputAttribute(
nLength: DWORD, nLength: DWORD,
dwWriteCoord: COORD, dwWriteCoord: COORD,
lpNumberOfAttrsWritten: *DWORD, lpNumberOfAttrsWritten: *DWORD,
) callconv(WINAPI) BOOL; ) callconv(.winapi) BOOL;
pub extern "kernel32" fn FillConsoleOutputCharacterW( pub extern "kernel32" fn FillConsoleOutputCharacterW(
hConsoleOutput: HANDLE, hConsoleOutput: HANDLE,
@ -496,12 +495,12 @@ pub extern "kernel32" fn FillConsoleOutputCharacterW(
nLength: DWORD, nLength: DWORD,
dwWriteCoord: COORD, dwWriteCoord: COORD,
lpNumberOfCharsWritten: *DWORD, lpNumberOfCharsWritten: *DWORD,
) callconv(WINAPI) BOOL; ) callconv(.winapi) BOOL;
pub extern "kernel32" fn SetConsoleCursorPosition( pub extern "kernel32" fn SetConsoleCursorPosition(
hConsoleOutput: HANDLE, hConsoleOutput: HANDLE,
dwCursorPosition: COORD, dwCursorPosition: COORD,
) callconv(WINAPI) BOOL; ) callconv(.winapi) BOOL;
pub extern "kernel32" fn WriteConsoleW( pub extern "kernel32" fn WriteConsoleW(
hConsoleOutput: HANDLE, hConsoleOutput: HANDLE,
@ -509,7 +508,7 @@ pub extern "kernel32" fn WriteConsoleW(
nNumberOfCharsToWrite: DWORD, nNumberOfCharsToWrite: DWORD,
lpNumberOfCharsWritten: ?*DWORD, lpNumberOfCharsWritten: ?*DWORD,
lpReserved: ?LPVOID, lpReserved: ?LPVOID,
) callconv(WINAPI) BOOL; ) callconv(.winapi) BOOL;
pub extern "kernel32" fn ReadConsoleOutputCharacterW( pub extern "kernel32" fn ReadConsoleOutputCharacterW(
hConsoleOutput: HANDLE, hConsoleOutput: HANDLE,
@ -517,7 +516,7 @@ pub extern "kernel32" fn ReadConsoleOutputCharacterW(
nLength: DWORD, nLength: DWORD,
dwReadCoord: COORD, dwReadCoord: COORD,
lpNumberOfCharsRead: *DWORD, lpNumberOfCharsRead: *DWORD,
) callconv(windows.WINAPI) BOOL; ) callconv(.winapi) BOOL;
// Memory Mapping/Allocation // Memory Mapping/Allocation
@ -526,12 +525,12 @@ pub extern "kernel32" fn HeapCreate(
flOptions: DWORD, flOptions: DWORD,
dwInitialSize: SIZE_T, dwInitialSize: SIZE_T,
dwMaximumSize: SIZE_T, dwMaximumSize: SIZE_T,
) callconv(WINAPI) ?HANDLE; ) callconv(.winapi) ?HANDLE;
// TODO: Wrapper around RtlDestroyHeap (BOOLEAN -> BOOL). // TODO: Wrapper around RtlDestroyHeap (BOOLEAN -> BOOL).
pub extern "kernel32" fn HeapDestroy( pub extern "kernel32" fn HeapDestroy(
hHeap: HANDLE, hHeap: HANDLE,
) callconv(WINAPI) BOOL; ) callconv(.winapi) BOOL;
// TODO: Forwarder to RtlReAllocateHeap. // TODO: Forwarder to RtlReAllocateHeap.
pub extern "kernel32" fn HeapReAlloc( pub extern "kernel32" fn HeapReAlloc(
@ -539,28 +538,28 @@ pub extern "kernel32" fn HeapReAlloc(
dwFlags: DWORD, dwFlags: DWORD,
lpMem: *anyopaque, lpMem: *anyopaque,
dwBytes: SIZE_T, dwBytes: SIZE_T,
) callconv(WINAPI) ?*anyopaque; ) callconv(.winapi) ?*anyopaque;
// TODO: Fowrarder to RtlAllocateHeap. // TODO: Fowrarder to RtlAllocateHeap.
pub extern "kernel32" fn HeapAlloc( pub extern "kernel32" fn HeapAlloc(
hHeap: HANDLE, hHeap: HANDLE,
dwFlags: DWORD, dwFlags: DWORD,
dwBytes: SIZE_T, dwBytes: SIZE_T,
) callconv(WINAPI) ?*anyopaque; ) callconv(.winapi) ?*anyopaque;
// TODO: Fowrarder to RtlFreeHeap. // TODO: Fowrarder to RtlFreeHeap.
pub extern "kernel32" fn HeapFree( pub extern "kernel32" fn HeapFree(
hHeap: HANDLE, hHeap: HANDLE,
dwFlags: DWORD, dwFlags: DWORD,
lpMem: LPVOID, lpMem: LPVOID,
) callconv(WINAPI) BOOL; ) callconv(.winapi) BOOL;
// TODO: Wrapper around RtlValidateHeap (BOOLEAN -> BOOL) // TODO: Wrapper around RtlValidateHeap (BOOLEAN -> BOOL)
pub extern "kernel32" fn HeapValidate( pub extern "kernel32" fn HeapValidate(
hHeap: HANDLE, hHeap: HANDLE,
dwFlags: DWORD, dwFlags: DWORD,
lpMem: ?*const anyopaque, lpMem: ?*const anyopaque,
) callconv(WINAPI) BOOL; ) callconv(.winapi) BOOL;
// TODO: Wrapper around NtAllocateVirtualMemory. // TODO: Wrapper around NtAllocateVirtualMemory.
pub extern "kernel32" fn VirtualAlloc( pub extern "kernel32" fn VirtualAlloc(
@ -568,7 +567,7 @@ pub extern "kernel32" fn VirtualAlloc(
dwSize: SIZE_T, dwSize: SIZE_T,
flAllocationType: DWORD, flAllocationType: DWORD,
flProtect: DWORD, flProtect: DWORD,
) callconv(WINAPI) ?LPVOID; ) callconv(.winapi) ?LPVOID;
// TODO: Wrapper around NtFreeVirtualMemory. // TODO: Wrapper around NtFreeVirtualMemory.
// If the return value is .INVALID_PAGE_PROTECTION, calls RtlFlushSecureMemoryCache and try again. // If the return value is .INVALID_PAGE_PROTECTION, calls RtlFlushSecureMemoryCache and try again.
@ -576,21 +575,21 @@ pub extern "kernel32" fn VirtualFree(
lpAddress: ?LPVOID, lpAddress: ?LPVOID,
dwSize: SIZE_T, dwSize: SIZE_T,
dwFreeType: DWORD, dwFreeType: DWORD,
) callconv(WINAPI) BOOL; ) callconv(.winapi) BOOL;
// TODO: Wrapper around NtQueryVirtualMemory. // TODO: Wrapper around NtQueryVirtualMemory.
pub extern "kernel32" fn VirtualQuery( pub extern "kernel32" fn VirtualQuery(
lpAddress: ?LPVOID, lpAddress: ?LPVOID,
lpBuffer: PMEMORY_BASIC_INFORMATION, lpBuffer: PMEMORY_BASIC_INFORMATION,
dwLength: SIZE_T, dwLength: SIZE_T,
) callconv(WINAPI) SIZE_T; ) callconv(.winapi) SIZE_T;
pub extern "kernel32" fn LocalFree( pub extern "kernel32" fn LocalFree(
hMem: HLOCAL, hMem: HLOCAL,
) callconv(WINAPI) ?HLOCAL; ) callconv(.winapi) ?HLOCAL;
// TODO: Getter for peb.ProcessHeap // TODO: Getter for peb.ProcessHeap
pub extern "kernel32" fn GetProcessHeap() callconv(WINAPI) ?HANDLE; pub extern "kernel32" fn GetProcessHeap() callconv(.winapi) ?HANDLE;
// Code Libraries/Modules // Code Libraries/Modules
@ -599,49 +598,49 @@ pub extern "kernel32" fn GetModuleFileNameW(
hModule: ?HMODULE, hModule: ?HMODULE,
lpFilename: [*]WCHAR, lpFilename: [*]WCHAR,
nSize: DWORD, nSize: DWORD,
) callconv(WINAPI) DWORD; ) callconv(.winapi) DWORD;
extern "kernel32" fn K32GetModuleFileNameExW( extern "kernel32" fn K32GetModuleFileNameExW(
hProcess: HANDLE, hProcess: HANDLE,
hModule: ?HMODULE, hModule: ?HMODULE,
lpFilename: LPWSTR, lpFilename: LPWSTR,
nSize: DWORD, nSize: DWORD,
) callconv(WINAPI) DWORD; ) callconv(.winapi) DWORD;
pub const GetModuleFileNameExW = K32GetModuleFileNameExW; pub const GetModuleFileNameExW = K32GetModuleFileNameExW;
// TODO: Wrapper around ntdll.LdrGetDllHandle, which is a wrapper around LdrGetDllHandleEx // TODO: Wrapper around ntdll.LdrGetDllHandle, which is a wrapper around LdrGetDllHandleEx
pub extern "kernel32" fn GetModuleHandleW( pub extern "kernel32" fn GetModuleHandleW(
lpModuleName: ?LPCWSTR, lpModuleName: ?LPCWSTR,
) callconv(WINAPI) ?HMODULE; ) callconv(.winapi) ?HMODULE;
pub extern "kernel32" fn Module32First( pub extern "kernel32" fn Module32First(
hSnapshot: HANDLE, hSnapshot: HANDLE,
lpme: *MODULEENTRY32, lpme: *MODULEENTRY32,
) callconv(WINAPI) BOOL; ) callconv(.winapi) BOOL;
pub extern "kernel32" fn Module32Next( pub extern "kernel32" fn Module32Next(
hSnapshot: HANDLE, hSnapshot: HANDLE,
lpme: *MODULEENTRY32, lpme: *MODULEENTRY32,
) callconv(WINAPI) BOOL; ) callconv(.winapi) BOOL;
pub extern "kernel32" fn LoadLibraryW( pub extern "kernel32" fn LoadLibraryW(
lpLibFileName: LPCWSTR, lpLibFileName: LPCWSTR,
) callconv(WINAPI) ?HMODULE; ) callconv(.winapi) ?HMODULE;
pub extern "kernel32" fn LoadLibraryExW( pub extern "kernel32" fn LoadLibraryExW(
lpLibFileName: LPCWSTR, lpLibFileName: LPCWSTR,
hFile: ?HANDLE, hFile: ?HANDLE,
dwFlags: DWORD, dwFlags: DWORD,
) callconv(WINAPI) ?HMODULE; ) callconv(.winapi) ?HMODULE;
pub extern "kernel32" fn GetProcAddress( pub extern "kernel32" fn GetProcAddress(
hModule: HMODULE, hModule: HMODULE,
lpProcName: LPCSTR, lpProcName: LPCSTR,
) callconv(WINAPI) ?FARPROC; ) callconv(.winapi) ?FARPROC;
pub extern "kernel32" fn FreeLibrary( pub extern "kernel32" fn FreeLibrary(
hModule: HMODULE, hModule: HMODULE,
) callconv(WINAPI) BOOL; ) callconv(.winapi) BOOL;
// Error Management // Error Management
@ -653,15 +652,15 @@ pub extern "kernel32" fn FormatMessageW(
lpBuffer: LPWSTR, lpBuffer: LPWSTR,
nSize: DWORD, nSize: DWORD,
Arguments: ?*va_list, Arguments: ?*va_list,
) callconv(WINAPI) DWORD; ) callconv(.winapi) DWORD;
// TODO: Getter for teb().LastErrorValue. // TODO: Getter for teb().LastErrorValue.
pub extern "kernel32" fn GetLastError() callconv(WINAPI) Win32Error; pub extern "kernel32" fn GetLastError() callconv(.winapi) Win32Error;
// TODO: Wrapper around RtlSetLastWin32Error. // TODO: Wrapper around RtlSetLastWin32Error.
pub extern "kernel32" fn SetLastError( pub extern "kernel32" fn SetLastError(
dwErrCode: Win32Error, dwErrCode: Win32Error,
) callconv(WINAPI) void; ) callconv(.winapi) void;
// Everything Else // Everything Else
@ -670,4 +669,4 @@ pub extern "kernel32" fn SetLastError(
// Much better to use NtQuerySystemTime or NtQuerySystemTimePrecise for guaranteed 0.1ns precision. // Much better to use NtQuerySystemTime or NtQuerySystemTimePrecise for guaranteed 0.1ns precision.
pub extern "kernel32" fn GetSystemTimeAsFileTime( pub extern "kernel32" fn GetSystemTimeAsFileTime(
lpSystemTimeAsFileTime: *FILETIME, lpSystemTimeAsFileTime: *FILETIME,
) callconv(WINAPI) void; ) callconv(.winapi) void;

View File

@ -5,7 +5,6 @@ const BOOL = windows.BOOL;
const DWORD = windows.DWORD; const DWORD = windows.DWORD;
const DWORD64 = windows.DWORD64; const DWORD64 = windows.DWORD64;
const ULONG = windows.ULONG; const ULONG = windows.ULONG;
const WINAPI = windows.WINAPI;
const NTSTATUS = windows.NTSTATUS; const NTSTATUS = windows.NTSTATUS;
const WORD = windows.WORD; const WORD = windows.WORD;
const HANDLE = windows.HANDLE; const HANDLE = windows.HANDLE;
@ -44,7 +43,7 @@ pub extern "ntdll" fn NtQueryInformationProcess(
ProcessInformation: *anyopaque, ProcessInformation: *anyopaque,
ProcessInformationLength: ULONG, ProcessInformationLength: ULONG,
ReturnLength: ?*ULONG, ReturnLength: ?*ULONG,
) callconv(WINAPI) NTSTATUS; ) callconv(.winapi) NTSTATUS;
pub extern "ntdll" fn NtQueryInformationThread( pub extern "ntdll" fn NtQueryInformationThread(
ThreadHandle: HANDLE, ThreadHandle: HANDLE,
@ -52,37 +51,37 @@ pub extern "ntdll" fn NtQueryInformationThread(
ThreadInformation: *anyopaque, ThreadInformation: *anyopaque,
ThreadInformationLength: ULONG, ThreadInformationLength: ULONG,
ReturnLength: ?*ULONG, ReturnLength: ?*ULONG,
) callconv(WINAPI) NTSTATUS; ) callconv(.winapi) NTSTATUS;
pub extern "ntdll" fn NtQuerySystemInformation( pub extern "ntdll" fn NtQuerySystemInformation(
SystemInformationClass: SYSTEM_INFORMATION_CLASS, SystemInformationClass: SYSTEM_INFORMATION_CLASS,
SystemInformation: PVOID, SystemInformation: PVOID,
SystemInformationLength: ULONG, SystemInformationLength: ULONG,
ReturnLength: ?*ULONG, ReturnLength: ?*ULONG,
) callconv(WINAPI) NTSTATUS; ) callconv(.winapi) NTSTATUS;
pub extern "ntdll" fn NtSetInformationThread( pub extern "ntdll" fn NtSetInformationThread(
ThreadHandle: HANDLE, ThreadHandle: HANDLE,
ThreadInformationClass: THREADINFOCLASS, ThreadInformationClass: THREADINFOCLASS,
ThreadInformation: *const anyopaque, ThreadInformation: *const anyopaque,
ThreadInformationLength: ULONG, ThreadInformationLength: ULONG,
) callconv(WINAPI) NTSTATUS; ) callconv(.winapi) NTSTATUS;
pub extern "ntdll" fn RtlGetVersion( pub extern "ntdll" fn RtlGetVersion(
lpVersionInformation: *RTL_OSVERSIONINFOW, lpVersionInformation: *RTL_OSVERSIONINFOW,
) callconv(WINAPI) NTSTATUS; ) callconv(.winapi) NTSTATUS;
pub extern "ntdll" fn RtlCaptureStackBackTrace( pub extern "ntdll" fn RtlCaptureStackBackTrace(
FramesToSkip: DWORD, FramesToSkip: DWORD,
FramesToCapture: DWORD, FramesToCapture: DWORD,
BackTrace: **anyopaque, BackTrace: **anyopaque,
BackTraceHash: ?*DWORD, BackTraceHash: ?*DWORD,
) callconv(WINAPI) WORD; ) callconv(.winapi) WORD;
pub extern "ntdll" fn RtlCaptureContext(ContextRecord: *CONTEXT) callconv(WINAPI) void; pub extern "ntdll" fn RtlCaptureContext(ContextRecord: *CONTEXT) callconv(.winapi) void;
pub extern "ntdll" fn RtlLookupFunctionEntry( pub extern "ntdll" fn RtlLookupFunctionEntry(
ControlPc: DWORD64, ControlPc: DWORD64,
ImageBase: *DWORD64, ImageBase: *DWORD64,
HistoryTable: *UNWIND_HISTORY_TABLE, HistoryTable: *UNWIND_HISTORY_TABLE,
) callconv(WINAPI) ?*RUNTIME_FUNCTION; ) callconv(.winapi) ?*RUNTIME_FUNCTION;
pub extern "ntdll" fn RtlVirtualUnwind( pub extern "ntdll" fn RtlVirtualUnwind(
HandlerType: DWORD, HandlerType: DWORD,
ImageBase: DWORD64, ImageBase: DWORD64,
@ -92,33 +91,33 @@ pub extern "ntdll" fn RtlVirtualUnwind(
HandlerData: *?PVOID, HandlerData: *?PVOID,
EstablisherFrame: *DWORD64, EstablisherFrame: *DWORD64,
ContextPointers: ?*KNONVOLATILE_CONTEXT_POINTERS, ContextPointers: ?*KNONVOLATILE_CONTEXT_POINTERS,
) callconv(WINAPI) *EXCEPTION_ROUTINE; ) callconv(.winapi) *EXCEPTION_ROUTINE;
pub extern "ntdll" fn NtQueryInformationFile( pub extern "ntdll" fn NtQueryInformationFile(
FileHandle: HANDLE, FileHandle: HANDLE,
IoStatusBlock: *IO_STATUS_BLOCK, IoStatusBlock: *IO_STATUS_BLOCK,
FileInformation: *anyopaque, FileInformation: *anyopaque,
Length: ULONG, Length: ULONG,
FileInformationClass: FILE_INFORMATION_CLASS, FileInformationClass: FILE_INFORMATION_CLASS,
) callconv(WINAPI) NTSTATUS; ) callconv(.winapi) NTSTATUS;
pub extern "ntdll" fn NtSetInformationFile( pub extern "ntdll" fn NtSetInformationFile(
FileHandle: HANDLE, FileHandle: HANDLE,
IoStatusBlock: *IO_STATUS_BLOCK, IoStatusBlock: *IO_STATUS_BLOCK,
FileInformation: PVOID, FileInformation: PVOID,
Length: ULONG, Length: ULONG,
FileInformationClass: FILE_INFORMATION_CLASS, FileInformationClass: FILE_INFORMATION_CLASS,
) callconv(WINAPI) NTSTATUS; ) callconv(.winapi) NTSTATUS;
pub extern "ntdll" fn NtQueryAttributesFile( pub extern "ntdll" fn NtQueryAttributesFile(
ObjectAttributes: *OBJECT_ATTRIBUTES, ObjectAttributes: *OBJECT_ATTRIBUTES,
FileAttributes: *FILE_BASIC_INFORMATION, FileAttributes: *FILE_BASIC_INFORMATION,
) callconv(WINAPI) NTSTATUS; ) callconv(.winapi) NTSTATUS;
pub extern "ntdll" fn RtlQueryPerformanceCounter(PerformanceCounter: *LARGE_INTEGER) callconv(WINAPI) BOOL; pub extern "ntdll" fn RtlQueryPerformanceCounter(PerformanceCounter: *LARGE_INTEGER) callconv(.winapi) BOOL;
pub extern "ntdll" fn RtlQueryPerformanceFrequency(PerformanceFrequency: *LARGE_INTEGER) callconv(WINAPI) BOOL; pub extern "ntdll" fn RtlQueryPerformanceFrequency(PerformanceFrequency: *LARGE_INTEGER) callconv(.winapi) BOOL;
pub extern "ntdll" fn NtQueryPerformanceCounter( pub extern "ntdll" fn NtQueryPerformanceCounter(
PerformanceCounter: *LARGE_INTEGER, PerformanceCounter: *LARGE_INTEGER,
PerformanceFrequency: ?*LARGE_INTEGER, PerformanceFrequency: ?*LARGE_INTEGER,
) callconv(WINAPI) NTSTATUS; ) callconv(.winapi) NTSTATUS;
pub extern "ntdll" fn NtCreateFile( pub extern "ntdll" fn NtCreateFile(
FileHandle: *HANDLE, FileHandle: *HANDLE,
@ -132,7 +131,7 @@ pub extern "ntdll" fn NtCreateFile(
CreateOptions: ULONG, CreateOptions: ULONG,
EaBuffer: ?*anyopaque, EaBuffer: ?*anyopaque,
EaLength: ULONG, EaLength: ULONG,
) callconv(WINAPI) NTSTATUS; ) callconv(.winapi) NTSTATUS;
pub extern "ntdll" fn NtCreateSection( pub extern "ntdll" fn NtCreateSection(
SectionHandle: *HANDLE, SectionHandle: *HANDLE,
DesiredAccess: ACCESS_MASK, DesiredAccess: ACCESS_MASK,
@ -141,7 +140,7 @@ pub extern "ntdll" fn NtCreateSection(
SectionPageProtection: ULONG, SectionPageProtection: ULONG,
AllocationAttributes: ULONG, AllocationAttributes: ULONG,
FileHandle: ?HANDLE, FileHandle: ?HANDLE,
) callconv(WINAPI) NTSTATUS; ) callconv(.winapi) NTSTATUS;
pub extern "ntdll" fn NtMapViewOfSection( pub extern "ntdll" fn NtMapViewOfSection(
SectionHandle: HANDLE, SectionHandle: HANDLE,
ProcessHandle: HANDLE, ProcessHandle: HANDLE,
@ -153,11 +152,11 @@ pub extern "ntdll" fn NtMapViewOfSection(
InheritDispostion: SECTION_INHERIT, InheritDispostion: SECTION_INHERIT,
AllocationType: ULONG, AllocationType: ULONG,
Win32Protect: ULONG, Win32Protect: ULONG,
) callconv(WINAPI) NTSTATUS; ) callconv(.winapi) NTSTATUS;
pub extern "ntdll" fn NtUnmapViewOfSection( pub extern "ntdll" fn NtUnmapViewOfSection(
ProcessHandle: HANDLE, ProcessHandle: HANDLE,
BaseAddress: PVOID, BaseAddress: PVOID,
) callconv(WINAPI) NTSTATUS; ) callconv(.winapi) NTSTATUS;
pub extern "ntdll" fn NtDeviceIoControlFile( pub extern "ntdll" fn NtDeviceIoControlFile(
FileHandle: HANDLE, FileHandle: HANDLE,
Event: ?HANDLE, Event: ?HANDLE,
@ -169,7 +168,7 @@ pub extern "ntdll" fn NtDeviceIoControlFile(
InputBufferLength: ULONG, InputBufferLength: ULONG,
OutputBuffer: ?PVOID, OutputBuffer: ?PVOID,
OutputBufferLength: ULONG, OutputBufferLength: ULONG,
) callconv(WINAPI) NTSTATUS; ) callconv(.winapi) NTSTATUS;
pub extern "ntdll" fn NtFsControlFile( pub extern "ntdll" fn NtFsControlFile(
FileHandle: HANDLE, FileHandle: HANDLE,
Event: ?HANDLE, Event: ?HANDLE,
@ -181,15 +180,15 @@ pub extern "ntdll" fn NtFsControlFile(
InputBufferLength: ULONG, InputBufferLength: ULONG,
OutputBuffer: ?PVOID, OutputBuffer: ?PVOID,
OutputBufferLength: ULONG, OutputBufferLength: ULONG,
) callconv(WINAPI) NTSTATUS; ) callconv(.winapi) NTSTATUS;
pub extern "ntdll" fn NtClose(Handle: HANDLE) callconv(WINAPI) NTSTATUS; pub extern "ntdll" fn NtClose(Handle: HANDLE) callconv(.winapi) NTSTATUS;
pub extern "ntdll" fn RtlDosPathNameToNtPathName_U( pub extern "ntdll" fn RtlDosPathNameToNtPathName_U(
DosPathName: [*:0]const u16, DosPathName: [*:0]const u16,
NtPathName: *UNICODE_STRING, NtPathName: *UNICODE_STRING,
NtFileNamePart: ?*?[*:0]const u16, NtFileNamePart: ?*?[*:0]const u16,
DirectoryInfo: ?*CURDIR, DirectoryInfo: ?*CURDIR,
) callconv(WINAPI) BOOL; ) callconv(.winapi) BOOL;
pub extern "ntdll" fn RtlFreeUnicodeString(UnicodeString: *UNICODE_STRING) callconv(WINAPI) void; pub extern "ntdll" fn RtlFreeUnicodeString(UnicodeString: *UNICODE_STRING) callconv(.winapi) void;
/// Returns the number of bytes written to `Buffer`. /// Returns the number of bytes written to `Buffer`.
/// If the returned count is larger than `BufferByteLength`, the buffer was too small. /// If the returned count is larger than `BufferByteLength`, the buffer was too small.
@ -199,7 +198,7 @@ pub extern "ntdll" fn RtlGetFullPathName_U(
BufferByteLength: ULONG, BufferByteLength: ULONG,
Buffer: [*]u16, Buffer: [*]u16,
ShortName: ?*[*:0]const u16, ShortName: ?*[*:0]const u16,
) callconv(windows.WINAPI) windows.ULONG; ) callconv(.winapi) windows.ULONG;
pub extern "ntdll" fn NtQueryDirectoryFile( pub extern "ntdll" fn NtQueryDirectoryFile(
FileHandle: HANDLE, FileHandle: HANDLE,
@ -213,30 +212,30 @@ pub extern "ntdll" fn NtQueryDirectoryFile(
ReturnSingleEntry: BOOLEAN, ReturnSingleEntry: BOOLEAN,
FileName: ?*UNICODE_STRING, FileName: ?*UNICODE_STRING,
RestartScan: BOOLEAN, RestartScan: BOOLEAN,
) callconv(WINAPI) NTSTATUS; ) callconv(.winapi) NTSTATUS;
pub extern "ntdll" fn NtCreateKeyedEvent( pub extern "ntdll" fn NtCreateKeyedEvent(
KeyedEventHandle: *HANDLE, KeyedEventHandle: *HANDLE,
DesiredAccess: ACCESS_MASK, DesiredAccess: ACCESS_MASK,
ObjectAttributes: ?PVOID, ObjectAttributes: ?PVOID,
Flags: ULONG, Flags: ULONG,
) callconv(WINAPI) NTSTATUS; ) callconv(.winapi) NTSTATUS;
pub extern "ntdll" fn NtReleaseKeyedEvent( pub extern "ntdll" fn NtReleaseKeyedEvent(
EventHandle: ?HANDLE, EventHandle: ?HANDLE,
Key: ?*const anyopaque, Key: ?*const anyopaque,
Alertable: BOOLEAN, Alertable: BOOLEAN,
Timeout: ?*const LARGE_INTEGER, Timeout: ?*const LARGE_INTEGER,
) callconv(WINAPI) NTSTATUS; ) callconv(.winapi) NTSTATUS;
pub extern "ntdll" fn NtWaitForKeyedEvent( pub extern "ntdll" fn NtWaitForKeyedEvent(
EventHandle: ?HANDLE, EventHandle: ?HANDLE,
Key: ?*const anyopaque, Key: ?*const anyopaque,
Alertable: BOOLEAN, Alertable: BOOLEAN,
Timeout: ?*const LARGE_INTEGER, Timeout: ?*const LARGE_INTEGER,
) callconv(WINAPI) NTSTATUS; ) callconv(.winapi) NTSTATUS;
pub extern "ntdll" fn RtlSetCurrentDirectory_U(PathName: *UNICODE_STRING) callconv(WINAPI) NTSTATUS; pub extern "ntdll" fn RtlSetCurrentDirectory_U(PathName: *UNICODE_STRING) callconv(.winapi) NTSTATUS;
pub extern "ntdll" fn NtQueryObject( pub extern "ntdll" fn NtQueryObject(
Handle: HANDLE, Handle: HANDLE,
@ -244,7 +243,7 @@ pub extern "ntdll" fn NtQueryObject(
ObjectInformation: PVOID, ObjectInformation: PVOID,
ObjectInformationLength: ULONG, ObjectInformationLength: ULONG,
ReturnLength: ?*ULONG, ReturnLength: ?*ULONG,
) callconv(WINAPI) NTSTATUS; ) callconv(.winapi) NTSTATUS;
pub extern "ntdll" fn NtQueryVolumeInformationFile( pub extern "ntdll" fn NtQueryVolumeInformationFile(
FileHandle: HANDLE, FileHandle: HANDLE,
@ -252,32 +251,32 @@ pub extern "ntdll" fn NtQueryVolumeInformationFile(
FsInformation: *anyopaque, FsInformation: *anyopaque,
Length: ULONG, Length: ULONG,
FsInformationClass: FS_INFORMATION_CLASS, FsInformationClass: FS_INFORMATION_CLASS,
) callconv(WINAPI) NTSTATUS; ) callconv(.winapi) NTSTATUS;
pub extern "ntdll" fn RtlWakeAddressAll( pub extern "ntdll" fn RtlWakeAddressAll(
Address: ?*const anyopaque, Address: ?*const anyopaque,
) callconv(WINAPI) void; ) callconv(.winapi) void;
pub extern "ntdll" fn RtlWakeAddressSingle( pub extern "ntdll" fn RtlWakeAddressSingle(
Address: ?*const anyopaque, Address: ?*const anyopaque,
) callconv(WINAPI) void; ) callconv(.winapi) void;
pub extern "ntdll" fn RtlWaitOnAddress( pub extern "ntdll" fn RtlWaitOnAddress(
Address: ?*const anyopaque, Address: ?*const anyopaque,
CompareAddress: ?*const anyopaque, CompareAddress: ?*const anyopaque,
AddressSize: SIZE_T, AddressSize: SIZE_T,
Timeout: ?*const LARGE_INTEGER, Timeout: ?*const LARGE_INTEGER,
) callconv(WINAPI) NTSTATUS; ) callconv(.winapi) NTSTATUS;
pub extern "ntdll" fn RtlEqualUnicodeString( pub extern "ntdll" fn RtlEqualUnicodeString(
String1: *const UNICODE_STRING, String1: *const UNICODE_STRING,
String2: *const UNICODE_STRING, String2: *const UNICODE_STRING,
CaseInSensitive: BOOLEAN, CaseInSensitive: BOOLEAN,
) callconv(WINAPI) BOOLEAN; ) callconv(.winapi) BOOLEAN;
pub extern "ntdll" fn RtlUpcaseUnicodeChar( pub extern "ntdll" fn RtlUpcaseUnicodeChar(
SourceCharacter: u16, SourceCharacter: u16,
) callconv(WINAPI) u16; ) callconv(.winapi) u16;
pub extern "ntdll" fn NtLockFile( pub extern "ntdll" fn NtLockFile(
FileHandle: HANDLE, FileHandle: HANDLE,
@ -290,7 +289,7 @@ pub extern "ntdll" fn NtLockFile(
Key: ?*ULONG, Key: ?*ULONG,
FailImmediately: BOOLEAN, FailImmediately: BOOLEAN,
ExclusiveLock: BOOLEAN, ExclusiveLock: BOOLEAN,
) callconv(WINAPI) NTSTATUS; ) callconv(.winapi) NTSTATUS;
pub extern "ntdll" fn NtUnlockFile( pub extern "ntdll" fn NtUnlockFile(
FileHandle: HANDLE, FileHandle: HANDLE,
@ -298,13 +297,13 @@ pub extern "ntdll" fn NtUnlockFile(
ByteOffset: *const LARGE_INTEGER, ByteOffset: *const LARGE_INTEGER,
Length: *const LARGE_INTEGER, Length: *const LARGE_INTEGER,
Key: ?*ULONG, Key: ?*ULONG,
) callconv(WINAPI) NTSTATUS; ) callconv(.winapi) NTSTATUS;
pub extern "ntdll" fn NtOpenKey( pub extern "ntdll" fn NtOpenKey(
KeyHandle: *HANDLE, KeyHandle: *HANDLE,
DesiredAccess: ACCESS_MASK, DesiredAccess: ACCESS_MASK,
ObjectAttributes: OBJECT_ATTRIBUTES, ObjectAttributes: OBJECT_ATTRIBUTES,
) callconv(WINAPI) NTSTATUS; ) callconv(.winapi) NTSTATUS;
pub extern "ntdll" fn RtlQueryRegistryValues( pub extern "ntdll" fn RtlQueryRegistryValues(
RelativeTo: ULONG, RelativeTo: ULONG,
@ -312,7 +311,7 @@ pub extern "ntdll" fn RtlQueryRegistryValues(
QueryTable: [*]RTL_QUERY_REGISTRY_TABLE, QueryTable: [*]RTL_QUERY_REGISTRY_TABLE,
Context: ?*anyopaque, Context: ?*anyopaque,
Environment: ?*anyopaque, Environment: ?*anyopaque,
) callconv(WINAPI) NTSTATUS; ) callconv(.winapi) NTSTATUS;
pub extern "ntdll" fn NtReadVirtualMemory( pub extern "ntdll" fn NtReadVirtualMemory(
ProcessHandle: HANDLE, ProcessHandle: HANDLE,
@ -320,7 +319,7 @@ pub extern "ntdll" fn NtReadVirtualMemory(
Buffer: LPVOID, Buffer: LPVOID,
NumberOfBytesToRead: SIZE_T, NumberOfBytesToRead: SIZE_T,
NumberOfBytesRead: ?*SIZE_T, NumberOfBytesRead: ?*SIZE_T,
) callconv(WINAPI) NTSTATUS; ) callconv(.winapi) NTSTATUS;
pub extern "ntdll" fn NtWriteVirtualMemory( pub extern "ntdll" fn NtWriteVirtualMemory(
ProcessHandle: HANDLE, ProcessHandle: HANDLE,
@ -328,7 +327,7 @@ pub extern "ntdll" fn NtWriteVirtualMemory(
Buffer: LPCVOID, Buffer: LPCVOID,
NumberOfBytesToWrite: SIZE_T, NumberOfBytesToWrite: SIZE_T,
NumberOfBytesWritten: ?*SIZE_T, NumberOfBytesWritten: ?*SIZE_T,
) callconv(WINAPI) NTSTATUS; ) callconv(.winapi) NTSTATUS;
pub extern "ntdll" fn NtProtectVirtualMemory( pub extern "ntdll" fn NtProtectVirtualMemory(
ProcessHandle: HANDLE, ProcessHandle: HANDLE,
@ -336,11 +335,11 @@ pub extern "ntdll" fn NtProtectVirtualMemory(
NumberOfBytesToProtect: *SIZE_T, NumberOfBytesToProtect: *SIZE_T,
NewAccessProtection: ULONG, NewAccessProtection: ULONG,
OldAccessProtection: *ULONG, OldAccessProtection: *ULONG,
) callconv(WINAPI) NTSTATUS; ) callconv(.winapi) NTSTATUS;
pub extern "ntdll" fn RtlExitUserProcess( pub extern "ntdll" fn RtlExitUserProcess(
ExitStatus: u32, ExitStatus: u32,
) callconv(WINAPI) noreturn; ) callconv(.winapi) noreturn;
pub extern "ntdll" fn NtCreateNamedPipeFile( pub extern "ntdll" fn NtCreateNamedPipeFile(
FileHandle: *HANDLE, FileHandle: *HANDLE,
@ -357,4 +356,4 @@ pub extern "ntdll" fn NtCreateNamedPipeFile(
InboundQuota: ULONG, InboundQuota: ULONG,
OutboundQuota: ULONG, OutboundQuota: ULONG,
DefaultTimeout: *LARGE_INTEGER, DefaultTimeout: *LARGE_INTEGER,
) callconv(WINAPI) NTSTATUS; ) callconv(.winapi) NTSTATUS;

View File

@ -250,7 +250,7 @@ test "loadWinsockExtensionFunction" {
SendBufLen: windows.DWORD, SendBufLen: windows.DWORD,
BytesSent: *windows.DWORD, BytesSent: *windows.DWORD,
Overlapped: *windows.OVERLAPPED, Overlapped: *windows.OVERLAPPED,
) callconv(windows.WINAPI) windows.BOOL; ) callconv(.winapi) windows.BOOL;
_ = windows.loadWinsockExtensionFunction( _ = windows.loadWinsockExtensionFunction(
LPFN_CONNECTEX, LPFN_CONNECTEX,

View File

@ -2,7 +2,6 @@ const std = @import("../../std.zig");
const assert = std.debug.assert; const assert = std.debug.assert;
const windows = std.os.windows; const windows = std.os.windows;
const WINAPI = windows.WINAPI;
const OVERLAPPED = windows.OVERLAPPED; const OVERLAPPED = windows.OVERLAPPED;
const WORD = windows.WORD; const WORD = windows.WORD;
const DWORD = windows.DWORD; const DWORD = windows.DWORD;
@ -958,14 +957,14 @@ pub const LPCONDITIONPROC = *const fn (
lpCalleeData: *WSABUF, lpCalleeData: *WSABUF,
g: *u32, g: *u32,
dwCallbackData: usize, dwCallbackData: usize,
) callconv(WINAPI) i32; ) callconv(.winapi) i32;
pub const LPWSAOVERLAPPED_COMPLETION_ROUTINE = *const fn ( pub const LPWSAOVERLAPPED_COMPLETION_ROUTINE = *const fn (
dwError: u32, dwError: u32,
cbTransferred: u32, cbTransferred: u32,
lpOverlapped: *OVERLAPPED, lpOverlapped: *OVERLAPPED,
dwFlags: u32, dwFlags: u32,
) callconv(WINAPI) void; ) callconv(.winapi) void;
pub const FLOWSPEC = extern struct { pub const FLOWSPEC = extern struct {
TokenRate: u32, TokenRate: u32,
@ -1196,7 +1195,7 @@ pub const LPFN_TRANSMITFILE = *const fn (
lpOverlapped: ?*OVERLAPPED, lpOverlapped: ?*OVERLAPPED,
lpTransmitBuffers: ?*TRANSMIT_FILE_BUFFERS, lpTransmitBuffers: ?*TRANSMIT_FILE_BUFFERS,
dwReserved: u32, dwReserved: u32,
) callconv(WINAPI) BOOL; ) callconv(.winapi) BOOL;
pub const LPFN_ACCEPTEX = *const fn ( pub const LPFN_ACCEPTEX = *const fn (
sListenSocket: SOCKET, sListenSocket: SOCKET,
@ -1207,7 +1206,7 @@ pub const LPFN_ACCEPTEX = *const fn (
dwRemoteAddressLength: u32, dwRemoteAddressLength: u32,
lpdwBytesReceived: *u32, lpdwBytesReceived: *u32,
lpOverlapped: *OVERLAPPED, lpOverlapped: *OVERLAPPED,
) callconv(WINAPI) BOOL; ) callconv(.winapi) BOOL;
pub const LPFN_GETACCEPTEXSOCKADDRS = *const fn ( pub const LPFN_GETACCEPTEXSOCKADDRS = *const fn (
lpOutputBuffer: *anyopaque, lpOutputBuffer: *anyopaque,
@ -1218,7 +1217,7 @@ pub const LPFN_GETACCEPTEXSOCKADDRS = *const fn (
LocalSockaddrLength: *i32, LocalSockaddrLength: *i32,
RemoteSockaddr: **sockaddr, RemoteSockaddr: **sockaddr,
RemoteSockaddrLength: *i32, RemoteSockaddrLength: *i32,
) callconv(WINAPI) void; ) callconv(.winapi) void;
pub const LPFN_WSASENDMSG = *const fn ( pub const LPFN_WSASENDMSG = *const fn (
s: SOCKET, s: SOCKET,
@ -1227,7 +1226,7 @@ pub const LPFN_WSASENDMSG = *const fn (
lpNumberOfBytesSent: ?*u32, lpNumberOfBytesSent: ?*u32,
lpOverlapped: ?*OVERLAPPED, lpOverlapped: ?*OVERLAPPED,
lpCompletionRoutine: ?LPWSAOVERLAPPED_COMPLETION_ROUTINE, lpCompletionRoutine: ?LPWSAOVERLAPPED_COMPLETION_ROUTINE,
) callconv(WINAPI) i32; ) callconv(.winapi) i32;
pub const LPFN_WSARECVMSG = *const fn ( pub const LPFN_WSARECVMSG = *const fn (
s: SOCKET, s: SOCKET,
@ -1235,12 +1234,12 @@ pub const LPFN_WSARECVMSG = *const fn (
lpdwNumberOfBytesRecv: ?*u32, lpdwNumberOfBytesRecv: ?*u32,
lpOverlapped: ?*OVERLAPPED, lpOverlapped: ?*OVERLAPPED,
lpCompletionRoutine: ?LPWSAOVERLAPPED_COMPLETION_ROUTINE, lpCompletionRoutine: ?LPWSAOVERLAPPED_COMPLETION_ROUTINE,
) callconv(WINAPI) i32; ) callconv(.winapi) i32;
pub const LPSERVICE_CALLBACK_PROC = *const fn ( pub const LPSERVICE_CALLBACK_PROC = *const fn (
lParam: LPARAM, lParam: LPARAM,
hAsyncTaskHandle: HANDLE, hAsyncTaskHandle: HANDLE,
) callconv(WINAPI) void; ) callconv(.winapi) void;
pub const SERVICE_ASYNC_INFO = extern struct { pub const SERVICE_ASYNC_INFO = extern struct {
lpServiceCallbackProc: LPSERVICE_CALLBACK_PROC, lpServiceCallbackProc: LPSERVICE_CALLBACK_PROC,
@ -1252,7 +1251,7 @@ pub const LPLOOKUPSERVICE_COMPLETION_ROUTINE = *const fn (
dwError: u32, dwError: u32,
dwBytes: u32, dwBytes: u32,
lpOverlapped: *OVERLAPPED, lpOverlapped: *OVERLAPPED,
) callconv(WINAPI) void; ) callconv(.winapi) void;
pub const fd_set = extern struct { pub const fd_set = extern struct {
fd_count: u32, fd_count: u32,
@ -1725,41 +1724,41 @@ pub extern "ws2_32" fn accept(
s: SOCKET, s: SOCKET,
addr: ?*sockaddr, addr: ?*sockaddr,
addrlen: ?*i32, addrlen: ?*i32,
) callconv(WINAPI) SOCKET; ) callconv(.winapi) SOCKET;
pub extern "ws2_32" fn bind( pub extern "ws2_32" fn bind(
s: SOCKET, s: SOCKET,
name: *const sockaddr, name: *const sockaddr,
namelen: i32, namelen: i32,
) callconv(WINAPI) i32; ) callconv(.winapi) i32;
pub extern "ws2_32" fn closesocket( pub extern "ws2_32" fn closesocket(
s: SOCKET, s: SOCKET,
) callconv(WINAPI) i32; ) callconv(.winapi) i32;
pub extern "ws2_32" fn connect( pub extern "ws2_32" fn connect(
s: SOCKET, s: SOCKET,
name: *const sockaddr, name: *const sockaddr,
namelen: i32, namelen: i32,
) callconv(WINAPI) i32; ) callconv(.winapi) i32;
pub extern "ws2_32" fn ioctlsocket( pub extern "ws2_32" fn ioctlsocket(
s: SOCKET, s: SOCKET,
cmd: i32, cmd: i32,
argp: *u32, argp: *u32,
) callconv(WINAPI) i32; ) callconv(.winapi) i32;
pub extern "ws2_32" fn getpeername( pub extern "ws2_32" fn getpeername(
s: SOCKET, s: SOCKET,
name: *sockaddr, name: *sockaddr,
namelen: *i32, namelen: *i32,
) callconv(WINAPI) i32; ) callconv(.winapi) i32;
pub extern "ws2_32" fn getsockname( pub extern "ws2_32" fn getsockname(
s: SOCKET, s: SOCKET,
name: *sockaddr, name: *sockaddr,
namelen: *i32, namelen: *i32,
) callconv(WINAPI) i32; ) callconv(.winapi) i32;
pub extern "ws2_32" fn getsockopt( pub extern "ws2_32" fn getsockopt(
s: SOCKET, s: SOCKET,
@ -1767,39 +1766,39 @@ pub extern "ws2_32" fn getsockopt(
optname: i32, optname: i32,
optval: [*]u8, optval: [*]u8,
optlen: *i32, optlen: *i32,
) callconv(WINAPI) i32; ) callconv(.winapi) i32;
pub extern "ws2_32" fn htonl( pub extern "ws2_32" fn htonl(
hostlong: u32, hostlong: u32,
) callconv(WINAPI) u32; ) callconv(.winapi) u32;
pub extern "ws2_32" fn htons( pub extern "ws2_32" fn htons(
hostshort: u16, hostshort: u16,
) callconv(WINAPI) u16; ) callconv(.winapi) u16;
pub extern "ws2_32" fn inet_addr( pub extern "ws2_32" fn inet_addr(
cp: ?[*]const u8, cp: ?[*]const u8,
) callconv(WINAPI) u32; ) callconv(.winapi) u32;
pub extern "ws2_32" fn listen( pub extern "ws2_32" fn listen(
s: SOCKET, s: SOCKET,
backlog: i32, backlog: i32,
) callconv(WINAPI) i32; ) callconv(.winapi) i32;
pub extern "ws2_32" fn ntohl( pub extern "ws2_32" fn ntohl(
netlong: u32, netlong: u32,
) callconv(WINAPI) u32; ) callconv(.winapi) u32;
pub extern "ws2_32" fn ntohs( pub extern "ws2_32" fn ntohs(
netshort: u16, netshort: u16,
) callconv(WINAPI) u16; ) callconv(.winapi) u16;
pub extern "ws2_32" fn recv( pub extern "ws2_32" fn recv(
s: SOCKET, s: SOCKET,
buf: [*]u8, buf: [*]u8,
len: i32, len: i32,
flags: i32, flags: i32,
) callconv(WINAPI) i32; ) callconv(.winapi) i32;
pub extern "ws2_32" fn recvfrom( pub extern "ws2_32" fn recvfrom(
s: SOCKET, s: SOCKET,
@ -1808,7 +1807,7 @@ pub extern "ws2_32" fn recvfrom(
flags: i32, flags: i32,
from: ?*sockaddr, from: ?*sockaddr,
fromlen: ?*i32, fromlen: ?*i32,
) callconv(WINAPI) i32; ) callconv(.winapi) i32;
pub extern "ws2_32" fn select( pub extern "ws2_32" fn select(
nfds: i32, nfds: i32,
@ -1816,14 +1815,14 @@ pub extern "ws2_32" fn select(
writefds: ?*fd_set, writefds: ?*fd_set,
exceptfds: ?*fd_set, exceptfds: ?*fd_set,
timeout: ?*const timeval, timeout: ?*const timeval,
) callconv(WINAPI) i32; ) callconv(.winapi) i32;
pub extern "ws2_32" fn send( pub extern "ws2_32" fn send(
s: SOCKET, s: SOCKET,
buf: [*]const u8, buf: [*]const u8,
len: i32, len: i32,
flags: u32, flags: u32,
) callconv(WINAPI) i32; ) callconv(.winapi) i32;
pub extern "ws2_32" fn sendto( pub extern "ws2_32" fn sendto(
s: SOCKET, s: SOCKET,
@ -1832,7 +1831,7 @@ pub extern "ws2_32" fn sendto(
flags: i32, flags: i32,
to: *const sockaddr, to: *const sockaddr,
tolen: i32, tolen: i32,
) callconv(WINAPI) i32; ) callconv(.winapi) i32;
pub extern "ws2_32" fn setsockopt( pub extern "ws2_32" fn setsockopt(
s: SOCKET, s: SOCKET,
@ -1840,37 +1839,37 @@ pub extern "ws2_32" fn setsockopt(
optname: i32, optname: i32,
optval: ?[*]const u8, optval: ?[*]const u8,
optlen: i32, optlen: i32,
) callconv(WINAPI) i32; ) callconv(.winapi) i32;
pub extern "ws2_32" fn shutdown( pub extern "ws2_32" fn shutdown(
s: SOCKET, s: SOCKET,
how: i32, how: i32,
) callconv(WINAPI) i32; ) callconv(.winapi) i32;
pub extern "ws2_32" fn socket( pub extern "ws2_32" fn socket(
af: i32, af: i32,
@"type": i32, @"type": i32,
protocol: i32, protocol: i32,
) callconv(WINAPI) SOCKET; ) callconv(.winapi) SOCKET;
pub extern "ws2_32" fn WSAStartup( pub extern "ws2_32" fn WSAStartup(
wVersionRequired: WORD, wVersionRequired: WORD,
lpWSAData: *WSADATA, lpWSAData: *WSADATA,
) callconv(WINAPI) i32; ) callconv(.winapi) i32;
pub extern "ws2_32" fn WSACleanup() callconv(WINAPI) i32; pub extern "ws2_32" fn WSACleanup() callconv(.winapi) i32;
pub extern "ws2_32" fn WSASetLastError(iError: i32) callconv(WINAPI) void; pub extern "ws2_32" fn WSASetLastError(iError: i32) callconv(.winapi) void;
pub extern "ws2_32" fn WSAGetLastError() callconv(WINAPI) WinsockError; pub extern "ws2_32" fn WSAGetLastError() callconv(.winapi) WinsockError;
pub extern "ws2_32" fn WSAIsBlocking() callconv(WINAPI) BOOL; pub extern "ws2_32" fn WSAIsBlocking() callconv(.winapi) BOOL;
pub extern "ws2_32" fn WSAUnhookBlockingHook() callconv(WINAPI) i32; pub extern "ws2_32" fn WSAUnhookBlockingHook() callconv(.winapi) i32;
pub extern "ws2_32" fn WSASetBlockingHook(lpBlockFunc: FARPROC) callconv(WINAPI) FARPROC; pub extern "ws2_32" fn WSASetBlockingHook(lpBlockFunc: FARPROC) callconv(.winapi) FARPROC;
pub extern "ws2_32" fn WSACancelBlockingCall() callconv(WINAPI) i32; pub extern "ws2_32" fn WSACancelBlockingCall() callconv(.winapi) i32;
pub extern "ws2_32" fn WSAAsyncGetServByName( pub extern "ws2_32" fn WSAAsyncGetServByName(
hWnd: HWND, hWnd: HWND,
@ -1879,7 +1878,7 @@ pub extern "ws2_32" fn WSAAsyncGetServByName(
proto: ?[*:0]const u8, proto: ?[*:0]const u8,
buf: [*]u8, buf: [*]u8,
buflen: i32, buflen: i32,
) callconv(WINAPI) HANDLE; ) callconv(.winapi) HANDLE;
pub extern "ws2_32" fn WSAAsyncGetServByPort( pub extern "ws2_32" fn WSAAsyncGetServByPort(
hWnd: HWND, hWnd: HWND,
@ -1888,7 +1887,7 @@ pub extern "ws2_32" fn WSAAsyncGetServByPort(
proto: ?[*:0]const u8, proto: ?[*:0]const u8,
buf: [*]u8, buf: [*]u8,
buflen: i32, buflen: i32,
) callconv(WINAPI) HANDLE; ) callconv(.winapi) HANDLE;
pub extern "ws2_32" fn WSAAsyncGetProtoByName( pub extern "ws2_32" fn WSAAsyncGetProtoByName(
hWnd: HWND, hWnd: HWND,
@ -1896,7 +1895,7 @@ pub extern "ws2_32" fn WSAAsyncGetProtoByName(
name: [*:0]const u8, name: [*:0]const u8,
buf: [*]u8, buf: [*]u8,
buflen: i32, buflen: i32,
) callconv(WINAPI) HANDLE; ) callconv(.winapi) HANDLE;
pub extern "ws2_32" fn WSAAsyncGetProtoByNumber( pub extern "ws2_32" fn WSAAsyncGetProtoByNumber(
hWnd: HWND, hWnd: HWND,
@ -1904,16 +1903,16 @@ pub extern "ws2_32" fn WSAAsyncGetProtoByNumber(
number: i32, number: i32,
buf: [*]u8, buf: [*]u8,
buflen: i32, buflen: i32,
) callconv(WINAPI) HANDLE; ) callconv(.winapi) HANDLE;
pub extern "ws2_32" fn WSACancelAsyncRequest(hAsyncTaskHandle: HANDLE) callconv(WINAPI) i32; pub extern "ws2_32" fn WSACancelAsyncRequest(hAsyncTaskHandle: HANDLE) callconv(.winapi) i32;
pub extern "ws2_32" fn WSAAsyncSelect( pub extern "ws2_32" fn WSAAsyncSelect(
s: SOCKET, s: SOCKET,
hWnd: HWND, hWnd: HWND,
wMsg: u32, wMsg: u32,
lEvent: i32, lEvent: i32,
) callconv(WINAPI) i32; ) callconv(.winapi) i32;
pub extern "ws2_32" fn WSAAccept( pub extern "ws2_32" fn WSAAccept(
s: SOCKET, s: SOCKET,
@ -1921,9 +1920,9 @@ pub extern "ws2_32" fn WSAAccept(
addrlen: ?*i32, addrlen: ?*i32,
lpfnCondition: ?LPCONDITIONPROC, lpfnCondition: ?LPCONDITIONPROC,
dwCallbackData: usize, dwCallbackData: usize,
) callconv(WINAPI) SOCKET; ) callconv(.winapi) SOCKET;
pub extern "ws2_32" fn WSACloseEvent(hEvent: HANDLE) callconv(WINAPI) BOOL; pub extern "ws2_32" fn WSACloseEvent(hEvent: HANDLE) callconv(.winapi) BOOL;
pub extern "ws2_32" fn WSAConnect( pub extern "ws2_32" fn WSAConnect(
s: SOCKET, s: SOCKET,
@ -1933,7 +1932,7 @@ pub extern "ws2_32" fn WSAConnect(
lpCalleeData: ?*WSABUF, lpCalleeData: ?*WSABUF,
lpSQOS: ?*QOS, lpSQOS: ?*QOS,
lpGQOS: ?*QOS, lpGQOS: ?*QOS,
) callconv(WINAPI) i32; ) callconv(.winapi) i32;
pub extern "ws2_32" fn WSAConnectByNameW( pub extern "ws2_32" fn WSAConnectByNameW(
s: SOCKET, s: SOCKET,
@ -1945,7 +1944,7 @@ pub extern "ws2_32" fn WSAConnectByNameW(
RemoteAddress: ?*sockaddr, RemoteAddress: ?*sockaddr,
timeout: ?*const timeval, timeout: ?*const timeval,
Reserved: *OVERLAPPED, Reserved: *OVERLAPPED,
) callconv(WINAPI) BOOL; ) callconv(.winapi) BOOL;
pub extern "ws2_32" fn WSAConnectByNameA( pub extern "ws2_32" fn WSAConnectByNameA(
s: SOCKET, s: SOCKET,
@ -1957,7 +1956,7 @@ pub extern "ws2_32" fn WSAConnectByNameA(
RemoteAddress: ?*sockaddr, RemoteAddress: ?*sockaddr,
timeout: ?*const timeval, timeout: ?*const timeval,
Reserved: *OVERLAPPED, Reserved: *OVERLAPPED,
) callconv(WINAPI) BOOL; ) callconv(.winapi) BOOL;
pub extern "ws2_32" fn WSAConnectByList( pub extern "ws2_32" fn WSAConnectByList(
s: SOCKET, s: SOCKET,
@ -1968,45 +1967,45 @@ pub extern "ws2_32" fn WSAConnectByList(
RemoteAddress: ?*sockaddr, RemoteAddress: ?*sockaddr,
timeout: ?*const timeval, timeout: ?*const timeval,
Reserved: *OVERLAPPED, Reserved: *OVERLAPPED,
) callconv(WINAPI) BOOL; ) callconv(.winapi) BOOL;
pub extern "ws2_32" fn WSACreateEvent() callconv(WINAPI) HANDLE; pub extern "ws2_32" fn WSACreateEvent() callconv(.winapi) HANDLE;
pub extern "ws2_32" fn WSADuplicateSocketA( pub extern "ws2_32" fn WSADuplicateSocketA(
s: SOCKET, s: SOCKET,
dwProcessId: u32, dwProcessId: u32,
lpProtocolInfo: *WSAPROTOCOL_INFOA, lpProtocolInfo: *WSAPROTOCOL_INFOA,
) callconv(WINAPI) i32; ) callconv(.winapi) i32;
pub extern "ws2_32" fn WSADuplicateSocketW( pub extern "ws2_32" fn WSADuplicateSocketW(
s: SOCKET, s: SOCKET,
dwProcessId: u32, dwProcessId: u32,
lpProtocolInfo: *WSAPROTOCOL_INFOW, lpProtocolInfo: *WSAPROTOCOL_INFOW,
) callconv(WINAPI) i32; ) callconv(.winapi) i32;
pub extern "ws2_32" fn WSAEnumNetworkEvents( pub extern "ws2_32" fn WSAEnumNetworkEvents(
s: SOCKET, s: SOCKET,
hEventObject: HANDLE, hEventObject: HANDLE,
lpNetworkEvents: *WSANETWORKEVENTS, lpNetworkEvents: *WSANETWORKEVENTS,
) callconv(WINAPI) i32; ) callconv(.winapi) i32;
pub extern "ws2_32" fn WSAEnumProtocolsA( pub extern "ws2_32" fn WSAEnumProtocolsA(
lpiProtocols: ?*i32, lpiProtocols: ?*i32,
lpProtocolBuffer: ?*WSAPROTOCOL_INFOA, lpProtocolBuffer: ?*WSAPROTOCOL_INFOA,
lpdwBufferLength: *u32, lpdwBufferLength: *u32,
) callconv(WINAPI) i32; ) callconv(.winapi) i32;
pub extern "ws2_32" fn WSAEnumProtocolsW( pub extern "ws2_32" fn WSAEnumProtocolsW(
lpiProtocols: ?*i32, lpiProtocols: ?*i32,
lpProtocolBuffer: ?*WSAPROTOCOL_INFOW, lpProtocolBuffer: ?*WSAPROTOCOL_INFOW,
lpdwBufferLength: *u32, lpdwBufferLength: *u32,
) callconv(WINAPI) i32; ) callconv(.winapi) i32;
pub extern "ws2_32" fn WSAEventSelect( pub extern "ws2_32" fn WSAEventSelect(
s: SOCKET, s: SOCKET,
hEventObject: HANDLE, hEventObject: HANDLE,
lNetworkEvents: i32, lNetworkEvents: i32,
) callconv(WINAPI) i32; ) callconv(.winapi) i32;
pub extern "ws2_32" fn WSAGetOverlappedResult( pub extern "ws2_32" fn WSAGetOverlappedResult(
s: SOCKET, s: SOCKET,
@ -2014,25 +2013,25 @@ pub extern "ws2_32" fn WSAGetOverlappedResult(
lpcbTransfer: *u32, lpcbTransfer: *u32,
fWait: BOOL, fWait: BOOL,
lpdwFlags: *u32, lpdwFlags: *u32,
) callconv(WINAPI) BOOL; ) callconv(.winapi) BOOL;
pub extern "ws2_32" fn WSAGetQOSByName( pub extern "ws2_32" fn WSAGetQOSByName(
s: SOCKET, s: SOCKET,
lpQOSName: *WSABUF, lpQOSName: *WSABUF,
lpQOS: *QOS, lpQOS: *QOS,
) callconv(WINAPI) BOOL; ) callconv(.winapi) BOOL;
pub extern "ws2_32" fn WSAHtonl( pub extern "ws2_32" fn WSAHtonl(
s: SOCKET, s: SOCKET,
hostlong: u32, hostlong: u32,
lpnetlong: *u32, lpnetlong: *u32,
) callconv(WINAPI) i32; ) callconv(.winapi) i32;
pub extern "ws2_32" fn WSAHtons( pub extern "ws2_32" fn WSAHtons(
s: SOCKET, s: SOCKET,
hostshort: u16, hostshort: u16,
lpnetshort: *u16, lpnetshort: *u16,
) callconv(WINAPI) i32; ) callconv(.winapi) i32;
pub extern "ws2_32" fn WSAIoctl( pub extern "ws2_32" fn WSAIoctl(
s: SOCKET, s: SOCKET,
@ -2044,7 +2043,7 @@ pub extern "ws2_32" fn WSAIoctl(
lpcbBytesReturned: *u32, lpcbBytesReturned: *u32,
lpOverlapped: ?*OVERLAPPED, lpOverlapped: ?*OVERLAPPED,
lpCompletionRoutine: ?LPWSAOVERLAPPED_COMPLETION_ROUTINE, lpCompletionRoutine: ?LPWSAOVERLAPPED_COMPLETION_ROUTINE,
) callconv(WINAPI) i32; ) callconv(.winapi) i32;
pub extern "ws2_32" fn WSAJoinLeaf( pub extern "ws2_32" fn WSAJoinLeaf(
s: SOCKET, s: SOCKET,
@ -2055,19 +2054,19 @@ pub extern "ws2_32" fn WSAJoinLeaf(
lpSQOS: ?*QOS, lpSQOS: ?*QOS,
lpGQOS: ?*QOS, lpGQOS: ?*QOS,
dwFlags: u32, dwFlags: u32,
) callconv(WINAPI) SOCKET; ) callconv(.winapi) SOCKET;
pub extern "ws2_32" fn WSANtohl( pub extern "ws2_32" fn WSANtohl(
s: SOCKET, s: SOCKET,
netlong: u32, netlong: u32,
lphostlong: *u32, lphostlong: *u32,
) callconv(WINAPI) u32; ) callconv(.winapi) u32;
pub extern "ws2_32" fn WSANtohs( pub extern "ws2_32" fn WSANtohs(
s: SOCKET, s: SOCKET,
netshort: u16, netshort: u16,
lphostshort: *u16, lphostshort: *u16,
) callconv(WINAPI) i32; ) callconv(.winapi) i32;
pub extern "ws2_32" fn WSARecv( pub extern "ws2_32" fn WSARecv(
s: SOCKET, s: SOCKET,
@ -2077,12 +2076,12 @@ pub extern "ws2_32" fn WSARecv(
lpFlags: *u32, lpFlags: *u32,
lpOverlapped: ?*OVERLAPPED, lpOverlapped: ?*OVERLAPPED,
lpCompletionRoutine: ?LPWSAOVERLAPPED_COMPLETION_ROUTINE, lpCompletionRoutine: ?LPWSAOVERLAPPED_COMPLETION_ROUTINE,
) callconv(WINAPI) i32; ) callconv(.winapi) i32;
pub extern "ws2_32" fn WSARecvDisconnect( pub extern "ws2_32" fn WSARecvDisconnect(
s: SOCKET, s: SOCKET,
lpInboundDisconnectData: ?*WSABUF, lpInboundDisconnectData: ?*WSABUF,
) callconv(WINAPI) i32; ) callconv(.winapi) i32;
pub extern "ws2_32" fn WSARecvFrom( pub extern "ws2_32" fn WSARecvFrom(
s: SOCKET, s: SOCKET,
@ -2094,9 +2093,9 @@ pub extern "ws2_32" fn WSARecvFrom(
lpFromlen: ?*i32, lpFromlen: ?*i32,
lpOverlapped: ?*OVERLAPPED, lpOverlapped: ?*OVERLAPPED,
lpCompletionRoutine: ?LPWSAOVERLAPPED_COMPLETION_ROUTINE, lpCompletionRoutine: ?LPWSAOVERLAPPED_COMPLETION_ROUTINE,
) callconv(WINAPI) i32; ) callconv(.winapi) i32;
pub extern "ws2_32" fn WSAResetEvent(hEvent: HANDLE) callconv(WINAPI) i32; pub extern "ws2_32" fn WSAResetEvent(hEvent: HANDLE) callconv(.winapi) i32;
pub extern "ws2_32" fn WSASend( pub extern "ws2_32" fn WSASend(
s: SOCKET, s: SOCKET,
@ -2106,7 +2105,7 @@ pub extern "ws2_32" fn WSASend(
dwFlags: u32, dwFlags: u32,
lpOverlapped: ?*OVERLAPPED, lpOverlapped: ?*OVERLAPPED,
lpCompletionRoutine: ?LPWSAOVERLAPPED_COMPLETION_ROUTINE, lpCompletionRoutine: ?LPWSAOVERLAPPED_COMPLETION_ROUTINE,
) callconv(WINAPI) i32; ) callconv(.winapi) i32;
pub extern "ws2_32" fn WSASendMsg( pub extern "ws2_32" fn WSASendMsg(
s: SOCKET, s: SOCKET,
@ -2115,7 +2114,7 @@ pub extern "ws2_32" fn WSASendMsg(
lpNumberOfBytesSent: ?*u32, lpNumberOfBytesSent: ?*u32,
lpOverlapped: ?*OVERLAPPED, lpOverlapped: ?*OVERLAPPED,
lpCompletionRoutine: ?LPWSAOVERLAPPED_COMPLETION_ROUTINE, lpCompletionRoutine: ?LPWSAOVERLAPPED_COMPLETION_ROUTINE,
) callconv(WINAPI) i32; ) callconv(.winapi) i32;
pub extern "ws2_32" fn WSARecvMsg( pub extern "ws2_32" fn WSARecvMsg(
s: SOCKET, s: SOCKET,
@ -2123,12 +2122,12 @@ pub extern "ws2_32" fn WSARecvMsg(
lpdwNumberOfBytesRecv: ?*u32, lpdwNumberOfBytesRecv: ?*u32,
lpOverlapped: ?*OVERLAPPED, lpOverlapped: ?*OVERLAPPED,
lpCompletionRoutine: ?LPWSAOVERLAPPED_COMPLETION_ROUTINE, lpCompletionRoutine: ?LPWSAOVERLAPPED_COMPLETION_ROUTINE,
) callconv(WINAPI) i32; ) callconv(.winapi) i32;
pub extern "ws2_32" fn WSASendDisconnect( pub extern "ws2_32" fn WSASendDisconnect(
s: SOCKET, s: SOCKET,
lpOutboundDisconnectData: ?*WSABUF, lpOutboundDisconnectData: ?*WSABUF,
) callconv(WINAPI) i32; ) callconv(.winapi) i32;
pub extern "ws2_32" fn WSASendTo( pub extern "ws2_32" fn WSASendTo(
s: SOCKET, s: SOCKET,
@ -2140,11 +2139,11 @@ pub extern "ws2_32" fn WSASendTo(
iToLen: i32, iToLen: i32,
lpOverlapped: ?*OVERLAPPED, lpOverlapped: ?*OVERLAPPED,
lpCompletionRounte: ?LPWSAOVERLAPPED_COMPLETION_ROUTINE, lpCompletionRounte: ?LPWSAOVERLAPPED_COMPLETION_ROUTINE,
) callconv(WINAPI) i32; ) callconv(.winapi) i32;
pub extern "ws2_32" fn WSASetEvent( pub extern "ws2_32" fn WSASetEvent(
hEvent: HANDLE, hEvent: HANDLE,
) callconv(WINAPI) BOOL; ) callconv(.winapi) BOOL;
pub extern "ws2_32" fn WSASocketA( pub extern "ws2_32" fn WSASocketA(
af: i32, af: i32,
@ -2153,7 +2152,7 @@ pub extern "ws2_32" fn WSASocketA(
lpProtocolInfo: ?*WSAPROTOCOL_INFOA, lpProtocolInfo: ?*WSAPROTOCOL_INFOA,
g: u32, g: u32,
dwFlags: u32, dwFlags: u32,
) callconv(WINAPI) SOCKET; ) callconv(.winapi) SOCKET;
pub extern "ws2_32" fn WSASocketW( pub extern "ws2_32" fn WSASocketW(
af: i32, af: i32,
@ -2162,7 +2161,7 @@ pub extern "ws2_32" fn WSASocketW(
lpProtocolInfo: ?*WSAPROTOCOL_INFOW, lpProtocolInfo: ?*WSAPROTOCOL_INFOW,
g: u32, g: u32,
dwFlags: u32, dwFlags: u32,
) callconv(WINAPI) SOCKET; ) callconv(.winapi) SOCKET;
pub extern "ws2_32" fn WSAWaitForMultipleEvents( pub extern "ws2_32" fn WSAWaitForMultipleEvents(
cEvents: u32, cEvents: u32,
@ -2170,7 +2169,7 @@ pub extern "ws2_32" fn WSAWaitForMultipleEvents(
fWaitAll: BOOL, fWaitAll: BOOL,
dwTimeout: u32, dwTimeout: u32,
fAlertable: BOOL, fAlertable: BOOL,
) callconv(WINAPI) u32; ) callconv(.winapi) u32;
pub extern "ws2_32" fn WSAAddressToStringA( pub extern "ws2_32" fn WSAAddressToStringA(
lpsaAddress: *sockaddr, lpsaAddress: *sockaddr,
@ -2178,7 +2177,7 @@ pub extern "ws2_32" fn WSAAddressToStringA(
lpProtocolInfo: ?*WSAPROTOCOL_INFOA, lpProtocolInfo: ?*WSAPROTOCOL_INFOA,
lpszAddressString: [*]u8, lpszAddressString: [*]u8,
lpdwAddressStringLength: *u32, lpdwAddressStringLength: *u32,
) callconv(WINAPI) i32; ) callconv(.winapi) i32;
pub extern "ws2_32" fn WSAAddressToStringW( pub extern "ws2_32" fn WSAAddressToStringW(
lpsaAddress: *sockaddr, lpsaAddress: *sockaddr,
@ -2186,7 +2185,7 @@ pub extern "ws2_32" fn WSAAddressToStringW(
lpProtocolInfo: ?*WSAPROTOCOL_INFOW, lpProtocolInfo: ?*WSAPROTOCOL_INFOW,
lpszAddressString: [*]u16, lpszAddressString: [*]u16,
lpdwAddressStringLength: *u32, lpdwAddressStringLength: *u32,
) callconv(WINAPI) i32; ) callconv(.winapi) i32;
pub extern "ws2_32" fn WSAStringToAddressA( pub extern "ws2_32" fn WSAStringToAddressA(
AddressString: [*:0]const u8, AddressString: [*:0]const u8,
@ -2194,7 +2193,7 @@ pub extern "ws2_32" fn WSAStringToAddressA(
lpProtocolInfo: ?*WSAPROTOCOL_INFOA, lpProtocolInfo: ?*WSAPROTOCOL_INFOA,
lpAddress: *sockaddr, lpAddress: *sockaddr,
lpAddressLength: *i32, lpAddressLength: *i32,
) callconv(WINAPI) i32; ) callconv(.winapi) i32;
pub extern "ws2_32" fn WSAStringToAddressW( pub extern "ws2_32" fn WSAStringToAddressW(
AddressString: [*:0]const u16, AddressString: [*:0]const u16,
@ -2202,26 +2201,26 @@ pub extern "ws2_32" fn WSAStringToAddressW(
lpProtocolInfo: ?*WSAPROTOCOL_INFOW, lpProtocolInfo: ?*WSAPROTOCOL_INFOW,
lpAddrses: *sockaddr, lpAddrses: *sockaddr,
lpAddressLength: *i32, lpAddressLength: *i32,
) callconv(WINAPI) i32; ) callconv(.winapi) i32;
pub extern "ws2_32" fn WSAProviderConfigChange( pub extern "ws2_32" fn WSAProviderConfigChange(
lpNotificationHandle: *HANDLE, lpNotificationHandle: *HANDLE,
lpOverlapped: ?*OVERLAPPED, lpOverlapped: ?*OVERLAPPED,
lpCompletionRoutine: ?LPWSAOVERLAPPED_COMPLETION_ROUTINE, lpCompletionRoutine: ?LPWSAOVERLAPPED_COMPLETION_ROUTINE,
) callconv(WINAPI) i32; ) callconv(.winapi) i32;
pub extern "ws2_32" fn WSAPoll( pub extern "ws2_32" fn WSAPoll(
fdArray: [*]WSAPOLLFD, fdArray: [*]WSAPOLLFD,
fds: u32, fds: u32,
timeout: i32, timeout: i32,
) callconv(WINAPI) i32; ) callconv(.winapi) i32;
pub extern "mswsock" fn WSARecvEx( pub extern "mswsock" fn WSARecvEx(
s: SOCKET, s: SOCKET,
buf: [*]u8, buf: [*]u8,
len: i32, len: i32,
flags: *i32, flags: *i32,
) callconv(WINAPI) i32; ) callconv(.winapi) i32;
pub extern "mswsock" fn TransmitFile( pub extern "mswsock" fn TransmitFile(
hSocket: SOCKET, hSocket: SOCKET,
@ -2231,7 +2230,7 @@ pub extern "mswsock" fn TransmitFile(
lpOverlapped: ?*OVERLAPPED, lpOverlapped: ?*OVERLAPPED,
lpTransmitBuffers: ?*TRANSMIT_FILE_BUFFERS, lpTransmitBuffers: ?*TRANSMIT_FILE_BUFFERS,
dwReserved: u32, dwReserved: u32,
) callconv(WINAPI) BOOL; ) callconv(.winapi) BOOL;
pub extern "mswsock" fn AcceptEx( pub extern "mswsock" fn AcceptEx(
sListenSocket: SOCKET, sListenSocket: SOCKET,
@ -2242,7 +2241,7 @@ pub extern "mswsock" fn AcceptEx(
dwRemoteAddressLength: u32, dwRemoteAddressLength: u32,
lpdwBytesReceived: *u32, lpdwBytesReceived: *u32,
lpOverlapped: *OVERLAPPED, lpOverlapped: *OVERLAPPED,
) callconv(WINAPI) BOOL; ) callconv(.winapi) BOOL;
pub extern "mswsock" fn GetAcceptExSockaddrs( pub extern "mswsock" fn GetAcceptExSockaddrs(
lpOutputBuffer: *anyopaque, lpOutputBuffer: *anyopaque,
@ -2253,24 +2252,24 @@ pub extern "mswsock" fn GetAcceptExSockaddrs(
LocalSockaddrLength: *i32, LocalSockaddrLength: *i32,
RemoteSockaddr: **sockaddr, RemoteSockaddr: **sockaddr,
RemoteSockaddrLength: *i32, RemoteSockaddrLength: *i32,
) callconv(WINAPI) void; ) callconv(.winapi) void;
pub extern "ws2_32" fn WSAProviderCompleteAsyncCall( pub extern "ws2_32" fn WSAProviderCompleteAsyncCall(
hAsyncCall: HANDLE, hAsyncCall: HANDLE,
iRetCode: i32, iRetCode: i32,
) callconv(WINAPI) i32; ) callconv(.winapi) i32;
pub extern "mswsock" fn EnumProtocolsA( pub extern "mswsock" fn EnumProtocolsA(
lpiProtocols: ?*i32, lpiProtocols: ?*i32,
lpProtocolBuffer: *anyopaque, lpProtocolBuffer: *anyopaque,
lpdwBufferLength: *u32, lpdwBufferLength: *u32,
) callconv(WINAPI) i32; ) callconv(.winapi) i32;
pub extern "mswsock" fn EnumProtocolsW( pub extern "mswsock" fn EnumProtocolsW(
lpiProtocols: ?*i32, lpiProtocols: ?*i32,
lpProtocolBuffer: *anyopaque, lpProtocolBuffer: *anyopaque,
lpdwBufferLength: *u32, lpdwBufferLength: *u32,
) callconv(WINAPI) i32; ) callconv(.winapi) i32;
pub extern "mswsock" fn GetAddressByNameA( pub extern "mswsock" fn GetAddressByNameA(
dwNameSpace: u32, dwNameSpace: u32,
@ -2282,7 +2281,7 @@ pub extern "mswsock" fn GetAddressByNameA(
lpCsaddrBuffer: *anyopaque, lpCsaddrBuffer: *anyopaque,
lpAliasBuffer: ?[*:0]const u8, lpAliasBuffer: ?[*:0]const u8,
lpdwAliasBufferLength: *u32, lpdwAliasBufferLength: *u32,
) callconv(WINAPI) i32; ) callconv(.winapi) i32;
pub extern "mswsock" fn GetAddressByNameW( pub extern "mswsock" fn GetAddressByNameW(
dwNameSpace: u32, dwNameSpace: u32,
@ -2295,36 +2294,36 @@ pub extern "mswsock" fn GetAddressByNameW(
ldwBufferLEngth: *u32, ldwBufferLEngth: *u32,
lpAliasBuffer: ?[*:0]u16, lpAliasBuffer: ?[*:0]u16,
lpdwAliasBufferLength: *u32, lpdwAliasBufferLength: *u32,
) callconv(WINAPI) i32; ) callconv(.winapi) i32;
pub extern "mswsock" fn GetTypeByNameA( pub extern "mswsock" fn GetTypeByNameA(
lpServiceName: [*:0]u8, lpServiceName: [*:0]u8,
lpServiceType: *GUID, lpServiceType: *GUID,
) callconv(WINAPI) i32; ) callconv(.winapi) i32;
pub extern "mswsock" fn GetTypeByNameW( pub extern "mswsock" fn GetTypeByNameW(
lpServiceName: [*:0]u16, lpServiceName: [*:0]u16,
lpServiceType: *GUID, lpServiceType: *GUID,
) callconv(WINAPI) i32; ) callconv(.winapi) i32;
pub extern "mswsock" fn GetNameByTypeA( pub extern "mswsock" fn GetNameByTypeA(
lpServiceType: *GUID, lpServiceType: *GUID,
lpServiceName: [*:0]u8, lpServiceName: [*:0]u8,
dwNameLength: u32, dwNameLength: u32,
) callconv(WINAPI) i32; ) callconv(.winapi) i32;
pub extern "mswsock" fn GetNameByTypeW( pub extern "mswsock" fn GetNameByTypeW(
lpServiceType: *GUID, lpServiceType: *GUID,
lpServiceName: [*:0]u16, lpServiceName: [*:0]u16,
dwNameLength: u32, dwNameLength: u32,
) callconv(WINAPI) i32; ) callconv(.winapi) i32;
pub extern "ws2_32" fn getaddrinfo( pub extern "ws2_32" fn getaddrinfo(
pNodeName: ?[*:0]const u8, pNodeName: ?[*:0]const u8,
pServiceName: ?[*:0]const u8, pServiceName: ?[*:0]const u8,
pHints: ?*const addrinfoa, pHints: ?*const addrinfoa,
ppResult: *?*addrinfoa, ppResult: *?*addrinfoa,
) callconv(WINAPI) i32; ) callconv(.winapi) i32;
pub extern "ws2_32" fn GetAddrInfoExA( pub extern "ws2_32" fn GetAddrInfoExA(
pName: ?[*:0]const u8, pName: ?[*:0]const u8,
@ -2336,23 +2335,23 @@ pub extern "ws2_32" fn GetAddrInfoExA(
timeout: ?*timeval, timeout: ?*timeval,
lpOverlapped: ?*OVERLAPPED, lpOverlapped: ?*OVERLAPPED,
lpCompletionRoutine: ?LPLOOKUPSERVICE_COMPLETION_ROUTINE, lpCompletionRoutine: ?LPLOOKUPSERVICE_COMPLETION_ROUTINE,
) callconv(WINAPI) i32; ) callconv(.winapi) i32;
pub extern "ws2_32" fn GetAddrInfoExCancel( pub extern "ws2_32" fn GetAddrInfoExCancel(
lpHandle: *HANDLE, lpHandle: *HANDLE,
) callconv(WINAPI) i32; ) callconv(.winapi) i32;
pub extern "ws2_32" fn GetAddrInfoExOverlappedResult( pub extern "ws2_32" fn GetAddrInfoExOverlappedResult(
lpOverlapped: *OVERLAPPED, lpOverlapped: *OVERLAPPED,
) callconv(WINAPI) i32; ) callconv(.winapi) i32;
pub extern "ws2_32" fn freeaddrinfo( pub extern "ws2_32" fn freeaddrinfo(
pAddrInfo: ?*addrinfoa, pAddrInfo: ?*addrinfoa,
) callconv(WINAPI) void; ) callconv(.winapi) void;
pub extern "ws2_32" fn FreeAddrInfoEx( pub extern "ws2_32" fn FreeAddrInfoEx(
pAddrInfoEx: ?*addrinfoexA, pAddrInfoEx: ?*addrinfoexA,
) callconv(WINAPI) void; ) callconv(.winapi) void;
pub extern "ws2_32" fn getnameinfo( pub extern "ws2_32" fn getnameinfo(
pSockaddr: *const sockaddr, pSockaddr: *const sockaddr,
@ -2362,8 +2361,8 @@ pub extern "ws2_32" fn getnameinfo(
pServiceBuffer: ?[*]u8, pServiceBuffer: ?[*]u8,
ServiceBufferName: u32, ServiceBufferName: u32,
Flags: i32, Flags: i32,
) callconv(WINAPI) i32; ) callconv(.winapi) i32;
pub extern "iphlpapi" fn if_nametoindex( pub extern "iphlpapi" fn if_nametoindex(
InterfaceName: [*:0]const u8, InterfaceName: [*:0]const u8,
) callconv(WINAPI) u32; ) callconv(.winapi) u32;

View File

@ -29,7 +29,7 @@ comptime {
if (simplified_logic) { if (simplified_logic) {
if (builtin.output_mode == .Exe) { if (builtin.output_mode == .Exe) {
if ((builtin.link_libc or builtin.object_format == .c) and @hasDecl(root, "main")) { if ((builtin.link_libc or builtin.object_format == .c) and @hasDecl(root, "main")) {
if (@typeInfo(@TypeOf(root.main)).@"fn".calling_convention != .C) { if (!@typeInfo(@TypeOf(root.main)).@"fn".calling_convention.eql(.c)) {
@export(&main2, .{ .name = "main" }); @export(&main2, .{ .name = "main" });
} }
} else if (builtin.os.tag == .windows) { } else if (builtin.os.tag == .windows) {
@ -96,7 +96,7 @@ comptime {
// Simplified start code for stage2 until it supports more language features /// // Simplified start code for stage2 until it supports more language features ///
fn main2() callconv(.C) c_int { fn main2() callconv(.c) c_int {
root.main(); root.main();
return 0; return 0;
} }
@ -110,11 +110,11 @@ fn callMain2() noreturn {
exit2(0); exit2(0);
} }
fn spirvMain2() callconv(.Kernel) void { fn spirvMain2() callconv(.kernel) void {
root.main(); root.main();
} }
fn wWinMainCRTStartup2() callconv(.C) noreturn { fn wWinMainCRTStartup2() callconv(.c) noreturn {
root.main(); root.main();
exit2(0); exit2(0);
} }
@ -172,7 +172,7 @@ fn _DllMainCRTStartup(
hinstDLL: std.os.windows.HINSTANCE, hinstDLL: std.os.windows.HINSTANCE,
fdwReason: std.os.windows.DWORD, fdwReason: std.os.windows.DWORD,
lpReserved: std.os.windows.LPVOID, lpReserved: std.os.windows.LPVOID,
) callconv(std.os.windows.WINAPI) std.os.windows.BOOL { ) callconv(.winapi) std.os.windows.BOOL {
if (!builtin.single_threaded and !builtin.link_libc) { if (!builtin.single_threaded and !builtin.link_libc) {
_ = @import("os/windows/tls.zig"); _ = @import("os/windows/tls.zig");
} }
@ -184,13 +184,13 @@ fn _DllMainCRTStartup(
return std.os.windows.TRUE; return std.os.windows.TRUE;
} }
fn wasm_freestanding_start() callconv(.C) void { fn wasm_freestanding_start() callconv(.c) void {
// This is marked inline because for some reason LLVM in // This is marked inline because for some reason LLVM in
// release mode fails to inline it, and we want fewer call frames in stack traces. // release mode fails to inline it, and we want fewer call frames in stack traces.
_ = @call(.always_inline, callMain, .{}); _ = @call(.always_inline, callMain, .{});
} }
fn wasi_start() callconv(.C) void { fn wasi_start() callconv(.c) void {
// The function call is marked inline because for some reason LLVM in // The function call is marked inline because for some reason LLVM in
// release mode fails to inline it, and we want fewer call frames in stack traces. // release mode fails to inline it, and we want fewer call frames in stack traces.
switch (builtin.wasi_exec_model) { switch (builtin.wasi_exec_model) {
@ -199,7 +199,7 @@ fn wasi_start() callconv(.C) void {
} }
} }
fn EfiMain(handle: uefi.Handle, system_table: *uefi.tables.SystemTable) callconv(.C) usize { fn EfiMain(handle: uefi.Handle, system_table: *uefi.tables.SystemTable) callconv(.c) usize {
uefi.handle = handle; uefi.handle = handle;
uefi.system_table = system_table; uefi.system_table = system_table;
@ -221,7 +221,7 @@ fn EfiMain(handle: uefi.Handle, system_table: *uefi.tables.SystemTable) callconv
} }
} }
fn _start() callconv(.Naked) noreturn { fn _start() callconv(.naked) noreturn {
// TODO set Top of Stack on non x86_64-plan9 // TODO set Top of Stack on non x86_64-plan9
if (native_os == .plan9 and native_arch == .x86_64) { if (native_os == .plan9 and native_arch == .x86_64) {
// from /sys/src/libc/amd64/main9.s // from /sys/src/libc/amd64/main9.s
@ -426,7 +426,7 @@ fn _start() callconv(.Naked) noreturn {
); );
} }
fn WinStartup() callconv(.withStackAlign(.winapi, 1)) noreturn { fn WinStartup() callconv(.withStackAlign(.c, 1)) noreturn {
if (!builtin.single_threaded and !builtin.link_libc) { if (!builtin.single_threaded and !builtin.link_libc) {
_ = @import("os/windows/tls.zig"); _ = @import("os/windows/tls.zig");
} }
@ -436,7 +436,7 @@ fn WinStartup() callconv(.withStackAlign(.winapi, 1)) noreturn {
std.os.windows.ntdll.RtlExitUserProcess(callMain()); std.os.windows.ntdll.RtlExitUserProcess(callMain());
} }
fn wWinMainCRTStartup() callconv(.withStackAlign(.winapi, 1)) noreturn { fn wWinMainCRTStartup() callconv(.withStackAlign(.c, 1)) noreturn {
if (!builtin.single_threaded and !builtin.link_libc) { if (!builtin.single_threaded and !builtin.link_libc) {
_ = @import("os/windows/tls.zig"); _ = @import("os/windows/tls.zig");
} }
@ -447,7 +447,7 @@ fn wWinMainCRTStartup() callconv(.withStackAlign(.winapi, 1)) noreturn {
std.os.windows.ntdll.RtlExitUserProcess(@as(std.os.windows.UINT, @bitCast(result))); std.os.windows.ntdll.RtlExitUserProcess(@as(std.os.windows.UINT, @bitCast(result)));
} }
fn posixCallMainAndExit(argc_argv_ptr: [*]usize) callconv(.C) noreturn { fn posixCallMainAndExit(argc_argv_ptr: [*]usize) callconv(.c) noreturn {
// We're not ready to panic until thread local storage is initialized. // We're not ready to panic until thread local storage is initialized.
@setRuntimeSafety(false); @setRuntimeSafety(false);
// Code coverage instrumentation might try to use thread local variables. // Code coverage instrumentation might try to use thread local variables.
@ -514,11 +514,11 @@ fn posixCallMainAndExit(argc_argv_ptr: [*]usize) callconv(.C) noreturn {
// to ask for more stack space. // to ask for more stack space.
expandStackSize(phdrs); expandStackSize(phdrs);
const opt_init_array_start = @extern([*]*const fn () callconv(.C) void, .{ const opt_init_array_start = @extern([*]*const fn () callconv(.c) void, .{
.name = "__init_array_start", .name = "__init_array_start",
.linkage = .weak, .linkage = .weak,
}); });
const opt_init_array_end = @extern([*]*const fn () callconv(.C) void, .{ const opt_init_array_end = @extern([*]*const fn () callconv(.c) void, .{
.name = "__init_array_end", .name = "__init_array_end",
.linkage = .weak, .linkage = .weak,
}); });
@ -577,7 +577,7 @@ inline fn callMainWithArgs(argc: usize, argv: [*][*:0]u8, envp: [][*:0]u8) u8 {
return callMain(); return callMain();
} }
fn main(c_argc: c_int, c_argv: [*][*:0]c_char, c_envp: [*:null]?[*:0]c_char) callconv(.C) c_int { fn main(c_argc: c_int, c_argv: [*][*:0]c_char, c_envp: [*:null]?[*:0]c_char) callconv(.c) c_int {
var env_count: usize = 0; var env_count: usize = 0;
while (c_envp[env_count] != null) : (env_count += 1) {} while (c_envp[env_count] != null) : (env_count += 1) {}
const envp = @as([*][*:0]u8, @ptrCast(c_envp))[0..env_count]; const envp = @as([*][*:0]u8, @ptrCast(c_envp))[0..env_count];
@ -592,7 +592,7 @@ fn main(c_argc: c_int, c_argv: [*][*:0]c_char, c_envp: [*:null]?[*:0]c_char) cal
return callMainWithArgs(@as(usize, @intCast(c_argc)), @as([*][*:0]u8, @ptrCast(c_argv)), envp); return callMainWithArgs(@as(usize, @intCast(c_argc)), @as([*][*:0]u8, @ptrCast(c_argv)), envp);
} }
fn mainWithoutEnv(c_argc: c_int, c_argv: [*][*:0]c_char) callconv(.C) c_int { fn mainWithoutEnv(c_argc: c_int, c_argv: [*][*:0]c_char) callconv(.c) c_int {
std.os.argv = @as([*][*:0]u8, @ptrCast(c_argv))[0..@as(usize, @intCast(c_argc))]; std.os.argv = @as([*][*:0]u8, @ptrCast(c_argv))[0..@as(usize, @intCast(c_argc))];
return callMain(); return callMain();
} }
@ -702,4 +702,4 @@ fn maybeIgnoreSigpipe() void {
} }
} }
fn noopSigHandler(_: i32) callconv(.C) void {} fn noopSigHandler(_: i32) callconv(.c) void {}

View File

@ -7574,13 +7574,13 @@ fn analyzeCall(
if (try sema.resolveValue(func)) |func_val| if (try sema.resolveValue(func)) |func_val|
if (func_val.isUndef(zcu)) if (func_val.isUndef(zcu))
return sema.failWithUseOfUndef(block, call_src); return sema.failWithUseOfUndef(block, call_src);
if (cc == .naked) { if (!callConvIsCallable(cc)) {
const maybe_func_inst = try sema.funcDeclSrcInst(func); const maybe_func_inst = try sema.funcDeclSrcInst(func);
const msg = msg: { const msg = msg: {
const msg = try sema.errMsg( const msg = try sema.errMsg(
func_src, func_src,
"unable to call function with naked calling convention", "unable to call function with calling convention '{s}'",
.{}, .{@tagName(cc)},
); );
errdefer msg.destroy(sema.gpa); errdefer msg.destroy(sema.gpa);
@ -9764,6 +9764,33 @@ fn checkCallConvSupportsVarArgs(sema: *Sema, block: *Block, src: LazySrcLoc, cc:
} }
} }
fn callConvIsCallable(cc: std.builtin.CallingConvention.Tag) bool {
return switch (cc) {
.naked,
.arm_interrupt,
.avr_interrupt,
.avr_signal,
.csky_interrupt,
.m68k_interrupt,
.mips_interrupt,
.mips64_interrupt,
.riscv32_interrupt,
.riscv64_interrupt,
.x86_interrupt,
.x86_64_interrupt,
.amdgcn_kernel,
.nvptx_kernel,
.spirv_kernel,
.spirv_fragment,
.spirv_vertex,
=> false,
else => true,
};
}
fn checkMergeAllowed(sema: *Sema, block: *Block, src: LazySrcLoc, peer_ty: Type) !void { fn checkMergeAllowed(sema: *Sema, block: *Block, src: LazySrcLoc, peer_ty: Type) !void {
const pt = sema.pt; const pt = sema.pt;
const zcu = pt.zcu; const zcu = pt.zcu;

View File

@ -3607,18 +3607,37 @@ pub fn callconvSupported(zcu: *Zcu, cc: std.builtin.CallingConvention) union(enu
.x86_64_vectorcall, .x86_64_vectorcall,
.x86_64_regcall_v3_sysv, .x86_64_regcall_v3_sysv,
.x86_64_regcall_v4_win, .x86_64_regcall_v4_win,
.x86_64_interrupt,
.x86_fastcall, .x86_fastcall,
.x86_thiscall, .x86_thiscall,
.x86_vectorcall, .x86_vectorcall,
.x86_regcall_v3, .x86_regcall_v3,
.x86_regcall_v4_win, .x86_regcall_v4_win,
.x86_interrupt,
.aarch64_vfabi, .aarch64_vfabi,
.aarch64_vfabi_sve, .aarch64_vfabi_sve,
.arm_aapcs, .arm_aapcs,
.arm_aapcs_vfp, .csky_interrupt,
.riscv64_lp64_v, .riscv64_lp64_v,
.riscv32_ilp32_v, .riscv32_ilp32_v,
.m68k_rtd, .m68k_rtd,
.m68k_interrupt,
=> |opts| opts.incoming_stack_alignment == null,
.arm_aapcs_vfp,
=> |opts| opts.incoming_stack_alignment == null and target.os.tag != .watchos,
.arm_aapcs16_vfp,
=> |opts| opts.incoming_stack_alignment == null and target.os.tag == .watchos,
.arm_interrupt,
=> |opts| opts.incoming_stack_alignment == null,
.mips_interrupt,
.mips64_interrupt,
=> |opts| opts.incoming_stack_alignment == null,
.riscv32_interrupt,
.riscv64_interrupt,
=> |opts| opts.incoming_stack_alignment == null, => |opts| opts.incoming_stack_alignment == null,
.x86_sysv, .x86_sysv,
@ -3626,6 +3645,10 @@ pub fn callconvSupported(zcu: *Zcu, cc: std.builtin.CallingConvention) union(enu
.x86_stdcall, .x86_stdcall,
=> |opts| opts.incoming_stack_alignment == null and opts.register_params == 0, => |opts| opts.incoming_stack_alignment == null and opts.register_params == 0,
.avr_interrupt,
.avr_signal,
=> true,
.naked => true, .naked => true,
else => false, else => false,

View File

@ -7622,11 +7622,44 @@ fn toCallingConvention(cc: std.builtin.CallingConvention, zcu: *Zcu) ?[]const u8
.aarch64_vfabi => "aarch64_vector_pcs", .aarch64_vfabi => "aarch64_vector_pcs",
.aarch64_vfabi_sve => "aarch64_sve_pcs", .aarch64_vfabi_sve => "aarch64_sve_pcs",
.arm_aapcs => "pcs(\"aapcs\")", .arm_aapcs => "pcs(\"aapcs\")",
.arm_aapcs_vfp => "pcs(\"aapcs-vfp\")", .arm_aapcs_vfp, .arm_aapcs16_vfp => "pcs(\"aapcs-vfp\")",
.arm_interrupt => |opts| switch (opts.type) {
.generic => "interrupt",
.irq => "interrupt(\"IRQ\")",
.fiq => "interrupt(\"FIQ\")",
.swi => "interrupt(\"SWI\")",
.abort => "interrupt(\"ABORT\")",
.undef => "interrupt(\"UNDEF\")",
},
.avr_signal => "signal",
.mips_interrupt,
.mips64_interrupt,
=> |opts| switch (opts.mode) {
inline else => |m| "interrupt(\"" ++ @tagName(m) ++ "\")",
},
.riscv64_lp64_v, .riscv32_ilp32_v => "riscv_vector_cc", .riscv64_lp64_v, .riscv32_ilp32_v => "riscv_vector_cc",
.riscv32_interrupt,
.riscv64_interrupt,
=> |opts| switch (opts.mode) {
inline else => |m| "interrupt(\"" ++ @tagName(m) ++ "\")",
},
.m68k_rtd => "m68k_rtd", .m68k_rtd => "m68k_rtd",
.avr_interrupt,
.csky_interrupt,
.m68k_interrupt,
.x86_interrupt,
.x86_64_interrupt,
=> "interrupt",
else => unreachable, // `Zcu.callconvSupported` else => unreachable, // `Zcu.callconvSupported`
}; };
} }

View File

@ -11749,7 +11749,14 @@ fn toLlvmCallConvTag(cc_tag: std.builtin.CallingConvention.Tag, target: std.Targ
.aarch64_vfabi_sve => .aarch64_sve_vector_pcs, .aarch64_vfabi_sve => .aarch64_sve_vector_pcs,
.arm_apcs => .arm_apcscc, .arm_apcs => .arm_apcscc,
.arm_aapcs => .arm_aapcscc, .arm_aapcs => .arm_aapcscc,
.arm_aapcs_vfp => .arm_aapcs_vfpcc, .arm_aapcs_vfp => if (target.os.tag != .watchos)
.arm_aapcs_vfpcc
else
null,
.arm_aapcs16_vfp => if (target.os.tag == .watchos)
.arm_aapcs_vfpcc
else
null,
.riscv64_lp64_v => .riscv_vectorcallcc, .riscv64_lp64_v => .riscv_vectorcallcc,
.riscv32_ilp32_v => .riscv_vectorcallcc, .riscv32_ilp32_v => .riscv_vectorcallcc,
.avr_builtin => .avr_builtincc, .avr_builtin => .avr_builtincc,
@ -11779,7 +11786,6 @@ fn toLlvmCallConvTag(cc_tag: std.builtin.CallingConvention.Tag, target: std.Targ
.aarch64_aapcs, .aarch64_aapcs,
.aarch64_aapcs_darwin, .aarch64_aapcs_darwin,
.aarch64_aapcs_win, .aarch64_aapcs_win,
.arm_aapcs16_vfp,
.mips64_n64, .mips64_n64,
.mips64_n32, .mips64_n32,
.mips_o32, .mips_o32,
@ -11977,7 +11983,7 @@ fn firstParamSRet(fn_info: InternPool.Key.FuncType, zcu: *Zcu, target: std.Targe
.aarch64_aapcs_darwin, .aarch64_aapcs_darwin,
.aarch64_aapcs_win, .aarch64_aapcs_win,
=> aarch64_c_abi.classifyType(return_type, zcu) == .memory, => aarch64_c_abi.classifyType(return_type, zcu) == .memory,
.arm_aapcs, .arm_aapcs_vfp => switch (arm_c_abi.classifyType(return_type, zcu, .ret)) { .arm_aapcs, .arm_aapcs_vfp, .arm_aapcs16_vfp => switch (arm_c_abi.classifyType(return_type, zcu, .ret)) {
.memory, .i64_array => true, .memory, .i64_array => true,
.i32_array => |size| size != 1, .i32_array => |size| size != 1,
.byval => false, .byval => false,
@ -12027,7 +12033,7 @@ fn lowerFnRetTy(o: *Object, fn_info: InternPool.Key.FuncType) Allocator.Error!Bu
.integer => return o.builder.intType(@intCast(return_type.bitSize(zcu))), .integer => return o.builder.intType(@intCast(return_type.bitSize(zcu))),
.double_integer => return o.builder.arrayType(2, .i64), .double_integer => return o.builder.arrayType(2, .i64),
}, },
.arm_aapcs, .arm_aapcs_vfp => switch (arm_c_abi.classifyType(return_type, zcu, .ret)) { .arm_aapcs, .arm_aapcs_vfp, .arm_aapcs16_vfp => switch (arm_c_abi.classifyType(return_type, zcu, .ret)) {
.memory, .i64_array => return .void, .memory, .i64_array => return .void,
.i32_array => |len| return if (len == 1) .i32 else .void, .i32_array => |len| return if (len == 1) .i32 else .void,
.byval => return o.lowerType(return_type), .byval => return o.lowerType(return_type),
@ -12276,7 +12282,7 @@ const ParamTypeIterator = struct {
.double_integer => return Lowering{ .i64_array = 2 }, .double_integer => return Lowering{ .i64_array = 2 },
} }
}, },
.arm_aapcs, .arm_aapcs_vfp => { .arm_aapcs, .arm_aapcs_vfp, .arm_aapcs16_vfp => {
it.zig_index += 1; it.zig_index += 1;
it.llvm_index += 1; it.llvm_index += 1;
switch (arm_c_abi.classifyType(ty, zcu, .arg)) { switch (arm_c_abi.classifyType(ty, zcu, .arg)) {

View File

@ -229,7 +229,7 @@ const WindowsSegfaultMessage = union(enum) {
illegal_instruction: void, illegal_instruction: void,
}; };
fn handleSegfaultWindows(info: *windows.EXCEPTION_POINTERS) callconv(windows.WINAPI) c_long { fn handleSegfaultWindows(info: *windows.EXCEPTION_POINTERS) callconv(.winapi) c_long {
switch (info.ExceptionRecord.ExceptionCode) { switch (info.ExceptionRecord.ExceptionCode) {
windows.EXCEPTION_DATATYPE_MISALIGNMENT => handleSegfaultWindowsExtra(info, .{ .literal = "Unaligned Memory Access" }), windows.EXCEPTION_DATATYPE_MISALIGNMENT => handleSegfaultWindowsExtra(info, .{ .literal = "Unaligned Memory Access" }),
windows.EXCEPTION_ACCESS_VIOLATION => handleSegfaultWindowsExtra(info, .segfault), windows.EXCEPTION_ACCESS_VIOLATION => handleSegfaultWindowsExtra(info, .segfault),

View File

@ -3415,8 +3415,8 @@ fn updateType(
.x86_64_regcall_v3_sysv => .LLVM_X86RegCall, .x86_64_regcall_v3_sysv => .LLVM_X86RegCall,
.x86_64_regcall_v4_win => .LLVM_X86RegCall, .x86_64_regcall_v4_win => .LLVM_X86RegCall,
.x86_64_vectorcall => .LLVM_vectorcall, .x86_64_vectorcall => .LLVM_vectorcall,
.x86_sysv => .nocall, .x86_sysv => .normal,
.x86_win => .nocall, .x86_win => .normal,
.x86_stdcall => .BORLAND_stdcall, .x86_stdcall => .BORLAND_stdcall,
.x86_fastcall => .BORLAND_msfastcall, .x86_fastcall => .BORLAND_msfastcall,
.x86_thiscall => .BORLAND_thiscall, .x86_thiscall => .BORLAND_thiscall,
@ -3425,16 +3425,17 @@ fn updateType(
.x86_regcall_v4_win => .LLVM_X86RegCall, .x86_regcall_v4_win => .LLVM_X86RegCall,
.x86_vectorcall => .LLVM_vectorcall, .x86_vectorcall => .LLVM_vectorcall,
.aarch64_aapcs => .LLVM_AAPCS, .aarch64_aapcs => .normal,
.aarch64_aapcs_darwin => .LLVM_AAPCS, .aarch64_aapcs_darwin => .normal,
.aarch64_aapcs_win => .LLVM_AAPCS, .aarch64_aapcs_win => .normal,
.aarch64_vfabi => .LLVM_AAPCS, .aarch64_vfabi => .LLVM_AAPCS,
.aarch64_vfabi_sve => .LLVM_AAPCS, .aarch64_vfabi_sve => .LLVM_AAPCS,
.arm_apcs => .nocall, .arm_apcs => .normal,
.arm_aapcs => .LLVM_AAPCS, .arm_aapcs => .LLVM_AAPCS,
.arm_aapcs_vfp => .LLVM_AAPCS_VFP, .arm_aapcs_vfp,
.arm_aapcs16_vfp => .nocall, .arm_aapcs16_vfp,
=> .LLVM_AAPCS_VFP,
.riscv64_lp64_v, .riscv64_lp64_v,
.riscv32_ilp32_v, .riscv32_ilp32_v,
@ -3442,10 +3443,10 @@ fn updateType(
.m68k_rtd => .LLVM_M68kRTD, .m68k_rtd => .LLVM_M68kRTD,
.amdgcn_kernel, .amdgcn_kernel => .LLVM_OpenCLKernel,
.nvptx_kernel, .nvptx_kernel,
.spirv_kernel, .spirv_kernel,
=> .LLVM_OpenCLKernel, => .nocall,
.x86_64_interrupt, .x86_64_interrupt,
.x86_interrupt, .x86_interrupt,

View File

@ -1,11 +1,11 @@
export fn entry() void { export fn entry() void {
foo(); foo();
} }
fn foo() callconv(.Naked) void {} fn foo() callconv(.naked) void {}
// error // error
// backend=llvm // backend=llvm
// target=native // target=native
// //
// :2:5: error: unable to call function with naked calling convention // :2:5: error: unable to call function with calling convention 'naked'
// :4:1: note: function declared here // :4:1: note: function declared here

View File

@ -576,7 +576,7 @@ fn knownOption(name: []const u8) ?[]const u8 {
const cpu_targets = struct { const cpu_targets = struct {
pub const aarch64 = std.Target.aarch64; pub const aarch64 = std.Target.aarch64;
pub const amdgpu = std.Target.amdgpu; pub const amdgcn = std.Target.amdgcn;
pub const arc = std.Target.arc; pub const arc = std.Target.arc;
pub const arm = std.Target.arm; pub const arm = std.Target.arm;
pub const avr = std.Target.avr; pub const avr = std.Target.avr;

View File

@ -390,7 +390,7 @@ const llvm_targets = [_]LlvmTarget{
}, },
}, },
.{ .{
.zig_name = "amdgpu", .zig_name = "amdgcn",
.llvm_name = "AMDGPU", .llvm_name = "AMDGPU",
.td_name = "AMDGPU.td", .td_name = "AMDGPU.td",
.feature_overrides = &.{ .feature_overrides = &.{