Merge pull request #6829 from tadeokondrak/error-unsupported-callconv

stage1: Compile error instead of falling back to C for unsupported cc
This commit is contained in:
Veikka Tuominen 2020-11-19 19:03:08 +02:00 committed by GitHub
commit cf819b95fe
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
17 changed files with 380 additions and 244 deletions

View File

@ -4191,7 +4191,7 @@ test "noreturn" {
<p>Another use case for {#syntax#}noreturn{#endsyntax#} is the {#syntax#}exit{#endsyntax#} function:</p>
{#code_begin|test#}
{#target_windows#}
pub extern "kernel32" fn ExitProcess(exit_code: c_uint) callconv(.Stdcall) noreturn;
pub extern "kernel32" fn ExitProcess(exit_code: c_uint) callconv(if (@import("builtin").arch == .i386) .Stdcall else .C) noreturn;
test "foo" {
const value = bar() catch ExitProcess(1);
@ -4226,7 +4226,7 @@ export fn sub(a: i8, b: i8) i8 { return a - b; }
// at link time, when linking statically, or at runtime, when linking
// dynamically.
// The callconv specifier changes the calling convention of the function.
extern "kernel32" fn ExitProcess(exit_code: u32) callconv(.Stdcall) noreturn;
extern "kernel32" fn ExitProcess(exit_code: u32) callconv(if (@import("builtin").arch == .i386) .Stdcall else .C) noreturn;
extern "c" fn atan2(a: f64, b: f64) f64;
// The @setCold builtin tells the optimizer that a function is rarely called.

View File

@ -1801,7 +1801,7 @@ fn handleSegfaultLinux(sig: i32, info: *const os.siginfo_t, ctx_ptr: ?*const c_v
os.abort();
}
fn handleSegfaultWindows(info: *windows.EXCEPTION_POINTERS) callconv(.Stdcall) c_long {
fn handleSegfaultWindows(info: *windows.EXCEPTION_POINTERS) callconv(windows.WINAPI) c_long {
switch (info.ExceptionRecord.ExceptionCode) {
windows.EXCEPTION_DATATYPE_MISALIGNMENT => handleSegfaultWindowsExtra(info, 0, "Unaligned Memory Access"),
windows.EXCEPTION_ACCESS_VIOLATION => handleSegfaultWindowsExtra(info, 1, null),

View File

@ -11,7 +11,7 @@ pub extern "advapi32" fn RegOpenKeyExW(
ulOptions: DWORD,
samDesired: REGSAM,
phkResult: *HKEY,
) callconv(.Stdcall) LSTATUS;
) callconv(WINAPI) LSTATUS;
pub extern "advapi32" fn RegQueryValueExW(
hKey: HKEY,
@ -20,9 +20,9 @@ pub extern "advapi32" fn RegQueryValueExW(
lpType: LPDWORD,
lpData: LPBYTE,
lpcbData: LPDWORD,
) callconv(.Stdcall) LSTATUS;
) callconv(WINAPI) LSTATUS;
// RtlGenRandom is known as SystemFunction036 under advapi32
// http://msdn.microsoft.com/en-us/library/windows/desktop/aa387694.aspx */
pub extern "advapi32" fn SystemFunction036(output: [*]u8, length: ULONG) callconv(.Stdcall) BOOL;
pub extern "advapi32" fn SystemFunction036(output: [*]u8, length: ULONG) callconv(WINAPI) BOOL;
pub const RtlGenRandom = SystemFunction036;

View File

@ -24,6 +24,11 @@ pub const STD_OUTPUT_HANDLE = maxInt(DWORD) - 11 + 1;
/// The standard error device. Initially, this is the active console screen buffer, CONOUT$.
pub const STD_ERROR_HANDLE = maxInt(DWORD) - 12 + 1;
pub const WINAPI: builtin.CallingConvention = if (builtin.arch == .i386)
.Stdcall
else
.C;
pub const BOOL = c_int;
pub const BOOLEAN = BYTE;
pub const BYTE = u8;
@ -1150,7 +1155,7 @@ pub const EXCEPTION_POINTERS = extern struct {
ContextRecord: PCONTEXT,
};
pub const VECTORED_EXCEPTION_HANDLER = fn (ExceptionInfo: *EXCEPTION_POINTERS) callconv(.Stdcall) c_long;
pub const VECTORED_EXCEPTION_HANDLER = fn (ExceptionInfo: *EXCEPTION_POINTERS) callconv(WINAPI) c_long;
pub const OBJECT_ATTRIBUTES = extern struct {
Length: ULONG,

View File

@ -38,13 +38,13 @@ pub extern "gdi32" fn SetPixelFormat(
hdc: ?HDC,
format: i32,
ppfd: ?*const PIXELFORMATDESCRIPTOR,
) callconv(.Stdcall) bool;
) callconv(WINAPI) bool;
pub extern "gdi32" fn ChoosePixelFormat(
hdc: ?HDC,
ppfd: ?*const PIXELFORMATDESCRIPTOR,
) callconv(.Stdcall) i32;
) callconv(WINAPI) i32;
pub extern "gdi32" fn SwapBuffers(hdc: ?HDC) callconv(.Stdcall) bool;
pub extern "gdi32" fn wglCreateContext(hdc: ?HDC) callconv(.Stdcall) ?HGLRC;
pub extern "gdi32" fn wglMakeCurrent(hdc: ?HDC, hglrc: ?HGLRC) callconv(.Stdcall) bool;
pub extern "gdi32" fn SwapBuffers(hdc: ?HDC) callconv(WINAPI) bool;
pub extern "gdi32" fn wglCreateContext(hdc: ?HDC) callconv(WINAPI) ?HGLRC;
pub extern "gdi32" fn wglMakeCurrent(hdc: ?HDC, hglrc: ?HGLRC) callconv(WINAPI) bool;

View File

@ -5,22 +5,22 @@
// and substantial portions of the software.
usingnamespace @import("bits.zig");
pub extern "kernel32" fn AddVectoredExceptionHandler(First: c_ulong, Handler: ?VECTORED_EXCEPTION_HANDLER) callconv(.Stdcall) ?*c_void;
pub extern "kernel32" fn RemoveVectoredExceptionHandler(Handle: HANDLE) callconv(.Stdcall) c_ulong;
pub extern "kernel32" fn AddVectoredExceptionHandler(First: c_ulong, Handler: ?VECTORED_EXCEPTION_HANDLER) callconv(WINAPI) ?*c_void;
pub extern "kernel32" fn RemoveVectoredExceptionHandler(Handle: HANDLE) callconv(WINAPI) c_ulong;
pub extern "kernel32" fn CancelIoEx(hFile: HANDLE, lpOverlapped: LPOVERLAPPED) callconv(.Stdcall) BOOL;
pub extern "kernel32" fn CancelIoEx(hFile: HANDLE, lpOverlapped: LPOVERLAPPED) callconv(WINAPI) BOOL;
pub extern "kernel32" fn CloseHandle(hObject: HANDLE) callconv(.Stdcall) BOOL;
pub extern "kernel32" fn CloseHandle(hObject: HANDLE) callconv(WINAPI) BOOL;
pub extern "kernel32" fn CreateDirectoryW(lpPathName: [*:0]const u16, lpSecurityAttributes: ?*SECURITY_ATTRIBUTES) callconv(.Stdcall) BOOL;
pub extern "kernel32" fn SetEndOfFile(hFile: HANDLE) callconv(.Stdcall) BOOL;
pub extern "kernel32" fn CreateDirectoryW(lpPathName: [*:0]const u16, lpSecurityAttributes: ?*SECURITY_ATTRIBUTES) callconv(WINAPI) BOOL;
pub extern "kernel32" fn SetEndOfFile(hFile: HANDLE) callconv(WINAPI) BOOL;
pub extern "kernel32" fn CreateEventExW(
lpEventAttributes: ?*SECURITY_ATTRIBUTES,
lpName: [*:0]const u16,
dwFlags: DWORD,
dwDesiredAccess: DWORD,
) callconv(.Stdcall) ?HANDLE;
) callconv(WINAPI) ?HANDLE;
pub extern "kernel32" fn CreateFileW(
lpFileName: [*:0]const u16,
@ -30,14 +30,14 @@ pub extern "kernel32" fn CreateFileW(
dwCreationDisposition: DWORD,
dwFlagsAndAttributes: DWORD,
hTemplateFile: ?HANDLE,
) callconv(.Stdcall) HANDLE;
) callconv(WINAPI) HANDLE;
pub extern "kernel32" fn CreatePipe(
hReadPipe: *HANDLE,
hWritePipe: *HANDLE,
lpPipeAttributes: *const SECURITY_ATTRIBUTES,
nSize: DWORD,
) callconv(.Stdcall) BOOL;
) callconv(WINAPI) BOOL;
pub extern "kernel32" fn CreateProcessW(
lpApplicationName: ?LPWSTR,
@ -50,13 +50,13 @@ pub extern "kernel32" fn CreateProcessW(
lpCurrentDirectory: ?LPWSTR,
lpStartupInfo: *STARTUPINFOW,
lpProcessInformation: *PROCESS_INFORMATION,
) callconv(.Stdcall) BOOL;
) callconv(WINAPI) BOOL;
pub extern "kernel32" fn CreateSymbolicLinkW(lpSymlinkFileName: [*:0]const u16, lpTargetFileName: [*:0]const u16, dwFlags: DWORD) callconv(.Stdcall) BOOLEAN;
pub extern "kernel32" fn CreateSymbolicLinkW(lpSymlinkFileName: [*:0]const u16, lpTargetFileName: [*:0]const u16, dwFlags: DWORD) callconv(WINAPI) BOOLEAN;
pub extern "kernel32" fn CreateIoCompletionPort(FileHandle: HANDLE, ExistingCompletionPort: ?HANDLE, CompletionKey: ULONG_PTR, NumberOfConcurrentThreads: DWORD) callconv(.Stdcall) ?HANDLE;
pub extern "kernel32" fn CreateIoCompletionPort(FileHandle: HANDLE, ExistingCompletionPort: ?HANDLE, CompletionKey: ULONG_PTR, NumberOfConcurrentThreads: DWORD) callconv(WINAPI) ?HANDLE;
pub extern "kernel32" fn CreateThread(lpThreadAttributes: ?LPSECURITY_ATTRIBUTES, dwStackSize: SIZE_T, lpStartAddress: LPTHREAD_START_ROUTINE, lpParameter: ?LPVOID, dwCreationFlags: DWORD, lpThreadId: ?LPDWORD) callconv(.Stdcall) ?HANDLE;
pub extern "kernel32" fn CreateThread(lpThreadAttributes: ?LPSECURITY_ATTRIBUTES, dwStackSize: SIZE_T, lpStartAddress: LPTHREAD_START_ROUTINE, lpParameter: ?LPVOID, dwCreationFlags: DWORD, lpThreadId: ?LPDWORD) callconv(WINAPI) ?HANDLE;
pub extern "kernel32" fn DeviceIoControl(
h: HANDLE,
@ -67,111 +67,111 @@ pub extern "kernel32" fn DeviceIoControl(
nOutBufferSize: DWORD,
lpBytesReturned: ?*DWORD,
lpOverlapped: ?*OVERLAPPED,
) callconv(.Stdcall) BOOL;
) callconv(WINAPI) BOOL;
pub extern "kernel32" fn DeleteFileW(lpFileName: [*:0]const u16) callconv(.Stdcall) BOOL;
pub extern "kernel32" fn DeleteFileW(lpFileName: [*:0]const u16) callconv(WINAPI) BOOL;
pub extern "kernel32" fn DuplicateHandle(hSourceProcessHandle: HANDLE, hSourceHandle: HANDLE, hTargetProcessHandle: HANDLE, lpTargetHandle: *HANDLE, dwDesiredAccess: DWORD, bInheritHandle: BOOL, dwOptions: DWORD) callconv(.Stdcall) BOOL;
pub extern "kernel32" fn DuplicateHandle(hSourceProcessHandle: HANDLE, hSourceHandle: HANDLE, hTargetProcessHandle: HANDLE, lpTargetHandle: *HANDLE, dwDesiredAccess: DWORD, bInheritHandle: BOOL, dwOptions: DWORD) callconv(WINAPI) BOOL;
pub extern "kernel32" fn ExitProcess(exit_code: UINT) callconv(.Stdcall) noreturn;
pub extern "kernel32" fn ExitProcess(exit_code: UINT) callconv(WINAPI) noreturn;
pub extern "kernel32" fn FindFirstFileW(lpFileName: [*:0]const u16, lpFindFileData: *WIN32_FIND_DATAW) callconv(.Stdcall) HANDLE;
pub extern "kernel32" fn FindClose(hFindFile: HANDLE) callconv(.Stdcall) BOOL;
pub extern "kernel32" fn FindNextFileW(hFindFile: HANDLE, lpFindFileData: *WIN32_FIND_DATAW) callconv(.Stdcall) BOOL;
pub extern "kernel32" fn FindFirstFileW(lpFileName: [*:0]const u16, lpFindFileData: *WIN32_FIND_DATAW) callconv(WINAPI) HANDLE;
pub extern "kernel32" fn FindClose(hFindFile: HANDLE) callconv(WINAPI) BOOL;
pub extern "kernel32" fn FindNextFileW(hFindFile: HANDLE, lpFindFileData: *WIN32_FIND_DATAW) callconv(WINAPI) BOOL;
pub extern "kernel32" fn FormatMessageW(dwFlags: DWORD, lpSource: ?LPVOID, dwMessageId: Win32Error, dwLanguageId: DWORD, lpBuffer: [*]u16, nSize: DWORD, Arguments: ?*va_list) callconv(.Stdcall) DWORD;
pub extern "kernel32" fn FormatMessageW(dwFlags: DWORD, lpSource: ?LPVOID, dwMessageId: Win32Error, dwLanguageId: DWORD, lpBuffer: [*]u16, nSize: DWORD, Arguments: ?*va_list) callconv(WINAPI) DWORD;
pub extern "kernel32" fn FreeEnvironmentStringsW(penv: [*:0]u16) callconv(.Stdcall) BOOL;
pub extern "kernel32" fn FreeEnvironmentStringsW(penv: [*:0]u16) callconv(WINAPI) BOOL;
pub extern "kernel32" fn GetCommandLineA() callconv(.Stdcall) LPSTR;
pub extern "kernel32" fn GetCommandLineW() callconv(.Stdcall) LPWSTR;
pub extern "kernel32" fn GetCommandLineA() callconv(WINAPI) LPSTR;
pub extern "kernel32" fn GetCommandLineW() callconv(WINAPI) LPWSTR;
pub extern "kernel32" fn GetConsoleMode(in_hConsoleHandle: HANDLE, out_lpMode: *DWORD) callconv(.Stdcall) BOOL;
pub extern "kernel32" fn GetConsoleMode(in_hConsoleHandle: HANDLE, out_lpMode: *DWORD) callconv(WINAPI) BOOL;
pub extern "kernel32" fn GetConsoleScreenBufferInfo(hConsoleOutput: HANDLE, lpConsoleScreenBufferInfo: *CONSOLE_SCREEN_BUFFER_INFO) callconv(.Stdcall) BOOL;
pub extern "kernel32" fn FillConsoleOutputCharacterA(hConsoleOutput: HANDLE, cCharacter: TCHAR, nLength: DWORD, dwWriteCoord: COORD, lpNumberOfCharsWritten: LPDWORD) callconv(.Stdcall) BOOL;
pub extern "kernel32" fn FillConsoleOutputAttribute(hConsoleOutput: HANDLE, wAttribute: WORD, nLength: DWORD, dwWriteCoord: COORD, lpNumberOfAttrsWritten: LPDWORD) callconv(.Stdcall) BOOL;
pub extern "kernel32" fn SetConsoleCursorPosition(hConsoleOutput: HANDLE, dwCursorPosition: COORD) callconv(.Stdcall) BOOL;
pub extern "kernel32" fn GetConsoleScreenBufferInfo(hConsoleOutput: HANDLE, lpConsoleScreenBufferInfo: *CONSOLE_SCREEN_BUFFER_INFO) callconv(WINAPI) BOOL;
pub extern "kernel32" fn FillConsoleOutputCharacterA(hConsoleOutput: HANDLE, cCharacter: TCHAR, nLength: DWORD, dwWriteCoord: COORD, lpNumberOfCharsWritten: LPDWORD) callconv(WINAPI) BOOL;
pub extern "kernel32" fn FillConsoleOutputAttribute(hConsoleOutput: HANDLE, wAttribute: WORD, nLength: DWORD, dwWriteCoord: COORD, lpNumberOfAttrsWritten: LPDWORD) callconv(WINAPI) BOOL;
pub extern "kernel32" fn SetConsoleCursorPosition(hConsoleOutput: HANDLE, dwCursorPosition: COORD) callconv(WINAPI) BOOL;
pub extern "kernel32" fn GetCurrentDirectoryW(nBufferLength: DWORD, lpBuffer: ?[*]WCHAR) callconv(.Stdcall) DWORD;
pub extern "kernel32" fn GetCurrentDirectoryW(nBufferLength: DWORD, lpBuffer: ?[*]WCHAR) callconv(WINAPI) DWORD;
pub extern "kernel32" fn GetCurrentThread() callconv(.Stdcall) HANDLE;
pub extern "kernel32" fn GetCurrentThreadId() callconv(.Stdcall) DWORD;
pub extern "kernel32" fn GetCurrentThread() callconv(WINAPI) HANDLE;
pub extern "kernel32" fn GetCurrentThreadId() callconv(WINAPI) DWORD;
pub extern "kernel32" fn GetCurrentProcess() callconv(.Stdcall) HANDLE;
pub extern "kernel32" fn GetCurrentProcess() callconv(WINAPI) HANDLE;
pub extern "kernel32" fn GetEnvironmentStringsW() callconv(.Stdcall) ?[*:0]u16;
pub extern "kernel32" fn GetEnvironmentStringsW() callconv(WINAPI) ?[*:0]u16;
pub extern "kernel32" fn GetEnvironmentVariableW(lpName: LPWSTR, lpBuffer: [*]u16, nSize: DWORD) callconv(.Stdcall) DWORD;
pub extern "kernel32" fn GetEnvironmentVariableW(lpName: LPWSTR, lpBuffer: [*]u16, nSize: DWORD) callconv(WINAPI) DWORD;
pub extern "kernel32" fn GetExitCodeProcess(hProcess: HANDLE, lpExitCode: *DWORD) callconv(.Stdcall) BOOL;
pub extern "kernel32" fn GetExitCodeProcess(hProcess: HANDLE, lpExitCode: *DWORD) callconv(WINAPI) BOOL;
pub extern "kernel32" fn GetFileSizeEx(hFile: HANDLE, lpFileSize: *LARGE_INTEGER) callconv(.Stdcall) BOOL;
pub extern "kernel32" fn GetFileSizeEx(hFile: HANDLE, lpFileSize: *LARGE_INTEGER) callconv(WINAPI) BOOL;
pub extern "kernel32" fn GetFileAttributesW(lpFileName: [*]const WCHAR) callconv(.Stdcall) DWORD;
pub extern "kernel32" fn GetFileAttributesW(lpFileName: [*]const WCHAR) callconv(WINAPI) DWORD;
pub extern "kernel32" fn GetModuleFileNameW(hModule: ?HMODULE, lpFilename: [*]u16, nSize: DWORD) callconv(.Stdcall) DWORD;
pub extern "kernel32" fn GetModuleFileNameW(hModule: ?HMODULE, lpFilename: [*]u16, nSize: DWORD) callconv(WINAPI) DWORD;
pub extern "kernel32" fn GetModuleHandleW(lpModuleName: ?[*:0]const WCHAR) callconv(.Stdcall) ?HMODULE;
pub extern "kernel32" fn GetModuleHandleW(lpModuleName: ?[*:0]const WCHAR) callconv(WINAPI) ?HMODULE;
pub extern "kernel32" fn GetLastError() callconv(.Stdcall) Win32Error;
pub extern "kernel32" fn GetLastError() callconv(WINAPI) Win32Error;
pub extern "kernel32" fn GetFileInformationByHandle(
hFile: HANDLE,
lpFileInformation: *BY_HANDLE_FILE_INFORMATION,
) callconv(.Stdcall) BOOL;
) callconv(WINAPI) BOOL;
pub extern "kernel32" fn GetFileInformationByHandleEx(
in_hFile: HANDLE,
in_FileInformationClass: FILE_INFO_BY_HANDLE_CLASS,
out_lpFileInformation: *c_void,
in_dwBufferSize: DWORD,
) callconv(.Stdcall) BOOL;
) callconv(WINAPI) BOOL;
pub extern "kernel32" fn GetFinalPathNameByHandleW(
hFile: HANDLE,
lpszFilePath: [*]u16,
cchFilePath: DWORD,
dwFlags: DWORD,
) callconv(.Stdcall) DWORD;
) callconv(WINAPI) DWORD;
pub extern "kernel32" fn GetOverlappedResult(hFile: HANDLE, lpOverlapped: *OVERLAPPED, lpNumberOfBytesTransferred: *DWORD, bWait: BOOL) callconv(.Stdcall) BOOL;
pub extern "kernel32" fn GetOverlappedResult(hFile: HANDLE, lpOverlapped: *OVERLAPPED, lpNumberOfBytesTransferred: *DWORD, bWait: BOOL) callconv(WINAPI) BOOL;
pub extern "kernel32" fn GetProcessHeap() callconv(.Stdcall) ?HANDLE;
pub extern "kernel32" fn GetQueuedCompletionStatus(CompletionPort: HANDLE, lpNumberOfBytesTransferred: LPDWORD, lpCompletionKey: *ULONG_PTR, lpOverlapped: *?*OVERLAPPED, dwMilliseconds: DWORD) callconv(.Stdcall) BOOL;
pub extern "kernel32" fn GetProcessHeap() callconv(WINAPI) ?HANDLE;
pub extern "kernel32" fn GetQueuedCompletionStatus(CompletionPort: HANDLE, lpNumberOfBytesTransferred: LPDWORD, lpCompletionKey: *ULONG_PTR, lpOverlapped: *?*OVERLAPPED, dwMilliseconds: DWORD) callconv(WINAPI) BOOL;
pub extern "kernel32" fn GetSystemInfo(lpSystemInfo: *SYSTEM_INFO) callconv(.Stdcall) void;
pub extern "kernel32" fn GetSystemTimeAsFileTime(*FILETIME) callconv(.Stdcall) void;
pub extern "kernel32" fn GetSystemInfo(lpSystemInfo: *SYSTEM_INFO) callconv(WINAPI) void;
pub extern "kernel32" fn GetSystemTimeAsFileTime(*FILETIME) callconv(WINAPI) void;
pub extern "kernel32" fn HeapCreate(flOptions: DWORD, dwInitialSize: SIZE_T, dwMaximumSize: SIZE_T) callconv(.Stdcall) ?HANDLE;
pub extern "kernel32" fn HeapDestroy(hHeap: HANDLE) callconv(.Stdcall) BOOL;
pub extern "kernel32" fn HeapReAlloc(hHeap: HANDLE, dwFlags: DWORD, lpMem: *c_void, dwBytes: SIZE_T) callconv(.Stdcall) ?*c_void;
pub extern "kernel32" fn HeapSize(hHeap: HANDLE, dwFlags: DWORD, lpMem: *const c_void) callconv(.Stdcall) SIZE_T;
pub extern "kernel32" fn HeapCompact(hHeap: HANDLE, dwFlags: DWORD) callconv(.Stdcall) SIZE_T;
pub extern "kernel32" fn HeapSummary(hHeap: HANDLE, dwFlags: DWORD, lpSummary: LPHEAP_SUMMARY) callconv(.Stdcall) BOOL;
pub extern "kernel32" fn HeapCreate(flOptions: DWORD, dwInitialSize: SIZE_T, dwMaximumSize: SIZE_T) callconv(WINAPI) ?HANDLE;
pub extern "kernel32" fn HeapDestroy(hHeap: HANDLE) callconv(WINAPI) BOOL;
pub extern "kernel32" fn HeapReAlloc(hHeap: HANDLE, dwFlags: DWORD, lpMem: *c_void, dwBytes: SIZE_T) callconv(WINAPI) ?*c_void;
pub extern "kernel32" fn HeapSize(hHeap: HANDLE, dwFlags: DWORD, lpMem: *const c_void) callconv(WINAPI) SIZE_T;
pub extern "kernel32" fn HeapCompact(hHeap: HANDLE, dwFlags: DWORD) callconv(WINAPI) SIZE_T;
pub extern "kernel32" fn HeapSummary(hHeap: HANDLE, dwFlags: DWORD, lpSummary: LPHEAP_SUMMARY) callconv(WINAPI) BOOL;
pub extern "kernel32" fn GetStdHandle(in_nStdHandle: DWORD) callconv(.Stdcall) ?HANDLE;
pub extern "kernel32" fn GetStdHandle(in_nStdHandle: DWORD) callconv(WINAPI) ?HANDLE;
pub extern "kernel32" fn HeapAlloc(hHeap: HANDLE, dwFlags: DWORD, dwBytes: SIZE_T) callconv(.Stdcall) ?*c_void;
pub extern "kernel32" fn HeapAlloc(hHeap: HANDLE, dwFlags: DWORD, dwBytes: SIZE_T) callconv(WINAPI) ?*c_void;
pub extern "kernel32" fn HeapFree(hHeap: HANDLE, dwFlags: DWORD, lpMem: *c_void) callconv(.Stdcall) BOOL;
pub extern "kernel32" fn HeapFree(hHeap: HANDLE, dwFlags: DWORD, lpMem: *c_void) callconv(WINAPI) BOOL;
pub extern "kernel32" fn HeapValidate(hHeap: HANDLE, dwFlags: DWORD, lpMem: ?*const c_void) callconv(.Stdcall) BOOL;
pub extern "kernel32" fn HeapValidate(hHeap: HANDLE, dwFlags: DWORD, lpMem: ?*const c_void) callconv(WINAPI) BOOL;
pub extern "kernel32" fn VirtualAlloc(lpAddress: ?LPVOID, dwSize: SIZE_T, flAllocationType: DWORD, flProtect: DWORD) callconv(.Stdcall) ?LPVOID;
pub extern "kernel32" fn VirtualFree(lpAddress: ?LPVOID, dwSize: SIZE_T, dwFreeType: DWORD) callconv(.Stdcall) BOOL;
pub extern "kernel32" fn VirtualAlloc(lpAddress: ?LPVOID, dwSize: SIZE_T, flAllocationType: DWORD, flProtect: DWORD) callconv(WINAPI) ?LPVOID;
pub extern "kernel32" fn VirtualFree(lpAddress: ?LPVOID, dwSize: SIZE_T, dwFreeType: DWORD) callconv(WINAPI) BOOL;
pub extern "kernel32" fn MoveFileExW(
lpExistingFileName: [*:0]const u16,
lpNewFileName: [*:0]const u16,
dwFlags: DWORD,
) callconv(.Stdcall) BOOL;
) callconv(WINAPI) BOOL;
pub extern "kernel32" fn PostQueuedCompletionStatus(CompletionPort: HANDLE, dwNumberOfBytesTransferred: DWORD, dwCompletionKey: ULONG_PTR, lpOverlapped: ?*OVERLAPPED) callconv(.Stdcall) BOOL;
pub extern "kernel32" fn PostQueuedCompletionStatus(CompletionPort: HANDLE, dwNumberOfBytesTransferred: DWORD, dwCompletionKey: ULONG_PTR, lpOverlapped: ?*OVERLAPPED) callconv(WINAPI) BOOL;
pub extern "kernel32" fn QueryPerformanceCounter(lpPerformanceCount: *LARGE_INTEGER) callconv(.Stdcall) BOOL;
pub extern "kernel32" fn QueryPerformanceCounter(lpPerformanceCount: *LARGE_INTEGER) callconv(WINAPI) BOOL;
pub extern "kernel32" fn QueryPerformanceFrequency(lpFrequency: *LARGE_INTEGER) callconv(.Stdcall) BOOL;
pub extern "kernel32" fn QueryPerformanceFrequency(lpFrequency: *LARGE_INTEGER) callconv(WINAPI) BOOL;
pub extern "kernel32" fn ReadDirectoryChangesW(
hDirectory: HANDLE,
@ -182,7 +182,7 @@ pub extern "kernel32" fn ReadDirectoryChangesW(
lpBytesReturned: ?*DWORD,
lpOverlapped: ?*OVERLAPPED,
lpCompletionRoutine: LPOVERLAPPED_COMPLETION_ROUTINE,
) callconv(.Stdcall) BOOL;
) callconv(WINAPI) BOOL;
pub extern "kernel32" fn ReadFile(
in_hFile: HANDLE,
@ -190,43 +190,43 @@ pub extern "kernel32" fn ReadFile(
in_nNumberOfBytesToRead: DWORD,
out_lpNumberOfBytesRead: ?*DWORD,
in_out_lpOverlapped: ?*OVERLAPPED,
) callconv(.Stdcall) BOOL;
) callconv(WINAPI) BOOL;
pub extern "kernel32" fn RemoveDirectoryW(lpPathName: [*:0]const u16) callconv(.Stdcall) BOOL;
pub extern "kernel32" fn RemoveDirectoryW(lpPathName: [*:0]const u16) callconv(WINAPI) BOOL;
pub extern "kernel32" fn SetConsoleTextAttribute(hConsoleOutput: HANDLE, wAttributes: WORD) callconv(.Stdcall) BOOL;
pub extern "kernel32" fn SetConsoleTextAttribute(hConsoleOutput: HANDLE, wAttributes: WORD) callconv(WINAPI) BOOL;
pub extern "kernel32" fn SetFilePointerEx(
in_fFile: HANDLE,
in_liDistanceToMove: LARGE_INTEGER,
out_opt_ldNewFilePointer: ?*LARGE_INTEGER,
in_dwMoveMethod: DWORD,
) callconv(.Stdcall) BOOL;
) callconv(WINAPI) BOOL;
pub extern "kernel32" fn SetFileTime(
hFile: HANDLE,
lpCreationTime: ?*const FILETIME,
lpLastAccessTime: ?*const FILETIME,
lpLastWriteTime: ?*const FILETIME,
) callconv(.Stdcall) BOOL;
) callconv(WINAPI) BOOL;
pub extern "kernel32" fn SetHandleInformation(hObject: HANDLE, dwMask: DWORD, dwFlags: DWORD) callconv(.Stdcall) BOOL;
pub extern "kernel32" fn SetHandleInformation(hObject: HANDLE, dwMask: DWORD, dwFlags: DWORD) callconv(WINAPI) BOOL;
pub extern "kernel32" fn Sleep(dwMilliseconds: DWORD) callconv(.Stdcall) void;
pub extern "kernel32" fn Sleep(dwMilliseconds: DWORD) callconv(WINAPI) void;
pub extern "kernel32" fn SwitchToThread() callconv(.Stdcall) BOOL;
pub extern "kernel32" fn SwitchToThread() callconv(WINAPI) BOOL;
pub extern "kernel32" fn TerminateProcess(hProcess: HANDLE, uExitCode: UINT) callconv(.Stdcall) BOOL;
pub extern "kernel32" fn TerminateProcess(hProcess: HANDLE, uExitCode: UINT) callconv(WINAPI) BOOL;
pub extern "kernel32" fn TlsAlloc() callconv(.Stdcall) DWORD;
pub extern "kernel32" fn TlsAlloc() callconv(WINAPI) DWORD;
pub extern "kernel32" fn TlsFree(dwTlsIndex: DWORD) callconv(.Stdcall) BOOL;
pub extern "kernel32" fn TlsFree(dwTlsIndex: DWORD) callconv(WINAPI) BOOL;
pub extern "kernel32" fn WaitForSingleObject(hHandle: HANDLE, dwMilliseconds: DWORD) callconv(.Stdcall) DWORD;
pub extern "kernel32" fn WaitForSingleObject(hHandle: HANDLE, dwMilliseconds: DWORD) callconv(WINAPI) DWORD;
pub extern "kernel32" fn WaitForSingleObjectEx(hHandle: HANDLE, dwMilliseconds: DWORD, bAlertable: BOOL) callconv(.Stdcall) DWORD;
pub extern "kernel32" fn WaitForSingleObjectEx(hHandle: HANDLE, dwMilliseconds: DWORD, bAlertable: BOOL) callconv(WINAPI) DWORD;
pub extern "kernel32" fn WaitForMultipleObjects(nCount: DWORD, lpHandle: [*]const HANDLE, bWaitAll: BOOL, dwMilliseconds: DWORD) callconv(.Stdcall) DWORD;
pub extern "kernel32" fn WaitForMultipleObjects(nCount: DWORD, lpHandle: [*]const HANDLE, bWaitAll: BOOL, dwMilliseconds: DWORD) callconv(WINAPI) DWORD;
pub extern "kernel32" fn WaitForMultipleObjectsEx(
nCount: DWORD,
@ -234,7 +234,7 @@ pub extern "kernel32" fn WaitForMultipleObjectsEx(
bWaitAll: BOOL,
dwMilliseconds: DWORD,
bAlertable: BOOL,
) callconv(.Stdcall) DWORD;
) callconv(WINAPI) DWORD;
pub extern "kernel32" fn WriteFile(
in_hFile: HANDLE,
@ -242,49 +242,49 @@ pub extern "kernel32" fn WriteFile(
in_nNumberOfBytesToWrite: DWORD,
out_lpNumberOfBytesWritten: ?*DWORD,
in_out_lpOverlapped: ?*OVERLAPPED,
) callconv(.Stdcall) BOOL;
) callconv(WINAPI) BOOL;
pub extern "kernel32" fn WriteFileEx(hFile: HANDLE, lpBuffer: [*]const u8, nNumberOfBytesToWrite: DWORD, lpOverlapped: LPOVERLAPPED, lpCompletionRoutine: LPOVERLAPPED_COMPLETION_ROUTINE) callconv(.Stdcall) BOOL;
pub extern "kernel32" fn WriteFileEx(hFile: HANDLE, lpBuffer: [*]const u8, nNumberOfBytesToWrite: DWORD, lpOverlapped: LPOVERLAPPED, lpCompletionRoutine: LPOVERLAPPED_COMPLETION_ROUTINE) callconv(WINAPI) BOOL;
pub extern "kernel32" fn LoadLibraryW(lpLibFileName: [*:0]const u16) callconv(.Stdcall) ?HMODULE;
pub extern "kernel32" fn LoadLibraryW(lpLibFileName: [*:0]const u16) callconv(WINAPI) ?HMODULE;
pub extern "kernel32" fn GetProcAddress(hModule: HMODULE, lpProcName: [*]const u8) callconv(.Stdcall) ?FARPROC;
pub extern "kernel32" fn GetProcAddress(hModule: HMODULE, lpProcName: [*]const u8) callconv(WINAPI) ?FARPROC;
pub extern "kernel32" fn FreeLibrary(hModule: HMODULE) callconv(.Stdcall) BOOL;
pub extern "kernel32" fn FreeLibrary(hModule: HMODULE) callconv(WINAPI) BOOL;
pub extern "kernel32" fn InitializeCriticalSection(lpCriticalSection: *CRITICAL_SECTION) callconv(.Stdcall) void;
pub extern "kernel32" fn EnterCriticalSection(lpCriticalSection: *CRITICAL_SECTION) callconv(.Stdcall) void;
pub extern "kernel32" fn LeaveCriticalSection(lpCriticalSection: *CRITICAL_SECTION) callconv(.Stdcall) void;
pub extern "kernel32" fn DeleteCriticalSection(lpCriticalSection: *CRITICAL_SECTION) callconv(.Stdcall) void;
pub extern "kernel32" fn InitializeCriticalSection(lpCriticalSection: *CRITICAL_SECTION) callconv(WINAPI) void;
pub extern "kernel32" fn EnterCriticalSection(lpCriticalSection: *CRITICAL_SECTION) callconv(WINAPI) void;
pub extern "kernel32" fn LeaveCriticalSection(lpCriticalSection: *CRITICAL_SECTION) callconv(WINAPI) void;
pub extern "kernel32" fn DeleteCriticalSection(lpCriticalSection: *CRITICAL_SECTION) callconv(WINAPI) void;
pub extern "kernel32" fn InitOnceExecuteOnce(InitOnce: *INIT_ONCE, InitFn: INIT_ONCE_FN, Parameter: ?*c_void, Context: ?*c_void) callconv(.Stdcall) BOOL;
pub extern "kernel32" fn InitOnceExecuteOnce(InitOnce: *INIT_ONCE, InitFn: INIT_ONCE_FN, Parameter: ?*c_void, Context: ?*c_void) callconv(WINAPI) BOOL;
pub extern "kernel32" fn K32EmptyWorkingSet(hProcess: HANDLE) callconv(.Stdcall) BOOL;
pub extern "kernel32" fn K32EnumDeviceDrivers(lpImageBase: [*]LPVOID, cb: DWORD, lpcbNeeded: LPDWORD) callconv(.Stdcall) BOOL;
pub extern "kernel32" fn K32EnumPageFilesA(pCallBackRoutine: PENUM_PAGE_FILE_CALLBACKA, pContext: LPVOID) callconv(.Stdcall) BOOL;
pub extern "kernel32" fn K32EnumPageFilesW(pCallBackRoutine: PENUM_PAGE_FILE_CALLBACKW, pContext: LPVOID) callconv(.Stdcall) BOOL;
pub extern "kernel32" fn K32EnumProcessModules(hProcess: HANDLE, lphModule: [*]HMODULE, cb: DWORD, lpcbNeeded: LPDWORD) callconv(.Stdcall) BOOL;
pub extern "kernel32" fn K32EnumProcessModulesEx(hProcess: HANDLE, lphModule: [*]HMODULE, cb: DWORD, lpcbNeeded: LPDWORD, dwFilterFlag: DWORD) callconv(.Stdcall) BOOL;
pub extern "kernel32" fn K32EnumProcesses(lpidProcess: [*]DWORD, cb: DWORD, cbNeeded: LPDWORD) callconv(.Stdcall) BOOL;
pub extern "kernel32" fn K32GetDeviceDriverBaseNameA(ImageBase: LPVOID, lpBaseName: LPSTR, nSize: DWORD) callconv(.Stdcall) DWORD;
pub extern "kernel32" fn K32GetDeviceDriverBaseNameW(ImageBase: LPVOID, lpBaseName: LPWSTR, nSize: DWORD) callconv(.Stdcall) DWORD;
pub extern "kernel32" fn K32GetDeviceDriverFileNameA(ImageBase: LPVOID, lpFilename: LPSTR, nSize: DWORD) callconv(.Stdcall) DWORD;
pub extern "kernel32" fn K32GetDeviceDriverFileNameW(ImageBase: LPVOID, lpFilename: LPWSTR, nSize: DWORD) callconv(.Stdcall) DWORD;
pub extern "kernel32" fn K32GetMappedFileNameA(hProcess: HANDLE, lpv: ?LPVOID, lpFilename: LPSTR, nSize: DWORD) callconv(.Stdcall) DWORD;
pub extern "kernel32" fn K32GetMappedFileNameW(hProcess: HANDLE, lpv: ?LPVOID, lpFilename: LPWSTR, nSize: DWORD) callconv(.Stdcall) DWORD;
pub extern "kernel32" fn K32GetModuleBaseNameA(hProcess: HANDLE, hModule: ?HMODULE, lpBaseName: LPSTR, nSize: DWORD) callconv(.Stdcall) DWORD;
pub extern "kernel32" fn K32GetModuleBaseNameW(hProcess: HANDLE, hModule: ?HMODULE, lpBaseName: LPWSTR, nSize: DWORD) callconv(.Stdcall) DWORD;
pub extern "kernel32" fn K32GetModuleFileNameExA(hProcess: HANDLE, hModule: ?HMODULE, lpFilename: LPSTR, nSize: DWORD) callconv(.Stdcall) DWORD;
pub extern "kernel32" fn K32GetModuleFileNameExW(hProcess: HANDLE, hModule: ?HMODULE, lpFilename: LPWSTR, nSize: DWORD) callconv(.Stdcall) DWORD;
pub extern "kernel32" fn K32GetModuleInformation(hProcess: HANDLE, hModule: HMODULE, lpmodinfo: LPMODULEINFO, cb: DWORD) callconv(.Stdcall) BOOL;
pub extern "kernel32" fn K32GetPerformanceInfo(pPerformanceInformation: PPERFORMACE_INFORMATION, cb: DWORD) callconv(.Stdcall) BOOL;
pub extern "kernel32" fn K32GetProcessImageFileNameA(hProcess: HANDLE, lpImageFileName: LPSTR, nSize: DWORD) callconv(.Stdcall) DWORD;
pub extern "kernel32" fn K32GetProcessImageFileNameW(hProcess: HANDLE, lpImageFileName: LPWSTR, nSize: DWORD) callconv(.Stdcall) DWORD;
pub extern "kernel32" fn K32GetProcessMemoryInfo(Process: HANDLE, ppsmemCounters: PPROCESS_MEMORY_COUNTERS, cb: DWORD) callconv(.Stdcall) BOOL;
pub extern "kernel32" fn K32GetWsChanges(hProcess: HANDLE, lpWatchInfo: PPSAPI_WS_WATCH_INFORMATION, cb: DWORD) callconv(.Stdcall) BOOL;
pub extern "kernel32" fn K32GetWsChangesEx(hProcess: HANDLE, lpWatchInfoEx: PPSAPI_WS_WATCH_INFORMATION_EX, cb: DWORD) callconv(.Stdcall) BOOL;
pub extern "kernel32" fn K32InitializeProcessForWsWatch(hProcess: HANDLE) callconv(.Stdcall) BOOL;
pub extern "kernel32" fn K32QueryWorkingSet(hProcess: HANDLE, pv: PVOID, cb: DWORD) callconv(.Stdcall) BOOL;
pub extern "kernel32" fn K32QueryWorkingSetEx(hProcess: HANDLE, pv: PVOID, cb: DWORD) callconv(.Stdcall) BOOL;
pub extern "kernel32" fn K32EmptyWorkingSet(hProcess: HANDLE) callconv(WINAPI) BOOL;
pub extern "kernel32" fn K32EnumDeviceDrivers(lpImageBase: [*]LPVOID, cb: DWORD, lpcbNeeded: LPDWORD) callconv(WINAPI) BOOL;
pub extern "kernel32" fn K32EnumPageFilesA(pCallBackRoutine: PENUM_PAGE_FILE_CALLBACKA, pContext: LPVOID) callconv(WINAPI) BOOL;
pub extern "kernel32" fn K32EnumPageFilesW(pCallBackRoutine: PENUM_PAGE_FILE_CALLBACKW, pContext: LPVOID) callconv(WINAPI) BOOL;
pub extern "kernel32" fn K32EnumProcessModules(hProcess: HANDLE, lphModule: [*]HMODULE, cb: DWORD, lpcbNeeded: LPDWORD) callconv(WINAPI) BOOL;
pub extern "kernel32" fn K32EnumProcessModulesEx(hProcess: HANDLE, lphModule: [*]HMODULE, cb: DWORD, lpcbNeeded: LPDWORD, dwFilterFlag: DWORD) callconv(WINAPI) BOOL;
pub extern "kernel32" fn K32EnumProcesses(lpidProcess: [*]DWORD, cb: DWORD, cbNeeded: LPDWORD) callconv(WINAPI) BOOL;
pub extern "kernel32" fn K32GetDeviceDriverBaseNameA(ImageBase: LPVOID, lpBaseName: LPSTR, nSize: DWORD) callconv(WINAPI) DWORD;
pub extern "kernel32" fn K32GetDeviceDriverBaseNameW(ImageBase: LPVOID, lpBaseName: LPWSTR, nSize: DWORD) callconv(WINAPI) DWORD;
pub extern "kernel32" fn K32GetDeviceDriverFileNameA(ImageBase: LPVOID, lpFilename: LPSTR, nSize: DWORD) callconv(WINAPI) DWORD;
pub extern "kernel32" fn K32GetDeviceDriverFileNameW(ImageBase: LPVOID, lpFilename: LPWSTR, nSize: DWORD) callconv(WINAPI) DWORD;
pub extern "kernel32" fn K32GetMappedFileNameA(hProcess: HANDLE, lpv: ?LPVOID, lpFilename: LPSTR, nSize: DWORD) callconv(WINAPI) DWORD;
pub extern "kernel32" fn K32GetMappedFileNameW(hProcess: HANDLE, lpv: ?LPVOID, lpFilename: LPWSTR, nSize: DWORD) callconv(WINAPI) DWORD;
pub extern "kernel32" fn K32GetModuleBaseNameA(hProcess: HANDLE, hModule: ?HMODULE, lpBaseName: LPSTR, nSize: DWORD) callconv(WINAPI) DWORD;
pub extern "kernel32" fn K32GetModuleBaseNameW(hProcess: HANDLE, hModule: ?HMODULE, lpBaseName: LPWSTR, nSize: DWORD) callconv(WINAPI) DWORD;
pub extern "kernel32" fn K32GetModuleFileNameExA(hProcess: HANDLE, hModule: ?HMODULE, lpFilename: LPSTR, nSize: DWORD) callconv(WINAPI) DWORD;
pub extern "kernel32" fn K32GetModuleFileNameExW(hProcess: HANDLE, hModule: ?HMODULE, lpFilename: LPWSTR, nSize: DWORD) callconv(WINAPI) DWORD;
pub extern "kernel32" fn K32GetModuleInformation(hProcess: HANDLE, hModule: HMODULE, lpmodinfo: LPMODULEINFO, cb: DWORD) callconv(WINAPI) BOOL;
pub extern "kernel32" fn K32GetPerformanceInfo(pPerformanceInformation: PPERFORMACE_INFORMATION, cb: DWORD) callconv(WINAPI) BOOL;
pub extern "kernel32" fn K32GetProcessImageFileNameA(hProcess: HANDLE, lpImageFileName: LPSTR, nSize: DWORD) callconv(WINAPI) DWORD;
pub extern "kernel32" fn K32GetProcessImageFileNameW(hProcess: HANDLE, lpImageFileName: LPWSTR, nSize: DWORD) callconv(WINAPI) DWORD;
pub extern "kernel32" fn K32GetProcessMemoryInfo(Process: HANDLE, ppsmemCounters: PPROCESS_MEMORY_COUNTERS, cb: DWORD) callconv(WINAPI) BOOL;
pub extern "kernel32" fn K32GetWsChanges(hProcess: HANDLE, lpWatchInfo: PPSAPI_WS_WATCH_INFORMATION, cb: DWORD) callconv(WINAPI) BOOL;
pub extern "kernel32" fn K32GetWsChangesEx(hProcess: HANDLE, lpWatchInfoEx: PPSAPI_WS_WATCH_INFORMATION_EX, cb: DWORD) callconv(WINAPI) BOOL;
pub extern "kernel32" fn K32InitializeProcessForWsWatch(hProcess: HANDLE) callconv(WINAPI) BOOL;
pub extern "kernel32" fn K32QueryWorkingSet(hProcess: HANDLE, pv: PVOID, cb: DWORD) callconv(WINAPI) BOOL;
pub extern "kernel32" fn K32QueryWorkingSetEx(hProcess: HANDLE, pv: PVOID, cb: DWORD) callconv(WINAPI) BOOL;
pub extern "kernel32" fn FlushFileBuffers(hFile: HANDLE) callconv(.Stdcall) BOOL;
pub extern "kernel32" fn FlushFileBuffers(hFile: HANDLE) callconv(WINAPI) BOOL;

