authorgravatar for thatlemon@gmail.comLemonBoy <thatlemon@gmail.com> 2019-12-23 21:52:06+01:00
committergravatar for thatlemon@gmail.comLemonBoy <thatlemon@gmail.com> 2020-01-02 18:53:16+01:00
log563d9ebfe597b313b265a5a30296c081fe35d87a
tree9b67e280b607498d1592fbc420d10ec39d835440
parent7bd80f207147167821634e16983edf9e9b115c9f

Implement the callconv() annotation


50 files changed, 572 insertions(+), 358 deletions(-)

doc/docgen.zig+1
......@@ -818,6 +818,7 @@ fn tokenizeAndPrintRaw(docgen_tokenizer: *Tokenizer, out: var, source_token: Tok
818818 .Keyword_resume,
819819 .Keyword_return,
820820 .Keyword_linksection,
821 .Keyword_callconv,
821822 .Keyword_stdcallcc,
822823 .Keyword_struct,
823824 .Keyword_suspend,
doc/langref.html.in+1-1
......@@ -2829,7 +2829,7 @@ test "@tagName" {
28292829 <p>
28302830 By default, enums are not guaranteed to be compatible with the C ABI:
28312831 </p>
2832 {#code_begin|obj_err|parameter of type 'Foo' not allowed in function with calling convention 'ccc'#}
2832 {#code_begin|obj_err|parameter of type 'Foo' not allowed in function with calling convention 'C'#}
28332833const Foo = enum { A, B, C };
28342834export fn entry(foo: Foo) void { }
28352835 {#code_end#}
lib/std/builtin.zig+19-12
......@@ -91,6 +91,24 @@ pub const Mode = enum {
9191 ReleaseSmall,
9292};
9393
94/// This data structure is used by the Zig language code generation and
95/// therefore must be kept in sync with the compiler implementation.
96pub const CallingConvention = enum {
97 Unspecified,
98 C,
99 Cold,
100 Naked,
101 Async,
102 Interrupt,
103 Signal,
104 Stdcall,
105 Fastcall,
106 Vectorcall,
107 APCS,
108 AAPCS,
109 AAPCSVFP,
110};
111
94112pub const TypeId = @TagType(TypeInfo);
95113
96114/// This data structure is used by the Zig language code generation and
......@@ -253,17 +271,6 @@ pub const TypeInfo = union(enum) {
253271 decls: []Declaration,
254272 };
255273
256 /// This data structure is used by the Zig language code generation and
257 /// therefore must be kept in sync with the compiler implementation.
258 pub const CallingConvention = enum {
259 Unspecified,
260 C,
261 Cold,
262 Naked,
263 Stdcall,
264 Async,
265 };
266
267274 /// This data structure is used by the Zig language code generation and
268275 /// therefore must be kept in sync with the compiler implementation.
269276 pub const FnArg = struct {
......@@ -416,7 +423,7 @@ pub const CallOptions = struct {
416423/// therefore must be kept in sync with the compiler implementation.
417424pub const TestFn = struct {
418425 name: []const u8,
419 func: fn()anyerror!void,
426 func: fn () anyerror!void,
420427};
421428
422429/// This function type is used by the Zig language code generation and
lib/std/debug.zig+1-1
......@@ -2475,7 +2475,7 @@ extern fn handleSegfaultLinux(sig: i32, info: *const os.siginfo_t, ctx_ptr: *con
24752475 os.abort();
24762476}
24772477
2478stdcallcc fn handleSegfaultWindows(info: *windows.EXCEPTION_POINTERS) c_long {
2478fn handleSegfaultWindows(info: *windows.EXCEPTION_POINTERS) callconv(.Stdcall) c_long {
24792479 const exception_address = @ptrToInt(info.ExceptionRecord.ExceptionAddress);
24802480 switch (info.ExceptionRecord.ExceptionCode) {
24812481 windows.EXCEPTION_DATATYPE_MISALIGNMENT => panicExtra(null, exception_address, "Unaligned Memory Access", .{}),
lib/std/fs.zig+1-1
......@@ -230,7 +230,7 @@ pub const AtomicFile = struct {
230230 b64_fs_encoder.encode(tmp_path_slice[dirname_component_len..tmp_path_len], &rand_buf);
231231
232232 const file = my_cwd.createFileC(
233 tmp_path_slice,
233 tmp_path_slice,
234234 .{ .mode = mode, .exclusive = true },
235235 ) catch |err| switch (err) {
236236 error.PathAlreadyExists => continue,
lib/std/mutex.zig+14-13
......@@ -48,8 +48,8 @@ pub const Mutex = if (builtin.single_threaded)
4848 return self.tryAcquire() orelse @panic("deadlock detected");
4949 }
5050 }
51else if (builtin.os == .windows)
52 // https://locklessinc.com/articles/keyed_events/
51else if (builtin.os == .windows)
52// https://locklessinc.com/articles/keyed_events/
5353 extern union {
5454 locked: u8,
5555 waiters: u32,
......@@ -97,8 +97,8 @@ else if (builtin.os == .windows)
9797 return Held{ .mutex = self };
9898 }
9999
100 // otherwise, try and update the waiting count.
101 // then unset the WAKE bit so that another unlocker can wake up a thread.
100 // otherwise, try and update the waiting count.
101 // then unset the WAKE bit so that another unlocker can wake up a thread.
102102 } else if (@cmpxchgWeak(u32, &self.waiters, waiters, (waiters + WAIT) | 1, .Monotonic, .Monotonic) == null) {
103103 const rc = windows.ntdll.NtWaitForKeyedEvent(handle, key, windows.FALSE, null);
104104 assert(rc == 0);
......@@ -118,7 +118,7 @@ else if (builtin.os == .windows)
118118
119119 while (true) : (SpinLock.loopHint(1)) {
120120 const waiters = @atomicLoad(u32, &self.mutex.waiters, .Monotonic);
121
121
122122 // no one is waiting
123123 if (waiters < WAIT) return;
124124 // someone grabbed the lock and will do the wake instead
......@@ -130,14 +130,14 @@ else if (builtin.os == .windows)
130130 if (@cmpxchgWeak(u32, &self.mutex.waiters, waiters, waiters - WAIT + WAKE, .Release, .Monotonic) == null) {
131131 const rc = windows.ntdll.NtReleaseKeyedEvent(handle, key, windows.FALSE, null);
132132 assert(rc == 0);
133 return;
133 return;
134134 }
135135 }
136136 }
137137 };
138138 }
139139else if (builtin.link_libc or builtin.os == .linux)
140 // stack-based version of https://github.com/Amanieu/parking_lot/blob/master/core/src/word_lock.rs
140// stack-based version of https://github.com/Amanieu/parking_lot/blob/master/core/src/word_lock.rs
141141 struct {
142142 state: usize,
143143
......@@ -170,8 +170,8 @@ else if (builtin.link_libc or builtin.os == .linux)
170170
171171 pub fn acquire(self: *Mutex) Held {
172172 return self.tryAcquire() orelse {
173 self.acquireSlow();
174 return Held{ .mutex = self };
173 self.acquireSlow();
174 return Held{ .mutex = self };
175175 };
176176 }
177177
......@@ -237,7 +237,7 @@ else if (builtin.link_libc or builtin.os == .linux)
237237
238238 fn releaseSlow(self: *Mutex) void {
239239 @setCold(true);
240
240
241241 // try and lock the LFIO queue to pop a node off,
242242 // stopping altogether if its already locked or the queue is empty
243243 var state = @atomicLoad(usize, &self.state, .Monotonic);
......@@ -265,9 +265,10 @@ else if (builtin.link_libc or builtin.os == .linux)
265265 }
266266 }
267267
268// for platforms without a known OS blocking
269// primitive, default to SpinLock for correctness
270else SpinLock;
268 // for platforms without a known OS blocking
269 // primitive, default to SpinLock for correctness
270else
271 SpinLock;
271272
272273const TestContext = struct {
273274 mutex: *Mutex,
lib/std/net.zig+1-5
......@@ -451,11 +451,7 @@ pub fn getAddressList(allocator: *mem.Allocator, name: []const u8, port: u16) !*
451451 .next = null,
452452 };
453453 var res: *os.addrinfo = undefined;
454 switch (os.system.getaddrinfo(
455 name_c.ptr,
456 @ptrCast([*:0]const u8, port_c.ptr),
457 &hints,
458 &res)) {
454 switch (os.system.getaddrinfo(name_c.ptr, @ptrCast([*:0]const u8, port_c.ptr), &hints, &res)) {
459455 0 => {},
460456 c.EAI_ADDRFAMILY => return error.HostLacksNetworkAddresses,
461457 c.EAI_AGAIN => return error.TemporaryNameServerFailure,
lib/std/os/linux/arm-eabi.zig+2-2
......@@ -97,7 +97,7 @@ pub extern fn getThreadPointer() usize {
9797 );
9898}
9999
100pub nakedcc fn restore() void {
100pub fn restore() callconv(.Naked) void {
101101 return asm volatile ("svc #0"
102102 :
103103 : [number] "{r7}" (@as(usize, SYS_sigreturn))
......@@ -105,7 +105,7 @@ pub nakedcc fn restore() void {
105105 );
106106}
107107
108pub nakedcc fn restore_rt() void {
108pub fn restore_rt() callconv(.Naked) void {
109109 return asm volatile ("svc #0"
110110 :
111111 : [number] "{r7}" (@as(usize, SYS_rt_sigreturn))
lib/std/os/linux/arm64.zig+1-1
......@@ -90,7 +90,7 @@ pub extern fn clone(func: extern fn (arg: usize) u8, stack: usize, flags: u32, a
9090
9191pub const restore = restore_rt;
9292
93pub nakedcc fn restore_rt() void {
93pub fn restore_rt() callconv(.Naked) void {
9494 return asm volatile ("svc #0"
9595 :
9696 : [number] "{x8}" (@as(usize, SYS_rt_sigreturn))
lib/std/os/linux/i386.zig+2-2
......@@ -102,7 +102,7 @@ pub fn socketcall(call: usize, args: [*]usize) usize {
102102/// This matches the libc clone function.
103103pub extern fn clone(func: extern fn (arg: usize) u8, stack: usize, flags: u32, arg: usize, ptid: *i32, tls: usize, ctid: *i32) usize;
104104
105pub nakedcc fn restore() void {
105pub fn restore() callconv(.Naked) void {
106106 return asm volatile ("int $0x80"
107107 :
108108 : [number] "{eax}" (@as(usize, SYS_sigreturn))
......@@ -110,7 +110,7 @@ pub nakedcc fn restore() void {
110110 );
111111}
112112
113pub nakedcc fn restore_rt() void {
113pub fn restore_rt() callconv(.Naked) void {
114114 return asm volatile ("int $0x80"
115115 :
116116 : [number] "{eax}" (@as(usize, SYS_rt_sigreturn))
lib/std/os/linux/mipsel.zig+2-2
......@@ -144,7 +144,7 @@ pub fn syscall6(
144144/// This matches the libc clone function.
145145pub extern fn clone(func: extern fn (arg: usize) u8, stack: usize, flags: u32, arg: usize, ptid: *i32, tls: usize, ctid: *i32) usize;
146146
147pub nakedcc fn restore() void {
147pub fn restore() callconv(.Naked) void {
148148 return asm volatile ("syscall"
149149 :
150150 : [number] "{$2}" (@as(usize, SYS_sigreturn))
......@@ -152,7 +152,7 @@ pub nakedcc fn restore() void {
152152 );
153153}
154154
155pub nakedcc fn restore_rt() void {
155pub fn restore_rt() callconv(.Naked) void {
156156 return asm volatile ("syscall"
157157 :
158158 : [number] "{$2}" (@as(usize, SYS_rt_sigreturn))
lib/std/os/linux/riscv64.zig+1-1
......@@ -89,7 +89,7 @@ pub extern fn clone(func: extern fn (arg: usize) u8, stack: usize, flags: u32, a
8989
9090pub const restore = restore_rt;
9191
92pub nakedcc fn restore_rt() void {
92pub fn restore_rt() callconv(.Naked) void {
9393 return asm volatile ("ecall"
9494 :
9595 : [number] "{x17}" (@as(usize, SYS_rt_sigreturn))
lib/std/os/linux/x86_64.zig+1-1
......@@ -90,7 +90,7 @@ pub extern fn clone(func: extern fn (arg: usize) u8, stack: usize, flags: usize,
9090
9191pub const restore = restore_rt;
9292
93pub nakedcc fn restore_rt() void {
93pub fn restore_rt() callconv(.Naked) void {
9494 return asm volatile ("syscall"
9595 :
9696 : [number] "{rax}" (@as(usize, SYS_rt_sigreturn))
lib/std/os/test.zig+1-1
......@@ -166,7 +166,7 @@ test "sigaltstack" {
166166// analyzed
167167const dl_phdr_info = if (@hasDecl(os, "dl_phdr_info")) os.dl_phdr_info else c_void;
168168
169export fn iter_fn(info: *dl_phdr_info, size: usize, data: ?*usize) i32 {
169extern fn iter_fn(info: *dl_phdr_info, size: usize, data: ?*usize) i32 {
170170 if (builtin.os == .windows or builtin.os == .wasi or builtin.os == .macosx)
171171 return 0;
172172
lib/std/os/uefi/protocols/simple_text_input_protocol.zig-1
......@@ -27,4 +27,3 @@ pub const SimpleTextInputProtocol = extern struct {
2727 .node = [_]u8{ 0x00, 0xa0, 0xc9, 0x69, 0x72, 0x3b },
2828 };
2929};
30
lib/std/os/windows/advapi32.zig+5-5
......@@ -1,23 +1,23 @@
11usingnamespace @import("bits.zig");
22
3pub extern "advapi32" stdcallcc fn RegOpenKeyExW(
3pub extern "advapi32" fn RegOpenKeyExW(
44 hKey: HKEY,
55 lpSubKey: LPCWSTR,
66 ulOptions: DWORD,
77 samDesired: REGSAM,
88 phkResult: *HKEY,
9) LSTATUS;
9) callconv(.Stdcall) LSTATUS;
1010
11pub extern "advapi32" stdcallcc fn RegQueryValueExW(
11pub extern "advapi32" fn RegQueryValueExW(
1212 hKey: HKEY,
1313 lpValueName: LPCWSTR,
1414 lpReserved: LPDWORD,
1515 lpType: LPDWORD,
1616 lpData: LPBYTE,
1717 lpcbData: LPDWORD,
18) LSTATUS;
18) callconv(.Stdcall) LSTATUS;
1919
2020// RtlGenRandom is known as SystemFunction036 under advapi32
2121// http://msdn.microsoft.com/en-us/library/windows/desktop/aa387694.aspx */
22pub extern "advapi32" stdcallcc fn SystemFunction036(output: [*]u8, length: ULONG) BOOL;
22pub extern "advapi32" fn SystemFunction036(output: [*]u8, length: ULONG) callconv(.Stdcall) BOOL;
2323pub const RtlGenRandom = SystemFunction036;
lib/std/os/windows/bits.zig+1-1
......@@ -892,7 +892,7 @@ pub const EXCEPTION_POINTERS = extern struct {
892892 ContextRecord: *c_void,
893893};
894894
895pub const VECTORED_EXCEPTION_HANDLER = stdcallcc fn (ExceptionInfo: *EXCEPTION_POINTERS) c_long;
895pub const VECTORED_EXCEPTION_HANDLER = fn (ExceptionInfo: *EXCEPTION_POINTERS) callconv(.Stdcall) c_long;
896896
897897pub const OBJECT_ATTRIBUTES = extern struct {
898898 Length: ULONG,
lib/std/os/windows/kernel32.zig+100-100
......@@ -1,22 +1,22 @@
11usingnamespace @import("bits.zig");
22
3pub extern "kernel32" stdcallcc fn AddVectoredExceptionHandler(First: c_ulong, Handler: ?VECTORED_EXCEPTION_HANDLER) ?*c_void;
4pub extern "kernel32" stdcallcc fn RemoveVectoredExceptionHandler(Handle: HANDLE) c_ulong;
3pub extern "kernel32" fn AddVectoredExceptionHandler(First: c_ulong, Handler: ?VECTORED_EXCEPTION_HANDLER) callconv(.Stdcall) ?*c_void;
4pub extern "kernel32" fn RemoveVectoredExceptionHandler(Handle: HANDLE) callconv(.Stdcall) c_ulong;
55
6pub extern "kernel32" stdcallcc fn CancelIoEx(hFile: HANDLE, lpOverlapped: LPOVERLAPPED) BOOL;
6pub extern "kernel32" fn CancelIoEx(hFile: HANDLE, lpOverlapped: LPOVERLAPPED) callconv(.Stdcall) BOOL;
77
8pub extern "kernel32" stdcallcc fn CloseHandle(hObject: HANDLE) BOOL;
8pub extern "kernel32" fn CloseHandle(hObject: HANDLE) callconv(.Stdcall) BOOL;
99
10pub extern "kernel32" stdcallcc fn CreateDirectoryW(lpPathName: [*]const u16, lpSecurityAttributes: ?*SECURITY_ATTRIBUTES) BOOL;
10pub extern "kernel32" fn CreateDirectoryW(lpPathName: [*]const u16, lpSecurityAttributes: ?*SECURITY_ATTRIBUTES) callconv(.Stdcall) BOOL;
1111
12pub extern "kernel32" stdcallcc fn CreateEventExW(
12pub extern "kernel32" fn CreateEventExW(
1313 lpEventAttributes: ?*SECURITY_ATTRIBUTES,
1414 lpName: [*:0]const u16,
1515 dwFlags: DWORD,
1616 dwDesiredAccess: DWORD,
17) ?HANDLE;
17) callconv(.Stdcall) ?HANDLE;
1818
19pub extern "kernel32" stdcallcc fn CreateFileW(
19pub extern "kernel32" fn CreateFileW(
2020 lpFileName: [*]const u16, // TODO null terminated pointer type
2121 dwDesiredAccess: DWORD,
2222 dwShareMode: DWORD,
......@@ -24,16 +24,16 @@ pub extern "kernel32" stdcallcc fn CreateFileW(
2424 dwCreationDisposition: DWORD,
2525 dwFlagsAndAttributes: DWORD,
2626 hTemplateFile: ?HANDLE,
27) HANDLE;
27) callconv(.Stdcall) HANDLE;
2828
29pub extern "kernel32" stdcallcc fn CreatePipe(
29pub extern "kernel32" fn CreatePipe(
3030 hReadPipe: *HANDLE,
3131 hWritePipe: *HANDLE,
3232 lpPipeAttributes: *const SECURITY_ATTRIBUTES,
3333 nSize: DWORD,
34) BOOL;
34) callconv(.Stdcall) BOOL;
3535
36pub extern "kernel32" stdcallcc fn CreateProcessW(
36pub extern "kernel32" fn CreateProcessW(
3737 lpApplicationName: ?LPWSTR,
3838 lpCommandLine: LPWSTR,
3939 lpProcessAttributes: ?*SECURITY_ATTRIBUTES,
......@@ -44,15 +44,15 @@ pub extern "kernel32" stdcallcc fn CreateProcessW(
4444 lpCurrentDirectory: ?LPWSTR,
4545 lpStartupInfo: *STARTUPINFOW,
4646 lpProcessInformation: *PROCESS_INFORMATION,
47) BOOL;
47) callconv(.Stdcall) BOOL;
4848
49pub extern "kernel32" stdcallcc fn CreateSymbolicLinkW(lpSymlinkFileName: [*]const u16, lpTargetFileName: [*]const u16, dwFlags: DWORD) BOOLEAN;
49pub extern "kernel32" fn CreateSymbolicLinkW(lpSymlinkFileName: [*]const u16, lpTargetFileName: [*]const u16, dwFlags: DWORD) callconv(.Stdcall) BOOLEAN;
5050
51pub extern "kernel32" stdcallcc fn CreateIoCompletionPort(FileHandle: HANDLE, ExistingCompletionPort: ?HANDLE, CompletionKey: ULONG_PTR, NumberOfConcurrentThreads: DWORD) ?HANDLE;
51pub extern "kernel32" fn CreateIoCompletionPort(FileHandle: HANDLE, ExistingCompletionPort: ?HANDLE, CompletionKey: ULONG_PTR, NumberOfConcurrentThreads: DWORD) callconv(.Stdcall) ?HANDLE;
5252
53pub extern "kernel32" stdcallcc fn CreateThread(lpThreadAttributes: ?LPSECURITY_ATTRIBUTES, dwStackSize: SIZE_T, lpStartAddress: LPTHREAD_START_ROUTINE, lpParameter: ?LPVOID, dwCreationFlags: DWORD, lpThreadId: ?LPDWORD) ?HANDLE;
53pub extern "kernel32" fn CreateThread(lpThreadAttributes: ?LPSECURITY_ATTRIBUTES, dwStackSize: SIZE_T, lpStartAddress: LPTHREAD_START_ROUTINE, lpParameter: ?LPVOID, dwCreationFlags: DWORD, lpThreadId: ?LPDWORD) callconv(.Stdcall) ?HANDLE;
5454
55pub extern "kernel32" stdcallcc fn DeviceIoControl(
55pub extern "kernel32" fn DeviceIoControl(
5656 h: HANDLE,
5757 dwIoControlCode: DWORD,
5858 lpInBuffer: ?*const c_void,
......@@ -61,107 +61,107 @@ pub extern "kernel32" stdcallcc fn DeviceIoControl(
6161 nOutBufferSize: DWORD,
6262 lpBytesReturned: ?*DWORD,
6363 lpOverlapped: ?*OVERLAPPED,
64) BOOL;
64) callconv(.Stdcall) BOOL;
6565
66pub extern "kernel32" stdcallcc fn DeleteFileW(lpFileName: [*]const u16) BOOL;
66pub extern "kernel32" fn DeleteFileW(lpFileName: [*]const u16) callconv(.Stdcall) BOOL;
6767
68pub extern "kernel32" stdcallcc fn DuplicateHandle(hSourceProcessHandle: HANDLE, hSourceHandle: HANDLE, hTargetProcessHandle: HANDLE, lpTargetHandle: *HANDLE, dwDesiredAccess: DWORD, bInheritHandle: BOOL, dwOptions: DWORD) BOOL;
68pub extern "kernel32" fn DuplicateHandle(hSourceProcessHandle: HANDLE, hSourceHandle: HANDLE, hTargetProcessHandle: HANDLE, lpTargetHandle: *HANDLE, dwDesiredAccess: DWORD, bInheritHandle: BOOL, dwOptions: DWORD) callconv(.Stdcall) BOOL;
6969
70pub extern "kernel32" stdcallcc fn ExitProcess(exit_code: UINT) noreturn;
70pub extern "kernel32" fn ExitProcess(exit_code: UINT) callconv(.Stdcall) noreturn;
7171
72pub extern "kernel32" stdcallcc fn FindFirstFileW(lpFileName: [*]const u16, lpFindFileData: *WIN32_FIND_DATAW) HANDLE;
73pub extern "kernel32" stdcallcc fn FindClose(hFindFile: HANDLE) BOOL;
74pub extern "kernel32" stdcallcc fn FindNextFileW(hFindFile: HANDLE, lpFindFileData: *WIN32_FIND_DATAW) BOOL;
72pub extern "kernel32" fn FindFirstFileW(lpFileName: [*]const u16, lpFindFileData: *WIN32_FIND_DATAW) callconv(.Stdcall) HANDLE;
73pub extern "kernel32" fn FindClose(hFindFile: HANDLE) callconv(.Stdcall) BOOL;
74pub extern "kernel32" fn FindNextFileW(hFindFile: HANDLE, lpFindFileData: *WIN32_FIND_DATAW) callconv(.Stdcall) BOOL;
7575
76pub extern "kernel32" stdcallcc fn FormatMessageW(dwFlags: DWORD, lpSource: ?LPVOID, dwMessageId: DWORD, dwLanguageId: DWORD, lpBuffer: LPWSTR, nSize: DWORD, Arguments: ?*va_list) DWORD;
76pub extern "kernel32" fn FormatMessageW(dwFlags: DWORD, lpSource: ?LPVOID, dwMessageId: DWORD, dwLanguageId: DWORD, lpBuffer: LPWSTR, nSize: DWORD, Arguments: ?*va_list) callconv(.Stdcall) DWORD;
7777
78pub extern "kernel32" stdcallcc fn FreeEnvironmentStringsW(penv: [*]u16) BOOL;
78pub extern "kernel32" fn FreeEnvironmentStringsW(penv: [*]u16) callconv(.Stdcall) BOOL;
7979
80pub extern "kernel32" stdcallcc fn GetCommandLineA() LPSTR;
80pub extern "kernel32" fn GetCommandLineA() callconv(.Stdcall) LPSTR;
8181
82pub extern "kernel32" stdcallcc fn GetConsoleMode(in_hConsoleHandle: HANDLE, out_lpMode: *DWORD) BOOL;
82pub extern "kernel32" fn GetConsoleMode(in_hConsoleHandle: HANDLE, out_lpMode: *DWORD) callconv(.Stdcall) BOOL;
8383
84pub extern "kernel32" stdcallcc fn GetConsoleScreenBufferInfo(hConsoleOutput: HANDLE, lpConsoleScreenBufferInfo: *CONSOLE_SCREEN_BUFFER_INFO) BOOL;
84pub extern "kernel32" fn GetConsoleScreenBufferInfo(hConsoleOutput: HANDLE, lpConsoleScreenBufferInfo: *CONSOLE_SCREEN_BUFFER_INFO) callconv(.Stdcall) BOOL;
8585
86pub extern "kernel32" stdcallcc fn GetCurrentDirectoryW(nBufferLength: DWORD, lpBuffer: ?[*]WCHAR) DWORD;
86pub extern "kernel32" fn GetCurrentDirectoryW(nBufferLength: DWORD, lpBuffer: ?[*]WCHAR) callconv(.Stdcall) DWORD;
8787
88pub extern "kernel32" stdcallcc fn GetCurrentThread() HANDLE;
89pub extern "kernel32" stdcallcc fn GetCurrentThreadId() DWORD;
88pub extern "kernel32" fn GetCurrentThread() callconv(.Stdcall) HANDLE;
89pub extern "kernel32" fn GetCurrentThreadId() callconv(.Stdcall) DWORD;
9090
91pub extern "kernel32" stdcallcc fn GetEnvironmentStringsW() ?[*]u16;
91pub extern "kernel32" fn GetEnvironmentStringsW() callconv(.Stdcall) ?[*]u16;
9292
93pub extern "kernel32" stdcallcc fn GetEnvironmentVariableW(lpName: LPWSTR, lpBuffer: LPWSTR, nSize: DWORD) DWORD;
93pub extern "kernel32" fn GetEnvironmentVariableW(lpName: LPWSTR, lpBuffer: LPWSTR, nSize: DWORD) callconv(.Stdcall) DWORD;
9494
95pub extern "kernel32" stdcallcc fn GetExitCodeProcess(hProcess: HANDLE, lpExitCode: *DWORD) BOOL;
95pub extern "kernel32" fn GetExitCodeProcess(hProcess: HANDLE, lpExitCode: *DWORD) callconv(.Stdcall) BOOL;
9696
97pub extern "kernel32" stdcallcc fn GetFileSizeEx(hFile: HANDLE, lpFileSize: *LARGE_INTEGER) BOOL;
97pub extern "kernel32" fn GetFileSizeEx(hFile: HANDLE, lpFileSize: *LARGE_INTEGER) callconv(.Stdcall) BOOL;
9898
99pub extern "kernel32" stdcallcc fn GetFileAttributesW(lpFileName: [*]const WCHAR) DWORD;
99pub extern "kernel32" fn GetFileAttributesW(lpFileName: [*]const WCHAR) callconv(.Stdcall) DWORD;
100100
101pub extern "kernel32" stdcallcc fn GetModuleFileNameW(hModule: ?HMODULE, lpFilename: [*]u16, nSize: DWORD) DWORD;
101pub extern "kernel32" fn GetModuleFileNameW(hModule: ?HMODULE, lpFilename: [*]u16, nSize: DWORD) callconv(.Stdcall) DWORD;
102102
103pub extern "kernel32" stdcallcc fn GetModuleHandleW(lpModuleName: ?[*]const WCHAR) HMODULE;
103pub extern "kernel32" fn GetModuleHandleW(lpModuleName: ?[*]const WCHAR) callconv(.Stdcall) HMODULE;
104104
105pub extern "kernel32" stdcallcc fn GetLastError() DWORD;
105pub extern "kernel32" fn GetLastError() callconv(.Stdcall) DWORD;
106106
107pub extern "kernel32" stdcallcc fn GetFileInformationByHandle(
107pub extern "kernel32" fn GetFileInformationByHandle(
108108 hFile: HANDLE,
109109 lpFileInformation: *BY_HANDLE_FILE_INFORMATION,
110) BOOL;
110) callconv(.Stdcall) BOOL;
111111
112pub extern "kernel32" stdcallcc fn GetFileInformationByHandleEx(
112pub extern "kernel32" fn GetFileInformationByHandleEx(
113113 in_hFile: HANDLE,
114114 in_FileInformationClass: FILE_INFO_BY_HANDLE_CLASS,
115115 out_lpFileInformation: *c_void,
116116 in_dwBufferSize: DWORD,
117) BOOL;
117) callconv(.Stdcall) BOOL;
118118
119pub extern "kernel32" stdcallcc fn GetFinalPathNameByHandleW(
119pub extern "kernel32" fn GetFinalPathNameByHandleW(
120120 hFile: HANDLE,
121121 lpszFilePath: [*]u16,
122122 cchFilePath: DWORD,
123123 dwFlags: DWORD,
124) DWORD;
124) callconv(.Stdcall) DWORD;
125125
126pub extern "kernel32" stdcallcc fn GetOverlappedResult(hFile: HANDLE, lpOverlapped: *OVERLAPPED, lpNumberOfBytesTransferred: *DWORD, bWait: BOOL) BOOL;
126pub extern "kernel32" fn GetOverlappedResult(hFile: HANDLE, lpOverlapped: *OVERLAPPED, lpNumberOfBytesTransferred: *DWORD, bWait: BOOL) callconv(.Stdcall) BOOL;
127127
128pub extern "kernel32" stdcallcc fn GetProcessHeap() ?HANDLE;
129pub extern "kernel32" stdcallcc fn GetQueuedCompletionStatus(CompletionPort: HANDLE, lpNumberOfBytesTransferred: LPDWORD, lpCompletionKey: *ULONG_PTR, lpOverlapped: *?*OVERLAPPED, dwMilliseconds: DWORD) BOOL;
128pub extern "kernel32" fn GetProcessHeap() callconv(.Stdcall) ?HANDLE;
129pub extern "kernel32" fn GetQueuedCompletionStatus(CompletionPort: HANDLE, lpNumberOfBytesTransferred: LPDWORD, lpCompletionKey: *ULONG_PTR, lpOverlapped: *?*OVERLAPPED, dwMilliseconds: DWORD) callconv(.Stdcall) BOOL;
130130
131pub extern "kernel32" stdcallcc fn GetSystemInfo(lpSystemInfo: *SYSTEM_INFO) void;
132pub extern "kernel32" stdcallcc fn GetSystemTimeAsFileTime(*FILETIME) void;
131pub extern "kernel32" fn GetSystemInfo(lpSystemInfo: *SYSTEM_INFO) callconv(.Stdcall) void;
132pub extern "kernel32" fn GetSystemTimeAsFileTime(*FILETIME) callconv(.Stdcall) void;
133133
134pub extern "kernel32" stdcallcc fn HeapCreate(flOptions: DWORD, dwInitialSize: SIZE_T, dwMaximumSize: SIZE_T) ?HANDLE;
135pub extern "kernel32" stdcallcc fn HeapDestroy(hHeap: HANDLE) BOOL;
136pub extern "kernel32" stdcallcc fn HeapReAlloc(hHeap: HANDLE, dwFlags: DWORD, lpMem: *c_void, dwBytes: SIZE_T) ?*c_void;
137pub extern "kernel32" stdcallcc fn HeapSize(hHeap: HANDLE, dwFlags: DWORD, lpMem: *const c_void) SIZE_T;
138pub extern "kernel32" stdcallcc fn HeapCompact(hHeap: HANDLE, dwFlags: DWORD) SIZE_T;
139pub extern "kernel32" stdcallcc fn HeapSummary(hHeap: HANDLE, dwFlags: DWORD, lpSummary: LPHEAP_SUMMARY) BOOL;
134pub extern "kernel32" fn HeapCreate(flOptions: DWORD, dwInitialSize: SIZE_T, dwMaximumSize: SIZE_T) callconv(.Stdcall) ?HANDLE;
135pub extern "kernel32" fn HeapDestroy(hHeap: HANDLE) callconv(.Stdcall) BOOL;
136pub extern "kernel32" fn HeapReAlloc(hHeap: HANDLE, dwFlags: DWORD, lpMem: *c_void, dwBytes: SIZE_T) callconv(.Stdcall) ?*c_void;
137pub extern "kernel32" fn HeapSize(hHeap: HANDLE, dwFlags: DWORD, lpMem: *const c_void) callconv(.Stdcall) SIZE_T;
138pub extern "kernel32" fn HeapCompact(hHeap: HANDLE, dwFlags: DWORD) callconv(.Stdcall) SIZE_T;
139pub extern "kernel32" fn HeapSummary(hHeap: HANDLE, dwFlags: DWORD, lpSummary: LPHEAP_SUMMARY) callconv(.Stdcall) BOOL;
140140
141pub extern "kernel32" stdcallcc fn GetStdHandle(in_nStdHandle: DWORD) ?HANDLE;
141pub extern "kernel32" fn GetStdHandle(in_nStdHandle: DWORD) callconv(.Stdcall) ?HANDLE;
142142
143pub extern "kernel32" stdcallcc fn HeapAlloc(hHeap: HANDLE, dwFlags: DWORD, dwBytes: SIZE_T) ?*c_void;
143pub extern "kernel32" fn HeapAlloc(hHeap: HANDLE, dwFlags: DWORD, dwBytes: SIZE_T) callconv(.Stdcall) ?*c_void;
144144
145pub extern "kernel32" stdcallcc fn HeapFree(hHeap: HANDLE, dwFlags: DWORD, lpMem: *c_void) BOOL;
145pub extern "kernel32" fn HeapFree(hHeap: HANDLE, dwFlags: DWORD, lpMem: *c_void) callconv(.Stdcall) BOOL;
146146
147pub extern "kernel32" stdcallcc fn HeapValidate(hHeap: HANDLE, dwFlags: DWORD, lpMem: ?*const c_void) BOOL;
147pub extern "kernel32" fn HeapValidate(hHeap: HANDLE, dwFlags: DWORD, lpMem: ?*const c_void) callconv(.Stdcall) BOOL;
148148
149pub extern "kernel32" stdcallcc fn VirtualAlloc(lpAddress: ?LPVOID, dwSize: SIZE_T, flAllocationType: DWORD, flProtect: DWORD) ?LPVOID;
150pub extern "kernel32" stdcallcc fn VirtualFree(lpAddress: ?LPVOID, dwSize: SIZE_T, dwFreeType: DWORD) BOOL;
149pub extern "kernel32" fn VirtualAlloc(lpAddress: ?LPVOID, dwSize: SIZE_T, flAllocationType: DWORD, flProtect: DWORD) callconv(.Stdcall) ?LPVOID;
150pub extern "kernel32" fn VirtualFree(lpAddress: ?LPVOID, dwSize: SIZE_T, dwFreeType: DWORD) callconv(.Stdcall) BOOL;
151151
152pub extern "kernel32" stdcallcc fn MoveFileExW(
152pub extern "kernel32" fn MoveFileExW(
153153 lpExistingFileName: [*]const u16,
154154 lpNewFileName: [*]const u16,
155155 dwFlags: DWORD,
156) BOOL;
156) callconv(.Stdcall) BOOL;
157157
158pub extern "kernel32" stdcallcc fn PostQueuedCompletionStatus(CompletionPort: HANDLE, dwNumberOfBytesTransferred: DWORD, dwCompletionKey: ULONG_PTR, lpOverlapped: ?*OVERLAPPED) BOOL;
158pub extern "kernel32" fn PostQueuedCompletionStatus(CompletionPort: HANDLE, dwNumberOfBytesTransferred: DWORD, dwCompletionKey: ULONG_PTR, lpOverlapped: ?*OVERLAPPED) callconv(.Stdcall) BOOL;
159159
160pub extern "kernel32" stdcallcc fn QueryPerformanceCounter(lpPerformanceCount: *LARGE_INTEGER) BOOL;
160pub extern "kernel32" fn QueryPerformanceCounter(lpPerformanceCount: *LARGE_INTEGER) callconv(.Stdcall) BOOL;
161161
162pub extern "kernel32" stdcallcc fn QueryPerformanceFrequency(lpFrequency: *LARGE_INTEGER) BOOL;
162pub extern "kernel32" fn QueryPerformanceFrequency(lpFrequency: *LARGE_INTEGER) callconv(.Stdcall) BOOL;
163163
164pub extern "kernel32" stdcallcc fn ReadDirectoryChangesW(
164pub extern "kernel32" fn ReadDirectoryChangesW(
165165 hDirectory: HANDLE,
166166 lpBuffer: [*]align(@alignOf(FILE_NOTIFY_INFORMATION)) u8,
167167 nBufferLength: DWORD,
......@@ -170,79 +170,79 @@ pub extern "kernel32" stdcallcc fn ReadDirectoryChangesW(
170170 lpBytesReturned: ?*DWORD,
171171 lpOverlapped: ?*OVERLAPPED,
172172 lpCompletionRoutine: LPOVERLAPPED_COMPLETION_ROUTINE,
173) BOOL;
173) callconv(.Stdcall) BOOL;
174174
175pub extern "kernel32" stdcallcc fn ReadFile(
175pub extern "kernel32" fn ReadFile(
176176 in_hFile: HANDLE,
177177 out_lpBuffer: [*]u8,
178178 in_nNumberOfBytesToRead: DWORD,
179179 out_lpNumberOfBytesRead: ?*DWORD,
180180 in_out_lpOverlapped: ?*OVERLAPPED,
181) BOOL;
181) callconv(.Stdcall) BOOL;
182182
183pub extern "kernel32" stdcallcc fn RemoveDirectoryW(lpPathName: [*]const u16) BOOL;
183pub extern "kernel32" fn RemoveDirectoryW(lpPathName: [*]const u16) callconv(.Stdcall) BOOL;
184184
185pub extern "kernel32" stdcallcc fn SetConsoleTextAttribute(hConsoleOutput: HANDLE, wAttributes: WORD) BOOL;
185pub extern "kernel32" fn SetConsoleTextAttribute(hConsoleOutput: HANDLE, wAttributes: WORD) callconv(.Stdcall) BOOL;
186186
187pub extern "kernel32" stdcallcc fn SetFilePointerEx(
187pub extern "kernel32" fn SetFilePointerEx(
188188 in_fFile: HANDLE,
189189 in_liDistanceToMove: LARGE_INTEGER,
190190 out_opt_ldNewFilePointer: ?*LARGE_INTEGER,
191191 in_dwMoveMethod: DWORD,
192) BOOL;
192) callconv(.Stdcall) BOOL;
193193
194pub extern "kernel32" stdcallcc fn SetFileTime(
194pub extern "kernel32" fn SetFileTime(
195195 hFile: HANDLE,
196196 lpCreationTime: ?*const FILETIME,
197197 lpLastAccessTime: ?*const FILETIME,
198198 lpLastWriteTime: ?*const FILETIME,
199) BOOL;
199) callconv(.Stdcall) BOOL;
200200
201pub extern "kernel32" stdcallcc fn SetHandleInformation(hObject: HANDLE, dwMask: DWORD, dwFlags: DWORD) BOOL;
201pub extern "kernel32" fn SetHandleInformation(hObject: HANDLE, dwMask: DWORD, dwFlags: DWORD) callconv(.Stdcall) BOOL;
202202
203pub extern "kernel32" stdcallcc fn Sleep(dwMilliseconds: DWORD) void;
203pub extern "kernel32" fn Sleep(dwMilliseconds: DWORD) callconv(.Stdcall) void;
204204
205pub extern "kernel32" stdcallcc fn SwitchToThread() BOOL;
205pub extern "kernel32" fn SwitchToThread() callconv(.Stdcall) BOOL;
206206
207pub extern "kernel32" stdcallcc fn TerminateProcess(hProcess: HANDLE, uExitCode: UINT) BOOL;
207pub extern "kernel32" fn TerminateProcess(hProcess: HANDLE, uExitCode: UINT) callconv(.Stdcall) BOOL;
208208
209pub extern "kernel32" stdcallcc fn TlsAlloc() DWORD;
209pub extern "kernel32" fn TlsAlloc() callconv(.Stdcall) DWORD;
210210
211pub extern "kernel32" stdcallcc fn TlsFree(dwTlsIndex: DWORD) BOOL;
211pub extern "kernel32" fn TlsFree(dwTlsIndex: DWORD) callconv(.Stdcall) BOOL;
212212
213pub extern "kernel32" stdcallcc fn WaitForSingleObject(hHandle: HANDLE, dwMilliseconds: DWORD) DWORD;
213pub extern "kernel32" fn WaitForSingleObject(hHandle: HANDLE, dwMilliseconds: DWORD) callconv(.Stdcall) DWORD;
214214
215pub extern "kernel32" stdcallcc fn WaitForSingleObjectEx(hHandle: HANDLE, dwMilliseconds: DWORD, bAlertable: BOOL) DWORD;
215pub extern "kernel32" fn WaitForSingleObjectEx(hHandle: HANDLE, dwMilliseconds: DWORD, bAlertable: BOOL) callconv(.Stdcall) DWORD;
216216
217pub extern "kernel32" stdcallcc fn WaitForMultipleObjects(nCount: DWORD, lpHandle: [*]const HANDLE, bWaitAll: BOOL, dwMilliseconds: DWORD) DWORD;
217pub extern "kernel32" fn WaitForMultipleObjects(nCount: DWORD, lpHandle: [*]const HANDLE, bWaitAll: BOOL, dwMilliseconds: DWORD) callconv(.Stdcall) DWORD;
218218
219pub extern "kernel32" stdcallcc fn WaitForMultipleObjectsEx(
219pub extern "kernel32" fn WaitForMultipleObjectsEx(
220220 nCount: DWORD,
221221 lpHandle: [*]const HANDLE,
222222 bWaitAll: BOOL,
223223 dwMilliseconds: DWORD,
224224 bAlertable: BOOL,
225) DWORD;
225) callconv(.Stdcall) DWORD;
226226
227pub extern "kernel32" stdcallcc fn WriteFile(
227pub extern "kernel32" fn WriteFile(
228228 in_hFile: HANDLE,
229229 in_lpBuffer: [*]const u8,
230230 in_nNumberOfBytesToWrite: DWORD,
231231 out_lpNumberOfBytesWritten: ?*DWORD,
232232 in_out_lpOverlapped: ?*OVERLAPPED,
233) BOOL;
233) callconv(.Stdcall) BOOL;
234234
235pub extern "kernel32" stdcallcc fn WriteFileEx(hFile: HANDLE, lpBuffer: [*]const u8, nNumberOfBytesToWrite: DWORD, lpOverlapped: LPOVERLAPPED, lpCompletionRoutine: LPOVERLAPPED_COMPLETION_ROUTINE) BOOL;
235pub extern "kernel32" fn WriteFileEx(hFile: HANDLE, lpBuffer: [*]const u8, nNumberOfBytesToWrite: DWORD, lpOverlapped: LPOVERLAPPED, lpCompletionRoutine: LPOVERLAPPED_COMPLETION_ROUTINE) callconv(.Stdcall) BOOL;
236236
237pub extern "kernel32" stdcallcc fn LoadLibraryW(lpLibFileName: [*]const u16) ?HMODULE;
237pub extern "kernel32" fn LoadLibraryW(lpLibFileName: [*]const u16) callconv(.Stdcall) ?HMODULE;
238238
239pub extern "kernel32" stdcallcc fn GetProcAddress(hModule: HMODULE, lpProcName: [*]const u8) ?FARPROC;
239pub extern "kernel32" fn GetProcAddress(hModule: HMODULE, lpProcName: [*]const u8) callconv(.Stdcall) ?FARPROC;
240240
241pub extern "kernel32" stdcallcc fn FreeLibrary(hModule: HMODULE) BOOL;
241pub extern "kernel32" fn FreeLibrary(hModule: HMODULE) callconv(.Stdcall) BOOL;
242242
243pub extern "kernel32" stdcallcc fn InitializeCriticalSection(lpCriticalSection: *CRITICAL_SECTION) void;
244pub extern "kernel32" stdcallcc fn EnterCriticalSection(lpCriticalSection: *CRITICAL_SECTION) void;
245pub extern "kernel32" stdcallcc fn LeaveCriticalSection(lpCriticalSection: *CRITICAL_SECTION) void;
246pub extern "kernel32" stdcallcc fn DeleteCriticalSection(lpCriticalSection: *CRITICAL_SECTION) void;
243pub extern "kernel32" fn InitializeCriticalSection(lpCriticalSection: *CRITICAL_SECTION) callconv(.Stdcall) void;
244pub extern "kernel32" fn EnterCriticalSection(lpCriticalSection: *CRITICAL_SECTION) callconv(.Stdcall) void;
245pub extern "kernel32" fn LeaveCriticalSection(lpCriticalSection: *CRITICAL_SECTION) callconv(.Stdcall) void;
246pub extern "kernel32" fn DeleteCriticalSection(lpCriticalSection: *CRITICAL_SECTION) callconv(.Stdcall) void;
247247
248pub extern "kernel32" stdcallcc fn InitOnceExecuteOnce(InitOnce: *INIT_ONCE, InitFn: INIT_ONCE_FN, Parameter: ?*c_void, Context: ?*c_void) BOOL;
248pub extern "kernel32" fn InitOnceExecuteOnce(InitOnce: *INIT_ONCE, InitFn: INIT_ONCE_FN, Parameter: ?*c_void, Context: ?*c_void) callconv(.Stdcall) BOOL;
lib/std/os/windows/ntdll.zig+19-19
......@@ -1,14 +1,14 @@
11usingnamespace @import("bits.zig");
22
3pub extern "NtDll" stdcallcc fn RtlCaptureStackBackTrace(FramesToSkip: DWORD, FramesToCapture: DWORD, BackTrace: **c_void, BackTraceHash: ?*DWORD) WORD;
4pub extern "NtDll" stdcallcc fn NtQueryInformationFile(
3pub extern "NtDll" fn RtlCaptureStackBackTrace(FramesToSkip: DWORD, FramesToCapture: DWORD, BackTrace: **c_void, BackTraceHash: ?*DWORD) callconv(.Stdcall) WORD;
4pub extern "NtDll" fn NtQueryInformationFile(
55 FileHandle: HANDLE,
66 IoStatusBlock: *IO_STATUS_BLOCK,
77 FileInformation: *c_void,
88 Length: ULONG,
99 FileInformationClass: FILE_INFORMATION_CLASS,
10) NTSTATUS;
11pub extern "NtDll" stdcallcc fn NtCreateFile(
10) callconv(.Stdcall) NTSTATUS;
11pub extern "NtDll" fn NtCreateFile(
1212 FileHandle: *HANDLE,
1313 DesiredAccess: ACCESS_MASK,
1414 ObjectAttributes: *OBJECT_ATTRIBUTES,
......@@ -20,8 +20,8 @@ pub extern "NtDll" stdcallcc fn NtCreateFile(
2020 CreateOptions: ULONG,
2121 EaBuffer: ?*c_void,
2222 EaLength: ULONG,
23) NTSTATUS;
24pub extern "NtDll" stdcallcc fn NtDeviceIoControlFile(
23) callconv(.Stdcall) NTSTATUS;
24pub extern "NtDll" fn NtDeviceIoControlFile(
2525 FileHandle: HANDLE,
2626 Event: ?HANDLE,
2727 ApcRoutine: ?IO_APC_ROUTINE,
......@@ -32,17 +32,17 @@ pub extern "NtDll" stdcallcc fn NtDeviceIoControlFile(
3232 InputBufferLength: ULONG,
3333 OutputBuffer: ?PVOID,
3434 OutputBufferLength: ULONG,
35) NTSTATUS;
36pub extern "NtDll" stdcallcc fn NtClose(Handle: HANDLE) NTSTATUS;
37pub extern "NtDll" stdcallcc fn RtlDosPathNameToNtPathName_U(
35) callconv(.Stdcall) NTSTATUS;
36pub extern "NtDll" fn NtClose(Handle: HANDLE) callconv(.Stdcall) NTSTATUS;
37pub extern "NtDll" fn RtlDosPathNameToNtPathName_U(
3838 DosPathName: [*]const u16,
3939 NtPathName: *UNICODE_STRING,
4040 NtFileNamePart: ?*?[*]const u16,
4141 DirectoryInfo: ?*CURDIR,
42) BOOL;
43pub extern "NtDll" stdcallcc fn RtlFreeUnicodeString(UnicodeString: *UNICODE_STRING) void;
42) callconv(.Stdcall) BOOL;
43pub extern "NtDll" fn RtlFreeUnicodeString(UnicodeString: *UNICODE_STRING) callconv(.Stdcall) void;
4444
45pub extern "NtDll" stdcallcc fn NtQueryDirectoryFile(
45pub extern "NtDll" fn NtQueryDirectoryFile(
4646 FileHandle: HANDLE,
4747 Event: ?HANDLE,
4848 ApcRoutine: ?IO_APC_ROUTINE,
......@@ -54,22 +54,22 @@ pub extern "NtDll" stdcallcc fn NtQueryDirectoryFile(
5454 ReturnSingleEntry: BOOLEAN,
5555 FileName: ?*UNICODE_STRING,
5656 RestartScan: BOOLEAN,
57) NTSTATUS;
58pub extern "NtDll" stdcallcc fn NtCreateKeyedEvent(
57) callconv(.Stdcall) NTSTATUS;
58pub extern "NtDll" fn NtCreateKeyedEvent(
5959 KeyedEventHandle: *HANDLE,
6060 DesiredAccess: ACCESS_MASK,
6161 ObjectAttributes: ?PVOID,
6262 Flags: ULONG,
63) NTSTATUS;
64pub extern "NtDll" stdcallcc fn NtReleaseKeyedEvent(
63) callconv(.Stdcall) NTSTATUS;
64pub extern "NtDll" fn NtReleaseKeyedEvent(
6565 EventHandle: HANDLE,
6666 Key: *const c_void,
6767 Alertable: BOOLEAN,
6868 Timeout: ?*LARGE_INTEGER,
69) NTSTATUS;
70pub extern "NtDll" stdcallcc fn NtWaitForKeyedEvent(
69) callconv(.Stdcall) NTSTATUS;
70pub extern "NtDll" fn NtWaitForKeyedEvent(
7171 EventHandle: HANDLE,
7272 Key: *const c_void,
7373 Alertable: BOOLEAN,
7474 Timeout: ?*LARGE_INTEGER,
75) NTSTATUS;
75) callconv(.Stdcall) NTSTATUS;
lib/std/os/windows/ole32.zig+4-4
......@@ -1,6 +1,6 @@
11usingnamespace @import("bits.zig");
22
3pub extern "ole32" stdcallcc fn CoTaskMemFree(pv: LPVOID) void;
4pub extern "ole32" stdcallcc fn CoUninitialize() void;
5pub extern "ole32" stdcallcc fn CoGetCurrentProcess() DWORD;
6pub extern "ole32" stdcallcc fn CoInitializeEx(pvReserved: LPVOID, dwCoInit: DWORD) HRESULT;
3pub extern "ole32" fn CoTaskMemFree(pv: LPVOID) callconv(.Stdcall) void;
4pub extern "ole32" fn CoUninitialize() callconv(.Stdcall) void;
5pub extern "ole32" fn CoGetCurrentProcess() callconv(.Stdcall) DWORD;
6pub extern "ole32" fn CoInitializeEx(pvReserved: LPVOID, dwCoInit: DWORD) callconv(.Stdcall) HRESULT;
lib/std/os/windows/shell32.zig+1-1
......@@ -1,3 +1,3 @@
11usingnamespace @import("bits.zig");
22
3pub extern "shell32" stdcallcc fn SHGetKnownFolderPath(rfid: *const KNOWNFOLDERID, dwFlags: DWORD, hToken: ?HANDLE, ppszPath: *[*]WCHAR) HRESULT;
3pub extern "shell32" fn SHGetKnownFolderPath(rfid: *const KNOWNFOLDERID, dwFlags: DWORD, hToken: ?HANDLE, ppszPath: *[*]WCHAR) callconv(.Stdcall) HRESULT;
lib/std/os/windows/ws2_32.zig+23-23
......@@ -315,30 +315,30 @@ const IOC_WS2 = 0x08000000;
315315
316316pub const SIO_BASE_HANDLE = IOC_OUT | IOC_WS2 | 34;
317317
318pub extern "ws2_32" stdcallcc fn WSAStartup(
318pub extern "ws2_32" fn WSAStartup(
319319 wVersionRequired: WORD,
320320 lpWSAData: *WSADATA,
321) c_int;
322pub extern "ws2_32" stdcallcc fn WSACleanup() c_int;
323pub extern "ws2_32" stdcallcc fn WSAGetLastError() c_int;
324pub extern "ws2_32" stdcallcc fn WSASocketA(
321) callconv(.Stdcall) c_int;
322pub extern "ws2_32" fn WSACleanup() callconv(.Stdcall) c_int;
323pub extern "ws2_32" fn WSAGetLastError() callconv(.Stdcall) c_int;
324pub extern "ws2_32" fn WSASocketA(
325325 af: c_int,
326326 type: c_int,
327327 protocol: c_int,
328328 lpProtocolInfo: ?*WSAPROTOCOL_INFOA,
329329 g: GROUP,
330330 dwFlags: DWORD,
331) SOCKET;
332pub extern "ws2_32" stdcallcc fn WSASocketW(
331) callconv(.Stdcall) SOCKET;
332pub extern "ws2_32" fn WSASocketW(
333333 af: c_int,
334334 type: c_int,
335335 protocol: c_int,
336336 lpProtocolInfo: ?*WSAPROTOCOL_INFOW,
337337 g: GROUP,
338338 dwFlags: DWORD,
339) SOCKET;
340pub extern "ws2_32" stdcallcc fn closesocket(s: SOCKET) c_int;
341pub extern "ws2_32" stdcallcc fn WSAIoctl(
339) callconv(.Stdcall) SOCKET;
340pub extern "ws2_32" fn closesocket(s: SOCKET) callconv(.Stdcall) c_int;
341pub extern "ws2_32" fn WSAIoctl(
342342 s: SOCKET,
343343 dwIoControlCode: DWORD,
344344 lpvInBuffer: ?*const c_void,
......@@ -348,18 +348,18 @@ pub extern "ws2_32" stdcallcc fn WSAIoctl(
348348 lpcbBytesReturned: LPDWORD,
349349 lpOverlapped: ?*WSAOVERLAPPED,
350350 lpCompletionRoutine: ?WSAOVERLAPPED_COMPLETION_ROUTINE,
351) c_int;
352pub extern "ws2_32" stdcallcc fn accept(
351) callconv(.Stdcall) c_int;
352pub extern "ws2_32" fn accept(
353353 s: SOCKET,
354354 addr: ?*sockaddr,
355355 addrlen: socklen_t,
356) SOCKET;
357pub extern "ws2_32" stdcallcc fn connect(
356) callconv(.Stdcall) SOCKET;
357pub extern "ws2_32" fn connect(
358358 s: SOCKET,
359359 name: *const sockaddr,
360360 namelen: socklen_t,
361) c_int;
362pub extern "ws2_32" stdcallcc fn WSARecv(
361) callconv(.Stdcall) c_int;
362pub extern "ws2_32" fn WSARecv(
363363 s: SOCKET,
364364 lpBuffers: [*]const WSABUF,
365365 dwBufferCount: DWORD,
......@@ -367,8 +367,8 @@ pub extern "ws2_32" stdcallcc fn WSARecv(
367367 lpFlags: *DWORD,
368368 lpOverlapped: ?*WSAOVERLAPPED,
369369 lpCompletionRoutine: ?WSAOVERLAPPED_COMPLETION_ROUTINE,
370) c_int;
371pub extern "ws2_32" stdcallcc fn WSARecvFrom(
370) callconv(.Stdcall) c_int;
371pub extern "ws2_32" fn WSARecvFrom(
372372 s: SOCKET,
373373 lpBuffers: [*]const WSABUF,
374374 dwBufferCount: DWORD,
......@@ -378,8 +378,8 @@ pub extern "ws2_32" stdcallcc fn WSARecvFrom(
378378 lpFromlen: socklen_t,
379379 lpOverlapped: ?*WSAOVERLAPPED,
380380 lpCompletionRoutine: ?WSAOVERLAPPED_COMPLETION_ROUTINE,
381) c_int;
382pub extern "ws2_32" stdcallcc fn WSASend(
381) callconv(.Stdcall) c_int;
382pub extern "ws2_32" fn WSASend(
383383 s: SOCKET,
384384 lpBuffers: [*]WSABUF,
385385 dwBufferCount: DWORD,
......@@ -387,8 +387,8 @@ pub extern "ws2_32" stdcallcc fn WSASend(
387387 dwFlags: DWORD,
388388 lpOverlapped: ?*WSAOVERLAPPED,
389389 lpCompletionRoutine: ?WSAOVERLAPPED_COMPLETION_ROUTINE,
390) c_int;
391pub extern "ws2_32" stdcallcc fn WSASendTo(
390) callconv(.Stdcall) c_int;
391pub extern "ws2_32" fn WSASendTo(
392392 s: SOCKET,
393393 lpBuffers: [*]WSABUF,
394394 dwBufferCount: DWORD,
......@@ -398,4 +398,4 @@ pub extern "ws2_32" stdcallcc fn WSASendTo(
398398 iTolen: socklen_t,
399399 lpOverlapped: ?*WSAOVERLAPPED,
400400 lpCompletionRoutine: ?WSAOVERLAPPED_COMPLETION_ROUTINE,
401) c_int;
401) callconv(.Stdcall) c_int;
lib/std/reset_event.zig+12-14
......@@ -14,13 +14,12 @@ const windows = os.windows;
1414pub const ResetEvent = struct {
1515 os_event: OsEvent,
1616
17 pub const OsEvent =
18 if (builtin.single_threaded)
19 DebugEvent
20 else if (builtin.link_libc and builtin.os != .windows and builtin.os != .linux)
21 PosixEvent
22 else
23 AtomicEvent;
17 pub const OsEvent = if (builtin.single_threaded)
18 DebugEvent
19 else if (builtin.link_libc and builtin.os != .windows and builtin.os != .linux)
20 PosixEvent
21 else
22 AtomicEvent;
2423
2524 pub fn init() ResetEvent {
2625 return ResetEvent{ .os_event = OsEvent.init() };
......@@ -105,7 +104,7 @@ const PosixEvent = struct {
105104 }
106105
107106 fn deinit(self: *PosixEvent) void {
108 // on dragonfly, *destroy() functions can return EINVAL
107 // on dragonfly, *destroy() functions can return EINVAL
109108 // for statically initialized pthread structures
110109 const err = if (builtin.os == .dragonfly) os.EINVAL else 0;
111110
......@@ -212,8 +211,7 @@ const AtomicEvent = struct {
212211 fn wait(self: *AtomicEvent, timeout: ?u64) !void {
213212 var waiters = @atomicLoad(u32, &self.waiters, .Acquire);
214213 while (waiters != WAKE) {
215 waiters = @cmpxchgWeak(u32, &self.waiters, waiters, waiters + WAIT, .Acquire, .Acquire)
216 orelse return Futex.wait(&self.waiters, timeout);
214 waiters = @cmpxchgWeak(u32, &self.waiters, waiters, waiters + WAIT, .Acquire, .Acquire) orelse return Futex.wait(&self.waiters, timeout);
217215 }
218216 }
219217
......@@ -281,7 +279,7 @@ const AtomicEvent = struct {
281279 pub fn wake(waiters: *u32, wake_count: u32) void {
282280 const handle = getEventHandle() orelse return SpinFutex.wake(waiters, wake_count);
283281 const key = @ptrCast(*const c_void, waiters);
284
282
285283 var waiting = wake_count;
286284 while (waiting != 0) : (waiting -= 1) {
287285 const rc = windows.ntdll.NtReleaseKeyedEvent(handle, key, windows.FALSE, null);
......@@ -408,7 +406,7 @@ test "std.ResetEvent" {
408406 // wait for receiver to update value and signal output
409407 self.out.wait();
410408 testing.expect(self.value == 2);
411
409
412410 // update value and signal final input
413411 self.value = 3;
414412 self.in.set();
......@@ -418,12 +416,12 @@ test "std.ResetEvent" {
418416 // wait for sender to update value and signal input
419417 self.in.wait();
420418 assert(self.value == 1);
421
419
422420 // update value and signal output
423421 self.in.reset();
424422 self.value = 2;
425423 self.out.set();
426
424
427425 // wait for sender to update value and signal final input
428426 self.in.wait();
429427 assert(self.value == 3);
lib/std/special/c.zig+1-1
......@@ -195,7 +195,7 @@ extern fn __stack_chk_fail() noreturn {
195195// TODO we should be able to put this directly in std/linux/x86_64.zig but
196196// it causes a segfault in release mode. this is a workaround of calling it
197197// across .o file boundaries. fix comptime @ptrCast of nakedcc functions.
198nakedcc fn clone() void {
198fn clone() callconv(.Naked) void {
199199 switch (builtin.arch) {
200200 .i386 => {
201201 // __clone(func, stack, flags, arg, ptid, tls, ctid)
lib/std/special/compiler_rt.zig+5-5
......@@ -528,7 +528,7 @@ fn usesThumb1PreArmv6(arch: builtin.Arch) bool {
528528 };
529529}
530530
531nakedcc fn __aeabi_memcpy() noreturn {
531fn __aeabi_memcpy() callconv(.Naked) noreturn {
532532 @setRuntimeSafety(false);
533533 if (use_thumb_1) {
534534 asm volatile (
......@@ -544,7 +544,7 @@ nakedcc fn __aeabi_memcpy() noreturn {
544544 unreachable;
545545}
546546
547nakedcc fn __aeabi_memmove() noreturn {
547fn __aeabi_memmove() callconv(.Naked) noreturn {
548548 @setRuntimeSafety(false);
549549 if (use_thumb_1) {
550550 asm volatile (
......@@ -560,7 +560,7 @@ nakedcc fn __aeabi_memmove() noreturn {
560560 unreachable;
561561}
562562
563nakedcc fn __aeabi_memset() noreturn {
563fn __aeabi_memset() callconv(.Naked) noreturn {
564564 @setRuntimeSafety(false);
565565 if (use_thumb_1_pre_armv6) {
566566 asm volatile (
......@@ -591,7 +591,7 @@ nakedcc fn __aeabi_memset() noreturn {
591591 unreachable;
592592}
593593
594nakedcc fn __aeabi_memclr() noreturn {
594fn __aeabi_memclr() callconv(.Naked) noreturn {
595595 @setRuntimeSafety(false);
596596 if (use_thumb_1_pre_armv6) {
597597 asm volatile (
......@@ -619,7 +619,7 @@ nakedcc fn __aeabi_memclr() noreturn {
619619 unreachable;
620620}
621621
622nakedcc fn __aeabi_memcmp() noreturn {
622fn __aeabi_memcmp() callconv(.Naked) noreturn {
623623 @setRuntimeSafety(false);
624624 if (use_thumb_1) {
625625 asm volatile (
lib/std/special/compiler_rt/arm/aeabi_dcmp.zig+5-5
......@@ -12,31 +12,31 @@ const ConditionalOperator = enum {
1212 Gt,
1313};
1414
15pub nakedcc fn __aeabi_dcmpeq() noreturn {
15pub fn __aeabi_dcmpeq() callconv(.Naked) noreturn {
1616 @setRuntimeSafety(false);
1717 @call(.{ .modifier = .always_inline }, aeabi_dcmp, .{.Eq});
1818 unreachable;
1919}
2020
21pub nakedcc fn __aeabi_dcmplt() noreturn {
21pub fn __aeabi_dcmplt() callconv(.Naked) noreturn {
2222 @setRuntimeSafety(false);
2323 @call(.{ .modifier = .always_inline }, aeabi_dcmp, .{.Lt});
2424 unreachable;
2525}
2626
27pub nakedcc fn __aeabi_dcmple() noreturn {
27pub fn __aeabi_dcmple() callconv(.Naked) noreturn {
2828 @setRuntimeSafety(false);
2929 @call(.{ .modifier = .always_inline }, aeabi_dcmp, .{.Le});
3030 unreachable;
3131}
3232
33pub nakedcc fn __aeabi_dcmpge() noreturn {
33pub fn __aeabi_dcmpge() callconv(.Naked) noreturn {
3434 @setRuntimeSafety(false);
3535 @call(.{ .modifier = .always_inline }, aeabi_dcmp, .{.Ge});
3636 unreachable;
3737}
3838
39pub nakedcc fn __aeabi_dcmpgt() noreturn {
39pub fn __aeabi_dcmpgt() callconv(.Naked) noreturn {
4040 @setRuntimeSafety(false);
4141 @call(.{ .modifier = .always_inline }, aeabi_dcmp, .{.Gt});
4242 unreachable;
lib/std/special/compiler_rt/arm/aeabi_fcmp.zig+5-5
......@@ -12,31 +12,31 @@ const ConditionalOperator = enum {
1212 Gt,
1313};
1414
15pub nakedcc fn __aeabi_fcmpeq() noreturn {
15pub fn __aeabi_fcmpeq() callconv(.Naked) noreturn {
1616 @setRuntimeSafety(false);
1717 @call(.{ .modifier = .always_inline }, aeabi_fcmp, .{.Eq});
1818 unreachable;
1919}
2020
21pub nakedcc fn __aeabi_fcmplt() noreturn {
21pub fn __aeabi_fcmplt() callconv(.Naked) noreturn {
2222 @setRuntimeSafety(false);
2323 @call(.{ .modifier = .always_inline }, aeabi_fcmp, .{.Lt});
2424 unreachable;
2525}
2626
27pub nakedcc fn __aeabi_fcmple() noreturn {
27pub fn __aeabi_fcmple() callconv(.Naked) noreturn {
2828 @setRuntimeSafety(false);
2929 @call(.{ .modifier = .always_inline }, aeabi_fcmp, .{.Le});
3030 unreachable;
3131}
3232
33pub nakedcc fn __aeabi_fcmpge() noreturn {
33pub fn __aeabi_fcmpge() callconv(.Naked) noreturn {
3434 @setRuntimeSafety(false);
3535 @call(.{ .modifier = .always_inline }, aeabi_fcmp, .{.Ge});
3636 unreachable;
3737}
3838
39pub nakedcc fn __aeabi_fcmpgt() noreturn {
39pub fn __aeabi_fcmpgt() callconv(.Naked) noreturn {
4040 @setRuntimeSafety(false);
4141 @call(.{ .modifier = .always_inline }, aeabi_fcmp, .{.Gt});
4242 unreachable;
lib/std/special/compiler_rt/aulldiv.zig+2-2
......@@ -1,6 +1,6 @@
11const builtin = @import("builtin");
22
3pub extern stdcallcc fn _alldiv(a: i64, b: i64) i64 {
3pub extern fn _alldiv(a: i64, b: i64) callconv(.Stdcall) i64 {
44 @setRuntimeSafety(builtin.is_test);
55 const s_a = a >> (i64.bit_count - 1);
66 const s_b = b >> (i64.bit_count - 1);
......@@ -13,7 +13,7 @@ pub extern stdcallcc fn _alldiv(a: i64, b: i64) i64 {
1313 return (@bitCast(i64, r) ^ s) -% s;
1414}
1515
16pub nakedcc fn _aulldiv() void {
16pub fn _aulldiv() callconv(.Naked) void {
1717 @setRuntimeSafety(false);
1818
1919 // The stack layout is:
lib/std/special/compiler_rt/aullrem.zig+2-2
......@@ -1,6 +1,6 @@
11const builtin = @import("builtin");
22
3pub extern stdcallcc fn _allrem(a: i64, b: i64) i64 {
3pub extern fn _allrem(a: i64, b: i64) callconv(.Stdcall) i64 {
44 @setRuntimeSafety(builtin.is_test);
55 const s_a = a >> (i64.bit_count - 1);
66 const s_b = b >> (i64.bit_count - 1);
......@@ -13,7 +13,7 @@ pub extern stdcallcc fn _allrem(a: i64, b: i64) i64 {
1313 return (@bitCast(i64, r) ^ s) -% s;
1414}
1515
16pub nakedcc fn _aullrem() void {
16pub fn _aullrem() callconv(.Naked) void {
1717 @setRuntimeSafety(false);
1818
1919 // The stack layout is:
lib/std/special/compiler_rt/stack_probe.zig+6-6
......@@ -1,7 +1,7 @@
11const builtin = @import("builtin");
22
33// Zig's own stack-probe routine (available only on x86 and x86_64)
4pub nakedcc fn zig_probe_stack() void {
4pub fn zig_probe_stack() callconv(.Naked) void {
55 @setRuntimeSafety(false);
66
77 // Versions of the Linux kernel before 5.1 treat any access below SP as
......@@ -180,11 +180,11 @@ fn win_probe_stack_adjust_sp() void {
180180// ___chkstk (__alloca) | yes | yes |
181181// ___chkstk_ms | no | no |
182182
183pub nakedcc fn _chkstk() void {
183pub fn _chkstk() callconv(.Naked) void {
184184 @setRuntimeSafety(false);
185185 @call(.{ .modifier = .always_inline }, win_probe_stack_adjust_sp, .{});
186186}
187pub nakedcc fn __chkstk() void {
187pub fn __chkstk() callconv(.Naked) void {
188188 @setRuntimeSafety(false);
189189 switch (builtin.arch) {
190190 .i386 => @call(.{ .modifier = .always_inline }, win_probe_stack_adjust_sp, .{}),
......@@ -192,15 +192,15 @@ pub nakedcc fn __chkstk() void {
192192 else => unreachable,
193193 }
194194}
195pub nakedcc fn ___chkstk() void {
195pub fn ___chkstk() callconv(.Naked) void {
196196 @setRuntimeSafety(false);
197197 @call(.{ .modifier = .always_inline }, win_probe_stack_adjust_sp, .{});
198198}
199pub nakedcc fn __chkstk_ms() void {
199pub fn __chkstk_ms() callconv(.Naked) void {
200200 @setRuntimeSafety(false);
201201 @call(.{ .modifier = .always_inline }, win_probe_stack_only, .{});
202202}
203pub nakedcc fn ___chkstk_ms() void {
203pub fn ___chkstk_ms() callconv(.Naked) void {
204204 @setRuntimeSafety(false);
205205 @call(.{ .modifier = .always_inline }, win_probe_stack_only, .{});
206206}
lib/std/spinlock.zig+10-2
......@@ -60,8 +60,16 @@ pub const SpinLock = struct {
6060 switch (builtin.arch) {
6161 // these instructions use a memory clobber as they
6262 // flush the pipeline of any speculated reads/writes.
63 .i386, .x86_64 => asm volatile ("pause" ::: "memory"),
64 .arm, .aarch64 => asm volatile ("yield" ::: "memory"),
63 .i386, .x86_64 => asm volatile ("pause"
64 :
65 :
66 : "memory"
67 ),
68 .arm, .aarch64 => asm volatile ("yield"
69 :
70 :
71 : "memory"
72 ),
6573 else => std.os.sched_yield() catch {},
6674 }
6775 }
lib/std/start.zig+4-4
......@@ -43,11 +43,11 @@ comptime {
4343 }
4444}
4545
46stdcallcc fn _DllMainCRTStartup(
46fn _DllMainCRTStartup(
4747 hinstDLL: std.os.windows.HINSTANCE,
4848 fdwReason: std.os.windows.DWORD,
4949 lpReserved: std.os.windows.LPVOID,
50) std.os.windows.BOOL {
50) callconv(.Stdcall) std.os.windows.BOOL {
5151 if (@hasDecl(root, "DllMain")) {
5252 return root.DllMain(hinstDLL, fdwReason, lpReserved);
5353 }
......@@ -84,7 +84,7 @@ extern fn EfiMain(handle: uefi.Handle, system_table: *uefi.tables.SystemTable) u
8484 }
8585}
8686
87nakedcc fn _start() noreturn {
87fn _start() callconv(.Naked) noreturn {
8888 if (builtin.os == builtin.Os.wasi) {
8989 // This is marked inline because for some reason LLVM in release mode fails to inline it,
9090 // and we want fewer call frames in stack traces.
......@@ -127,7 +127,7 @@ nakedcc fn _start() noreturn {
127127 @call(.{ .modifier = .never_inline }, posixCallMainAndExit, .{});
128128}
129129
130stdcallcc fn WinMainCRTStartup() noreturn {
130fn WinMainCRTStartup() callconv(.Stdcall) noreturn {
131131 @setAlignStack(16);
132132 if (!builtin.single_threaded) {
133133 _ = @import("start_windows_tls.zig");
lib/std/zig/ast.zig+1
......@@ -860,6 +860,7 @@ pub const Node = struct {
860860 lib_name: ?*Node, // populated if this is an extern declaration
861861 align_expr: ?*Node, // populated if align(A) is present
862862 section_expr: ?*Node, // populated if linksection(A) is present
863 callconv_expr: ?*Node, // populated if callconv(A) is present
863864
864865 pub const ParamList = SegmentedList(*Node, 2);
865866
lib/std/zig/parse.zig+13
......@@ -311,6 +311,7 @@ fn parseFnProto(arena: *Allocator, it: *TokenIterator, tree: *Tree) !?*Node {
311311 const rparen = try expectToken(it, tree, .RParen);
312312 const align_expr = try parseByteAlign(arena, it, tree);
313313 const section_expr = try parseLinkSection(arena, it, tree);
314 const callconv_expr = try parseCallconv(arena, it, tree);
314315 const exclamation_token = eatToken(it, .Bang);
315316
316317 const return_type_expr = (try parseVarType(arena, it, tree)) orelse
......@@ -347,6 +348,7 @@ fn parseFnProto(arena: *Allocator, it: *TokenIterator, tree: *Tree) !?*Node {
347348 .lib_name = null,
348349 .align_expr = align_expr,
349350 .section_expr = section_expr,
351 .callconv_expr = callconv_expr,
350352 };
351353
352354 if (cc) |kind| {
......@@ -1678,6 +1680,17 @@ fn parseLinkSection(arena: *Allocator, it: *TokenIterator, tree: *Tree) !?*Node
16781680 return expr_node;
16791681}
16801682
1683/// CallConv <- KEYWORD_callconv LPAREN Expr RPAREN
1684fn parseCallconv(arena: *Allocator, it: *TokenIterator, tree: *Tree) !?*Node {
1685 _ = eatToken(it, .Keyword_callconv) orelse return null;
1686 _ = try expectToken(it, tree, .LParen);
1687 const expr_node = try expectNode(arena, it, tree, parseExpr, AstError{
1688 .ExpectedExpr = AstError.ExpectedExpr{ .token = it.index },
1689 });
1690 _ = try expectToken(it, tree, .RParen);
1691 return expr_node;
1692}
1693
16811694/// FnCC
16821695/// <- KEYWORD_nakedcc
16831696/// / KEYWORD_stdcallcc
lib/std/zig/parser_test.zig+2-2
......@@ -219,7 +219,7 @@ test "zig fmt: threadlocal" {
219219test "zig fmt: linksection" {
220220 try testCanonical(
221221 \\export var aoeu: u64 linksection(".text.derp") = 1234;
222 \\export nakedcc fn _start() linksection(".text.boot") noreturn {}
222 \\export fn _start() linksection(".text.boot") callconv(.Naked) noreturn {}
223223 \\
224224 );
225225}
......@@ -2311,7 +2311,7 @@ test "zig fmt: fn type" {
23112311 \\
23122312 \\const a: fn (u8) u8 = undefined;
23132313 \\const b: extern fn (u8) u8 = undefined;
2314 \\const c: nakedcc fn (u8) u8 = undefined;
2314 \\const c: fn (u8) callconv(.Naked) u8 = undefined;
23152315 \\const ap: fn (u8) u8 = a;
23162316 \\
23172317 );
lib/std/zig/render.zig+24-1
......@@ -1295,8 +1295,16 @@ fn renderExpression(
12951295 try renderExpression(allocator, stream, tree, indent, start_col, lib_name, Space.Space);
12961296 }
12971297
1298 // Some extra machinery is needed to rewrite the old-style cc
1299 // notation to the new callconv one
1300 var cc_rewrite_str: ?[*:0]const u8 = null;
12981301 if (fn_proto.cc_token) |cc_token| {
1299 try renderToken(tree, stream, cc_token, indent, start_col, Space.Space); // stdcallcc
1302 var str = tree.tokenSlicePtr(tree.tokens.at(cc_token));
1303 if (mem.eql(u8, str, "stdcallcc")) {
1304 cc_rewrite_str = ".Stdcall";
1305 } else if (mem.eql(u8, str, "nakedcc")) {
1306 cc_rewrite_str = ".Naked";
1307 } else try renderToken(tree, stream, cc_token, indent, start_col, Space.Space); // stdcallcc
13001308 }
13011309
13021310 const lparen = if (fn_proto.name_token) |name_token| blk: {
......@@ -1368,6 +1376,21 @@ fn renderExpression(
13681376 try renderToken(tree, stream, section_rparen, indent, start_col, Space.Space); // )
13691377 }
13701378
1379 if (fn_proto.callconv_expr) |callconv_expr| {
1380 const section_rparen = tree.nextToken(callconv_expr.lastToken());
1381 const section_lparen = tree.prevToken(callconv_expr.firstToken());
1382 const section_kw = tree.prevToken(section_lparen);
1383
1384 try renderToken(tree, stream, section_kw, indent, start_col, Space.None); // section
1385 try renderToken(tree, stream, section_lparen, indent, start_col, Space.None); // (
1386 try renderExpression(allocator, stream, tree, indent, start_col, callconv_expr, Space.None);
1387 try renderToken(tree, stream, section_rparen, indent, start_col, Space.Space); // )
1388 } else if (cc_rewrite_str) |str| {
1389 try stream.write("callconv(");
1390 try stream.write(mem.toSliceConst(u8, str));
1391 try stream.write(") ");
1392 }
1393
13711394 switch (fn_proto.return_type) {
13721395 ast.Node.FnProto.ReturnType.Explicit => |node| {
13731396 return renderExpression(allocator, stream, tree, indent, start_col, node, space);
lib/std/zig/tokenizer.zig+3
......@@ -30,6 +30,7 @@ pub const Token = struct {
3030 Keyword.init("async", .Keyword_async),
3131 Keyword.init("await", .Keyword_await),
3232 Keyword.init("break", .Keyword_break),
33 Keyword.init("callconv", .Keyword_callconv),
3334 Keyword.init("catch", .Keyword_catch),
3435 Keyword.init("comptime", .Keyword_comptime),
3536 Keyword.init("const", .Keyword_const),
......@@ -162,6 +163,7 @@ pub const Token = struct {
162163 Keyword_async,
163164 Keyword_await,
164165 Keyword_break,
166 Keyword_callconv,
165167 Keyword_catch,
166168 Keyword_comptime,
167169 Keyword_const,
......@@ -286,6 +288,7 @@ pub const Token = struct {
286288 .Keyword_async => "async",
287289 .Keyword_await => "await",
288290 .Keyword_break => "break",
291 .Keyword_callconv => "callconv",
289292 .Keyword_catch => "catch",
290293 .Keyword_comptime => "comptime",
291294 .Keyword_const => "const",
src-self-hosted/translate_c.zig+4-1
......@@ -11,7 +11,7 @@ const CToken = ctok.CToken;
1111const mem = std.mem;
1212const math = std.math;
1313
14const CallingConvention = std.builtin.TypeInfo.CallingConvention;
14const CallingConvention = std.builtin.CallingConvention;
1515
1616pub const ClangErrMsg = Stage2ErrorMsg;
1717
......@@ -3529,6 +3529,7 @@ fn transCreateNodeMacroFn(c: *Context, name: []const u8, ref: *ast.Node, proto_a
35293529 .lib_name = null,
35303530 .align_expr = null,
35313531 .section_expr = null,
3532 .callconv_expr = null,
35323533 };
35333534
35343535 const block = try transCreateNodeBlock(c, null);
......@@ -4135,6 +4136,7 @@ fn finishTransFnProto(
41354136 .lib_name = null,
41364137 .align_expr = null,
41374138 .section_expr = null,
4139 .callconv_expr = null,
41384140 };
41394141 return fn_proto;
41404142}
......@@ -4483,6 +4485,7 @@ fn transMacroFnDefine(c: *Context, it: *ctok.TokenList.Iterator, name: []const u
44834485 .lib_name = null,
44844486 .align_expr = null,
44854487 .section_expr = null,
4488 .callconv_expr = null,
44864489 };
44874490
44884491 const block = try transCreateNodeBlock(c, null);
src-self-hosted/type.zig+2-1
......@@ -337,7 +337,7 @@ pub const Type = struct {
337337 }
338338 };
339339
340 const CallingConvention = builtin.TypeInfo.CallingConvention;
340 const CallingConvention = builtin.CallingConvention;
341341
342342 pub const Param = struct {
343343 is_noalias: bool,
......@@ -352,6 +352,7 @@ pub const Type = struct {
352352 .Naked => "nakedcc ",
353353 .Stdcall => "stdcallcc ",
354354 .Async => "async ",
355 else => unreachable,
355356 };
356357 }
357358
src/all_types.hpp+24-10
......@@ -57,6 +57,22 @@ enum PtrLen {
5757 PtrLenC,
5858};
5959
60enum CallingConvention {
61 CallingConventionUnspecified,
62 CallingConventionC,
63 CallingConventionCold,
64 CallingConventionNaked,
65 CallingConventionAsync,
66 CallingConventionInterrupt,
67 CallingConventionSignal,
68 CallingConventionStdcall,
69 CallingConventionFastcall,
70 CallingConventionVectorcall,
71 CallingConventionAPCS,
72 CallingConventionAAPCS,
73 CallingConventionAAPCSVFP,
74};
75
6076// This one corresponds to the builtin.zig enum.
6177enum BuiltinPtrSize {
6278 BuiltinPtrSizeOne,
......@@ -398,6 +414,7 @@ struct LazyValueFnType {
398414 IrInstruction *align_inst; // can be null
399415 IrInstruction *return_type;
400416
417 CallingConvention cc;
401418 bool is_generic;
402419};
403420
......@@ -612,15 +629,6 @@ enum NodeType {
612629 NodeTypeVarFieldType,
613630};
614631
615enum CallingConvention {
616 CallingConventionUnspecified,
617 CallingConventionC,
618 CallingConventionCold,
619 CallingConventionNaked,
620 CallingConventionStdcall,
621 CallingConventionAsync,
622};
623
624632enum FnInline {
625633 FnInlineAuto,
626634 FnInlineAlways,
......@@ -639,10 +647,14 @@ struct AstNodeFnProto {
639647 AstNode *align_expr;
640648 // populated if the "section(S)" is present
641649 AstNode *section_expr;
650 // populated if the "callconv(S)" is present
651 AstNode *callconv_expr;
642652 Buf doc_comments;
643653
644654 FnInline fn_inline;
645 CallingConvention cc;
655 bool is_nakedcc;
656 bool is_stdcallcc;
657 bool is_async;
646658
647659 VisibMod visib_mod;
648660 bool auto_err_set;
......@@ -1597,6 +1609,7 @@ struct ZigFn {
15971609 Buf **param_names;
15981610 IrInstruction *err_code_spill;
15991611 AstNode *assumed_non_async;
1612 CallingConvention cc;
16001613
16011614 AstNode *fn_no_inline_set_node;
16021615 AstNode *fn_static_eval_set_node;
......@@ -3549,6 +3562,7 @@ struct IrInstructionFnProto {
35493562
35503563 IrInstruction **param_types;
35513564 IrInstruction *align_value;
3565 IrInstruction *callconv_value;
35523566 IrInstruction *return_type;
35533567 bool is_var_args;
35543568};
src/analyze.cpp+99-55
......@@ -919,24 +919,19 @@ ZigType *get_bound_fn_type(CodeGen *g, ZigFn *fn_entry) {
919919
920920const char *calling_convention_name(CallingConvention cc) {
921921 switch (cc) {
922 case CallingConventionUnspecified: return "undefined";
923 case CallingConventionC: return "ccc";
924 case CallingConventionCold: return "coldcc";
925 case CallingConventionNaked: return "nakedcc";
926 case CallingConventionStdcall: return "stdcallcc";
927 case CallingConventionAsync: return "async";
928 }
929 zig_unreachable();
930}
931
932static const char *calling_convention_fn_type_str(CallingConvention cc) {
933 switch (cc) {
934 case CallingConventionUnspecified: return "";
935 case CallingConventionC: return "extern ";
936 case CallingConventionCold: return "coldcc ";
937 case CallingConventionNaked: return "nakedcc ";
938 case CallingConventionStdcall: return "stdcallcc ";
939 case CallingConventionAsync: return "async ";
922 case CallingConventionUnspecified: return "Unspecified";
923 case CallingConventionC: return "C";
924 case CallingConventionCold: return "Cold";
925 case CallingConventionNaked: return "Naked";
926 case CallingConventionAsync: return "Async";
927 case CallingConventionInterrupt: return "Interrupt";
928 case CallingConventionSignal: return "Signal";
929 case CallingConventionStdcall: return "Stdcall";
930 case CallingConventionFastcall: return "Fastcall";
931 case CallingConventionVectorcall: return "Vectorcall";
932 case CallingConventionAPCS: return "Apcs";
933 case CallingConventionAAPCS: return "Aapcs";
934 case CallingConventionAAPCSVFP: return "Aapcsvfp";
940935 }
941936 zig_unreachable();
942937}
......@@ -949,7 +944,14 @@ bool calling_convention_allows_zig_types(CallingConvention cc) {
949944 case CallingConventionC:
950945 case CallingConventionCold:
951946 case CallingConventionNaked:
947 case CallingConventionInterrupt:
948 case CallingConventionSignal:
952949 case CallingConventionStdcall:
950 case CallingConventionFastcall:
951 case CallingConventionVectorcall:
952 case CallingConventionAPCS:
953 case CallingConventionAAPCS:
954 case CallingConventionAAPCSVFP:
953955 return false;
954956 }
955957 zig_unreachable();
......@@ -1006,8 +1008,8 @@ ZigType *get_fn_type(CodeGen *g, FnTypeId *fn_type_id) {
10061008
10071009 // populate the name of the type
10081010 buf_resize(&fn_type->name, 0);
1009 const char *cc_str = calling_convention_fn_type_str(fn_type->data.fn.fn_type_id.cc);
1010 buf_appendf(&fn_type->name, "%s", cc_str);
1011 if (fn_type->data.fn.fn_type_id.cc == CallingConventionC)
1012 buf_append_str(&fn_type->name, "extern ");
10111013 buf_appendf(&fn_type->name, "fn(");
10121014 for (size_t i = 0; i < fn_type_id->param_count; i += 1) {
10131015 FnTypeParamInfo *param_info = &fn_type_id->param_info[i];
......@@ -1026,6 +1028,9 @@ ZigType *get_fn_type(CodeGen *g, FnTypeId *fn_type_id) {
10261028 if (fn_type_id->alignment != 0) {
10271029 buf_appendf(&fn_type->name, " align(%" PRIu32 ")", fn_type_id->alignment);
10281030 }
1031 if (fn_type_id->cc != CallingConventionUnspecified && fn_type_id->cc != CallingConventionC) {
1032 buf_appendf(&fn_type->name, " callconv(%s)", calling_convention_name(fn_type_id->cc));
1033 }
10291034 buf_appendf(&fn_type->name, " %s", buf_ptr(&fn_type_id->return_type->name));
10301035
10311036 // The fn_type is a pointer; not to be confused with the raw function type.
......@@ -1442,8 +1447,8 @@ ZigType *analyze_type_expr(CodeGen *g, Scope *scope, AstNode *node) {
14421447ZigType *get_generic_fn_type(CodeGen *g, FnTypeId *fn_type_id) {
14431448 ZigType *fn_type = new_type_table_entry(ZigTypeIdFn);
14441449 buf_resize(&fn_type->name, 0);
1445 const char *cc_str = calling_convention_fn_type_str(fn_type->data.fn.fn_type_id.cc);
1446 buf_appendf(&fn_type->name, "%s", cc_str);
1450 if (fn_type->data.fn.fn_type_id.cc == CallingConventionC)
1451 buf_append_str(&fn_type->name, "extern ");
14471452 buf_appendf(&fn_type->name, "fn(");
14481453 size_t i = 0;
14491454 for (; i < fn_type_id->next_param_index; i += 1) {
......@@ -1455,7 +1460,11 @@ ZigType *get_generic_fn_type(CodeGen *g, FnTypeId *fn_type_id) {
14551460 const char *comma_str = (i == 0) ? "" : ",";
14561461 buf_appendf(&fn_type->name, "%svar", comma_str);
14571462 }
1458 buf_appendf(&fn_type->name, ")var");
1463 buf_append_str(&fn_type->name, ")");
1464 if (fn_type_id->cc != CallingConventionUnspecified && fn_type_id->cc != CallingConventionC) {
1465 buf_appendf(&fn_type->name, " callconv(%s)", calling_convention_name(fn_type_id->cc));
1466 }
1467 buf_append_str(&fn_type->name, " var");
14591468
14601469 fn_type->data.fn.fn_type_id = *fn_type_id;
14611470 fn_type->data.fn.is_generic = true;
......@@ -1465,17 +1474,25 @@ ZigType *get_generic_fn_type(CodeGen *g, FnTypeId *fn_type_id) {
14651474 return fn_type;
14661475}
14671476
1468void init_fn_type_id(FnTypeId *fn_type_id, AstNode *proto_node, size_t param_count_alloc) {
1477CallingConvention cc_from_fn_proto(AstNodeFnProto *fn_proto) {
1478 if (fn_proto->is_nakedcc)
1479 return CallingConventionNaked;
1480 if (fn_proto->is_stdcallcc)
1481 return CallingConventionStdcall;
1482 if (fn_proto->is_async)
1483 return CallingConventionAsync;
1484 // Compatible with the C ABI
1485 if (fn_proto->is_extern || fn_proto->is_export)
1486 return CallingConventionC;
1487
1488 return CallingConventionUnspecified;
1489}
1490
1491void init_fn_type_id(FnTypeId *fn_type_id, AstNode *proto_node, CallingConvention cc, size_t param_count_alloc) {
14691492 assert(proto_node->type == NodeTypeFnProto);
14701493 AstNodeFnProto *fn_proto = &proto_node->data.fn_proto;
14711494
1472 if (fn_proto->cc == CallingConventionUnspecified) {
1473 bool extern_abi = fn_proto->is_extern || fn_proto->is_export;
1474 fn_type_id->cc = extern_abi ? CallingConventionC : CallingConventionUnspecified;
1475 } else {
1476 fn_type_id->cc = fn_proto->cc;
1477 }
1478
1495 fn_type_id->cc = cc;
14791496 fn_type_id->param_count = fn_proto->params.length;
14801497 fn_type_id->param_info = allocate<FnTypeParamInfo>(param_count_alloc);
14811498 fn_type_id->next_param_index = 0;
......@@ -1690,7 +1707,8 @@ Error type_allowed_in_extern(CodeGen *g, ZigType *type_entry, bool *result) {
16901707 return type_allowed_in_extern(g, type_entry->data.array.child_type, result);
16911708 case ZigTypeIdFn:
16921709 *result = type_entry->data.fn.fn_type_id.cc == CallingConventionC ||
1693 type_entry->data.fn.fn_type_id.cc == CallingConventionStdcall;
1710 type_entry->data.fn.fn_type_id.cc == CallingConventionStdcall ||
1711 type_entry->data.fn.fn_type_id.cc == CallingConventionAAPCS;
16941712 return ErrorNone;
16951713 case ZigTypeIdPointer:
16961714 if ((err = type_resolve(g, type_entry, ResolveStatusZeroBitsKnown)))
......@@ -1750,7 +1768,7 @@ static ZigType *analyze_fn_type(CodeGen *g, AstNode *proto_node, Scope *child_sc
17501768 Error err;
17511769
17521770 FnTypeId fn_type_id = {0};
1753 init_fn_type_id(&fn_type_id, proto_node, proto_node->data.fn_proto.params.length);
1771 init_fn_type_id(&fn_type_id, proto_node, fn_entry->cc, proto_node->data.fn_proto.params.length);
17541772
17551773 for (; fn_type_id.next_param_index < fn_type_id.param_count; fn_type_id.next_param_index += 1) {
17561774 AstNode *param_node = fn_proto->params.at(fn_type_id.next_param_index);
......@@ -3393,27 +3411,6 @@ static void resolve_decl_fn(CodeGen *g, TldFn *tld_fn) {
33933411 get_fully_qualified_decl_name(g, &fn_table_entry->symbol_name, &tld_fn->base, false);
33943412 }
33953413
3396 if (fn_proto->is_export) {
3397 switch (fn_proto->cc) {
3398 case CallingConventionAsync: {
3399 add_node_error(g, fn_def_node,
3400 buf_sprintf("exported function cannot be async"));
3401 } break;
3402 case CallingConventionC:
3403 case CallingConventionNaked:
3404 case CallingConventionCold:
3405 case CallingConventionStdcall:
3406 case CallingConventionUnspecified:
3407 // An exported function without a specific calling
3408 // convention defaults to C
3409 CallingConvention cc = (fn_proto->cc != CallingConventionUnspecified) ?
3410 fn_proto->cc : CallingConventionC;
3411 add_fn_export(g, fn_table_entry, buf_ptr(&fn_table_entry->symbol_name),
3412 GlobalLinkageIdStrong, cc);
3413 break;
3414 }
3415 }
3416
34173414 if (!is_extern) {
34183415 fn_table_entry->fndef_scope = create_fndef_scope(g,
34193416 fn_table_entry->body_node, tld_fn->base.parent_scope, fn_table_entry);
......@@ -3432,6 +3429,21 @@ static void resolve_decl_fn(CodeGen *g, TldFn *tld_fn) {
34323429
34333430 Scope *child_scope = fn_table_entry->fndef_scope ? &fn_table_entry->fndef_scope->base : tld_fn->base.parent_scope;
34343431
3432 fn_table_entry->cc = cc_from_fn_proto(fn_proto);
3433 if (fn_proto->callconv_expr != nullptr) {
3434 ZigType *cc_enum_value = get_builtin_type(g, "CallingConvention");
3435
3436 ZigValue *result_val = analyze_const_value(g, child_scope, fn_proto->callconv_expr,
3437 cc_enum_value, nullptr, UndefBad);
3438 if (type_is_invalid(result_val->type)) {
3439 fn_table_entry->type_entry = g->builtin_types.entry_invalid;
3440 tld_fn->base.resolution = TldResolutionInvalid;
3441 return;
3442 }
3443
3444 fn_table_entry->cc = (CallingConvention)bigint_as_u32(&result_val->data.x_enum_tag);
3445 }
3446
34353447 fn_table_entry->type_entry = analyze_fn_type(g, source_node, child_scope, fn_table_entry);
34363448
34373449 if (fn_proto->section_expr != nullptr) {
......@@ -3450,10 +3462,42 @@ static void resolve_decl_fn(CodeGen *g, TldFn *tld_fn) {
34503462 g->fn_defs.append(fn_table_entry);
34513463 }
34523464
3465 const CallingConvention fn_cc = fn_table_entry->type_entry->data.fn.fn_type_id.cc;
3466
3467 if (fn_proto->is_export) {
3468 switch (fn_cc) {
3469 case CallingConventionAsync:
3470 add_node_error(g, fn_def_node,
3471 buf_sprintf("exported function cannot be async"));
3472 tld_fn->base.resolution = TldResolutionInvalid;
3473 return;
3474 case CallingConventionC:
3475 case CallingConventionCold:
3476 case CallingConventionNaked:
3477 case CallingConventionInterrupt:
3478 case CallingConventionSignal:
3479 case CallingConventionStdcall:
3480 case CallingConventionFastcall:
3481 case CallingConventionVectorcall:
3482 case CallingConventionAPCS:
3483 case CallingConventionAAPCS:
3484 case CallingConventionAAPCSVFP:
3485 add_fn_export(g, fn_table_entry, buf_ptr(&fn_table_entry->symbol_name),
3486 GlobalLinkageIdStrong, fn_cc);
3487 break;
3488 case CallingConventionUnspecified:
3489 // An exported function without a specific calling
3490 // convention defaults to C
3491 add_fn_export(g, fn_table_entry, buf_ptr(&fn_table_entry->symbol_name),
3492 GlobalLinkageIdStrong, CallingConventionC);
3493 break;
3494 }
3495 }
3496
34533497 // if the calling convention implies that it cannot be async, we save that for later
34543498 // and leave the value to be nullptr to indicate that we have not emitted possible
34553499 // compile errors for improperly calling async functions.
3456 if (fn_table_entry->type_entry->data.fn.fn_type_id.cc == CallingConventionAsync) {
3500 if (fn_cc == CallingConventionAsync) {
34573501 fn_table_entry->inferred_async_node = fn_table_entry->proto_node;
34583502 }
34593503 } else if (source_node->type == NodeTypeTestDecl) {
src/analyze.hpp+2-1
......@@ -100,7 +100,7 @@ ZigType *analyze_type_expr(CodeGen *g, Scope *scope, AstNode *node);
100100void append_namespace_qualification(CodeGen *g, Buf *buf, ZigType *container_type);
101101ZigFn *create_fn(CodeGen *g, AstNode *proto_node);
102102ZigFn *create_fn_raw(CodeGen *g, FnInline inline_value);
103void init_fn_type_id(FnTypeId *fn_type_id, AstNode *proto_node, size_t param_count_alloc);
103void init_fn_type_id(FnTypeId *fn_type_id, AstNode *proto_node, CallingConvention cc, size_t param_count_alloc);
104104AstNode *get_param_decl_node(ZigFn *fn_entry, size_t index);
105105Error ATTRIBUTE_MUST_USE type_resolve(CodeGen *g, ZigType *type_entry, ResolveStatus status);
106106void complete_enum(CodeGen *g, ZigType *enum_type);
......@@ -259,6 +259,7 @@ ZigValue *analyze_const_value(CodeGen *g, Scope *scope, AstNode *node, ZigType *
259259
260260void resolve_llvm_types_fn(CodeGen *g, ZigFn *fn);
261261bool fn_is_async(ZigFn *fn);
262CallingConvention cc_from_fn_proto(AstNodeFnProto *fn_proto);
262263
263264Error type_val_resolve_abi_align(CodeGen *g, ZigValue *type_val, uint32_t *abi_align);
264265Error type_val_resolve_abi_size(CodeGen *g, AstNode *source_node, ZigValue *type_val,
src/ast_render.cpp+5
......@@ -488,6 +488,11 @@ static void render_node_extra(AstRender *ar, AstNode *node, bool grouped) {
488488 render_node_grouped(ar, node->data.fn_proto.section_expr);
489489 fprintf(ar->f, ")");
490490 }
491 if (node->data.fn_proto.callconv_expr) {
492 fprintf(ar->f, " callconv(");
493 render_node_grouped(ar, node->data.fn_proto.callconv_expr);
494 fprintf(ar->f, ")");
495 }
491496
492497 if (node->data.fn_proto.return_var_token != nullptr) {
493498 fprintf(ar->f, "var");
src/codegen.cpp+50-7
......@@ -284,14 +284,43 @@ static LLVMCallConv get_llvm_cc(CodeGen *g, CallingConvention cc) {
284284 case CallingConventionNaked:
285285 zig_unreachable();
286286 case CallingConventionStdcall:
287 // stdcall calling convention only works on x86.
288 if (g->zig_target->arch == ZigLLVM_x86) {
287 if (g->zig_target->arch == ZigLLVM_x86)
289288 return LLVMX86StdcallCallConv;
290 } else {
291 return LLVMCCallConv;
292 }
289 return LLVMCCallConv;
290 case CallingConventionFastcall:
291 if (g->zig_target->arch == ZigLLVM_x86)
292 return LLVMX86FastcallCallConv;
293 return LLVMFastCallConv;
294 case CallingConventionVectorcall:
295 if (g->zig_target->arch == ZigLLVM_x86)
296 return LLVMX86VectorCallCallConv;
297 return LLVMCCallConv;
293298 case CallingConventionAsync:
294299 return LLVMFastCallConv;
300 case CallingConventionAPCS:
301 if (target_is_arm(g->zig_target))
302 return LLVMARMAPCSCallConv;
303 return LLVMCCallConv;
304 case CallingConventionAAPCS:
305 if (target_is_arm(g->zig_target))
306 return LLVMARMAAPCSCallConv;
307 return LLVMCCallConv;
308 case CallingConventionAAPCSVFP:
309 if (target_is_arm(g->zig_target))
310 return LLVMARMAAPCSVFPCallConv;
311 return LLVMCCallConv;
312 case CallingConventionInterrupt:
313 if (g->zig_target->arch == ZigLLVM_x86 || g->zig_target->arch == ZigLLVM_x86_64)
314 return LLVMX86INTRCallConv;
315 if (g->zig_target->arch == ZigLLVM_avr)
316 return LLVMAVRINTRCallConv;
317 if (g->zig_target->arch == ZigLLVM_msp430)
318 return LLVMMSP430INTRCallConv;
319 return LLVMCCallConv;
320 case CallingConventionSignal:
321 if (g->zig_target->arch == ZigLLVM_avr)
322 return LLVMAVRSIGNALCallConv;
323 return LLVMCCallConv;
295324 }
296325 zig_unreachable();
297326}
......@@ -383,7 +412,14 @@ static bool cc_want_sret_attr(CallingConvention cc) {
383412 zig_unreachable();
384413 case CallingConventionC:
385414 case CallingConventionCold:
415 case CallingConventionInterrupt:
416 case CallingConventionSignal:
386417 case CallingConventionStdcall:
418 case CallingConventionFastcall:
419 case CallingConventionVectorcall:
420 case CallingConventionAPCS:
421 case CallingConventionAAPCS:
422 case CallingConventionAAPCSVFP:
387423 return true;
388424 case CallingConventionAsync:
389425 case CallingConventionUnspecified:
......@@ -8463,8 +8499,15 @@ Buf *codegen_generate_builtin_source(CodeGen *g) {
84638499 static_assert(CallingConventionC == 1, "");
84648500 static_assert(CallingConventionCold == 2, "");
84658501 static_assert(CallingConventionNaked == 3, "");
8466 static_assert(CallingConventionStdcall == 4, "");
8467 static_assert(CallingConventionAsync == 5, "");
8502 static_assert(CallingConventionAsync == 4, "");
8503 static_assert(CallingConventionInterrupt == 5, "");
8504 static_assert(CallingConventionSignal == 6, "");
8505 static_assert(CallingConventionStdcall == 7, "");
8506 static_assert(CallingConventionFastcall == 8, "");
8507 static_assert(CallingConventionVectorcall == 9, "");
8508 static_assert(CallingConventionAPCS == 10, "");
8509 static_assert(CallingConventionAAPCS == 11, "");
8510 static_assert(CallingConventionAAPCSVFP == 12, "");
84688511
84698512 static_assert(FnInlineAuto == 0, "");
84708513 static_assert(FnInlineAlways == 1, "");
src/ir.cpp+45-12
......@@ -3250,12 +3250,13 @@ static IrInstruction *ir_build_unwrap_err_payload(IrBuilder *irb, Scope *scope,
32503250}
32513251
32523252static IrInstruction *ir_build_fn_proto(IrBuilder *irb, Scope *scope, AstNode *source_node,
3253 IrInstruction **param_types, IrInstruction *align_value, IrInstruction *return_type,
3254 bool is_var_args)
3253 IrInstruction **param_types, IrInstruction *align_value, IrInstruction *callconv_value,
3254 IrInstruction *return_type, bool is_var_args)
32553255{
32563256 IrInstructionFnProto *instruction = ir_build_instruction<IrInstructionFnProto>(irb, scope, source_node);
32573257 instruction->param_types = param_types;
32583258 instruction->align_value = align_value;
3259 instruction->callconv_value = callconv_value;
32593260 instruction->return_type = return_type;
32603261 instruction->is_var_args = is_var_args;
32613262
......@@ -3266,6 +3267,7 @@ static IrInstruction *ir_build_fn_proto(IrBuilder *irb, Scope *scope, AstNode *s
32663267 if (param_types[i] != nullptr) ir_ref_instruction(param_types[i], irb->current_basic_block);
32673268 }
32683269 if (align_value != nullptr) ir_ref_instruction(align_value, irb->current_basic_block);
3270 if (callconv_value != nullptr) ir_ref_instruction(callconv_value, irb->current_basic_block);
32693271 ir_ref_instruction(return_type, irb->current_basic_block);
32703272
32713273 return &instruction->base;
......@@ -8850,6 +8852,13 @@ static IrInstruction *ir_gen_fn_proto(IrBuilder *irb, Scope *parent_scope, AstNo
88508852 return irb->codegen->invalid_instruction;
88518853 }
88528854
8855 IrInstruction *callconv_value = nullptr;
8856 if (node->data.fn_proto.callconv_expr != nullptr) {
8857 callconv_value = ir_gen_node(irb, node->data.fn_proto.callconv_expr, parent_scope);
8858 if (callconv_value == irb->codegen->invalid_instruction)
8859 return irb->codegen->invalid_instruction;
8860 }
8861
88538862 IrInstruction *return_type;
88548863 if (node->data.fn_proto.return_var_token == nullptr) {
88558864 if (node->data.fn_proto.return_type == nullptr) {
......@@ -8866,7 +8875,7 @@ static IrInstruction *ir_gen_fn_proto(IrBuilder *irb, Scope *parent_scope, AstNo
88668875 //return_type = nullptr;
88678876 }
88688877
8869 return ir_build_fn_proto(irb, parent_scope, node, param_types, align_value, return_type, is_var_args);
8878 return ir_build_fn_proto(irb, parent_scope, node, param_types, align_value, callconv_value, return_type, is_var_args);
88708879}
88718880
88728881static IrInstruction *ir_gen_resume(IrBuilder *irb, Scope *scope, AstNode *node) {
......@@ -16736,9 +16745,16 @@ static IrInstruction *ir_analyze_instruction_export(IrAnalyze *ira, IrInstructio
1673616745 add_error_note(ira->codegen, msg, fn_entry->proto_node, buf_sprintf("declared here"));
1673716746 } break;
1673816747 case CallingConventionC:
16739 case CallingConventionNaked:
1674016748 case CallingConventionCold:
16749 case CallingConventionNaked:
16750 case CallingConventionInterrupt:
16751 case CallingConventionSignal:
1674116752 case CallingConventionStdcall:
16753 case CallingConventionFastcall:
16754 case CallingConventionVectorcall:
16755 case CallingConventionAPCS:
16756 case CallingConventionAAPCS:
16757 case CallingConventionAAPCSVFP:
1674216758 add_fn_export(ira->codegen, fn_entry, buf_ptr(symbol_name), global_linkage_id, cc);
1674316759 break;
1674416760 }
......@@ -18101,7 +18117,6 @@ static IrInstruction *ir_analyze_fn_call(IrAnalyze *ira, IrInstruction *source_i
1810118117 return ira->codegen->invalid_instruction;
1810218118 }
1810318119
18104
1810518120 if (fn_type_id->is_var_args) {
1810618121 if (call_param_count < src_param_count) {
1810718122 ErrorMsg *msg = ir_add_error_node(ira, source_node,
......@@ -18254,8 +18269,9 @@ static IrInstruction *ir_analyze_fn_call(IrAnalyze *ira, IrInstruction *source_i
1825418269 buf_init_from_buf(&impl_fn->symbol_name, &fn_entry->symbol_name);
1825518270 impl_fn->fndef_scope = create_fndef_scope(ira->codegen, impl_fn->body_node, parent_scope, impl_fn);
1825618271 impl_fn->child_scope = &impl_fn->fndef_scope->base;
18272 impl_fn->cc = fn_entry->cc;
1825718273 FnTypeId inst_fn_type_id = {0};
18258 init_fn_type_id(&inst_fn_type_id, fn_proto_node, new_fn_arg_count);
18274 init_fn_type_id(&inst_fn_type_id, fn_proto_node, fn_type_id->cc, new_fn_arg_count);
1825918275 inst_fn_type_id.param_count = 0;
1826018276 inst_fn_type_id.is_var_args = false;
1826118277
......@@ -22592,8 +22608,8 @@ static Error ir_make_type_info_decls(IrAnalyze *ira, IrInstruction *source_instr
2259222608 // calling_convention: TypeInfo.CallingConvention
2259322609 ensure_field_index(fn_decl_val->type, "calling_convention", 2);
2259422610 fn_decl_fields[2]->special = ConstValSpecialStatic;
22595 fn_decl_fields[2]->type = ir_type_info_get_type(ira, "CallingConvention", nullptr);
22596 bigint_init_unsigned(&fn_decl_fields[2]->data.x_enum_tag, fn_node->cc);
22611 fn_decl_fields[2]->type = get_builtin_type(ira->codegen, "CallingConvention");
22612 bigint_init_unsigned(&fn_decl_fields[2]->data.x_enum_tag, fn_entry->cc);
2259722613 // is_var_args: bool
2259822614 ensure_field_index(fn_decl_val->type, "is_var_args", 3);
2259922615 bool is_varargs = fn_node->is_var_args;
......@@ -23280,7 +23296,7 @@ static Error ir_make_type_info_value(IrAnalyze *ira, IrInstruction *source_instr
2328023296 // calling_convention: TypeInfo.CallingConvention
2328123297 ensure_field_index(result->type, "calling_convention", 0);
2328223298 fields[0]->special = ConstValSpecialStatic;
23283 fields[0]->type = ir_type_info_get_type(ira, "CallingConvention", nullptr);
23299 fields[0]->type = get_builtin_type(ira->codegen, "CallingConvention");
2328423300 bigint_init_unsigned(&fields[0]->data.x_enum_tag, type_entry->data.fn.fn_type_id.cc);
2328523301 // is_generic: bool
2328623302 ensure_field_index(result->type, "is_generic", 1);
......@@ -26192,6 +26208,21 @@ static IrInstruction *ir_analyze_instruction_fn_proto(IrAnalyze *ira, IrInstruct
2619226208 return ira->codegen->invalid_instruction;
2619326209 }
2619426210
26211 lazy_fn_type->cc = cc_from_fn_proto(&proto_node->data.fn_proto);
26212 if (instruction->callconv_value != nullptr) {
26213 ZigType *cc_enum_type = get_builtin_type(ira->codegen, "CallingConvention");
26214
26215 IrInstruction *casted_value = ir_implicit_cast(ira, instruction->callconv_value, cc_enum_type);
26216 if (type_is_invalid(casted_value->value->type))
26217 return ira->codegen->invalid_instruction;
26218
26219 ZigValue *const_value = ir_resolve_const(ira, casted_value, UndefBad);
26220 if (const_value == nullptr)
26221 return ira->codegen->invalid_instruction;
26222
26223 lazy_fn_type->cc = (CallingConvention)bigint_as_u32(&const_value->data.x_enum_tag);
26224 }
26225
2619526226 size_t param_count = proto_node->data.fn_proto.params.length;
2619626227 lazy_fn_type->proto_node = proto_node;
2619726228 lazy_fn_type->param_types = allocate<IrInstruction *>(param_count);
......@@ -26202,9 +26233,11 @@ static IrInstruction *ir_analyze_instruction_fn_proto(IrAnalyze *ira, IrInstruct
2620226233
2620326234 bool param_is_var_args = param_node->data.param_decl.is_var_args;
2620426235 if (param_is_var_args) {
26205 if (proto_node->data.fn_proto.cc == CallingConventionC) {
26236 const CallingConvention cc = lazy_fn_type->cc;
26237
26238 if (cc == CallingConventionC) {
2620626239 break;
26207 } else if (proto_node->data.fn_proto.cc == CallingConventionUnspecified) {
26240 } else if (cc == CallingConventionUnspecified) {
2620826241 lazy_fn_type->is_generic = true;
2620926242 return result;
2621026243 } else {
......@@ -29062,7 +29095,7 @@ static ZigType *ir_resolve_lazy_fn_type(IrAnalyze *ira, AstNode *source_node, La
2906229095 AstNode *proto_node = lazy_fn_type->proto_node;
2906329096
2906429097 FnTypeId fn_type_id = {0};
29065 init_fn_type_id(&fn_type_id, proto_node, proto_node->data.fn_proto.params.length);
29098 init_fn_type_id(&fn_type_id, proto_node, lazy_fn_type->cc, proto_node->data.fn_proto.params.length);
2906629099
2906729100 for (; fn_type_id.next_param_index < fn_type_id.param_count; fn_type_id.next_param_index += 1) {
2906829101 AstNode *param_node = proto_node->data.fn_proto.params.at(fn_type_id.next_param_index);
src/parser.cpp+25-8
......@@ -92,6 +92,7 @@ static Token *ast_parse_block_label(ParseContext *pc);
9292static AstNode *ast_parse_field_init(ParseContext *pc);
9393static AstNode *ast_parse_while_continue_expr(ParseContext *pc);
9494static AstNode *ast_parse_link_section(ParseContext *pc);
95static AstNode *ast_parse_callconv(ParseContext *pc);
9596static Optional<AstNodeFnProto> ast_parse_fn_cc(ParseContext *pc);
9697static AstNode *ast_parse_param_decl(ParseContext *pc);
9798static AstNode *ast_parse_param_type(ParseContext *pc);
......@@ -676,7 +677,9 @@ static AstNode *ast_parse_top_level_decl(ParseContext *pc, VisibMod visib_mod, B
676677 fn_proto->column = first->start_column;
677678 fn_proto->data.fn_proto.visib_mod = visib_mod;
678679 fn_proto->data.fn_proto.doc_comments = *doc_comments;
679 fn_proto->data.fn_proto.is_extern = first->id == TokenIdKeywordExtern;
680 // ast_parse_fn_cc may set it
681 if (!fn_proto->data.fn_proto.is_extern)
682 fn_proto->data.fn_proto.is_extern = first->id == TokenIdKeywordExtern;
680683 fn_proto->data.fn_proto.is_export = first->id == TokenIdKeywordExport;
681684 switch (first->id) {
682685 case TokenIdKeywordInline:
......@@ -761,7 +764,7 @@ static AstNode *ast_parse_fn_proto(ParseContext *pc) {
761764 // The extern keyword for fn CC is also used for container decls.
762765 // We therefore put it back, as allow container decl to consume it
763766 // later.
764 if (fn_cc.cc == CallingConventionC) {
767 if (fn_cc.is_extern) {
765768 fn = eat_token_if(pc, TokenIdKeywordFn);
766769 if (fn == nullptr) {
767770 put_back_token(pc);
......@@ -784,6 +787,7 @@ static AstNode *ast_parse_fn_proto(ParseContext *pc) {
784787
785788 AstNode *align_expr = ast_parse_byte_align(pc);
786789 AstNode *section_expr = ast_parse_link_section(pc);
790 AstNode *callconv_expr = ast_parse_callconv(pc);
787791 Token *var = eat_token_if(pc, TokenIdKeywordVar);
788792 Token *exmark = nullptr;
789793 AstNode *return_type = nullptr;
......@@ -798,6 +802,7 @@ static AstNode *ast_parse_fn_proto(ParseContext *pc) {
798802 res->data.fn_proto.params = params;
799803 res->data.fn_proto.align_expr = align_expr;
800804 res->data.fn_proto.section_expr = section_expr;
805 res->data.fn_proto.callconv_expr = callconv_expr;
801806 res->data.fn_proto.return_var_token = var;
802807 res->data.fn_proto.auto_err_set = exmark != nullptr;
803808 res->data.fn_proto.return_type = return_type;
......@@ -2099,6 +2104,18 @@ static AstNode *ast_parse_link_section(ParseContext *pc) {
20992104 return res;
21002105}
21012106
2107// CallConv <- KEYWORD_callconv LPAREN Expr RPAREN
2108static AstNode *ast_parse_callconv(ParseContext *pc) {
2109 Token *first = eat_token_if(pc, TokenIdKeywordCallconv);
2110 if (first == nullptr)
2111 return nullptr;
2112
2113 expect_token(pc, TokenIdLParen);
2114 AstNode *res = ast_expect(pc, ast_parse_expr);
2115 expect_token(pc, TokenIdRParen);
2116 return res;
2117}
2118
21022119// FnCC
21032120// <- KEYWORD_nakedcc
21042121// / KEYWORD_stdcallcc
......@@ -2107,19 +2124,19 @@ static AstNode *ast_parse_link_section(ParseContext *pc) {
21072124static Optional<AstNodeFnProto> ast_parse_fn_cc(ParseContext *pc) {
21082125 AstNodeFnProto res = {};
21092126 if (eat_token_if(pc, TokenIdKeywordNakedCC) != nullptr) {
2110 res.cc = CallingConventionNaked;
2127 res.is_nakedcc = true;
21112128 return Optional<AstNodeFnProto>::some(res);
21122129 }
21132130 if (eat_token_if(pc, TokenIdKeywordStdcallCC) != nullptr) {
2114 res.cc = CallingConventionStdcall;
2131 res.is_stdcallcc = true;
21152132 return Optional<AstNodeFnProto>::some(res);
21162133 }
2117 if (eat_token_if(pc, TokenIdKeywordExtern) != nullptr) {
2118 res.cc = CallingConventionC;
2134 if (eat_token_if(pc, TokenIdKeywordAsync) != nullptr) {
2135 res.is_async = true;
21192136 return Optional<AstNodeFnProto>::some(res);
21202137 }
2121 if (eat_token_if(pc, TokenIdKeywordAsync) != nullptr) {
2122 res.cc = CallingConventionAsync;
2138 if (eat_token_if(pc, TokenIdKeywordExtern) != nullptr) {
2139 res.is_extern = true;
21232140 return Optional<AstNodeFnProto>::some(res);
21242141 }
21252142
src/tokenizer.cpp+2
......@@ -110,6 +110,7 @@ static const struct ZigKeyword zig_keywords[] = {
110110 {"async", TokenIdKeywordAsync},
111111 {"await", TokenIdKeywordAwait},
112112 {"break", TokenIdKeywordBreak},
113 {"callconv", TokenIdKeywordCallconv},
113114 {"catch", TokenIdKeywordCatch},
114115 {"comptime", TokenIdKeywordCompTime},
115116 {"const", TokenIdKeywordConst},
......@@ -1545,6 +1546,7 @@ const char * token_name(TokenId id) {
15451546 case TokenIdKeywordAsm: return "asm";
15461547 case TokenIdKeywordBreak: return "break";
15471548 case TokenIdKeywordCatch: return "catch";
1549 case TokenIdKeywordCallconv: return "callconv";
15481550 case TokenIdKeywordCompTime: return "comptime";
15491551 case TokenIdKeywordConst: return "const";
15501552 case TokenIdKeywordContinue: return "continue";
src/tokenizer.hpp+1
......@@ -59,6 +59,7 @@ enum TokenId {
5959 TokenIdKeywordAwait,
6060 TokenIdKeywordBreak,
6161 TokenIdKeywordCatch,
62 TokenIdKeywordCallconv,
6263 TokenIdKeywordCompTime,
6364 TokenIdKeywordConst,
6465 TokenIdKeywordContinue,
test/compile_errors.zig+15-15
......@@ -752,7 +752,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
752752 \\ _ = @frame();
753753 \\}
754754 , &[_][]const u8{
755 "tmp.zig:1:1: error: function with calling convention 'ccc' cannot be async",
755 "tmp.zig:1:1: error: function with calling convention 'C' cannot be async",
756756 "tmp.zig:5:9: note: @frame() causes function to be async",
757757 });
758758
......@@ -765,7 +765,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
765765 \\ suspend;
766766 \\}
767767 , &[_][]const u8{
768 "tmp.zig:1:1: error: function with calling convention 'ccc' cannot be async",
768 "tmp.zig:1:1: error: function with calling convention 'C' cannot be async",
769769 "tmp.zig:3:18: note: await here is a suspend point",
770770 });
771771
......@@ -843,7 +843,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
843843 \\ suspend;
844844 \\}
845845 , &[_][]const u8{
846 "tmp.zig:1:1: error: function with calling convention 'ccc' cannot be async",
846 "tmp.zig:1:1: error: function with calling convention 'C' cannot be async",
847847 "tmp.zig:2:8: note: async function call here",
848848 "tmp.zig:5:8: note: async function call here",
849849 "tmp.zig:8:5: note: suspends here",
......@@ -1140,7 +1140,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
11401140 \\ while (true) {}
11411141 \\}
11421142 , &[_][]const u8{
1143 "error: expected type 'fn([]const u8, ?*std.builtin.StackTrace) noreturn', found 'fn([]const u8,var)var'",
1143 "error: expected type 'fn([]const u8, ?*std.builtin.StackTrace) noreturn', found 'fn([]const u8,var) var'",
11441144 "note: only one of the functions is generic",
11451145 });
11461146
......@@ -1362,7 +1362,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
13621362 \\ return 0;
13631363 \\}
13641364 , &[_][]const u8{
1365 "tmp.zig:1:15: error: parameter of type 'var' not allowed in function with calling convention 'ccc'",
1365 "tmp.zig:1:15: error: parameter of type 'var' not allowed in function with calling convention 'C'",
13661366 });
13671367
13681368 cases.add("C pointer to c_void",
......@@ -2187,7 +2187,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
21872187 \\ f(g);
21882188 \\}
21892189 , &[_][]const u8{
2190 "tmp.zig:1:9: error: parameter of type 'fn(var)var' must be declared comptime",
2190 "tmp.zig:1:9: error: parameter of type 'fn(var) var' must be declared comptime",
21912191 });
21922192
21932193 cases.add("optional pointer to void in extern struct",
......@@ -2859,7 +2859,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
28592859 \\const Foo = enum { A, B, C };
28602860 \\export fn entry(foo: Foo) void { }
28612861 , &[_][]const u8{
2862 "tmp.zig:2:22: error: parameter of type 'Foo' not allowed in function with calling convention 'ccc'",
2862 "tmp.zig:2:22: error: parameter of type 'Foo' not allowed in function with calling convention 'C'",
28632863 });
28642864
28652865 cases.add("function with non-extern non-packed struct parameter",
......@@ -2870,7 +2870,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
28702870 \\};
28712871 \\export fn entry(foo: Foo) void { }
28722872 , &[_][]const u8{
2873 "tmp.zig:6:22: error: parameter of type 'Foo' not allowed in function with calling convention 'ccc'",
2873 "tmp.zig:6:22: error: parameter of type 'Foo' not allowed in function with calling convention 'C'",
28742874 });
28752875
28762876 cases.add("function with non-extern non-packed union parameter",
......@@ -2881,7 +2881,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
28812881 \\};
28822882 \\export fn entry(foo: Foo) void { }
28832883 , &[_][]const u8{
2884 "tmp.zig:6:22: error: parameter of type 'Foo' not allowed in function with calling convention 'ccc'",
2884 "tmp.zig:6:22: error: parameter of type 'Foo' not allowed in function with calling convention 'C'",
28852885 });
28862886
28872887 cases.add("switch on enum with 1 field with no prongs",
......@@ -2977,8 +2977,8 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
29772977 \\ bar(&{});
29782978 \\}
29792979 , &[_][]const u8{
2980 "tmp.zig:1:30: error: parameter of type '*void' has 0 bits; not allowed in function with calling convention 'ccc'",
2981 "tmp.zig:7:18: error: parameter of type '*void' has 0 bits; not allowed in function with calling convention 'ccc'",
2980 "tmp.zig:1:30: error: parameter of type '*void' has 0 bits; not allowed in function with calling convention 'C'",
2981 "tmp.zig:7:18: error: parameter of type '*void' has 0 bits; not allowed in function with calling convention 'C'",
29822982 });
29832983
29842984 cases.add("implicit semicolon - block statement",
......@@ -4552,7 +4552,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
45524552 \\ return x + y;
45534553 \\}
45544554 , &[_][]const u8{
4555 "tmp.zig:1:15: error: comptime parameter not allowed in function with calling convention 'ccc'",
4555 "tmp.zig:1:15: error: comptime parameter not allowed in function with calling convention 'C'",
45564556 });
45574557
45584558 cases.add("extern function with comptime parameter",
......@@ -4562,7 +4562,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
45624562 \\}
45634563 \\export fn entry() usize { return @sizeOf(@TypeOf(f)); }
45644564 , &[_][]const u8{
4565 "tmp.zig:1:15: error: comptime parameter not allowed in function with calling convention 'ccc'",
4565 "tmp.zig:1:15: error: comptime parameter not allowed in function with calling convention 'C'",
45664566 });
45674567
45684568 cases.add("convert fixed size array to slice with invalid size",
......@@ -6303,7 +6303,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
63036303 \\ _ = @TypeOf(generic).ReturnType;
63046304 \\}
63056305 , &[_][]const u8{
6306 "tmp.zig:3:25: error: ReturnType has not been resolved because 'fn(var)var' is generic",
6306 "tmp.zig:3:25: error: ReturnType has not been resolved because 'fn(var) var' is generic",
63076307 });
63086308
63096309 cases.add("getting @ArgType of generic function",
......@@ -6312,7 +6312,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
63126312 \\ _ = @ArgType(@TypeOf(generic), 0);
63136313 \\}
63146314 , &[_][]const u8{
6315 "tmp.zig:3:36: error: @ArgType could not resolve the type of arg 0 because 'fn(var)var' is generic",
6315 "tmp.zig:3:36: error: @ArgType could not resolve the type of arg 0 because 'fn(var) var' is generic",
63166316 });
63176317
63186318 cases.add("unsupported modifier at start of asm output constraint",
test/stage1/behavior/type_info.zig+2-2
......@@ -202,7 +202,7 @@ fn testUnion() void {
202202 expect(typeinfo_info.Union.fields[4].enum_field != null);
203203 expect(typeinfo_info.Union.fields[4].enum_field.?.value == 4);
204204 expect(typeinfo_info.Union.fields[4].field_type == @TypeOf(@typeInfo(u8).Int));
205 expect(typeinfo_info.Union.decls.len == 21);
205 expect(typeinfo_info.Union.decls.len == 20);
206206
207207 const TestNoTagUnion = union {
208208 Foo: void,
......@@ -266,7 +266,7 @@ test "type info: function type info" {
266266fn testFunction() void {
267267 const fn_info = @typeInfo(@TypeOf(foo));
268268 expect(@as(TypeId, fn_info) == TypeId.Fn);
269 expect(fn_info.Fn.calling_convention == TypeInfo.CallingConvention.Unspecified);
269 expect(fn_info.Fn.calling_convention == .Unspecified);
270270 expect(fn_info.Fn.is_generic);
271271 expect(fn_info.Fn.args.len == 2);
272272 expect(fn_info.Fn.is_var_args);