View File

@ -7,32 +7,32 @@ usingnamespace @import("bits.zig");
pub extern "NtDll" fn RtlGetVersion(
lpVersionInformation: PRTL_OSVERSIONINFOW,
) callconv(.Stdcall) NTSTATUS;
) callconv(WINAPI) NTSTATUS;
pub extern "NtDll" fn RtlCaptureStackBackTrace(
FramesToSkip: DWORD,
FramesToCapture: DWORD,
BackTrace: **c_void,
BackTraceHash: ?*DWORD,
) callconv(.Stdcall) WORD;
) callconv(WINAPI) WORD;
pub extern "NtDll" fn NtQueryInformationFile(
FileHandle: HANDLE,
IoStatusBlock: *IO_STATUS_BLOCK,
FileInformation: *c_void,
Length: ULONG,
FileInformationClass: FILE_INFORMATION_CLASS,
) callconv(.Stdcall) NTSTATUS;
) callconv(WINAPI) NTSTATUS;
pub extern "NtDll" fn NtSetInformationFile(
FileHandle: HANDLE,
IoStatusBlock: *IO_STATUS_BLOCK,
FileInformation: PVOID,
Length: ULONG,
FileInformationClass: FILE_INFORMATION_CLASS,
) callconv(.Stdcall) NTSTATUS;
) callconv(WINAPI) NTSTATUS;
pub extern "NtDll" fn NtQueryAttributesFile(
ObjectAttributes: *OBJECT_ATTRIBUTES,
FileAttributes: *FILE_BASIC_INFORMATION,
) callconv(.Stdcall) NTSTATUS;
) callconv(WINAPI) NTSTATUS;
pub extern "NtDll" fn NtCreateFile(
FileHandle: *HANDLE,
@ -46,7 +46,7 @@ pub extern "NtDll" fn NtCreateFile(
CreateOptions: ULONG,
EaBuffer: ?*c_void,
EaLength: ULONG,
) callconv(.Stdcall) NTSTATUS;
) callconv(WINAPI) NTSTATUS;
pub extern "NtDll" fn NtDeviceIoControlFile(
FileHandle: HANDLE,
Event: ?HANDLE,
@ -58,7 +58,7 @@ pub extern "NtDll" fn NtDeviceIoControlFile(
InputBufferLength: ULONG,
OutputBuffer: ?PVOID,
OutputBufferLength: ULONG,
) callconv(.Stdcall) NTSTATUS;
) callconv(WINAPI) NTSTATUS;
pub extern "NtDll" fn NtFsControlFile(
FileHandle: HANDLE,
Event: ?HANDLE,
@ -70,15 +70,15 @@ pub extern "NtDll" fn NtFsControlFile(
InputBufferLength: ULONG,
OutputBuffer: ?PVOID,
OutputBufferLength: ULONG,
) callconv(.Stdcall) NTSTATUS;
pub extern "NtDll" fn NtClose(Handle: HANDLE) callconv(.Stdcall) NTSTATUS;
) callconv(WINAPI) NTSTATUS;
pub extern "NtDll" fn NtClose(Handle: HANDLE) callconv(WINAPI) NTSTATUS;
pub extern "NtDll" fn RtlDosPathNameToNtPathName_U(
DosPathName: [*:0]const u16,
NtPathName: *UNICODE_STRING,
NtFileNamePart: ?*?[*:0]const u16,
DirectoryInfo: ?*CURDIR,
) callconv(.Stdcall) BOOL;
pub extern "NtDll" fn RtlFreeUnicodeString(UnicodeString: *UNICODE_STRING) callconv(.Stdcall) void;
) callconv(WINAPI) BOOL;
pub extern "NtDll" fn RtlFreeUnicodeString(UnicodeString: *UNICODE_STRING) callconv(WINAPI) void;
pub extern "NtDll" fn NtQueryDirectoryFile(
FileHandle: HANDLE,
@ -92,26 +92,26 @@ pub extern "NtDll" fn NtQueryDirectoryFile(
ReturnSingleEntry: BOOLEAN,
FileName: ?*UNICODE_STRING,
RestartScan: BOOLEAN,
) callconv(.Stdcall) NTSTATUS;
) callconv(WINAPI) NTSTATUS;
pub extern "NtDll" fn NtCreateKeyedEvent(
KeyedEventHandle: *HANDLE,
DesiredAccess: ACCESS_MASK,
ObjectAttributes: ?PVOID,
Flags: ULONG,
) callconv(.Stdcall) NTSTATUS;
) callconv(WINAPI) NTSTATUS;
pub extern "NtDll" fn NtReleaseKeyedEvent(
EventHandle: HANDLE,
Key: *const c_void,
Alertable: BOOLEAN,
Timeout: ?*LARGE_INTEGER,
) callconv(.Stdcall) NTSTATUS;
) callconv(WINAPI) NTSTATUS;
pub extern "NtDll" fn NtWaitForKeyedEvent(
EventHandle: HANDLE,
Key: *const c_void,
Alertable: BOOLEAN,
Timeout: ?*LARGE_INTEGER,
) callconv(.Stdcall) NTSTATUS;
) callconv(WINAPI) NTSTATUS;
pub extern "NtDll" fn RtlSetCurrentDirectory_U(
PathName: *UNICODE_STRING
) callconv(.Stdcall) NTSTATUS;
) callconv(WINAPI) NTSTATUS;

View File

@ -5,7 +5,7 @@
// and substantial portions of the software.
usingnamespace @import("bits.zig");
pub extern "ole32" fn CoTaskMemFree(pv: LPVOID) callconv(.Stdcall) void;
pub extern "ole32" fn CoUninitialize() callconv(.Stdcall) void;
pub extern "ole32" fn CoGetCurrentProcess() callconv(.Stdcall) DWORD;
pub extern "ole32" fn CoInitializeEx(pvReserved: ?LPVOID, dwCoInit: DWORD) callconv(.Stdcall) HRESULT;
pub extern "ole32" fn CoTaskMemFree(pv: LPVOID) callconv(WINAPI) void;
pub extern "ole32" fn CoUninitialize() callconv(WINAPI) void;
pub extern "ole32" fn CoGetCurrentProcess() callconv(WINAPI) DWORD;
pub extern "ole32" fn CoInitializeEx(pvReserved: ?LPVOID, dwCoInit: DWORD) callconv(WINAPI) HRESULT;

View File

@ -5,30 +5,30 @@
// and substantial portions of the software.
usingnamespace @import("bits.zig");
pub extern "psapi" fn EmptyWorkingSet(hProcess: HANDLE) callconv(.Stdcall) BOOL;
pub extern "psapi" fn EnumDeviceDrivers(lpImageBase: [*]LPVOID, cb: DWORD, lpcbNeeded: LPDWORD) callconv(.Stdcall) BOOL;
pub extern "psapi" fn EnumPageFilesA(pCallBackRoutine: PENUM_PAGE_FILE_CALLBACKA, pContext: LPVOID) callconv(.Stdcall) BOOL;
pub extern "psapi" fn EnumPageFilesW(pCallBackRoutine: PENUM_PAGE_FILE_CALLBACKW, pContext: LPVOID) callconv(.Stdcall) BOOL;
pub extern "psapi" fn EnumProcessModules(hProcess: HANDLE, lphModule: [*]HMODULE, cb: DWORD, lpcbNeeded: LPDWORD) callconv(.Stdcall) BOOL;
pub extern "psapi" fn EnumProcessModulesEx(hProcess: HANDLE, lphModule: [*]HMODULE, cb: DWORD, lpcbNeeded: LPDWORD, dwFilterFlag: DWORD) callconv(.Stdcall) BOOL;
pub extern "psapi" fn EnumProcesses(lpidProcess: [*]DWORD, cb: DWORD, cbNeeded: LPDWORD) callconv(.Stdcall) BOOL;
pub extern "psapi" fn GetDeviceDriverBaseNameA(ImageBase: LPVOID, lpBaseName: LPSTR, nSize: DWORD) callconv(.Stdcall) DWORD;
pub extern "psapi" fn GetDeviceDriverBaseNameW(ImageBase: LPVOID, lpBaseName: LPWSTR, nSize: DWORD) callconv(.Stdcall) DWORD;
pub extern "psapi" fn GetDeviceDriverFileNameA(ImageBase: LPVOID, lpFilename: LPSTR, nSize: DWORD) callconv(.Stdcall) DWORD;
pub extern "psapi" fn GetDeviceDriverFileNameW(ImageBase: LPVOID, lpFilename: LPWSTR, nSize: DWORD) callconv(.Stdcall) DWORD;
pub extern "psapi" fn GetMappedFileNameA(hProcess: HANDLE, lpv: ?LPVOID, lpFilename: LPSTR, nSize: DWORD) callconv(.Stdcall) DWORD;
pub extern "psapi" fn GetMappedFileNameW(hProcess: HANDLE, lpv: ?LPVOID, lpFilename: LPWSTR, nSize: DWORD) callconv(.Stdcall) DWORD;
pub extern "psapi" fn GetModuleBaseNameA(hProcess: HANDLE, hModule: ?HMODULE, lpBaseName: LPSTR, nSize: DWORD) callconv(.Stdcall) DWORD;
pub extern "psapi" fn GetModuleBaseNameW(hProcess: HANDLE, hModule: ?HMODULE, lpBaseName: LPWSTR, nSize: DWORD) callconv(.Stdcall) DWORD;
pub extern "psapi" fn GetModuleFileNameExA(hProcess: HANDLE, hModule: ?HMODULE, lpFilename: LPSTR, nSize: DWORD) callconv(.Stdcall) DWORD;
pub extern "psapi" fn GetModuleFileNameExW(hProcess: HANDLE, hModule: ?HMODULE, lpFilename: LPWSTR, nSize: DWORD) callconv(.Stdcall) DWORD;
pub extern "psapi" fn GetModuleInformation(hProcess: HANDLE, hModule: HMODULE, lpmodinfo: LPMODULEINFO, cb: DWORD) callconv(.Stdcall) BOOL;
pub extern "psapi" fn GetPerformanceInfo(pPerformanceInformation: PPERFORMACE_INFORMATION, cb: DWORD) callconv(.Stdcall) BOOL;
pub extern "psapi" fn GetProcessImageFileNameA(hProcess: HANDLE, lpImageFileName: LPSTR, nSize: DWORD) callconv(.Stdcall) DWORD;
pub extern "psapi" fn GetProcessImageFileNameW(hProcess: HANDLE, lpImageFileName: LPWSTR, nSize: DWORD) callconv(.Stdcall) DWORD;
pub extern "psapi" fn GetProcessMemoryInfo(Process: HANDLE, ppsmemCounters: PPROCESS_MEMORY_COUNTERS, cb: DWORD) callconv(.Stdcall) BOOL;
pub extern "psapi" fn GetWsChanges(hProcess: HANDLE, lpWatchInfo: PPSAPI_WS_WATCH_INFORMATION, cb: DWORD) callconv(.Stdcall) BOOL;
pub extern "psapi" fn GetWsChangesEx(hProcess: HANDLE, lpWatchInfoEx: PPSAPI_WS_WATCH_INFORMATION_EX, cb: DWORD) callconv(.Stdcall) BOOL;
pub extern "psapi" fn InitializeProcessForWsWatch(hProcess: HANDLE) callconv(.Stdcall) BOOL;
pub extern "psapi" fn QueryWorkingSet(hProcess: HANDLE, pv: PVOID, cb: DWORD) callconv(.Stdcall) BOOL;
pub extern "psapi" fn QueryWorkingSetEx(hProcess: HANDLE, pv: PVOID, cb: DWORD) callconv(.Stdcall) BOOL;
pub extern "psapi" fn EmptyWorkingSet(hProcess: HANDLE) callconv(WINAPI) BOOL;
pub extern "psapi" fn EnumDeviceDrivers(lpImageBase: [*]LPVOID, cb: DWORD, lpcbNeeded: LPDWORD) callconv(WINAPI) BOOL;
pub extern "psapi" fn EnumPageFilesA(pCallBackRoutine: PENUM_PAGE_FILE_CALLBACKA, pContext: LPVOID) callconv(WINAPI) BOOL;
pub extern "psapi" fn EnumPageFilesW(pCallBackRoutine: PENUM_PAGE_FILE_CALLBACKW, pContext: LPVOID) callconv(WINAPI) BOOL;
pub extern "psapi" fn EnumProcessModules(hProcess: HANDLE, lphModule: [*]HMODULE, cb: DWORD, lpcbNeeded: LPDWORD) callconv(WINAPI) BOOL;
pub extern "psapi" fn EnumProcessModulesEx(hProcess: HANDLE, lphModule: [*]HMODULE, cb: DWORD, lpcbNeeded: LPDWORD, dwFilterFlag: DWORD) callconv(WINAPI) BOOL;
pub extern "psapi" fn EnumProcesses(lpidProcess: [*]DWORD, cb: DWORD, cbNeeded: LPDWORD) callconv(WINAPI) BOOL;
pub extern "psapi" fn GetDeviceDriverBaseNameA(ImageBase: LPVOID, lpBaseName: LPSTR, nSize: DWORD) callconv(WINAPI) DWORD;
pub extern "psapi" fn GetDeviceDriverBaseNameW(ImageBase: LPVOID, lpBaseName: LPWSTR, nSize: DWORD) callconv(WINAPI) DWORD;
pub extern "psapi" fn GetDeviceDriverFileNameA(ImageBase: LPVOID, lpFilename: LPSTR, nSize: DWORD) callconv(WINAPI) DWORD;
pub extern "psapi" fn GetDeviceDriverFileNameW(ImageBase: LPVOID, lpFilename: LPWSTR, nSize: DWORD) callconv(WINAPI) DWORD;
pub extern "psapi" fn GetMappedFileNameA(hProcess: HANDLE, lpv: ?LPVOID, lpFilename: LPSTR, nSize: DWORD) callconv(WINAPI) DWORD;
pub extern "psapi" fn GetMappedFileNameW(hProcess: HANDLE, lpv: ?LPVOID, lpFilename: LPWSTR, nSize: DWORD) callconv(WINAPI) DWORD;
pub extern "psapi" fn GetModuleBaseNameA(hProcess: HANDLE, hModule: ?HMODULE, lpBaseName: LPSTR, nSize: DWORD) callconv(WINAPI) DWORD;
pub extern "psapi" fn GetModuleBaseNameW(hProcess: HANDLE, hModule: ?HMODULE, lpBaseName: LPWSTR, nSize: DWORD) callconv(WINAPI) DWORD;
pub extern "psapi" fn GetModuleFileNameExA(hProcess: HANDLE, hModule: ?HMODULE, lpFilename: LPSTR, nSize: DWORD) callconv(WINAPI) DWORD;
pub extern "psapi" fn GetModuleFileNameExW(hProcess: HANDLE, hModule: ?HMODULE, lpFilename: LPWSTR, nSize: DWORD) callconv(WINAPI) DWORD;
pub extern "psapi" fn GetModuleInformation(hProcess: HANDLE, hModule: HMODULE, lpmodinfo: LPMODULEINFO, cb: DWORD) callconv(WINAPI) BOOL;
pub extern "psapi" fn GetPerformanceInfo(pPerformanceInformation: PPERFORMACE_INFORMATION, cb: DWORD) callconv(WINAPI) BOOL;
pub extern "psapi" fn GetProcessImageFileNameA(hProcess: HANDLE, lpImageFileName: LPSTR, nSize: DWORD) callconv(WINAPI) DWORD;
pub extern "psapi" fn GetProcessImageFileNameW(hProcess: HANDLE, lpImageFileName: LPWSTR, nSize: DWORD) callconv(WINAPI) DWORD;
pub extern "psapi" fn GetProcessMemoryInfo(Process: HANDLE, ppsmemCounters: PPROCESS_MEMORY_COUNTERS, cb: DWORD) callconv(WINAPI) BOOL;
pub extern "psapi" fn GetWsChanges(hProcess: HANDLE, lpWatchInfo: PPSAPI_WS_WATCH_INFORMATION, cb: DWORD) callconv(WINAPI) BOOL;
pub extern "psapi" fn GetWsChangesEx(hProcess: HANDLE, lpWatchInfoEx: PPSAPI_WS_WATCH_INFORMATION_EX, cb: DWORD) callconv(WINAPI) BOOL;
pub extern "psapi" fn InitializeProcessForWsWatch(hProcess: HANDLE) callconv(WINAPI) BOOL;
pub extern "psapi" fn QueryWorkingSet(hProcess: HANDLE, pv: PVOID, cb: DWORD) callconv(WINAPI) BOOL;
pub extern "psapi" fn QueryWorkingSetEx(hProcess: HANDLE, pv: PVOID, cb: DWORD) callconv(WINAPI) BOOL;

View File

@ -5,4 +5,4 @@
// and substantial portions of the software.
usingnamespace @import("bits.zig");
pub extern "shell32" fn SHGetKnownFolderPath(rfid: *const KNOWNFOLDERID, dwFlags: DWORD, hToken: ?HANDLE, ppszPath: *[*:0]WCHAR) callconv(.Stdcall) HRESULT;
pub extern "shell32" fn SHGetKnownFolderPath(rfid: *const KNOWNFOLDERID, dwFlags: DWORD, hToken: ?HANDLE, ppszPath: *[*:0]WCHAR) callconv(WINAPI) HRESULT;

View File

@ -103,7 +103,7 @@ pub const CS_OWNDC = 0x0020;
pub const SW_HIDE = 0;
pub const SW_SHOW = 5;
pub const WNDPROC = fn (HWND, UINT, WPARAM, LPARAM) callconv(.Stdcall) LRESULT;
pub const WNDPROC = fn (HWND, UINT, WPARAM, LPARAM) callconv(WINAPI) LRESULT;
pub const WNDCLASSEXA = extern struct {
cbSize: UINT = @sizeOf(WNDCLASSEXA),
@ -147,13 +147,13 @@ pub extern "user32" fn CreateWindowExA(
hMenu: ?HMENU,
hInstance: HINSTANCE,
lpParam: ?LPVOID,
) callconv(.Stdcall) ?HWND;
) callconv(WINAPI) ?HWND;
pub extern "user32" fn RegisterClassExA(*const WNDCLASSEXA) callconv(.Stdcall) c_ushort;
pub extern "user32" fn DefWindowProcA(HWND, Msg: UINT, WPARAM, LPARAM) callconv(.Stdcall) LRESULT;
pub extern "user32" fn ShowWindow(hWnd: ?HWND, nCmdShow: i32) callconv(.Stdcall) bool;
pub extern "user32" fn UpdateWindow(hWnd: ?HWND) callconv(.Stdcall) bool;
pub extern "user32" fn GetDC(hWnd: ?HWND) callconv(.Stdcall) ?HDC;
pub extern "user32" fn RegisterClassExA(*const WNDCLASSEXA) callconv(WINAPI) c_ushort;
pub extern "user32" fn DefWindowProcA(HWND, Msg: UINT, WPARAM, LPARAM) callconv(WINAPI) LRESULT;
pub extern "user32" fn ShowWindow(hWnd: ?HWND, nCmdShow: i32) callconv(WINAPI) bool;
pub extern "user32" fn UpdateWindow(hWnd: ?HWND) callconv(WINAPI) bool;
pub extern "user32" fn GetDC(hWnd: ?HWND) callconv(WINAPI) ?HDC;
pub extern "user32" fn PeekMessageA(
lpMsg: ?*MSG,
@ -161,15 +161,15 @@ pub extern "user32" fn PeekMessageA(
wMsgFilterMin: UINT,
wMsgFilterMax: UINT,
wRemoveMsg: UINT,
) callconv(.Stdcall) bool;
) callconv(WINAPI) bool;
pub extern "user32" fn GetMessageA(
lpMsg: ?*MSG,
hWnd: ?HWND,
wMsgFilterMin: UINT,
wMsgFilterMax: UINT,
) callconv(.Stdcall) bool;
) callconv(WINAPI) bool;
pub extern "user32" fn TranslateMessage(lpMsg: *const MSG) callconv(.Stdcall) bool;
pub extern "user32" fn DispatchMessageA(lpMsg: *const MSG) callconv(.Stdcall) LRESULT;
pub extern "user32" fn PostQuitMessage(nExitCode: i32) callconv(.Stdcall) void;
pub extern "user32" fn TranslateMessage(lpMsg: *const MSG) callconv(WINAPI) bool;
pub extern "user32" fn DispatchMessageA(lpMsg: *const MSG) callconv(WINAPI) LRESULT;
pub extern "user32" fn PostQuitMessage(nExitCode: i32) callconv(WINAPI) void;

View File

@ -756,9 +756,9 @@ pub const TCP_NODELAY = 0x0001;
pub extern "ws2_32" fn WSAStartup(
wVersionRequired: WORD,
lpWSAData: *WSADATA,
) callconv(.Stdcall) c_int;
pub extern "ws2_32" fn WSACleanup() callconv(.Stdcall) c_int;
pub extern "ws2_32" fn WSAGetLastError() callconv(.Stdcall) WinsockError;
) callconv(WINAPI) c_int;
pub extern "ws2_32" fn WSACleanup() callconv(WINAPI) c_int;
pub extern "ws2_32" fn WSAGetLastError() callconv(WINAPI) WinsockError;
pub extern "ws2_32" fn WSASocketA(
af: c_int,
type: c_int,
@ -766,7 +766,7 @@ pub extern "ws2_32" fn WSASocketA(
lpProtocolInfo: ?*WSAPROTOCOL_INFOA,
g: GROUP,
dwFlags: DWORD,
) callconv(.Stdcall) SOCKET;
) callconv(WINAPI) SOCKET;
pub extern "ws2_32" fn WSASocketW(
af: c_int,
type: c_int,
@ -774,8 +774,8 @@ pub extern "ws2_32" fn WSASocketW(
lpProtocolInfo: ?*WSAPROTOCOL_INFOW,
g: GROUP,
dwFlags: DWORD,
) callconv(.Stdcall) SOCKET;
pub extern "ws2_32" fn closesocket(s: SOCKET) callconv(.Stdcall) c_int;
) callconv(WINAPI) SOCKET;
pub extern "ws2_32" fn closesocket(s: SOCKET) callconv(WINAPI) c_int;
pub extern "ws2_32" fn WSAIoctl(
s: SOCKET,
dwIoControlCode: DWORD,
@ -786,26 +786,26 @@ pub extern "ws2_32" fn WSAIoctl(
lpcbBytesReturned: LPDWORD,
lpOverlapped: ?*WSAOVERLAPPED,
lpCompletionRoutine: ?WSAOVERLAPPED_COMPLETION_ROUTINE,
) callconv(.Stdcall) c_int;
) callconv(WINAPI) c_int;
pub extern "ws2_32" fn accept(
s: SOCKET,
addr: ?*sockaddr,
addrlen: ?*c_int,
) callconv(.Stdcall) SOCKET;
) callconv(WINAPI) SOCKET;
pub extern "ws2_32" fn bind(
s: SOCKET,
addr: ?*const sockaddr,
addrlen: c_int,
) callconv(.Stdcall) c_int;
) callconv(WINAPI) c_int;
pub extern "ws2_32" fn connect(
s: SOCKET,
name: *const sockaddr,
namelen: c_int,
) callconv(.Stdcall) c_int;
) callconv(WINAPI) c_int;
pub extern "ws2_32" fn listen(
s: SOCKET,
backlog: c_int,
) callconv(.Stdcall) c_int;
) callconv(WINAPI) c_int;
pub extern "ws2_32" fn WSARecv(
s: SOCKET,
lpBuffers: [*]const WSABUF,
@ -814,7 +814,7 @@ pub extern "ws2_32" fn WSARecv(
lpFlags: *DWORD,
lpOverlapped: ?*WSAOVERLAPPED,
lpCompletionRoutine: ?WSAOVERLAPPED_COMPLETION_ROUTINE,
) callconv(.Stdcall) c_int;
) callconv(WINAPI) c_int;
pub extern "ws2_32" fn WSARecvFrom(
s: SOCKET,
lpBuffers: [*]const WSABUF,
@ -825,7 +825,7 @@ pub extern "ws2_32" fn WSARecvFrom(
lpFromlen: ?*socklen_t,
lpOverlapped: ?*WSAOVERLAPPED,
lpCompletionRoutine: ?WSAOVERLAPPED_COMPLETION_ROUTINE,
) callconv(.Stdcall) c_int;
) callconv(WINAPI) c_int;
pub extern "ws2_32" fn WSASend(
s: SOCKET,
lpBuffers: [*]WSABUF,
@ -834,7 +834,7 @@ pub extern "ws2_32" fn WSASend(
dwFlags: DWORD,
lpOverlapped: ?*WSAOVERLAPPED,
lpCompletionRoutine: ?WSAOVERLAPPED_COMPLETION_ROUTINE,
) callconv(.Stdcall) c_int;
) callconv(WINAPI) c_int;
pub extern "ws2_32" fn WSASendTo(
s: SOCKET,
lpBuffers: [*]WSABUF,
@ -845,35 +845,35 @@ pub extern "ws2_32" fn WSASendTo(
iTolen: c_int,
lpOverlapped: ?*WSAOVERLAPPED,
lpCompletionRoutine: ?WSAOVERLAPPED_COMPLETION_ROUTINE,
) callconv(.Stdcall) c_int;
) callconv(WINAPI) c_int;
pub extern "ws2_32" fn WSAPoll(
fdArray: [*]pollfd,
fds: c_ulong,
timeout: c_int,
) callconv(.Stdcall) c_int;
) callconv(WINAPI) c_int;
pub extern "ws2_32" fn getaddrinfo(
pNodeName: [*:0]const u8,
pServiceName: [*:0]const u8,
pHints: *const addrinfo,
ppResult: **addrinfo,
) callconv(.Stdcall) i32;
) callconv(WINAPI) i32;
pub extern "ws2_32" fn freeaddrinfo(
pAddrInfo: *addrinfo,
) callconv(.Stdcall) void;
) callconv(WINAPI) void;
pub extern "ws2_32" fn ioctlsocket(
s: SOCKET,
cmd: c_long,
argp: *c_ulong,
) callconv(.Stdcall) c_int;
) callconv(WINAPI) c_int;
pub extern "ws2_32" fn getsockname(
s: SOCKET,
name: *sockaddr,
namelen: *c_int,
) callconv(.Stdcall) c_int;
) callconv(WINAPI) c_int;
pub extern "ws2_32" fn setsockopt(
s: SOCKET,
level: u32,
optname: u32,
optval: ?*const c_void,
optlen: socklen_t,
) callconv(.Stdcall) c_int;
) callconv(WINAPI) c_int;

View File

@ -53,7 +53,7 @@ fn _DllMainCRTStartup(
hinstDLL: std.os.windows.HINSTANCE,
fdwReason: std.os.windows.DWORD,
lpReserved: std.os.windows.LPVOID,
) callconv(.Stdcall) std.os.windows.BOOL {
) callconv(std.os.windows.WINAPI) std.os.windows.BOOL {
if (!builtin.single_threaded and !builtin.link_libc) {
_ = @import("start_windows_tls.zig");
}
@ -162,7 +162,7 @@ fn _start() callconv(.Naked) noreturn {
@call(.{ .modifier = .never_inline }, posixCallMainAndExit, .{});
}
fn WinStartup() callconv(.Stdcall) noreturn {
fn WinStartup() callconv(std.os.windows.WINAPI) noreturn {
@setAlignStack(16);
if (!builtin.single_threaded) {
_ = @import("start_windows_tls.zig");
@ -173,7 +173,7 @@ fn WinStartup() callconv(.Stdcall) noreturn {
std.os.windows.kernel32.ExitProcess(initEventLoopAndCallMain());
}
fn wWinMainCRTStartup() callconv(.Stdcall) noreturn {
fn wWinMainCRTStartup() callconv(std.os.windows.WINAPI) noreturn {
@setAlignStack(16);
if (!builtin.single_threaded) {
_ = @import("start_windows_tls.zig");

View File

@ -971,9 +971,9 @@ const char *calling_convention_name(CallingConvention cc) {
case CallingConventionFastcall: return "Fastcall";
case CallingConventionVectorcall: return "Vectorcall";
case CallingConventionThiscall: return "Thiscall";
case CallingConventionAPCS: return "Apcs";
case CallingConventionAAPCS: return "Aapcs";
case CallingConventionAAPCSVFP: return "Aapcsvfp";
case CallingConventionAPCS: return "APCS";
case CallingConventionAAPCS: return "AAPCS";
case CallingConventionAAPCSVFP: return "AAPCSVFP";
}
zig_unreachable();
}
@ -1880,6 +1880,58 @@ ZigType *get_auto_err_set_type(CodeGen *g, ZigFn *fn_entry) {
return err_set_type;
}
// Sync this with get_llvm_cc in codegen.cpp
static Error emit_error_unless_callconv_allowed_for_target(CodeGen *g, AstNode *source_node, CallingConvention cc) {
Error ret = ErrorNone;
const char *allowed_platforms = nullptr;
switch (cc) {
case CallingConventionUnspecified:
case CallingConventionC:
case CallingConventionNaked:
case CallingConventionAsync:
break;
case CallingConventionInterrupt:
if (g->zig_target->arch != ZigLLVM_x86
&& g->zig_target->arch != ZigLLVM_x86_64
&& g->zig_target->arch != ZigLLVM_avr
&& g->zig_target->arch != ZigLLVM_msp430)
{
allowed_platforms = "x86, x86_64, AVR, and MSP430";
}
break;
case CallingConventionSignal:
if (g->zig_target->arch != ZigLLVM_avr)
allowed_platforms = "AVR";
break;
case CallingConventionStdcall:
case CallingConventionFastcall:
case CallingConventionThiscall:
if (g->zig_target->arch != ZigLLVM_x86)
allowed_platforms = "x86";
break;
case CallingConventionVectorcall:
if (g->zig_target->arch != ZigLLVM_x86
&& !(target_is_arm(g->zig_target) && target_arch_pointer_bit_width(g->zig_target->arch) == 64))
{
allowed_platforms = "x86 and AArch64";
}
break;
case CallingConventionAPCS:
case CallingConventionAAPCS:
case CallingConventionAAPCSVFP:
if (!target_is_arm(g->zig_target))
allowed_platforms = "ARM";
}
if (allowed_platforms != nullptr) {
add_node_error(g, source_node, buf_sprintf(
"callconv '%s' is only available on %s, not %s",
calling_convention_name(cc), allowed_platforms,
target_arch_name(g->zig_target->arch)));
ret = ErrorSemanticAnalyzeFail;
}
return ret;
}
static ZigType *analyze_fn_type(CodeGen *g, AstNode *proto_node, Scope *child_scope, ZigFn *fn_entry,
CallingConvention cc)
{
@ -2014,6 +2066,9 @@ static ZigType *analyze_fn_type(CodeGen *g, AstNode *proto_node, Scope *child_sc
fn_entry->align_bytes = fn_type_id.alignment;
}
if ((err = emit_error_unless_callconv_allowed_for_target(g, proto_node->data.fn_proto.callconv_expr, cc)))
return g->builtin_types.entry_invalid;
if (fn_proto->return_anytype_token != nullptr) {
if (!calling_convention_allows_zig_types(fn_type_id.cc)) {
add_node_error(g, fn_proto->return_type,
@ -3577,9 +3632,13 @@ void add_var_export(CodeGen *g, ZigVar *var, const char *symbol_name, GlobalLink
}
void add_fn_export(CodeGen *g, ZigFn *fn_table_entry, const char *symbol_name, GlobalLinkageId linkage, CallingConvention cc) {
CallingConvention winapi_cc = g->zig_target->arch == ZigLLVM_x86
? CallingConventionStdcall
: CallingConventionC;
if (cc == CallingConventionC && strcmp(symbol_name, "main") == 0 && g->link_libc) {
g->stage1.have_c_main = true;
} else if (cc == CallingConventionStdcall && g->zig_target->os == OsWindows) {
} else if (cc == winapi_cc && g->zig_target->os == OsWindows) {
if (strcmp(symbol_name, "WinMain") == 0) {
g->stage1.have_winmain = true;
} else if (strcmp(symbol_name, "wWinMain") == 0) {

View File

@ -155,6 +155,7 @@ static const char *get_mangled_name(CodeGen *g, const char *original_name) {
}
}
// Sync this with emit_error_unless_callconv_allowed_for_target in analyze.cpp
static ZigLLVM_CallingConv get_llvm_cc(CodeGen *g, CallingConvention cc) {
switch (cc) {
case CallingConventionUnspecified:
@ -164,38 +165,32 @@ static ZigLLVM_CallingConv get_llvm_cc(CodeGen *g, CallingConvention cc) {
case CallingConventionNaked:
zig_unreachable();
case CallingConventionStdcall:
if (g->zig_target->arch == ZigLLVM_x86)
return ZigLLVM_X86_StdCall;
return ZigLLVM_C;
assert(g->zig_target->arch == ZigLLVM_x86);
return ZigLLVM_X86_StdCall;
case CallingConventionFastcall:
if (g->zig_target->arch == ZigLLVM_x86)
return ZigLLVM_X86_FastCall;
return ZigLLVM_C;
assert(g->zig_target->arch == ZigLLVM_x86);
return ZigLLVM_X86_FastCall;
case CallingConventionVectorcall:
if (g->zig_target->arch == ZigLLVM_x86)
return ZigLLVM_X86_VectorCall;
if (target_is_arm(g->zig_target) &&
target_arch_pointer_bit_width(g->zig_target->arch) == 64)
return ZigLLVM_AArch64_VectorCall;
return ZigLLVM_C;
zig_unreachable();
case CallingConventionThiscall:
if (g->zig_target->arch == ZigLLVM_x86)
return ZigLLVM_X86_ThisCall;
return ZigLLVM_C;
assert(g->zig_target->arch == ZigLLVM_x86);
return ZigLLVM_X86_ThisCall;
case CallingConventionAsync:
return ZigLLVM_Fast;
case CallingConventionAPCS:
if (target_is_arm(g->zig_target))
return ZigLLVM_ARM_APCS;
return ZigLLVM_C;
assert(target_is_arm(g->zig_target));
return ZigLLVM_ARM_APCS;
case CallingConventionAAPCS:
if (target_is_arm(g->zig_target))
return ZigLLVM_ARM_AAPCS;
return ZigLLVM_C;
assert(target_is_arm(g->zig_target));
return ZigLLVM_ARM_AAPCS;
case CallingConventionAAPCSVFP:
if (target_is_arm(g->zig_target))
return ZigLLVM_ARM_AAPCS_VFP;
return ZigLLVM_C;
assert(target_is_arm(g->zig_target));
return ZigLLVM_ARM_AAPCS_VFP;
case CallingConventionInterrupt:
if (g->zig_target->arch == ZigLLVM_x86 ||
g->zig_target->arch == ZigLLVM_x86_64)
@ -204,11 +199,10 @@ static ZigLLVM_CallingConv get_llvm_cc(CodeGen *g, CallingConvention cc) {
return ZigLLVM_AVR_INTR;
if (g->zig_target->arch == ZigLLVM_msp430)
return ZigLLVM_MSP430_INTR;
return ZigLLVM_C;
zig_unreachable();
case CallingConventionSignal:
if (g->zig_target->arch == ZigLLVM_avr)
return ZigLLVM_AVR_SIGNAL;
return ZigLLVM_C;
assert(g->zig_target->arch == ZigLLVM_avr);
return ZigLLVM_AVR_SIGNAL;
}
zig_unreachable();
}

View File

@ -57,6 +57,84 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
"tmp.zig:1:22: note: type u2 cannot fit values in range 0...4",
});
cases.addCase(x: {
var tc = cases.create("callconv(.Interrupt) on unsupported platform",
\\export fn entry() callconv(.Interrupt) void {}
, &[_][]const u8{
"tmp.zig:1:28: error: callconv 'Interrupt' is only available on x86, x86_64, AVR, and MSP430, not aarch64",
});
tc.target = std.zig.CrossTarget{
.cpu_arch = .aarch64,
.os_tag = .linux,
.abi = .none,
};
break :x tc;
});
cases.addCase(x: {
var tc = cases.create("callconv(.Signal) on unsupported platform",
\\export fn entry() callconv(.Signal) void {}
, &[_][]const u8{
"tmp.zig:1:28: error: callconv 'Signal' is only available on AVR, not x86_64",
});
tc.target = std.zig.CrossTarget{
.cpu_arch = .x86_64,
.os_tag = .linux,
.abi = .none,
};
break :x tc;
});
cases.addCase(x: {
var tc = cases.create("callconv(.Stdcall, .Fastcall, .Thiscall) on unsupported platform",
\\export fn entry1() callconv(.Stdcall) void {}
\\export fn entry2() callconv(.Fastcall) void {}
\\export fn entry3() callconv(.Thiscall) void {}
, &[_][]const u8{
"tmp.zig:1:29: error: callconv 'Stdcall' is only available on x86, not x86_64",
"tmp.zig:2:29: error: callconv 'Fastcall' is only available on x86, not x86_64",
"tmp.zig:3:29: error: callconv 'Thiscall' is only available on x86, not x86_64",
});
tc.target = std.zig.CrossTarget{
.cpu_arch = .x86_64,
.os_tag = .linux,
.abi = .none,
};
break :x tc;
});
cases.addCase(x: {
var tc = cases.create("callconv(.Vectorcall) on unsupported platform",
\\export fn entry() callconv(.Vectorcall) void {}
, &[_][]const u8{
"tmp.zig:1:28: error: callconv 'Vectorcall' is only available on x86 and AArch64, not x86_64",
});
tc.target = std.zig.CrossTarget{
.cpu_arch = .x86_64,
.os_tag = .linux,
.abi = .none,
};
break :x tc;
});
cases.addCase(x: {
var tc = cases.create("callconv(.APCS, .AAPCS, .AAPCSVFP) on unsupported platform",
\\export fn entry1() callconv(.APCS) void {}
\\export fn entry2() callconv(.AAPCS) void {}
\\export fn entry3() callconv(.AAPCSVFP) void {}
, &[_][]const u8{
"tmp.zig:1:29: error: callconv 'APCS' is only available on ARM, not x86_64",
"tmp.zig:2:29: error: callconv 'AAPCS' is only available on ARM, not x86_64",
"tmp.zig:3:29: error: callconv 'AAPCSVFP' is only available on ARM, not x86_64",
});
tc.target = std.zig.CrossTarget{
.cpu_arch = .x86_64,
.os_tag = .linux,
.abi = .none,
};
break :x tc;
});
cases.add("unreachable executed at comptime",
\\fn foo(comptime x: i32) i32 {
\\ comptime {

View File

@ -189,9 +189,9 @@ test "return inner function which references comptime variable of outer function
test "extern struct with stdcallcc fn pointer" {
const S = extern struct {
ptr: fn () callconv(.Stdcall) i32,
ptr: fn () callconv(if (std.builtin.arch == .i386) .Stdcall else .C) i32,
fn foo() callconv(.Stdcall) i32 {
fn foo() callconv(if (std.builtin.arch == .i386) .Stdcall else .C) i32 {
return 1234;
}
};