authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2020-05-07 12:42:26-04:00
committergravatar for noreply@github.comGitHub <noreply@github.com> 2020-05-07 12:42:26-04:00
logba43492c0e4b37924caf5956b4dbaf832b964b81
tree37af3289400d9536f170c8bf439de7e2eaedbc4b
parent20c1696865fc859e4f02a1f7a3e2e4bf4177a2d8
parent84a0a9688caea0f7cfe19bac07d5b5d46a06d470
signature Signed by PGP key 4AEE18F83AFDEB23

Merge pull request #5268 from tadeokondrak/remove-callconv-redundant-syntax

Remove syntax redundant with callconv

70 files changed, 299 insertions(+), 429 deletions(-)

doc/docgen.zig-2
......@@ -800,7 +800,6 @@ fn tokenizeAndPrintRaw(docgen_tokenizer: *Tokenizer, out: var, source_token: Tok
800800 .Keyword_for,
801801 .Keyword_if,
802802 .Keyword_inline,
803 .Keyword_nakedcc,
804803 .Keyword_noalias,
805804 .Keyword_noinline,
806805 .Keyword_nosuspend,
......@@ -813,7 +812,6 @@ fn tokenizeAndPrintRaw(docgen_tokenizer: *Tokenizer, out: var, source_token: Tok
813812 .Keyword_return,
814813 .Keyword_linksection,
815814 .Keyword_callconv,
816 .Keyword_stdcallcc,
817815 .Keyword_struct,
818816 .Keyword_suspend,
819817 .Keyword_switch,
doc/langref.html.in+3-8
......@@ -6713,7 +6713,7 @@ const assert = std.debug.assert;
67136713test "async fn pointer in a struct field" {
67146714 var data: i32 = 1;
67156715 const Foo = struct {
6716 bar: async fn (*i32) void,
6716 bar: fn (*i32) callconv(.Async) void,
67176717 };
67186718 var foo = Foo{ .bar = func };
67196719 var bytes: [64]u8 align(@alignOf(@Frame(func))) = undefined;
......@@ -6723,7 +6723,7 @@ test "async fn pointer in a struct field" {
67236723 assert(data == 4);
67246724}
67256725
6726async fn func(y: *i32) void {
6726fn func(y: *i32) void {
67276727 defer y.* += 2;
67286728 y.* += 1;
67296729 suspend;
......@@ -10086,7 +10086,7 @@ TopLevelDecl
1008610086 / (KEYWORD_export / KEYWORD_extern STRINGLITERALSINGLE?)? KEYWORD_threadlocal? VarDecl
1008710087 / KEYWORD_usingnamespace Expr SEMICOLON
1008810088
10089FnProto &lt;- FnCC? KEYWORD_fn IDENTIFIER? LPAREN ParamDeclList RPAREN ByteAlign? LinkSection? EXCLAMATIONMARK? (KEYWORD_var / TypeExpr)
10089FnProto &lt;- KEYWORD_fn IDENTIFIER? LPAREN ParamDeclList RPAREN ByteAlign? LinkSection? EXCLAMATIONMARK? (KEYWORD_var / TypeExpr)
1009010090
1009110091VarDecl &lt;- (KEYWORD_const / KEYWORD_var) IDENTIFIER (COLON TypeExpr)? ByteAlign? LinkSection? (EQUAL Expr)? SEMICOLON
1009210092
......@@ -10253,11 +10253,6 @@ WhileContinueExpr &lt;- COLON LPAREN AssignExpr RPAREN
1025310253
1025410254LinkSection &lt;- KEYWORD_linksection LPAREN Expr RPAREN
1025510255
10256# Fn specific
10257FnCC
10258 &lt;- KEYWORD_extern
10259 / KEYWORD_async
10260
1026110256ParamDecl &lt;- (KEYWORD_noalias / KEYWORD_comptime)? (IDENTIFIER COLON)? ParamType
1026210257
1026310258ParamType
lib/std/c.zig+1-1
......@@ -217,7 +217,7 @@ pub extern "c" fn utimes(path: [*:0]const u8, times: *[2]timeval) c_int;
217217pub extern "c" fn utimensat(dirfd: fd_t, pathname: [*:0]const u8, times: *[2]timespec, flags: u32) c_int;
218218pub extern "c" fn futimens(fd: fd_t, times: *const [2]timespec) c_int;
219219
220pub extern "c" fn pthread_create(noalias newthread: *pthread_t, noalias attr: ?*const pthread_attr_t, start_routine: extern fn (?*c_void) ?*c_void, noalias arg: ?*c_void) c_int;
220pub extern "c" fn pthread_create(noalias newthread: *pthread_t, noalias attr: ?*const pthread_attr_t, start_routine: fn (?*c_void) callconv(.C) ?*c_void, noalias arg: ?*c_void) c_int;
221221pub extern "c" fn pthread_attr_init(attr: *pthread_attr_t) c_int;
222222pub extern "c" fn pthread_attr_setstack(attr: *pthread_attr_t, stackaddr: *c_void, stacksize: usize) c_int;
223223pub extern "c" fn pthread_attr_setguardsize(attr: *pthread_attr_t, guardsize: usize) c_int;
lib/std/c/dragonfly.zig+1-1
......@@ -9,7 +9,7 @@ pub extern "c" fn getdents(fd: c_int, buf_ptr: [*]u8, nbytes: usize) usize;
99pub extern "c" fn sigaltstack(ss: ?*stack_t, old_ss: ?*stack_t) c_int;
1010pub extern "c" fn getrandom(buf_ptr: [*]u8, buf_len: usize, flags: c_uint) isize;
1111
12pub const dl_iterate_phdr_callback = extern fn (info: *dl_phdr_info, size: usize, data: ?*c_void) c_int;
12pub const dl_iterate_phdr_callback = fn (info: *dl_phdr_info, size: usize, data: ?*c_void) callconv(.C) c_int;
1313pub extern "c" fn dl_iterate_phdr(callback: dl_iterate_phdr_callback, data: ?*c_void) c_int;
1414
1515pub const pthread_mutex_t = extern struct {
lib/std/c/freebsd.zig+1-1
......@@ -24,7 +24,7 @@ pub extern "c" fn sendfile(
2424 flags: u32,
2525) c_int;
2626
27pub const dl_iterate_phdr_callback = extern fn (info: *dl_phdr_info, size: usize, data: ?*c_void) c_int;
27pub const dl_iterate_phdr_callback = fn (info: *dl_phdr_info, size: usize, data: ?*c_void) callconv(.C) c_int;
2828pub extern "c" fn dl_iterate_phdr(callback: dl_iterate_phdr_callback, data: ?*c_void) c_int;
2929
3030pub const pthread_mutex_t = extern struct {
lib/std/c/linux.zig+1-1
......@@ -75,7 +75,7 @@ pub extern "c" fn inotify_add_watch(fd: fd_t, pathname: [*]const u8, mask: u32)
7575/// See std.elf for constants for this
7676pub extern "c" fn getauxval(__type: c_ulong) c_ulong;
7777
78pub const dl_iterate_phdr_callback = extern fn (info: *dl_phdr_info, size: usize, data: ?*c_void) c_int;
78pub const dl_iterate_phdr_callback = fn (info: *dl_phdr_info, size: usize, data: ?*c_void) callconv(.C) c_int;
7979pub extern "c" fn dl_iterate_phdr(callback: dl_iterate_phdr_callback, data: ?*c_void) c_int;
8080
8181pub extern "c" fn sigaltstack(ss: ?*stack_t, old_ss: ?*stack_t) c_int;
lib/std/c/netbsd.zig+1-1
......@@ -6,7 +6,7 @@ usingnamespace std.c;
66extern "c" fn __errno() *c_int;
77pub const _errno = __errno;
88
9pub const dl_iterate_phdr_callback = extern fn (info: *dl_phdr_info, size: usize, data: ?*c_void) c_int;
9pub const dl_iterate_phdr_callback = fn (info: *dl_phdr_info, size: usize, data: ?*c_void) callconv(.C) c_int;
1010pub extern "c" fn dl_iterate_phdr(callback: dl_iterate_phdr_callback, data: ?*c_void) c_int;
1111
1212pub extern "c" fn arc4random_buf(buf: [*]u8, len: usize) void;
lib/std/event/channel.zig+4-7
......@@ -105,7 +105,7 @@ pub fn Channel(comptime T: type) type {
105105
106106 /// await this function to get an item from the channel. If the buffer is empty, the frame will
107107 /// complete when the next item is put in the channel.
108 pub async fn get(self: *SelfChannel) T {
108 pub fn get(self: *SelfChannel) callconv(.Async) T {
109109 // TODO https://github.com/ziglang/zig/issues/2765
110110 var result: T = undefined;
111111 var my_tick_node = Loop.NextTickNode.init(@frame());
......@@ -305,8 +305,7 @@ test "std.event.Channel wraparound" {
305305 channel.put(7);
306306 testing.expectEqual(@as(i32, 7), channel.get());
307307}
308
309async fn testChannelGetter(channel: *Channel(i32)) void {
308fn testChannelGetter(channel: *Channel(i32)) callconv(.Async) void {
310309 const value1 = channel.get();
311310 testing.expect(value1 == 1234);
312311
......@@ -321,12 +320,10 @@ async fn testChannelGetter(channel: *Channel(i32)) void {
321320 testing.expect(value4.? == 4444);
322321 await last_put;
323322}
324
325async fn testChannelPutter(channel: *Channel(i32)) void {
323fn testChannelPutter(channel: *Channel(i32)) callconv(.Async) void {
326324 channel.put(1234);
327325 channel.put(4567);
328326}
329
330async fn testPut(channel: *Channel(i32), value: i32) void {
327fn testPut(channel: *Channel(i32), value: i32) callconv(.Async) void {
331328 channel.put(value);
332329}
lib/std/event/future.zig+2-2
......@@ -34,7 +34,7 @@ pub fn Future(comptime T: type) type {
3434 /// Obtain the value. If it's not available, wait until it becomes
3535 /// available.
3636 /// Thread-safe.
37 pub async fn get(self: *Self) *T {
37 pub fn get(self: *Self) callconv(.Async) *T {
3838 if (@atomicLoad(Available, &self.available, .SeqCst) == .Finished) {
3939 return &self.data;
4040 }
......@@ -59,7 +59,7 @@ pub fn Future(comptime T: type) type {
5959 /// should start working on the data.
6060 /// It's not required to call start() before resolve() but it can be useful since
6161 /// this method is thread-safe.
62 pub async fn start(self: *Self) ?*T {
62 pub fn start(self: *Self) callconv(.Async) ?*T {
6363 const state = @cmpxchgStrong(Available, &self.available, .NotStarted, .Started, .SeqCst, .SeqCst) orelse return null;
6464 switch (state) {
6565 .Started => {
lib/std/event/group.zig+6-10
......@@ -84,7 +84,7 @@ pub fn Group(comptime ReturnType: type) type {
8484 /// Wait for all the calls and promises of the group to complete.
8585 /// Thread-safe.
8686 /// Safe to call any number of times.
87 pub async fn wait(self: *Self) ReturnType {
87 pub fn wait(self: *Self) callconv(.Async) ReturnType {
8888 const held = self.lock.acquire();
8989 defer held.release();
9090
......@@ -127,8 +127,7 @@ test "std.event.Group" {
127127
128128 const handle = async testGroup(std.heap.page_allocator);
129129}
130
131async fn testGroup(allocator: *Allocator) void {
130fn testGroup(allocator: *Allocator) callconv(.Async) void {
132131 var count: usize = 0;
133132 var group = Group(void).init(allocator);
134133 var sleep_a_little_frame = async sleepALittle(&count);
......@@ -145,20 +144,17 @@ async fn testGroup(allocator: *Allocator) void {
145144 another.add(&something_that_fails_frame) catch @panic("memory");
146145 testing.expectError(error.ItBroke, another.wait());
147146}
148
149async fn sleepALittle(count: *usize) void {
147fn sleepALittle(count: *usize) callconv(.Async) void {
150148 std.time.sleep(1 * std.time.millisecond);
151149 _ = @atomicRmw(usize, count, .Add, 1, .SeqCst);
152150}
153
154async fn increaseByTen(count: *usize) void {
151fn increaseByTen(count: *usize) callconv(.Async) void {
155152 var i: usize = 0;
156153 while (i < 10) : (i += 1) {
157154 _ = @atomicRmw(usize, count, .Add, 1, .SeqCst);
158155 }
159156}
160
161async fn doSomethingThatFails() anyerror!void {}
162async fn somethingElse() anyerror!void {
157fn doSomethingThatFails() callconv(.Async) anyerror!void {}
158fn somethingElse() callconv(.Async) anyerror!void {
163159 return error.ItBroke;
164160}
lib/std/event/lock.zig+3-5
......@@ -89,7 +89,7 @@ pub const Lock = struct {
8989 while (self.queue.get()) |node| resume node.data;
9090 }
9191
92 pub async fn acquire(self: *Lock) Held {
92 pub fn acquire(self: *Lock) callconv(.Async) Held {
9393 var my_tick_node = Loop.NextTickNode.init(@frame());
9494
9595 errdefer _ = self.queue.remove(&my_tick_node); // TODO test canceling an acquire
......@@ -134,8 +134,7 @@ test "std.event.Lock" {
134134 const expected_result = [1]i32{3 * @intCast(i32, shared_test_data.len)} ** shared_test_data.len;
135135 testing.expectEqualSlices(i32, &expected_result, &shared_test_data);
136136}
137
138async fn testLock(lock: *Lock) void {
137fn testLock(lock: *Lock) callconv(.Async) void {
139138 var handle1 = async lockRunner(lock);
140139 var tick_node1 = Loop.NextTickNode{
141140 .prev = undefined,
......@@ -167,8 +166,7 @@ async fn testLock(lock: *Lock) void {
167166
168167var shared_test_data = [1]i32{0} ** 10;
169168var shared_test_index: usize = 0;
170
171async fn lockRunner(lock: *Lock) void {
169fn lockRunner(lock: *Lock) callconv(.Async) void {
172170 suspend; // resumed by onNextTick
173171
174172 var i: usize = 0;
lib/std/event/locked.zig+1-1
......@@ -31,7 +31,7 @@ pub fn Locked(comptime T: type) type {
3131 self.lock.deinit();
3232 }
3333
34 pub async fn acquire(self: *Self) HeldLock {
34 pub fn acquire(self: *Self) callconv(.Async) HeldLock {
3535 return HeldLock{
3636 // TODO guaranteed allocation elision
3737 .held = self.lock.acquire(),
lib/std/event/loop.zig+1-1
......@@ -503,7 +503,7 @@ pub const Loop = struct {
503503 }
504504 }
505505
506 pub async fn bsdWaitKev(self: *Loop, ident: usize, filter: i16, fflags: u32) void {
506 pub fn bsdWaitKev(self: *Loop, ident: usize, filter: i16, fflags: u32) callconv(.Async) void {
507507 var resume_node = ResumeNode.Basic{
508508 .base = ResumeNode{
509509 .id = ResumeNode.Id.Basic,
lib/std/event/rwlock.zig+5-8
......@@ -97,7 +97,7 @@ pub const RwLock = struct {
9797 while (self.reader_queue.get()) |node| resume node.data;
9898 }
9999
100 pub async fn acquireRead(self: *RwLock) HeldRead {
100 pub fn acquireRead(self: *RwLock) callconv(.Async) HeldRead {
101101 _ = @atomicRmw(usize, &self.reader_lock_count, .Add, 1, .SeqCst);
102102
103103 suspend {
......@@ -130,7 +130,7 @@ pub const RwLock = struct {
130130 return HeldRead{ .lock = self };
131131 }
132132
133 pub async fn acquireWrite(self: *RwLock) HeldWrite {
133 pub fn acquireWrite(self: *RwLock) callconv(.Async) HeldWrite {
134134 suspend {
135135 var my_tick_node = Loop.NextTickNode{
136136 .data = @frame(),
......@@ -225,8 +225,7 @@ test "std.event.RwLock" {
225225 const expected_result = [1]i32{shared_it_count * @intCast(i32, shared_test_data.len)} ** shared_test_data.len;
226226 testing.expectEqualSlices(i32, expected_result, shared_test_data);
227227}
228
229async fn testLock(allocator: *Allocator, lock: *RwLock) void {
228fn testLock(allocator: *Allocator, lock: *RwLock) callconv(.Async) void {
230229 var read_nodes: [100]Loop.NextTickNode = undefined;
231230 for (read_nodes) |*read_node| {
232231 const frame = allocator.create(@Frame(readRunner)) catch @panic("memory");
......@@ -259,8 +258,7 @@ const shared_it_count = 10;
259258var shared_test_data = [1]i32{0} ** 10;
260259var shared_test_index: usize = 0;
261260var shared_count: usize = 0;
262
263async fn writeRunner(lock: *RwLock) void {
261fn writeRunner(lock: *RwLock) callconv(.Async) void {
264262 suspend; // resumed by onNextTick
265263
266264 var i: usize = 0;
......@@ -277,8 +275,7 @@ async fn writeRunner(lock: *RwLock) void {
277275 shared_test_index = 0;
278276 }
279277}
280
281async fn readRunner(lock: *RwLock) void {
278fn readRunner(lock: *RwLock) callconv(.Async) void {
282279 suspend; // resumed by onNextTick
283280 std.time.sleep(1);
284281
lib/std/event/rwlocked.zig+2-2
......@@ -40,14 +40,14 @@ pub fn RwLocked(comptime T: type) type {
4040 self.lock.deinit();
4141 }
4242
43 pub async fn acquireRead(self: *Self) HeldReadLock {
43 pub fn acquireRead(self: *Self) callconv(.Async) HeldReadLock {
4444 return HeldReadLock{
4545 .held = self.lock.acquireRead(),
4646 .value = &self.locked_data,
4747 };
4848 }
4949
50 pub async fn acquireWrite(self: *Self) HeldWriteLock {
50 pub fn acquireWrite(self: *Self) callconv(.Async) HeldWriteLock {
5151 return HeldWriteLock{
5252 .held = self.lock.acquireWrite(),
5353 .value = &self.locked_data,
lib/std/os/bits/darwin.zig+1-1
......@@ -125,7 +125,7 @@ pub const empty_sigset = sigset_t(0);
125125
126126/// Renamed from `sigaction` to `Sigaction` to avoid conflict with function name.
127127pub const Sigaction = extern struct {
128 handler: extern fn (c_int) void,
128 handler: fn (c_int) callconv(.C) void,
129129 sa_mask: sigset_t,
130130 sa_flags: c_int,
131131};
lib/std/os/bits/dragonfly.zig+6-6
......@@ -458,9 +458,9 @@ pub const S_IFSOCK = 49152;
458458pub const S_IFWHT = 57344;
459459pub const S_IFMT = 61440;
460460
461pub const SIG_ERR = @intToPtr(extern fn (i32) void, maxInt(usize));
462pub const SIG_DFL = @intToPtr(extern fn (i32) void, 0);
463pub const SIG_IGN = @intToPtr(extern fn (i32) void, 1);
461pub const SIG_ERR = @intToPtr(fn (i32) callconv(.C) void, maxInt(usize));
462pub const SIG_DFL = @intToPtr(fn (i32) callconv(.C) void, 0);
463pub const SIG_IGN = @intToPtr(fn (i32) callconv(.C) void, 1);
464464pub const BADSIG = SIG_ERR;
465465pub const SIG_BLOCK = 1;
466466pub const SIG_UNBLOCK = 2;
......@@ -519,13 +519,13 @@ pub const sigset_t = extern struct {
519519pub const sig_atomic_t = c_int;
520520pub const Sigaction = extern struct {
521521 __sigaction_u: extern union {
522 __sa_handler: ?extern fn (c_int) void,
523 __sa_sigaction: ?extern fn (c_int, [*c]siginfo_t, ?*c_void) void,
522 __sa_handler: ?fn (c_int) callconv(.C) void,
523 __sa_sigaction: ?fn (c_int, [*c]siginfo_t, ?*c_void) callconv(.C) void,
524524 },
525525 sa_flags: c_int,
526526 sa_mask: sigset_t,
527527};
528pub const sig_t = [*c]extern fn (c_int) void;
528pub const sig_t = [*c]fn (c_int) callconv(.C) void;
529529
530530pub const sigvec = extern struct {
531531 sv_handler: [*c]__sighandler_t,
lib/std/os/bits/freebsd.zig+5-5
......@@ -725,16 +725,16 @@ pub const winsize = extern struct {
725725
726726const NSIG = 32;
727727
728pub const SIG_ERR = @intToPtr(extern fn (i32) void, maxInt(usize));
729pub const SIG_DFL = @intToPtr(extern fn (i32) void, 0);
730pub const SIG_IGN = @intToPtr(extern fn (i32) void, 1);
728pub const SIG_ERR = @intToPtr(fn (i32) callconv(.C) void, maxInt(usize));
729pub const SIG_DFL = @intToPtr(fn (i32) callconv(.C) void, 0);
730pub const SIG_IGN = @intToPtr(fn (i32) callconv(.C) void, 1);
731731
732732/// Renamed from `sigaction` to `Sigaction` to avoid conflict with the syscall.
733733pub const Sigaction = extern struct {
734734 /// signal handler
735735 __sigaction_u: extern union {
736 __sa_handler: extern fn (i32) void,
737 __sa_sigaction: extern fn (i32, *__siginfo, usize) void,
736 __sa_handler: fn (i32) callconv(.C) void,
737 __sa_sigaction: fn (i32, *__siginfo, usize) callconv(.C) void,
738738 },
739739
740740 /// see signal options
lib/std/os/bits/linux.zig+5-5
......@@ -813,15 +813,15 @@ pub const app_mask: sigset_t = [2]u32{ 0xfffffffc, 0x7fffffff } ++ [_]u32{0xffff
813813pub const k_sigaction = if (is_mips)
814814 extern struct {
815815 flags: usize,
816 sigaction: ?extern fn (i32, *siginfo_t, ?*c_void) void,
816 sigaction: ?fn (i32, *siginfo_t, ?*c_void) callconv(.C) void,
817817 mask: [4]u32,
818 restorer: extern fn () void,
818 restorer: fn () callconv(.C) void,
819819 }
820820else
821821 extern struct {
822 sigaction: ?extern fn (i32, *siginfo_t, ?*c_void) void,
822 sigaction: ?fn (i32, *siginfo_t, ?*c_void) callconv(.C) void,
823823 flags: usize,
824 restorer: extern fn () void,
824 restorer: fn () callconv(.C) void,
825825 mask: [2]u32,
826826 };
827827
......@@ -831,7 +831,7 @@ pub const Sigaction = extern struct {
831831 sigaction: ?sigaction_fn,
832832 mask: sigset_t,
833833 flags: u32,
834 restorer: ?extern fn () void = null,
834 restorer: ?fn () callconv(.C) void = null,
835835};
836836
837837pub const SIG_ERR = @intToPtr(?Sigaction.sigaction_fn, maxInt(usize));
lib/std/os/linux.zig+2-2
......@@ -599,7 +599,7 @@ pub fn flock(fd: fd_t, operation: i32) usize {
599599var vdso_clock_gettime = @ptrCast(?*const c_void, init_vdso_clock_gettime);
600600
601601// We must follow the C calling convention when we call into the VDSO
602const vdso_clock_gettime_ty = extern fn (i32, *timespec) usize;
602const vdso_clock_gettime_ty = fn (i32, *timespec) callconv(.C) usize;
603603
604604pub fn clock_gettime(clk_id: i32, tp: *timespec) usize {
605605 if (@hasDecl(@This(), "VDSO_CGT_SYM")) {
......@@ -791,7 +791,7 @@ pub fn sigaction(sig: u6, noalias act: *const Sigaction, noalias oact: ?*Sigacti
791791 .sigaction = act.sigaction,
792792 .flags = act.flags | SA_RESTORER,
793793 .mask = undefined,
794 .restorer = @ptrCast(extern fn () void, restorer_fn),
794 .restorer = @ptrCast(fn () callconv(.C) void, restorer_fn),
795795 };
796796 var ksa_old: k_sigaction = undefined;
797797 const ksa_mask_size = @sizeOf(@TypeOf(ksa_old.mask));
lib/std/os/linux/arm-eabi.zig+1-1
......@@ -86,7 +86,7 @@ pub fn syscall6(
8686}
8787
8888/// This matches the libc clone function.
89pub extern fn clone(func: extern fn (arg: usize) u8, stack: usize, flags: u32, arg: usize, ptid: *i32, tls: usize, ctid: *i32) usize;
89pub extern fn clone(func: fn (arg: usize) callconv(.C) u8, stack: usize, flags: u32, arg: usize, ptid: *i32, tls: usize, ctid: *i32) usize;
9090
9191pub fn restore() callconv(.Naked) void {
9292 return asm volatile ("svc #0"
lib/std/os/linux/arm64.zig+1-1
......@@ -86,7 +86,7 @@ pub fn syscall6(
8686}
8787
8888/// This matches the libc clone function.
89pub extern fn clone(func: extern fn (arg: usize) u8, stack: usize, flags: u32, arg: usize, ptid: *i32, tls: usize, ctid: *i32) usize;
89pub extern fn clone(func: fn (arg: usize) callconv(.C) u8, stack: usize, flags: u32, arg: usize, ptid: *i32, tls: usize, ctid: *i32) usize;
9090
9191pub const restore = restore_rt;
9292
lib/std/os/linux/i386.zig+1-1
......@@ -106,7 +106,7 @@ pub fn socketcall(call: usize, args: [*]usize) usize {
106106}
107107
108108/// This matches the libc clone function.
109pub extern fn clone(func: extern fn (arg: usize) u8, stack: usize, flags: u32, arg: usize, ptid: *i32, tls: usize, ctid: *i32) usize;
109pub extern fn clone(func: fn (arg: usize) callconv(.C) u8, stack: usize, flags: u32, arg: usize, ptid: *i32, tls: usize, ctid: *i32) usize;
110110
111111pub fn restore() callconv(.Naked) void {
112112 return asm volatile ("int $0x80"
lib/std/os/linux/mips.zig+1-1
......@@ -142,7 +142,7 @@ pub fn syscall6(
142142}
143143
144144/// This matches the libc clone function.
145pub extern fn clone(func: extern fn (arg: usize) u8, stack: usize, flags: u32, arg: usize, ptid: *i32, tls: usize, ctid: *i32) usize;
145pub extern fn clone(func: fn (arg: usize) callconv(.C) u8, stack: usize, flags: u32, arg: usize, ptid: *i32, tls: usize, ctid: *i32) usize;
146146
147147pub fn restore() callconv(.Naked) void {
148148 return asm volatile ("syscall"
lib/std/os/linux/riscv64.zig+1-1
......@@ -85,7 +85,7 @@ pub fn syscall6(
8585 );
8686}
8787
88pub extern fn clone(func: extern fn (arg: usize) u8, stack: usize, flags: u32, arg: usize, ptid: *i32, tls: usize, ctid: *i32) usize;
88pub extern fn clone(func: fn (arg: usize) callconv(.C) u8, stack: usize, flags: u32, arg: usize, ptid: *i32, tls: usize, ctid: *i32) usize;
8989
9090pub const restore = restore_rt;
9191
lib/std/os/linux/x86_64.zig+1-1
......@@ -86,7 +86,7 @@ pub fn syscall6(
8686}
8787
8888/// This matches the libc clone function.
89pub extern fn clone(func: extern fn (arg: usize) u8, stack: usize, flags: usize, arg: usize, ptid: *i32, tls: usize, ctid: *i32) usize;
89pub extern fn clone(func: fn (arg: usize) callconv(.C) u8, stack: usize, flags: usize, arg: usize, ptid: *i32, tls: usize, ctid: *i32) usize;
9090
9191pub const restore = restore_rt;
9292
lib/std/os/uefi/protocols/absolute_pointer_protocol.zig+2-2
......@@ -5,8 +5,8 @@ const Status = uefi.Status;
55
66/// Protocol for touchscreens
77pub const AbsolutePointerProtocol = extern struct {
8 _reset: extern fn (*const AbsolutePointerProtocol, bool) Status,
9 _get_state: extern fn (*const AbsolutePointerProtocol, *AbsolutePointerState) Status,
8 _reset: fn (*const AbsolutePointerProtocol, bool) callconv(.C) Status,
9 _get_state: fn (*const AbsolutePointerProtocol, *AbsolutePointerState) callconv(.C) Status,
1010 wait_for_input: Event,
1111 mode: *AbsolutePointerMode,
1212
lib/std/os/uefi/protocols/edid_override_protocol.zig+1-1
......@@ -5,7 +5,7 @@ const Status = uefi.Status;
55
66/// Override EDID information
77pub const EdidOverrideProtocol = extern struct {
8 _get_edid: extern fn (*const EdidOverrideProtocol, Handle, *u32, *usize, *?[*]u8) Status,
8 _get_edid: fn (*const EdidOverrideProtocol, Handle, *u32, *usize, *?[*]u8) callconv(.C) Status,
99
1010 /// Returns policy information and potentially a replacement EDID for the specified video output device.
1111 /// attributes must be align(4)
lib/std/os/uefi/protocols/file_protocol.zig+10-10
......@@ -5,16 +5,16 @@ const Status = uefi.Status;
55
66pub const FileProtocol = extern struct {
77 revision: u64,
8 _open: extern fn (*const FileProtocol, **const FileProtocol, [*:0]const u16, u64, u64) Status,
9 _close: extern fn (*const FileProtocol) Status,
10 _delete: extern fn (*const FileProtocol) Status,
11 _read: extern fn (*const FileProtocol, *usize, [*]u8) Status,
12 _write: extern fn (*const FileProtocol, *usize, [*]const u8) Status,
13 _get_position: extern fn (*const FileProtocol, *u64) Status,
14 _set_position: extern fn (*const FileProtocol, *const u64) Status,
15 _get_info: extern fn (*const FileProtocol, *align(8) const Guid, *const usize, [*]u8) Status,
16 _set_info: extern fn (*const FileProtocol, *align(8) const Guid, usize, [*]const u8) Status,
17 _flush: extern fn (*const FileProtocol) Status,
8 _open: fn (*const FileProtocol, **const FileProtocol, [*:0]const u16, u64, u64) callconv(.C) Status,
9 _close: fn (*const FileProtocol) callconv(.C) Status,
10 _delete: fn (*const FileProtocol) callconv(.C) Status,
11 _read: fn (*const FileProtocol, *usize, [*]u8) callconv(.C) Status,
12 _write: fn (*const FileProtocol, *usize, [*]const u8) callconv(.C) Status,
13 _get_position: fn (*const FileProtocol, *u64) callconv(.C) Status,
14 _set_position: fn (*const FileProtocol, *const u64) callconv(.C) Status,
15 _get_info: fn (*const FileProtocol, *align(8) const Guid, *const usize, [*]u8) callconv(.C) Status,
16 _set_info: fn (*const FileProtocol, *align(8) const Guid, usize, [*]const u8) callconv(.C) Status,
17 _flush: fn (*const FileProtocol) callconv(.C) Status,
1818
1919 pub fn open(self: *const FileProtocol, new_handle: **const FileProtocol, file_name: [*:0]const u16, open_mode: u64, attributes: u64) Status {
2020 return self._open(self, new_handle, file_name, open_mode, attributes);
lib/std/os/uefi/protocols/graphics_output_protocol.zig+3-3
......@@ -4,9 +4,9 @@ const Status = uefi.Status;
44
55/// Graphics output
66pub const GraphicsOutputProtocol = extern struct {
7 _query_mode: extern fn (*const GraphicsOutputProtocol, u32, *usize, **GraphicsOutputModeInformation) Status,
8 _set_mode: extern fn (*const GraphicsOutputProtocol, u32) Status,
9 _blt: extern fn (*const GraphicsOutputProtocol, ?[*]GraphicsOutputBltPixel, GraphicsOutputBltOperation, usize, usize, usize, usize, usize, usize, usize) Status,
7 _query_mode: fn (*const GraphicsOutputProtocol, u32, *usize, **GraphicsOutputModeInformation) callconv(.C) Status,
8 _set_mode: fn (*const GraphicsOutputProtocol, u32) callconv(.C) Status,
9 _blt: fn (*const GraphicsOutputProtocol, ?[*]GraphicsOutputBltPixel, GraphicsOutputBltOperation, usize, usize, usize, usize, usize, usize, usize) callconv(.C) Status,
1010 mode: *GraphicsOutputProtocolMode,
1111
1212 /// Returns information for an available graphics mode that the graphics device and the set of active video output devices supports.
lib/std/os/uefi/protocols/hii_database_protocol.zig+4-4
......@@ -6,10 +6,10 @@ const hii = uefi.protocols.hii;
66/// Database manager for HII-related data structures.
77pub const HIIDatabaseProtocol = extern struct {
88 _new_package_list: Status, // TODO
9 _remove_package_list: extern fn (*const HIIDatabaseProtocol, hii.HIIHandle) Status,
10 _update_package_list: extern fn (*const HIIDatabaseProtocol, hii.HIIHandle, *const hii.HIIPackageList) Status,
11 _list_package_lists: extern fn (*const HIIDatabaseProtocol, u8, ?*const Guid, *usize, [*]hii.HIIHandle) Status,
12 _export_package_lists: extern fn (*const HIIDatabaseProtocol, ?hii.HIIHandle, *usize, *hii.HIIPackageList) Status,
9 _remove_package_list: fn (*const HIIDatabaseProtocol, hii.HIIHandle) callconv(.C) Status,
10 _update_package_list: fn (*const HIIDatabaseProtocol, hii.HIIHandle, *const hii.HIIPackageList) callconv(.C) Status,
11 _list_package_lists: fn (*const HIIDatabaseProtocol, u8, ?*const Guid, *usize, [*]hii.HIIHandle) callconv(.C) Status,
12 _export_package_lists: fn (*const HIIDatabaseProtocol, ?hii.HIIHandle, *usize, *hii.HIIPackageList) callconv(.C) Status,
1313 _register_package_notify: Status, // TODO
1414 _unregister_package_notify: Status, // TODO
1515 _find_keyboard_layouts: Status, // TODO
lib/std/os/uefi/protocols/hii_popup_protocol.zig+1-1
......@@ -6,7 +6,7 @@ const hii = uefi.protocols.hii;
66/// Display a popup window
77pub const HIIPopupProtocol = extern struct {
88 revision: u64,
9 _create_popup: extern fn (*const HIIPopupProtocol, HIIPopupStyle, HIIPopupType, hii.HIIHandle, u16, ?*HIIPopupSelection) Status,
9 _create_popup: fn (*const HIIPopupProtocol, HIIPopupStyle, HIIPopupType, hii.HIIHandle, u16, ?*HIIPopupSelection) callconv(.C) Status,
1010
1111 /// Displays a popup window.
1212 pub fn createPopup(self: *const HIIPopupProtocol, style: HIIPopupStyle, popup_type: HIIPopupType, handle: hii.HIIHandle, msg: u16, user_selection: ?*HIIPopupSelection) Status {
lib/std/os/uefi/protocols/ip6_config_protocol.zig+4-4
......@@ -4,10 +4,10 @@ const Event = uefi.Event;
44const Status = uefi.Status;
55
66pub const Ip6ConfigProtocol = extern struct {
7 _set_data: extern fn (*const Ip6ConfigProtocol, Ip6ConfigDataType, usize, *const c_void) Status,
8 _get_data: extern fn (*const Ip6ConfigProtocol, Ip6ConfigDataType, *usize, ?*const c_void) Status,
9 _register_data_notify: extern fn (*const Ip6ConfigProtocol, Ip6ConfigDataType, Event) Status,
10 _unregister_data_notify: extern fn (*const Ip6ConfigProtocol, Ip6ConfigDataType, Event) Status,
7 _set_data: fn (*const Ip6ConfigProtocol, Ip6ConfigDataType, usize, *const c_void) callconv(.C) Status,
8 _get_data: fn (*const Ip6ConfigProtocol, Ip6ConfigDataType, *usize, ?*const c_void) callconv(.C) Status,
9 _register_data_notify: fn (*const Ip6ConfigProtocol, Ip6ConfigDataType, Event) callconv(.C) Status,
10 _unregister_data_notify: fn (*const Ip6ConfigProtocol, Ip6ConfigDataType, Event) callconv(.C) Status,
1111
1212 pub fn setData(self: *const Ip6ConfigProtocol, data_type: Ip6ConfigDataType, data_size: usize, data: *const c_void) Status {
1313 return self._set_data(self, data_type, data_size, data);
lib/std/os/uefi/protocols/ip6_protocol.zig+9-9
......@@ -7,15 +7,15 @@ const ManagedNetworkConfigData = uefi.protocols.ManagedNetworkConfigData;
77const SimpleNetworkMode = uefi.protocols.SimpleNetworkMode;
88
99pub const Ip6Protocol = extern struct {
10 _get_mode_data: extern fn (*const Ip6Protocol, ?*Ip6ModeData, ?*ManagedNetworkConfigData, ?*SimpleNetworkMode) Status,
11 _configure: extern fn (*const Ip6Protocol, ?*const Ip6ConfigData) Status,
12 _groups: extern fn (*const Ip6Protocol, bool, ?*const Ip6Address) Status,
13 _routes: extern fn (*const Ip6Protocol, bool, ?*const Ip6Address, u8, ?*const Ip6Address) Status,
14 _neighbors: extern fn (*const Ip6Protocol, bool, *const Ip6Address, ?*const MacAddress, u32, bool) Status,
15 _transmit: extern fn (*const Ip6Protocol, *Ip6CompletionToken) Status,
16 _receive: extern fn (*const Ip6Protocol, *Ip6CompletionToken) Status,
17 _cancel: extern fn (*const Ip6Protocol, ?*Ip6CompletionToken) Status,
18 _poll: extern fn (*const Ip6Protocol) Status,
10 _get_mode_data: fn (*const Ip6Protocol, ?*Ip6ModeData, ?*ManagedNetworkConfigData, ?*SimpleNetworkMode) callconv(.C) Status,
11 _configure: fn (*const Ip6Protocol, ?*const Ip6ConfigData) callconv(.C) Status,
12 _groups: fn (*const Ip6Protocol, bool, ?*const Ip6Address) callconv(.C) Status,
13 _routes: fn (*const Ip6Protocol, bool, ?*const Ip6Address, u8, ?*const Ip6Address) callconv(.C) Status,
14 _neighbors: fn (*const Ip6Protocol, bool, *const Ip6Address, ?*const MacAddress, u32, bool) callconv(.C) Status,
15 _transmit: fn (*const Ip6Protocol, *Ip6CompletionToken) callconv(.C) Status,
16 _receive: fn (*const Ip6Protocol, *Ip6CompletionToken) callconv(.C) Status,
17 _cancel: fn (*const Ip6Protocol, ?*Ip6CompletionToken) callconv(.C) Status,
18 _poll: fn (*const Ip6Protocol) callconv(.C) Status,
1919
2020 /// Gets the current operational settings for this instance of the EFI IPv6 Protocol driver.
2121 pub fn getModeData(self: *const Ip6Protocol, ip6_mode_data: ?*Ip6ModeData, mnp_config_data: ?*ManagedNetworkConfigData, snp_mode_data: ?*SimpleNetworkMode) Status {
lib/std/os/uefi/protocols/ip6_service_binding_protocol.zig+2-2
......@@ -4,8 +4,8 @@ const Guid = uefi.Guid;
44const Status = uefi.Status;
55
66pub const Ip6ServiceBindingProtocol = extern struct {
7 _create_child: extern fn (*const Ip6ServiceBindingProtocol, *?Handle) Status,
8 _destroy_child: extern fn (*const Ip6ServiceBindingProtocol, Handle) Status,
7 _create_child: fn (*const Ip6ServiceBindingProtocol, *?Handle) callconv(.C) Status,
8 _destroy_child: fn (*const Ip6ServiceBindingProtocol, Handle) callconv(.C) Status,
99
1010 pub fn createChild(self: *const Ip6ServiceBindingProtocol, handle: *?Handle) Status {
1111 return self._create_child(self, handle);
lib/std/os/uefi/protocols/loaded_image_protocol.zig+1-1
......@@ -19,7 +19,7 @@ pub const LoadedImageProtocol = extern struct {
1919 image_size: u64,
2020 image_code_type: MemoryType,
2121 image_data_type: MemoryType,
22 _unload: extern fn (*const LoadedImageProtocol, Handle) Status,
22 _unload: fn (*const LoadedImageProtocol, Handle) callconv(.C) Status,
2323
2424 /// Unloads an image from memory.
2525 pub fn unload(self: *const LoadedImageProtocol, handle: Handle) Status {
lib/std/os/uefi/protocols/managed_network_protocol.zig+8-8
......@@ -7,14 +7,14 @@ const SimpleNetworkMode = uefi.protocols.SimpleNetworkMode;
77const MacAddress = uefi.protocols.MacAddress;
88
99pub const ManagedNetworkProtocol = extern struct {
10 _get_mode_data: extern fn (*const ManagedNetworkProtocol, ?*ManagedNetworkConfigData, ?*SimpleNetworkMode) Status,
11 _configure: extern fn (*const ManagedNetworkProtocol, ?*const ManagedNetworkConfigData) Status,
12 _mcast_ip_to_mac: extern fn (*const ManagedNetworkProtocol, bool, *const c_void, *MacAddress) Status,
13 _groups: extern fn (*const ManagedNetworkProtocol, bool, ?*const MacAddress) Status,
14 _transmit: extern fn (*const ManagedNetworkProtocol, *const ManagedNetworkCompletionToken) Status,
15 _receive: extern fn (*const ManagedNetworkProtocol, *const ManagedNetworkCompletionToken) Status,
16 _cancel: extern fn (*const ManagedNetworkProtocol, ?*const ManagedNetworkCompletionToken) Status,
17 _poll: extern fn (*const ManagedNetworkProtocol) usize,
10 _get_mode_data: fn (*const ManagedNetworkProtocol, ?*ManagedNetworkConfigData, ?*SimpleNetworkMode) callconv(.C) Status,
11 _configure: fn (*const ManagedNetworkProtocol, ?*const ManagedNetworkConfigData) callconv(.C) Status,
12 _mcast_ip_to_mac: fn (*const ManagedNetworkProtocol, bool, *const c_void, *MacAddress) callconv(.C) Status,
13 _groups: fn (*const ManagedNetworkProtocol, bool, ?*const MacAddress) callconv(.C) Status,
14 _transmit: fn (*const ManagedNetworkProtocol, *const ManagedNetworkCompletionToken) callconv(.C) Status,
15 _receive: fn (*const ManagedNetworkProtocol, *const ManagedNetworkCompletionToken) callconv(.C) Status,
16 _cancel: fn (*const ManagedNetworkProtocol, ?*const ManagedNetworkCompletionToken) callconv(.C) Status,
17 _poll: fn (*const ManagedNetworkProtocol) callconv(.C) usize,
1818
1919 /// Returns the operational parameters for the current MNP child driver.
2020 /// May also support returning the underlying SNP driver mode data.
lib/std/os/uefi/protocols/managed_network_service_binding_protocol.zig+2-2
......@@ -4,8 +4,8 @@ const Guid = uefi.Guid;
44const Status = uefi.Status;
55
66pub const ManagedNetworkServiceBindingProtocol = extern struct {
7 _create_child: extern fn (*const ManagedNetworkServiceBindingProtocol, *?Handle) Status,
8 _destroy_child: extern fn (*const ManagedNetworkServiceBindingProtocol, Handle) Status,
7 _create_child: fn (*const ManagedNetworkServiceBindingProtocol, *?Handle) callconv(.C) Status,
8 _destroy_child: fn (*const ManagedNetworkServiceBindingProtocol, Handle) callconv(.C) Status,
99
1010 pub fn createChild(self: *const ManagedNetworkServiceBindingProtocol, handle: *?Handle) Status {
1111 return self._create_child(self, handle);
lib/std/os/uefi/protocols/rng_protocol.zig+2-2
......@@ -4,8 +4,8 @@ const Status = uefi.Status;
44
55/// Random Number Generator protocol
66pub const RNGProtocol = extern struct {
7 _get_info: extern fn (*const RNGProtocol, *usize, [*]align(8) Guid) Status,
8 _get_rng: extern fn (*const RNGProtocol, ?*align(8) const Guid, usize, [*]u8) Status,
7 _get_info: fn (*const RNGProtocol, *usize, [*]align(8) Guid) callconv(.C) Status,
8 _get_rng: fn (*const RNGProtocol, ?*align(8) const Guid, usize, [*]u8) callconv(.C) Status,
99
1010 /// Returns information about the random number generation implementation.
1111 pub fn getInfo(self: *const RNGProtocol, list_size: *usize, list: [*]align(8) Guid) Status {
lib/std/os/uefi/protocols/simple_file_system_protocol.zig+1-1
......@@ -5,7 +5,7 @@ const Status = uefi.Status;
55
66pub const SimpleFileSystemProtocol = extern struct {
77 revision: u64,
8 _open_volume: extern fn (*const SimpleFileSystemProtocol, **const FileProtocol) Status,
8 _open_volume: fn (*const SimpleFileSystemProtocol, **const FileProtocol) callconv(.C) Status,
99
1010 pub fn openVolume(self: *const SimpleFileSystemProtocol, root: **const FileProtocol) Status {
1111 return self._open_volume(self, root);
lib/std/os/uefi/protocols/simple_network_protocol.zig+13-13
......@@ -5,19 +5,19 @@ const Status = uefi.Status;
55
66pub const SimpleNetworkProtocol = extern struct {
77 revision: u64,
8 _start: extern fn (*const SimpleNetworkProtocol) Status,
9 _stop: extern fn (*const SimpleNetworkProtocol) Status,
10 _initialize: extern fn (*const SimpleNetworkProtocol, usize, usize) Status,
11 _reset: extern fn (*const SimpleNetworkProtocol, bool) Status,
12 _shutdown: extern fn (*const SimpleNetworkProtocol) Status,
13 _receive_filters: extern fn (*const SimpleNetworkProtocol, SimpleNetworkReceiveFilter, SimpleNetworkReceiveFilter, bool, usize, ?[*]const MacAddress) Status,
14 _station_address: extern fn (*const SimpleNetworkProtocol, bool, ?*const MacAddress) Status,
15 _statistics: extern fn (*const SimpleNetworkProtocol, bool, ?*usize, ?*NetworkStatistics) Status,
16 _mcast_ip_to_mac: extern fn (*const SimpleNetworkProtocol, bool, *const c_void, *MacAddress) Status,
17 _nvdata: extern fn (*const SimpleNetworkProtocol, bool, usize, usize, [*]u8) Status,
18 _get_status: extern fn (*const SimpleNetworkProtocol, *SimpleNetworkInterruptStatus, ?*?[*]u8) Status,
19 _transmit: extern fn (*const SimpleNetworkProtocol, usize, usize, [*]const u8, ?*const MacAddress, ?*const MacAddress, ?*const u16) Status,
20 _receive: extern fn (*const SimpleNetworkProtocol, ?*usize, *usize, [*]u8, ?*MacAddress, ?*MacAddress, ?*u16) Status,
8 _start: fn (*const SimpleNetworkProtocol) callconv(.C) Status,
9 _stop: fn (*const SimpleNetworkProtocol) callconv(.C) Status,
10 _initialize: fn (*const SimpleNetworkProtocol, usize, usize) callconv(.C) Status,
11 _reset: fn (*const SimpleNetworkProtocol, bool) callconv(.C) Status,
12 _shutdown: fn (*const SimpleNetworkProtocol) callconv(.C) Status,
13 _receive_filters: fn (*const SimpleNetworkProtocol, SimpleNetworkReceiveFilter, SimpleNetworkReceiveFilter, bool, usize, ?[*]const MacAddress) callconv(.C) Status,
14 _station_address: fn (*const SimpleNetworkProtocol, bool, ?*const MacAddress) callconv(.C) Status,
15 _statistics: fn (*const SimpleNetworkProtocol, bool, ?*usize, ?*NetworkStatistics) callconv(.C) Status,
16 _mcast_ip_to_mac: fn (*const SimpleNetworkProtocol, bool, *const c_void, *MacAddress) callconv(.C) Status,
17 _nvdata: fn (*const SimpleNetworkProtocol, bool, usize, usize, [*]u8) callconv(.C) Status,
18 _get_status: fn (*const SimpleNetworkProtocol, *SimpleNetworkInterruptStatus, ?*?[*]u8) callconv(.C) Status,
19 _transmit: fn (*const SimpleNetworkProtocol, usize, usize, [*]const u8, ?*const MacAddress, ?*const MacAddress, ?*const u16) callconv(.C) Status,
20 _receive: fn (*const SimpleNetworkProtocol, ?*usize, *usize, [*]u8, ?*MacAddress, ?*MacAddress, ?*u16) callconv(.C) Status,
2121 wait_for_packet: Event,
2222 mode: *SimpleNetworkMode,
2323
lib/std/os/uefi/protocols/simple_pointer_protocol.zig+2-2
......@@ -5,8 +5,8 @@ const Status = uefi.Status;
55
66/// Protocol for mice
77pub const SimplePointerProtocol = struct {
8 _reset: extern fn (*const SimplePointerProtocol, bool) Status,
9 _get_state: extern fn (*const SimplePointerProtocol, *SimplePointerState) Status,
8 _reset: fn (*const SimplePointerProtocol, bool) callconv(.C) Status,
9 _get_state: fn (*const SimplePointerProtocol, *SimplePointerState) callconv(.C) Status,
1010 wait_for_input: Event,
1111 mode: *SimplePointerMode,
1212
lib/std/os/uefi/protocols/simple_text_input_ex_protocol.zig+6-6
......@@ -5,12 +5,12 @@ const Status = uefi.Status;
55
66/// Character input devices, e.g. Keyboard
77pub const SimpleTextInputExProtocol = extern struct {
8 _reset: extern fn (*const SimpleTextInputExProtocol, bool) Status,
9 _read_key_stroke_ex: extern fn (*const SimpleTextInputExProtocol, *KeyData) Status,
8 _reset: fn (*const SimpleTextInputExProtocol, bool) callconv(.C) Status,
9 _read_key_stroke_ex: fn (*const SimpleTextInputExProtocol, *KeyData) callconv(.C) Status,
1010 wait_for_key_ex: Event,
11 _set_state: extern fn (*const SimpleTextInputExProtocol, *const u8) Status,
12 _register_key_notify: extern fn (*const SimpleTextInputExProtocol, *const KeyData, extern fn (*const KeyData) usize, **c_void) Status,
13 _unregister_key_notify: extern fn (*const SimpleTextInputExProtocol, *const c_void) Status,
11 _set_state: fn (*const SimpleTextInputExProtocol, *const u8) callconv(.C) Status,
12 _register_key_notify: fn (*const SimpleTextInputExProtocol, *const KeyData, fn (*const KeyData) callconv(.C) usize, **c_void) callconv(.C) Status,
13 _unregister_key_notify: fn (*const SimpleTextInputExProtocol, *const c_void) callconv(.C) Status,
1414
1515 /// Resets the input device hardware.
1616 pub fn reset(self: *const SimpleTextInputExProtocol, verify: bool) Status {
......@@ -28,7 +28,7 @@ pub const SimpleTextInputExProtocol = extern struct {
2828 }
2929
3030 /// Register a notification function for a particular keystroke for the input device.
31 pub fn registerKeyNotify(self: *const SimpleTextInputExProtocol, key_data: *const KeyData, notify: extern fn (*const KeyData) usize, handle: **c_void) Status {
31 pub fn registerKeyNotify(self: *const SimpleTextInputExProtocol, key_data: *const KeyData, notify: fn (*const KeyData) callconv(.C) usize, handle: **c_void) Status {
3232 return self._register_key_notify(self, key_data, notify, handle);
3333 }
3434
lib/std/os/uefi/protocols/simple_text_input_protocol.zig+2-2
......@@ -6,8 +6,8 @@ const Status = uefi.Status;
66
77/// Character input devices, e.g. Keyboard
88pub const SimpleTextInputProtocol = extern struct {
9 _reset: extern fn (*const SimpleTextInputProtocol, bool) usize,
10 _read_key_stroke: extern fn (*const SimpleTextInputProtocol, *InputKey) Status,
9 _reset: fn (*const SimpleTextInputProtocol, bool) callconv(.C) usize,
10 _read_key_stroke: fn (*const SimpleTextInputProtocol, *InputKey) callconv(.C) Status,
1111 wait_for_key: Event,
1212
1313 /// Resets the input device hardware.
lib/std/os/uefi/protocols/simple_text_output_protocol.zig+9-9
......@@ -4,15 +4,15 @@ const Status = uefi.Status;
44
55/// Character output devices
66pub const SimpleTextOutputProtocol = extern struct {
7 _reset: extern fn (*const SimpleTextOutputProtocol, bool) Status,
8 _output_string: extern fn (*const SimpleTextOutputProtocol, [*:0]const u16) Status,
9 _test_string: extern fn (*const SimpleTextOutputProtocol, [*:0]const u16) Status,
10 _query_mode: extern fn (*const SimpleTextOutputProtocol, usize, *usize, *usize) Status,
11 _set_mode: extern fn (*const SimpleTextOutputProtocol, usize) Status,
12 _set_attribute: extern fn (*const SimpleTextOutputProtocol, usize) Status,
13 _clear_screen: extern fn (*const SimpleTextOutputProtocol) Status,
14 _set_cursor_position: extern fn (*const SimpleTextOutputProtocol, usize, usize) Status,
15 _enable_cursor: extern fn (*const SimpleTextOutputProtocol, bool) Status,
7 _reset: fn (*const SimpleTextOutputProtocol, bool) callconv(.C) Status,
8 _output_string: fn (*const SimpleTextOutputProtocol, [*:0]const u16) callconv(.C) Status,
9 _test_string: fn (*const SimpleTextOutputProtocol, [*:0]const u16) callconv(.C) Status,
10 _query_mode: fn (*const SimpleTextOutputProtocol, usize, *usize, *usize) callconv(.C) Status,
11 _set_mode: fn (*const SimpleTextOutputProtocol, usize) callconv(.C) Status,
12 _set_attribute: fn (*const SimpleTextOutputProtocol, usize) callconv(.C) Status,
13 _clear_screen: fn (*const SimpleTextOutputProtocol) callconv(.C) Status,
14 _set_cursor_position: fn (*const SimpleTextOutputProtocol, usize, usize) callconv(.C) Status,
15 _enable_cursor: fn (*const SimpleTextOutputProtocol, bool) callconv(.C) Status,
1616 mode: *SimpleTextOutputMode,
1717
1818 /// Resets the text output device hardware.
lib/std/os/uefi/protocols/udp6_protocol.zig+7-7
......@@ -9,13 +9,13 @@ const ManagedNetworkConfigData = uefi.protocols.ManagedNetworkConfigData;
99const SimpleNetworkMode = uefi.protocols.SimpleNetworkMode;
1010
1111pub const Udp6Protocol = extern struct {
12 _get_mode_data: extern fn (*const Udp6Protocol, ?*Udp6ConfigData, ?*Ip6ModeData, ?*ManagedNetworkConfigData, ?*SimpleNetworkMode) Status,
13 _configure: extern fn (*const Udp6Protocol, ?*const Udp6ConfigData) Status,
14 _groups: extern fn (*const Udp6Protocol, bool, ?*const Ip6Address) Status,
15 _transmit: extern fn (*const Udp6Protocol, *Udp6CompletionToken) Status,
16 _receive: extern fn (*const Udp6Protocol, *Udp6CompletionToken) Status,
17 _cancel: extern fn (*const Udp6Protocol, ?*Udp6CompletionToken) Status,
18 _poll: extern fn (*const Udp6Protocol) Status,
12 _get_mode_data: fn (*const Udp6Protocol, ?*Udp6ConfigData, ?*Ip6ModeData, ?*ManagedNetworkConfigData, ?*SimpleNetworkMode) callconv(.C) Status,
13 _configure: fn (*const Udp6Protocol, ?*const Udp6ConfigData) callconv(.C) Status,
14 _groups: fn (*const Udp6Protocol, bool, ?*const Ip6Address) callconv(.C) Status,
15 _transmit: fn (*const Udp6Protocol, *Udp6CompletionToken) callconv(.C) Status,
16 _receive: fn (*const Udp6Protocol, *Udp6CompletionToken) callconv(.C) Status,
17 _cancel: fn (*const Udp6Protocol, ?*Udp6CompletionToken) callconv(.C) Status,
18 _poll: fn (*const Udp6Protocol) callconv(.C) Status,
1919
2020 pub fn getModeData(self: *const Udp6Protocol, udp6_config_data: ?*Udp6ConfigData, ip6_mode_data: ?*Ip6ModeData, mnp_config_data: ?*ManagedNetworkConfigData, snp_mode_data: ?*SimpleNetworkMode) Status {
2121 return self._get_mode_data(self, udp6_config_data, ip6_mode_data, mnp_config_data, snp_mode_data);
lib/std/os/uefi/protocols/udp6_service_binding_protocol.zig+2-2
......@@ -4,8 +4,8 @@ const Guid = uefi.Guid;
44const Status = uefi.Status;
55
66pub const Udp6ServiceBindingProtocol = extern struct {
7 _create_child: extern fn (*const Udp6ServiceBindingProtocol, *?Handle) Status,
8 _destroy_child: extern fn (*const Udp6ServiceBindingProtocol, Handle) Status,
7 _create_child: fn (*const Udp6ServiceBindingProtocol, *?Handle) callconv(.C) Status,
8 _destroy_child: fn (*const Udp6ServiceBindingProtocol, Handle) callconv(.C) Status,
99
1010 pub fn createChild(self: *const Udp6ServiceBindingProtocol, handle: *?Handle) Status {
1111 return self._create_child(self, handle);
lib/std/os/uefi/tables/boot_services.zig+32-32
......@@ -21,117 +21,117 @@ pub const BootServices = extern struct {
2121 hdr: TableHeader,
2222
2323 /// Raises a task's priority level and returns its previous level.
24 raiseTpl: extern fn (usize) usize,
24 raiseTpl: fn (usize) callconv(.C) usize,
2525
2626 /// Restores a task's priority level to its previous value.
27 restoreTpl: extern fn (usize) void,
27 restoreTpl: fn (usize) callconv(.C) void,
2828
2929 /// Allocates memory pages from the system.
30 allocatePages: extern fn (AllocateType, MemoryType, usize, *[*]align(4096) u8) Status,
30 allocatePages: fn (AllocateType, MemoryType, usize, *[*]align(4096) u8) callconv(.C) Status,
3131
3232 /// Frees memory pages.
33 freePages: extern fn ([*]align(4096) u8, usize) Status,
33 freePages: fn ([*]align(4096) u8, usize) callconv(.C) Status,
3434
3535 /// Returns the current memory map.
36 getMemoryMap: extern fn (*usize, [*]MemoryDescriptor, *usize, *usize, *u32) Status,
36 getMemoryMap: fn (*usize, [*]MemoryDescriptor, *usize, *usize, *u32) callconv(.C) Status,
3737
3838 /// Allocates pool memory.
39 allocatePool: extern fn (MemoryType, usize, *[*]align(8) u8) Status,
39 allocatePool: fn (MemoryType, usize, *[*]align(8) u8) callconv(.C) Status,
4040
4141 /// Returns pool memory to the system.
42 freePool: extern fn ([*]align(8) u8) Status,
42 freePool: fn ([*]align(8) u8) callconv(.C) Status,
4343
4444 /// Creates an event.
45 createEvent: extern fn (u32, usize, ?extern fn (Event, ?*c_void) void, ?*const c_void, *Event) Status,
45 createEvent: fn (u32, usize, ?fn (Event, ?*c_void) callconv(.C) void, ?*const c_void, *Event) callconv(.C) Status,
4646
4747 /// Sets the type of timer and the trigger time for a timer event.
48 setTimer: extern fn (Event, TimerDelay, u64) Status,
48 setTimer: fn (Event, TimerDelay, u64) callconv(.C) Status,
4949
5050 /// Stops execution until an event is signaled.
51 waitForEvent: extern fn (usize, [*]const Event, *usize) Status,
51 waitForEvent: fn (usize, [*]const Event, *usize) callconv(.C) Status,
5252
5353 /// Signals an event.
54 signalEvent: extern fn (Event) Status,
54 signalEvent: fn (Event) callconv(.C) Status,
5555
5656 /// Closes an event.
57 closeEvent: extern fn (Event) Status,
57 closeEvent: fn (Event) callconv(.C) Status,
5858
5959 /// Checks whether an event is in the signaled state.
60 checkEvent: extern fn (Event) Status,
60 checkEvent: fn (Event) callconv(.C) Status,
6161
6262 installProtocolInterface: Status, // TODO
6363 reinstallProtocolInterface: Status, // TODO
6464 uninstallProtocolInterface: Status, // TODO
6565
6666 /// Queries a handle to determine if it supports a specified protocol.
67 handleProtocol: extern fn (Handle, *align(8) const Guid, *?*c_void) Status,
67 handleProtocol: fn (Handle, *align(8) const Guid, *?*c_void) callconv(.C) Status,
6868
6969 reserved: *c_void,
7070
7171 registerProtocolNotify: Status, // TODO
7272
7373 /// Returns an array of handles that support a specified protocol.
74 locateHandle: extern fn (LocateSearchType, ?*align(8) const Guid, ?*const c_void, *usize, [*]Handle) Status,
74 locateHandle: fn (LocateSearchType, ?*align(8) const Guid, ?*const c_void, *usize, [*]Handle) callconv(.C) Status,
7575
7676 locateDevicePath: Status, // TODO
7777 installConfigurationTable: Status, // TODO
7878
7979 /// Loads an EFI image into memory.
80 loadImage: extern fn (bool, Handle, ?*const DevicePathProtocol, ?[*]const u8, usize, *?Handle) Status,
80 loadImage: fn (bool, Handle, ?*const DevicePathProtocol, ?[*]const u8, usize, *?Handle) callconv(.C) Status,
8181
8282 /// Transfers control to a loaded image's entry point.
83 startImage: extern fn (Handle, ?*usize, ?*[*]u16) Status,
83 startImage: fn (Handle, ?*usize, ?*[*]u16) callconv(.C) Status,
8484
8585 /// Terminates a loaded EFI image and returns control to boot services.
86 exit: extern fn (Handle, Status, usize, ?*const c_void) Status,
86 exit: fn (Handle, Status, usize, ?*const c_void) callconv(.C) Status,
8787
8888 /// Unloads an image.
89 unloadImage: extern fn (Handle) Status,
89 unloadImage: fn (Handle) callconv(.C) Status,
9090
9191 /// Terminates all boot services.
92 exitBootServices: extern fn (Handle, usize) Status,
92 exitBootServices: fn (Handle, usize) callconv(.C) Status,
9393
9494 /// Returns a monotonically increasing count for the platform.
95 getNextMonotonicCount: extern fn (*u64) Status,
95 getNextMonotonicCount: fn (*u64) callconv(.C) Status,
9696
9797 /// Induces a fine-grained stall.
98 stall: extern fn (usize) Status,
98 stall: fn (usize) callconv(.C) Status,
9999
100100 /// Sets the system's watchdog timer.
101 setWatchdogTimer: extern fn (usize, u64, usize, ?[*]const u16) Status,
101 setWatchdogTimer: fn (usize, u64, usize, ?[*]const u16) callconv(.C) Status,
102102
103103 connectController: Status, // TODO
104104 disconnectController: Status, // TODO
105105
106106 /// Queries a handle to determine if it supports a specified protocol.
107 openProtocol: extern fn (Handle, *align(8) const Guid, *?*c_void, ?Handle, ?Handle, OpenProtocolAttributes) Status,
107 openProtocol: fn (Handle, *align(8) const Guid, *?*c_void, ?Handle, ?Handle, OpenProtocolAttributes) callconv(.C) Status,
108108
109109 /// Closes a protocol on a handle that was opened using openProtocol().
110 closeProtocol: extern fn (Handle, *align(8) const Guid, Handle, ?Handle) Status,
110 closeProtocol: fn (Handle, *align(8) const Guid, Handle, ?Handle) callconv(.C) Status,
111111
112112 /// Retrieves the list of agents that currently have a protocol interface opened.
113 openProtocolInformation: extern fn (Handle, *align(8) const Guid, *[*]ProtocolInformationEntry, *usize) Status,
113 openProtocolInformation: fn (Handle, *align(8) const Guid, *[*]ProtocolInformationEntry, *usize) callconv(.C) Status,
114114
115115 /// Retrieves the list of protocol interface GUIDs that are installed on a handle in a buffer allocated from pool.
116 protocolsPerHandle: extern fn (Handle, *[*]*align(8) const Guid, *usize) Status,
116 protocolsPerHandle: fn (Handle, *[*]*align(8) const Guid, *usize) callconv(.C) Status,
117117
118118 /// Returns an array of handles that support the requested protocol in a buffer allocated from pool.
119 locateHandleBuffer: extern fn (LocateSearchType, ?*align(8) const Guid, ?*const c_void, *usize, *[*]Handle) Status,
119 locateHandleBuffer: fn (LocateSearchType, ?*align(8) const Guid, ?*const c_void, *usize, *[*]Handle) callconv(.C) Status,
120120
121121 /// Returns the first protocol instance that matches the given protocol.
122 locateProtocol: extern fn (*align(8) const Guid, ?*const c_void, *?*c_void) Status,
122 locateProtocol: fn (*align(8) const Guid, ?*const c_void, *?*c_void) callconv(.C) Status,
123123
124124 installMultipleProtocolInterfaces: Status, // TODO
125125 uninstallMultipleProtocolInterfaces: Status, // TODO
126126
127127 /// Computes and returns a 32-bit CRC for a data buffer.
128 calculateCrc32: extern fn ([*]const u8, usize, *u32) Status,
128 calculateCrc32: fn ([*]const u8, usize, *u32) callconv(.C) Status,
129129
130130 /// Copies the contents of one buffer to another buffer
131 copyMem: extern fn ([*]u8, [*]const u8, usize) void,
131 copyMem: fn ([*]u8, [*]const u8, usize) callconv(.C) void,
132132
133133 /// Fills a buffer with a specified value
134 setMem: extern fn ([*]u8, usize, u8) void,
134 setMem: fn ([*]u8, usize, u8) callconv(.C) void,
135135
136136 createEventEx: Status, // TODO
137137
lib/std/os/uefi/tables/runtime_services.zig+5-5
......@@ -17,7 +17,7 @@ pub const RuntimeServices = extern struct {
1717 hdr: TableHeader,
1818
1919 /// Returns the current time and date information, and the time-keeping capabilities of the hardware platform.
20 getTime: extern fn (*uefi.Time, ?*TimeCapabilities) Status,
20 getTime: fn (*uefi.Time, ?*TimeCapabilities) callconv(.C) Status,
2121
2222 setTime: Status, // TODO
2323 getWakeupTime: Status, // TODO
......@@ -26,18 +26,18 @@ pub const RuntimeServices = extern struct {
2626 convertPointer: Status, // TODO
2727
2828 /// Returns the value of a variable.
29 getVariable: extern fn ([*:0]const u16, *align(8) const Guid, ?*u32, *usize, ?*c_void) Status,
29 getVariable: fn ([*:0]const u16, *align(8) const Guid, ?*u32, *usize, ?*c_void) callconv(.C) Status,
3030
3131 /// Enumerates the current variable names.
32 getNextVariableName: extern fn (*usize, [*:0]u16, *align(8) Guid) Status,
32 getNextVariableName: fn (*usize, [*:0]u16, *align(8) Guid) callconv(.C) Status,
3333
3434 /// Sets the value of a variable.
35 setVariable: extern fn ([*:0]const u16, *align(8) const Guid, u32, usize, *c_void) Status,
35 setVariable: fn ([*:0]const u16, *align(8) const Guid, u32, usize, *c_void) callconv(.C) Status,
3636
3737 getNextHighMonotonicCount: Status, // TODO
3838
3939 /// Resets the entire platform.
40 resetSystem: extern fn (ResetType, Status, usize, ?*const c_void) noreturn,
40 resetSystem: fn (ResetType, Status, usize, ?*const c_void) callconv(.C) noreturn,
4141
4242 updateCapsule: Status, // TODO
4343 queryCapsuleCapabilities: Status, // TODO
lib/std/os/windows/bits.zig+6-6
......@@ -627,7 +627,7 @@ pub const MEM_RESERVE_PLACEHOLDERS = 0x2;
627627pub const MEM_DECOMMIT = 0x4000;
628628pub const MEM_RELEASE = 0x8000;
629629
630pub const PTHREAD_START_ROUTINE = extern fn (LPVOID) DWORD;
630pub const PTHREAD_START_ROUTINE = fn (LPVOID) callconv(.C) DWORD;
631631pub const LPTHREAD_START_ROUTINE = PTHREAD_START_ROUTINE;
632632
633633pub const WIN32_FIND_DATAW = extern struct {
......@@ -784,7 +784,7 @@ pub const IMAGE_TLS_DIRECTORY = extern struct {
784784pub const IMAGE_TLS_DIRECTORY64 = IMAGE_TLS_DIRECTORY;
785785pub const IMAGE_TLS_DIRECTORY32 = IMAGE_TLS_DIRECTORY;
786786
787pub const PIMAGE_TLS_CALLBACK = ?extern fn (PVOID, DWORD, PVOID) void;
787pub const PIMAGE_TLS_CALLBACK = ?fn (PVOID, DWORD, PVOID) callconv(.C) void;
788788
789789pub const PROV_RSA_FULL = 1;
790790
......@@ -810,7 +810,7 @@ pub const FILE_ACTION_MODIFIED = 0x00000003;
810810pub const FILE_ACTION_RENAMED_OLD_NAME = 0x00000004;
811811pub const FILE_ACTION_RENAMED_NEW_NAME = 0x00000005;
812812
813pub const LPOVERLAPPED_COMPLETION_ROUTINE = ?extern fn (DWORD, DWORD, *OVERLAPPED) void;
813pub const LPOVERLAPPED_COMPLETION_ROUTINE = ?fn (DWORD, DWORD, *OVERLAPPED) callconv(.C) void;
814814
815815pub const FILE_NOTIFY_CHANGE_CREATION = 64;
816816pub const FILE_NOTIFY_CHANGE_SIZE = 8;
......@@ -863,7 +863,7 @@ pub const RTL_CRITICAL_SECTION = extern struct {
863863pub const CRITICAL_SECTION = RTL_CRITICAL_SECTION;
864864pub const INIT_ONCE = RTL_RUN_ONCE;
865865pub const INIT_ONCE_STATIC_INIT = RTL_RUN_ONCE_INIT;
866pub const INIT_ONCE_FN = extern fn (InitOnce: *INIT_ONCE, Parameter: ?*c_void, Context: ?*c_void) BOOL;
866pub const INIT_ONCE_FN = fn (InitOnce: *INIT_ONCE, Parameter: ?*c_void, Context: ?*c_void) callconv(.C) BOOL;
867867
868868pub const RTL_RUN_ONCE = extern struct {
869869 Ptr: ?*c_void,
......@@ -1418,7 +1418,7 @@ pub const RTL_DRIVE_LETTER_CURDIR = extern struct {
14181418 DosPath: UNICODE_STRING,
14191419};
14201420
1421pub const PPS_POST_PROCESS_INIT_ROUTINE = ?extern fn () void;
1421pub const PPS_POST_PROCESS_INIT_ROUTINE = ?fn () callconv(.C) void;
14221422
14231423pub const FILE_BOTH_DIR_INFORMATION = extern struct {
14241424 NextEntryOffset: ULONG,
......@@ -1438,7 +1438,7 @@ pub const FILE_BOTH_DIR_INFORMATION = extern struct {
14381438};
14391439pub const FILE_BOTH_DIRECTORY_INFORMATION = FILE_BOTH_DIR_INFORMATION;
14401440
1441pub const IO_APC_ROUTINE = extern fn (PVOID, *IO_STATUS_BLOCK, ULONG) void;
1441pub const IO_APC_ROUTINE = fn (PVOID, *IO_STATUS_BLOCK, ULONG) callconv(.C) void;
14421442
14431443pub const CURDIR = extern struct {
14441444 DosPath: UNICODE_STRING,
lib/std/os/windows/ws2_32.zig+1-1
......@@ -106,7 +106,7 @@ pub const WSAOVERLAPPED = extern struct {
106106 hEvent: ?WSAEVENT,
107107};
108108
109pub const WSAOVERLAPPED_COMPLETION_ROUTINE = extern fn (dwError: DWORD, cbTransferred: DWORD, lpOverlapped: *WSAOVERLAPPED, dwFlags: DWORD) void;
109pub const WSAOVERLAPPED_COMPLETION_ROUTINE = fn (dwError: DWORD, cbTransferred: DWORD, lpOverlapped: *WSAOVERLAPPED, dwFlags: DWORD) callconv(.C) void;
110110
111111pub const ADDRESS_FAMILY = u16;
112112
lib/std/special/test_runner.zig+1-1
......@@ -34,7 +34,7 @@ pub fn main() anyerror!void {
3434 std.heap.page_allocator.free(async_frame_buffer);
3535 async_frame_buffer = try std.heap.page_allocator.alignedAlloc(u8, std.Target.stack_align, size);
3636 }
37 const casted_fn = @ptrCast(async fn () anyerror!void, test_fn.func);
37 const casted_fn = @ptrCast(fn () callconv(.Async) anyerror!void, test_fn.func);
3838 break :blk await @asyncCall(async_frame_buffer, {}, casted_fn);
3939 },
4040 .blocking => {
lib/std/start.zig+1-2
......@@ -224,8 +224,7 @@ inline fn initEventLoopAndCallMain() u8 {
224224 // and we want fewer call frames in stack traces.
225225 return @call(.{ .modifier = .always_inline }, callMain, .{});
226226}
227
228async fn callMainAsync(loop: *std.event.Loop) u8 {
227fn callMainAsync(loop: *std.event.Loop) callconv(.Async) u8 {
229228 // This prevents the event loop from terminating at least until main() has returned.
230229 loop.beginOneEvent();
231230 defer loop.finishOneEvent();
lib/std/zig/ast.zig+2-2
......@@ -875,12 +875,13 @@ pub const Node = struct {
875875 return_type: ReturnType,
876876 var_args_token: ?TokenIndex,
877877 extern_export_inline_token: ?TokenIndex,
878 cc_token: ?TokenIndex,
879878 body_node: ?*Node,
880879 lib_name: ?*Node, // populated if this is an extern declaration
881880 align_expr: ?*Node, // populated if align(A) is present
882881 section_expr: ?*Node, // populated if linksection(A) is present
883882 callconv_expr: ?*Node, // populated if callconv(A) is present
883 is_extern_prototype: bool = false, // TODO: Remove once extern fn rewriting is
884 is_async: bool = false, // TODO: remove once async fn rewriting is
884885
885886 pub const ParamList = SegmentedList(*Node, 2);
886887
......@@ -929,7 +930,6 @@ pub const Node = struct {
929930 if (self.visib_token) |visib_token| return visib_token;
930931 if (self.extern_export_inline_token) |extern_export_inline_token| return extern_export_inline_token;
931932 assert(self.lib_name == null);
932 if (self.cc_token) |cc_token| return cc_token;
933933 return self.fn_token;
934934 }
935935
lib/std/zig/parse.zig+20-39
......@@ -335,20 +335,25 @@ fn parseTopLevelDecl(arena: *Allocator, it: *TokenIterator, tree: *Tree) !?*Node
335335 return use_node;
336336}
337337
338/// FnProto <- FnCC? KEYWORD_fn IDENTIFIER? LPAREN ParamDeclList RPAREN ByteAlign? LinkSection? EXCLAMATIONMARK? (KEYWORD_var / TypeExpr)
338/// FnProto <- KEYWORD_fn IDENTIFIER? LPAREN ParamDeclList RPAREN ByteAlign? LinkSection? EXCLAMATIONMARK? (KEYWORD_var / TypeExpr)
339339fn parseFnProto(arena: *Allocator, it: *TokenIterator, tree: *Tree) !?*Node {
340 const cc = parseFnCC(arena, it, tree);
341 const fn_token = eatToken(it, .Keyword_fn) orelse {
342 if (cc) |fnCC| {
343 if (fnCC == .Extern) {
344 putBackToken(it, fnCC.Extern); // 'extern' is also used in ContainerDecl
345 } else {
346 try tree.errors.push(.{
347 .ExpectedToken = .{ .token = it.index, .expected_id = .Keyword_fn },
348 });
349 return error.ParseError;
350 }
340 // TODO: Remove once extern/async fn rewriting is
341 var is_async = false;
342 var is_extern = false;
343 const cc_token: ?usize = blk: {
344 if (eatToken(it, .Keyword_extern)) |token| {
345 is_extern = true;
346 break :blk token;
347 }
348 if (eatToken(it, .Keyword_async)) |token| {
349 is_async = true;
350 break :blk token;
351351 }
352 break :blk null;
353 };
354 const fn_token = eatToken(it, .Keyword_fn) orelse {
355 if (cc_token) |token|
356 putBackToken(it, token);
352357 return null;
353358 };
354359 const name_token = eatToken(it, .Identifier);
......@@ -389,21 +394,15 @@ fn parseFnProto(arena: *Allocator, it: *TokenIterator, tree: *Tree) !?*Node {
389394 .return_type = return_type,
390395 .var_args_token = var_args_token,
391396 .extern_export_inline_token = null,
392 .cc_token = null,
393397 .body_node = null,
394398 .lib_name = null,
395399 .align_expr = align_expr,
396400 .section_expr = section_expr,
397401 .callconv_expr = callconv_expr,
402 .is_extern_prototype = is_extern,
403 .is_async = is_async,
398404 };
399405
400 if (cc) |kind| {
401 switch (kind) {
402 .CC => |token| fn_proto_node.cc_token = token,
403 .Extern => |token| fn_proto_node.extern_export_inline_token = token,
404 }
405 }
406
407406 return &fn_proto_node.base;
408407}
409408
......@@ -1197,6 +1196,7 @@ fn parseSuffixExpr(arena: *Allocator, it: *TokenIterator, tree: *Tree) !?*Node {
11971196 if (maybe_async) |async_token| {
11981197 const token_fn = eatToken(it, .Keyword_fn);
11991198 if (token_fn != null) {
1199 // TODO: remove this hack when async fn rewriting is
12001200 // HACK: If we see the keyword `fn`, then we assume that
12011201 // we are parsing an async fn proto, and not a call.
12021202 // We therefore put back all tokens consumed by the async
......@@ -1205,7 +1205,6 @@ fn parseSuffixExpr(arena: *Allocator, it: *TokenIterator, tree: *Tree) !?*Node {
12051205 putBackToken(it, async_token);
12061206 return parsePrimaryTypeExpr(arena, it, tree);
12071207 }
1208 // TODO: Implement hack for parsing `async fn ...` in ast_parse_suffix_expr
12091208 var res = try expectNode(arena, it, tree, parsePrimaryTypeExpr, .{
12101209 .ExpectedPrimaryTypeExpr = .{ .token = it.index },
12111210 });
......@@ -1778,24 +1777,6 @@ fn parseCallconv(arena: *Allocator, it: *TokenIterator, tree: *Tree) !?*Node {
17781777 return expr_node;
17791778}
17801779
1781/// FnCC
1782/// <- KEYWORD_nakedcc
1783/// / KEYWORD_stdcallcc
1784/// / KEYWORD_extern
1785/// / KEYWORD_async
1786fn parseFnCC(arena: *Allocator, it: *TokenIterator, tree: *Tree) ?FnCC {
1787 if (eatToken(it, .Keyword_nakedcc)) |token| return FnCC{ .CC = token };
1788 if (eatToken(it, .Keyword_stdcallcc)) |token| return FnCC{ .CC = token };
1789 if (eatToken(it, .Keyword_extern)) |token| return FnCC{ .Extern = token };
1790 if (eatToken(it, .Keyword_async)) |token| return FnCC{ .CC = token };
1791 return null;
1792}
1793
1794const FnCC = union(enum) {
1795 CC: TokenIndex,
1796 Extern: TokenIndex,
1797};
1798
17991780/// ParamDecl <- (KEYWORD_noalias / KEYWORD_comptime)? (IDENTIFIER COLON)? ParamType
18001781fn parseParamDecl(arena: *Allocator, it: *TokenIterator, tree: *Tree) !?*Node {
18011782 const doc_comments = try parseDocComment(arena, it, tree);
lib/std/zig/parser_test.zig+25-34
......@@ -123,22 +123,6 @@ test "zig fmt: trailing comma in fn parameter list" {
123123 );
124124}
125125
126// TODO: Remove nakedcc/stdcallcc once zig 0.6.0 is released. See https://github.com/ziglang/zig/pull/3977
127test "zig fmt: convert extern/nakedcc/stdcallcc into callconv(...)" {
128 try testTransform(
129 \\nakedcc fn foo1() void {}
130 \\stdcallcc fn foo2() void {}
131 \\extern fn foo3() void {}
132 \\extern "mylib" fn foo4() void {}
133 ,
134 \\fn foo1() callconv(.Naked) void {}
135 \\fn foo2() callconv(.Stdcall) void {}
136 \\fn foo3() callconv(.C) void {}
137 \\fn foo4() callconv(.C) void {}
138 \\
139 );
140}
141
142126test "zig fmt: comptime struct field" {
143127 try testCanonical(
144128 \\const Foo = struct {
......@@ -252,10 +236,10 @@ test "zig fmt: anon list literal syntax" {
252236test "zig fmt: async function" {
253237 try testCanonical(
254238 \\pub const Server = struct {
255 \\ handleRequestFn: async fn (*Server, *const std.net.Address, File) void,
239 \\ handleRequestFn: fn (*Server, *const std.net.Address, File) callconv(.Async) void,
256240 \\};
257241 \\test "hi" {
258 \\ var ptr = @ptrCast(async fn (i32) void, other);
242 \\ var ptr = @ptrCast(fn (i32) callconv(.Async) void, other);
259243 \\}
260244 \\
261245 );
......@@ -451,15 +435,6 @@ test "zig fmt: aligned struct field" {
451435 );
452436}
453437
454test "zig fmt: preserve space between async fn definitions" {
455 try testCanonical(
456 \\async fn a() void {}
457 \\
458 \\async fn b() void {}
459 \\
460 );
461}
462
463438test "zig fmt: comment to disable/enable zig fmt first" {
464439 try testCanonical(
465440 \\// Test trailing comma syntax
......@@ -1515,7 +1490,7 @@ test "zig fmt: line comments in struct initializer" {
15151490
15161491test "zig fmt: first line comment in struct initializer" {
15171492 try testCanonical(
1518 \\pub async fn acquire(self: *Self) HeldLock {
1493 \\pub fn acquire(self: *Self) HeldLock {
15191494 \\ return HeldLock{
15201495 \\ // guaranteed allocation elision
15211496 \\ .held = self.lock.acquire(),
......@@ -2477,8 +2452,7 @@ test "zig fmt: fn type" {
24772452 \\}
24782453 \\
24792454 \\const a: fn (u8) u8 = undefined;
2480 \\const b: extern fn (u8) u8 = undefined;
2481 \\const c: fn (u8) callconv(.Naked) u8 = undefined;
2455 \\const b: fn (u8) callconv(.Naked) u8 = undefined;
24822456 \\const ap: fn (u8) u8 = a;
24832457 \\
24842458 );
......@@ -2500,7 +2474,7 @@ test "zig fmt: inline asm" {
25002474
25012475test "zig fmt: async functions" {
25022476 try testCanonical(
2503 \\async fn simpleAsyncFn() void {
2477 \\fn simpleAsyncFn() void {
25042478 \\ const a = async a.b();
25052479 \\ x += 1;
25062480 \\ suspend;
......@@ -2940,6 +2914,26 @@ test "zig fmt: noasync to nosuspend" {
29402914 );
29412915}
29422916
2917test "zig fmt: convert async fn into callconv(.Async)" {
2918 try testTransform(
2919 \\async fn foo() void {}
2920 ,
2921 \\fn foo() callconv(.Async) void {}
2922 \\
2923 );
2924}
2925
2926test "zig fmt: convert extern fn proto into callconv(.C)" {
2927 try testTransform(
2928 \\extern fn foo0() void {}
2929 \\const foo1 = extern fn () void;
2930 ,
2931 \\extern fn foo0() void {}
2932 \\const foo1 = fn () callconv(.C) void;
2933 \\
2934 );
2935}
2936
29432937const std = @import("std");
29442938const mem = std.mem;
29452939const warn = std.debug.warn;
......@@ -2986,7 +2980,6 @@ fn testParse(source: []const u8, allocator: *mem.Allocator, anything_changed: *b
29862980 anything_changed.* = try std.zig.render(allocator, buffer.outStream(), tree);
29872981 return buffer.toOwnedSlice();
29882982}
2989
29902983fn testTransform(source: []const u8, expected_source: []const u8) !void {
29912984 const needed_alloc_count = x: {
29922985 // Try it once with unlimited memory, make sure it works
......@@ -3034,11 +3027,9 @@ fn testTransform(source: []const u8, expected_source: []const u8) !void {
30343027 }
30353028 }
30363029}
3037
30383030fn testCanonical(source: []const u8) !void {
30393031 return testTransform(source, source);
30403032}
3041
30423033fn testError(source: []const u8) !void {
30433034 const tree = try std.zig.parse(std.testing.allocator, source);
30443035 defer tree.deinit();
lib/std/zig/render.zig+6-23
......@@ -1413,32 +1413,15 @@ fn renderExpression(
14131413 try renderToken(tree, stream, visib_token_index, indent, start_col, Space.Space); // pub
14141414 }
14151415
1416 // Some extra machinery is needed to rewrite the old-style cc
1417 // notation to the new callconv one
1418 var cc_rewrite_str: ?[*:0]const u8 = null;
14191416 if (fn_proto.extern_export_inline_token) |extern_export_inline_token| {
1420 const tok = tree.tokens.at(extern_export_inline_token);
1421 if (tok.id != .Keyword_extern or fn_proto.body_node == null) {
1422 try renderToken(tree, stream, extern_export_inline_token, indent, start_col, Space.Space); // extern/export
1423 } else {
1424 cc_rewrite_str = ".C";
1425 fn_proto.lib_name = null;
1426 }
1417 if (!fn_proto.is_extern_prototype)
1418 try renderToken(tree, stream, extern_export_inline_token, indent, start_col, Space.Space); // extern/export/inline
14271419 }
14281420
14291421 if (fn_proto.lib_name) |lib_name| {
14301422 try renderExpression(allocator, stream, tree, indent, start_col, lib_name, Space.Space);
14311423 }
14321424
1433 if (fn_proto.cc_token) |cc_token| {
1434 var str = tree.tokenSlicePtr(tree.tokens.at(cc_token));
1435 if (mem.eql(u8, str, "stdcallcc")) {
1436 cc_rewrite_str = ".Stdcall";
1437 } else if (mem.eql(u8, str, "nakedcc")) {
1438 cc_rewrite_str = ".Naked";
1439 } else try renderToken(tree, stream, cc_token, indent, start_col, Space.Space); // stdcallcc
1440 }
1441
14421425 const lparen = if (fn_proto.name_token) |name_token| blk: {
14431426 try renderToken(tree, stream, fn_proto.fn_token, indent, start_col, Space.Space); // fn
14441427 try renderToken(tree, stream, name_token, indent, start_col, Space.None); // name
......@@ -1528,10 +1511,10 @@ fn renderExpression(
15281511 try renderToken(tree, stream, callconv_lparen, indent, start_col, Space.None); // (
15291512 try renderExpression(allocator, stream, tree, indent, start_col, callconv_expr, Space.None);
15301513 try renderToken(tree, stream, callconv_rparen, indent, start_col, Space.Space); // )
1531 } else if (cc_rewrite_str) |str| {
1532 try stream.writeAll("callconv(");
1533 try stream.writeAll(mem.spanZ(str));
1534 try stream.writeAll(") ");
1514 } else if (fn_proto.is_extern_prototype) {
1515 try stream.writeAll("callconv(.C) ");
1516 } else if (fn_proto.is_async) {
1517 try stream.writeAll("callconv(.Async) ");
15351518 }
15361519
15371520 switch (fn_proto.return_type) {
lib/std/zig/tokenizer.zig-6
......@@ -47,7 +47,6 @@ pub const Token = struct {
4747 Keyword.init("for", .Keyword_for),
4848 Keyword.init("if", .Keyword_if),
4949 Keyword.init("inline", .Keyword_inline),
50 Keyword.init("nakedcc", .Keyword_nakedcc),
5150 Keyword.init("noalias", .Keyword_noalias),
5251 Keyword.init("noasync", .Keyword_nosuspend), // TODO: remove this
5352 Keyword.init("noinline", .Keyword_noinline),
......@@ -60,7 +59,6 @@ pub const Token = struct {
6059 Keyword.init("resume", .Keyword_resume),
6160 Keyword.init("return", .Keyword_return),
6261 Keyword.init("linksection", .Keyword_linksection),
63 Keyword.init("stdcallcc", .Keyword_stdcallcc),
6462 Keyword.init("struct", .Keyword_struct),
6563 Keyword.init("suspend", .Keyword_suspend),
6664 Keyword.init("switch", .Keyword_switch),
......@@ -181,7 +179,6 @@ pub const Token = struct {
181179 Keyword_for,
182180 Keyword_if,
183181 Keyword_inline,
184 Keyword_nakedcc,
185182 Keyword_noalias,
186183 Keyword_noinline,
187184 Keyword_nosuspend,
......@@ -194,7 +191,6 @@ pub const Token = struct {
194191 Keyword_resume,
195192 Keyword_return,
196193 Keyword_linksection,
197 Keyword_stdcallcc,
198194 Keyword_struct,
199195 Keyword_suspend,
200196 Keyword_switch,
......@@ -306,7 +302,6 @@ pub const Token = struct {
306302 .Keyword_for => "for",
307303 .Keyword_if => "if",
308304 .Keyword_inline => "inline",
309 .Keyword_nakedcc => "nakedcc",
310305 .Keyword_noalias => "noalias",
311306 .Keyword_noinline => "noinline",
312307 .Keyword_nosuspend => "nosuspend",
......@@ -318,7 +313,6 @@ pub const Token = struct {
318313 .Keyword_resume => "resume",
319314 .Keyword_return => "return",
320315 .Keyword_linksection => "linksection",
321 .Keyword_stdcallcc => "stdcallcc",
322316 .Keyword_struct => "struct",
323317 .Keyword_suspend => "suspend",
324318 .Keyword_switch => "switch",
src-self-hosted/clang.zig+1-1
......@@ -781,7 +781,7 @@ pub extern fn ZigClangSourceManager_getCharacterData(self: ?*const struct_ZigCla
781781pub extern fn ZigClangASTContext_getPointerType(self: ?*const struct_ZigClangASTContext, T: struct_ZigClangQualType) struct_ZigClangQualType;
782782pub extern fn ZigClangASTUnit_getASTContext(self: ?*struct_ZigClangASTUnit) ?*struct_ZigClangASTContext;
783783pub extern fn ZigClangASTUnit_getSourceManager(self: *struct_ZigClangASTUnit) *struct_ZigClangSourceManager;
784pub extern fn ZigClangASTUnit_visitLocalTopLevelDecls(self: *struct_ZigClangASTUnit, context: ?*c_void, Fn: ?extern fn (?*c_void, *const struct_ZigClangDecl) bool) bool;
784pub extern fn ZigClangASTUnit_visitLocalTopLevelDecls(self: *struct_ZigClangASTUnit, context: ?*c_void, Fn: ?fn (?*c_void, *const struct_ZigClangDecl) callconv(.C) bool) bool;
785785pub extern fn ZigClangRecordType_getDecl(record_ty: ?*const struct_ZigClangRecordType) *const struct_ZigClangRecordDecl;
786786pub extern fn ZigClangTagDecl_isThisDeclarationADefinition(self: *const ZigClangTagDecl) bool;
787787pub extern fn ZigClangEnumType_getDecl(record_ty: ?*const struct_ZigClangEnumType) *const struct_ZigClangEnumDecl;
src-self-hosted/main.zig+2-3
......@@ -41,7 +41,7 @@ const usage =
4141
4242const Command = struct {
4343 name: []const u8,
44 exec: async fn (*Allocator, []const []const u8) anyerror!void,
44 exec: fn (*Allocator, []const []const u8) callconv(.Async) anyerror!void,
4545};
4646
4747pub fn main() !void {
......@@ -713,8 +713,7 @@ const FmtError = error{
713713 FileBusy,
714714 CurrentWorkingDirectoryUnlinked,
715715} || fs.File.OpenError;
716
717async fn fmtPath(fmt: *Fmt, file_path_ref: []const u8, check_mode: bool) FmtError!void {
716fn fmtPath(fmt: *Fmt, file_path_ref: []const u8, check_mode: bool) callconv(.Async) FmtError!void {
718717 const stderr_file = io.getStdErr();
719718 const stderr = stderr_file.outStream();
720719
src-self-hosted/translate_c.zig-3
......@@ -4121,7 +4121,6 @@ fn transCreateNodeMacroFn(c: *Context, name: []const u8, ref: *ast.Node, proto_a
41214121 .return_type = proto_alias.return_type,
41224122 .var_args_token = null,
41234123 .extern_export_inline_token = inline_tok,
4124 .cc_token = null,
41254124 .body_node = null,
41264125 .lib_name = null,
41274126 .align_expr = null,
......@@ -4780,7 +4779,6 @@ fn finishTransFnProto(
47804779 .return_type = .{ .Explicit = return_type_node },
47814780 .var_args_token = null, // TODO this field is broken in the AST data model
47824781 .extern_export_inline_token = extern_export_inline_tok,
4783 .cc_token = null,
47844782 .body_node = null,
47854783 .lib_name = null,
47864784 .align_expr = align_expr,
......@@ -5146,7 +5144,6 @@ fn transMacroFnDefine(c: *Context, it: *CTokenList.Iterator, source: []const u8,
51465144 .return_type = .{ .Explicit = &type_of.base },
51475145 .doc_comments = null,
51485146 .var_args_token = null,
5149 .cc_token = null,
51505147 .body_node = null,
51515148 .lib_name = null,
51525149 .align_expr = null,
src/all_types.hpp-1
......@@ -718,7 +718,6 @@ struct AstNodeFnProto {
718718 Buf doc_comments;
719719
720720 FnInline fn_inline;
721 bool is_async;
722721
723722 VisibMod visib_mod;
724723 bool auto_err_set;
src/analyze.cpp-2
......@@ -1528,8 +1528,6 @@ ZigType *get_generic_fn_type(CodeGen *g, FnTypeId *fn_type_id) {
15281528}
15291529
15301530CallingConvention cc_from_fn_proto(AstNodeFnProto *fn_proto) {
1531 if (fn_proto->is_async)
1532 return CallingConventionAsync;
15331531 // Compatible with the C ABI
15341532 if (fn_proto->is_extern || fn_proto->is_export)
15351533 return CallingConventionC;
src/parser.cpp+5-53
......@@ -93,7 +93,6 @@ static AstNode *ast_parse_field_init(ParseContext *pc);
9393static AstNode *ast_parse_while_continue_expr(ParseContext *pc);
9494static AstNode *ast_parse_link_section(ParseContext *pc);
9595static AstNode *ast_parse_callconv(ParseContext *pc);
96static Optional<AstNodeFnProto> ast_parse_fn_cc(ParseContext *pc);
9796static AstNode *ast_parse_param_decl(ParseContext *pc);
9897static AstNode *ast_parse_param_type(ParseContext *pc);
9998static AstNode *ast_parse_if_prefix(ParseContext *pc);
......@@ -707,7 +706,6 @@ static AstNode *ast_parse_top_level_decl(ParseContext *pc, VisibMod visib_mod, B
707706 fn_proto->column = first->start_column;
708707 fn_proto->data.fn_proto.visib_mod = visib_mod;
709708 fn_proto->data.fn_proto.doc_comments = *doc_comments;
710 // ast_parse_fn_cc may set it
711709 if (!fn_proto->data.fn_proto.is_extern)
712710 fn_proto->data.fn_proto.is_extern = first->id == TokenIdKeywordExtern;
713711 fn_proto->data.fn_proto.is_export = first->id == TokenIdKeywordExport;
......@@ -788,29 +786,11 @@ static AstNode *ast_parse_top_level_decl(ParseContext *pc, VisibMod visib_mod, B
788786 return nullptr;
789787}
790788
791// FnProto <- FnCC? KEYWORD_fn IDENTIFIER? LPAREN ParamDeclList RPAREN ByteAlign? LinkSection? EXCLAMATIONMARK? (KEYWORD_var / TypeExpr)
789// FnProto <- KEYWORD_fn IDENTIFIER? LPAREN ParamDeclList RPAREN ByteAlign? LinkSection? EXCLAMATIONMARK? (KEYWORD_var / TypeExpr)
792790static AstNode *ast_parse_fn_proto(ParseContext *pc) {
793 Token *first = peek_token(pc);
794 AstNodeFnProto fn_cc;
795 Token *fn;
796 if (ast_parse_fn_cc(pc).unwrap(&fn_cc)) {
797 // The extern keyword for fn CC is also used for container decls.
798 // We therefore put it back, as allow container decl to consume it
799 // later.
800 if (fn_cc.is_extern) {
801 fn = eat_token_if(pc, TokenIdKeywordFn);
802 if (fn == nullptr) {
803 put_back_token(pc);
804 return nullptr;
805 }
806 } else {
807 fn = expect_token(pc, TokenIdKeywordFn);
808 }
809 } else {
810 fn_cc = {};
811 fn = eat_token_if(pc, TokenIdKeywordFn);
812 if (fn == nullptr)
813 return nullptr;
791 Token *first = eat_token_if(pc, TokenIdKeywordFn);
792 if (first == nullptr) {
793 return nullptr;
814794 }
815795
816796 Token *identifier = eat_token_if(pc, TokenIdSymbol);
......@@ -830,7 +810,7 @@ static AstNode *ast_parse_fn_proto(ParseContext *pc) {
830810 }
831811
832812 AstNode *res = ast_create_node(pc, NodeTypeFnProto, first);
833 res->data.fn_proto = fn_cc;
813 res->data.fn_proto = {};
834814 res->data.fn_proto.name = token_buf(identifier);
835815 res->data.fn_proto.params = params;
836816 res->data.fn_proto.align_expr = align_expr;
......@@ -1524,17 +1504,6 @@ static AstNode *ast_parse_error_union_expr(ParseContext *pc) {
15241504static AstNode *ast_parse_suffix_expr(ParseContext *pc) {
15251505 Token *async_token = eat_token_if(pc, TokenIdKeywordAsync);
15261506 if (async_token) {
1527 if (eat_token_if(pc, TokenIdKeywordFn) != nullptr) {
1528 // HACK: If we see the keyword `fn`, then we assume that
1529 // we are parsing an async fn proto, and not a call.
1530 // We therefore put back all tokens consumed by the async
1531 // prefix...
1532 put_back_token(pc);
1533 put_back_token(pc);
1534
1535 return ast_parse_primary_type_expr(pc);
1536 }
1537
15381507 AstNode *child = ast_expect(pc, ast_parse_primary_type_expr);
15391508 while (true) {
15401509 AstNode *suffix = ast_parse_suffix_op(pc);
......@@ -2187,23 +2156,6 @@ static AstNode *ast_parse_callconv(ParseContext *pc) {
21872156 return res;
21882157}
21892158
2190// FnCC
2191// <- KEYWORD_extern
2192// / KEYWORD_async
2193static Optional<AstNodeFnProto> ast_parse_fn_cc(ParseContext *pc) {
2194 AstNodeFnProto res = {};
2195 if (eat_token_if(pc, TokenIdKeywordAsync) != nullptr) {
2196 res.is_async = true;
2197 return Optional<AstNodeFnProto>::some(res);
2198 }
2199 if (eat_token_if(pc, TokenIdKeywordExtern) != nullptr) {
2200 res.is_extern = true;
2201 return Optional<AstNodeFnProto>::some(res);
2202 }
2203
2204 return Optional<AstNodeFnProto>::none();
2205}
2206
22072159// ParamDecl <- (KEYWORD_noalias / KEYWORD_comptime)? (IDENTIFIER COLON)? ParamType
22082160static AstNode *ast_parse_param_decl(ParseContext *pc) {
22092161 Buf doc_comments = BUF_INIT;
test/compile_errors.zig+11-11
......@@ -802,7 +802,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
802802 });
803803
804804 cases.add("exported async function",
805 \\export async fn foo() void {}
805 \\export fn foo() callconv(.Async) void {}
806806 , &[_][]const u8{
807807 "tmp.zig:1:1: error: exported function cannot be async",
808808 });
......@@ -1281,11 +1281,11 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
12811281
12821282 cases.add("bad alignment in @asyncCall",
12831283 \\export fn entry() void {
1284 \\ var ptr: async fn () void = func;
1284 \\ var ptr: fn () callconv(.Async) void = func;
12851285 \\ var bytes: [64]u8 = undefined;
12861286 \\ _ = @asyncCall(&bytes, {}, ptr);
12871287 \\}
1288 \\async fn func() void {}
1288 \\fn func() callconv(.Async) void {}
12891289 , &[_][]const u8{
12901290 "tmp.zig:4:21: error: expected type '[]align(16) u8', found '*[64]u8'",
12911291 });
......@@ -1431,7 +1431,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
14311431 \\export fn entry() void {
14321432 \\ _ = async amain();
14331433 \\}
1434 \\async fn amain() void {
1434 \\fn amain() callconv(.Async) void {
14351435 \\ other();
14361436 \\}
14371437 \\fn other() void {
......@@ -1447,7 +1447,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
14471447 \\export fn entry() void {
14481448 \\ _ = async amain();
14491449 \\}
1450 \\async fn amain() void {
1450 \\fn amain() callconv(.Async) void {
14511451 \\ var x: [@sizeOf(@Frame(amain))]u8 = undefined;
14521452 \\}
14531453 , &[_][]const u8{
......@@ -1474,7 +1474,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
14741474 \\ var ptr = afunc;
14751475 \\ _ = ptr();
14761476 \\}
1477 \\async fn afunc() void {}
1477 \\fn afunc() callconv(.Async) void {}
14781478 , &[_][]const u8{
14791479 "tmp.zig:6:12: error: function is not comptime-known; @asyncCall required",
14801480 });
......@@ -1485,7 +1485,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
14851485 \\ _ = async ptr();
14861486 \\}
14871487 \\
1488 \\async fn afunc() void { }
1488 \\fn afunc() callconv(.Async) void { }
14891489 , &[_][]const u8{
14901490 "tmp.zig:3:15: error: function is not comptime-known; @asyncCall required",
14911491 });
......@@ -3074,7 +3074,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
30743074 \\export fn entry() void {
30753075 \\ _ = async foo();
30763076 \\}
3077 \\async fn foo() void {
3077 \\fn foo() void {
30783078 \\ suspend {
30793079 \\ suspend {
30803080 \\ }
......@@ -3122,7 +3122,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
31223122 \\export fn entry() void {
31233123 \\ _ = async amain();
31243124 \\}
3125 \\async fn amain() void {
3125 \\fn amain() callconv(.Async) void {
31263126 \\ return error.ShouldBeCompileError;
31273127 \\}
31283128 , &[_][]const u8{
......@@ -3592,7 +3592,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
35923592 });
35933593
35943594 cases.add("attempt to use 0 bit type in extern fn",
3595 \\extern fn foo(ptr: extern fn(*void) void) void;
3595 \\extern fn foo(ptr: fn(*void) callconv(.C) void) void;
35963596 \\
35973597 \\export fn entry() void {
35983598 \\ foo(bar);
......@@ -3603,7 +3603,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
36033603 \\ bar(&{});
36043604 \\}
36053605 , &[_][]const u8{
3606 "tmp.zig:1:30: error: parameter of type '*void' has 0 bits; not allowed in function with calling convention 'C'",
3606 "tmp.zig:1:23: error: parameter of type '*void' has 0 bits; not allowed in function with calling convention 'C'",
36073607 "tmp.zig:7:11: error: parameter of type '*void' has 0 bits; not allowed in function with calling convention 'C'",
36083608 });
36093609
test/runtime_safety.zig+4-4
......@@ -282,7 +282,7 @@ pub fn addCases(cases: *tests.CompareOutputContext) void {
282282 \\ var ptr = other;
283283 \\ var frame = @asyncCall(&bytes, {}, ptr);
284284 \\}
285 \\async fn other() void {
285 \\fn other() callconv(.Async) void {
286286 \\ suspend;
287287 \\}
288288 );
......@@ -874,16 +874,16 @@ pub fn addCases(cases: *tests.CompareOutputContext) void {
874874 \\ return &failing_frame;
875875 \\}
876876 \\
877 \\async fn failing() anyerror!void {
877 \\fn failing() anyerror!void {
878878 \\ suspend;
879879 \\ return second();
880880 \\}
881881 \\
882 \\async fn second() anyerror!void {
882 \\fn second() callconv(.Async) anyerror!void {
883883 \\ return error.Fail;
884884 \\}
885885 \\
886 \\async fn printTrace(p: anyframe->anyerror!void) void {
886 \\fn printTrace(p: anyframe->anyerror!void) void {
887887 \\ (await p) catch unreachable;
888888 \\}
889889 );
test/stack_traces.zig+1-1
......@@ -282,7 +282,7 @@ pub fn addCases(cases: *tests.StackTracesContext) void {
282282 \\source.zig:10:8: [address] in main (test)
283283 \\ foo();
284284 \\ ^
285 \\start.zig:250:29: [address] in std.start.posixCallMainAndExit (test)
285 \\start.zig:249:29: [address] in std.start.posixCallMainAndExit (test)
286286 \\ return root.main();
287287 \\ ^
288288 \\start.zig:123:5: [address] in std.start._start (test)
test/stage1/behavior/async_fn.zig+25-29
......@@ -112,12 +112,12 @@ test "@frameSize" {
112112 const S = struct {
113113 fn doTheTest() void {
114114 {
115 var ptr = @ptrCast(async fn (i32) void, other);
115 var ptr = @ptrCast(fn (i32) callconv(.Async) void, other);
116116 const size = @frameSize(ptr);
117117 expect(size == @sizeOf(@Frame(other)));
118118 }
119119 {
120 var ptr = @ptrCast(async fn () void, first);
120 var ptr = @ptrCast(fn () callconv(.Async) void, first);
121121 const size = @frameSize(ptr);
122122 expect(size == @sizeOf(@Frame(first)));
123123 }
......@@ -184,7 +184,7 @@ test "coroutine suspend with block" {
184184
185185var a_promise: anyframe = undefined;
186186var global_result = false;
187async fn testSuspendBlock() void {
187fn testSuspendBlock() callconv(.Async) void {
188188 suspend {
189189 comptime expect(@TypeOf(@frame()) == *@Frame(testSuspendBlock));
190190 a_promise = @frame();
......@@ -209,14 +209,14 @@ test "coroutine await" {
209209 expect(await_final_result == 1234);
210210 expect(std.mem.eql(u8, &await_points, "abcdefghi"));
211211}
212async fn await_amain() void {
212fn await_amain() callconv(.Async) void {
213213 await_seq('b');
214214 var p = async await_another();
215215 await_seq('e');
216216 await_final_result = await p;
217217 await_seq('h');
218218}
219async fn await_another() i32 {
219fn await_another() callconv(.Async) i32 {
220220 await_seq('c');
221221 suspend {
222222 await_seq('d');
......@@ -243,14 +243,14 @@ test "coroutine await early return" {
243243 expect(early_final_result == 1234);
244244 expect(std.mem.eql(u8, &early_points, "abcdef"));
245245}
246async fn early_amain() void {
246fn early_amain() callconv(.Async) void {
247247 early_seq('b');
248248 var p = async early_another();
249249 early_seq('d');
250250 early_final_result = await p;
251251 early_seq('e');
252252}
253async fn early_another() i32 {
253fn early_another() callconv(.Async) i32 {
254254 early_seq('c');
255255 return 1234;
256256}
......@@ -266,7 +266,7 @@ fn early_seq(c: u8) void {
266266test "async function with dot syntax" {
267267 const S = struct {
268268 var y: i32 = 1;
269 async fn foo() void {
269 fn foo() callconv(.Async) void {
270270 y += 1;
271271 suspend;
272272 }
......@@ -278,7 +278,7 @@ test "async function with dot syntax" {
278278test "async fn pointer in a struct field" {
279279 var data: i32 = 1;
280280 const Foo = struct {
281 bar: async fn (*i32) void,
281 bar: fn (*i32) callconv(.Async) void,
282282 };
283283 var foo = Foo{ .bar = simpleAsyncFn2 };
284284 var bytes: [64]u8 align(16) = undefined;
......@@ -294,8 +294,7 @@ test "async fn pointer in a struct field" {
294294fn doTheAwait(f: anyframe->void) void {
295295 await f;
296296}
297
298async fn simpleAsyncFn2(y: *i32) void {
297fn simpleAsyncFn2(y: *i32) callconv(.Async) void {
299298 defer y.* += 2;
300299 y.* += 1;
301300 suspend;
......@@ -303,11 +302,10 @@ async fn simpleAsyncFn2(y: *i32) void {
303302
304303test "@asyncCall with return type" {
305304 const Foo = struct {
306 bar: async fn () i32,
305 bar: fn () callconv(.Async) i32,
307306
308307 var global_frame: anyframe = undefined;
309
310 async fn middle() i32 {
308 fn middle() callconv(.Async) i32 {
311309 return afunc();
312310 }
313311
......@@ -338,8 +336,7 @@ test "async fn with inferred error set" {
338336 resume global_frame;
339337 std.testing.expectError(error.Fail, result);
340338 }
341
342 async fn middle() !void {
339 fn middle() callconv(.Async) !void {
343340 var f = async middle2();
344341 return await f;
345342 }
......@@ -376,11 +373,11 @@ fn nonFailing() (anyframe->anyerror!void) {
376373 Static.frame = async suspendThenFail();
377374 return &Static.frame;
378375}
379async fn suspendThenFail() anyerror!void {
376fn suspendThenFail() callconv(.Async) anyerror!void {
380377 suspend;
381378 return error.Fail;
382379}
383async fn printTrace(p: anyframe->(anyerror!void)) void {
380fn printTrace(p: anyframe->(anyerror!void)) callconv(.Async) void {
384381 (await p) catch |e| {
385382 std.testing.expect(e == error.Fail);
386383 if (@errorReturnTrace()) |trace| {
......@@ -397,7 +394,7 @@ test "break from suspend" {
397394 const p = async testBreakFromSuspend(&my_result);
398395 std.testing.expect(my_result == 2);
399396}
400async fn testBreakFromSuspend(my_result: *i32) void {
397fn testBreakFromSuspend(my_result: *i32) callconv(.Async) void {
401398 suspend {
402399 resume @frame();
403400 }
......@@ -826,7 +823,7 @@ test "cast fn to async fn when it is inferred to be async" {
826823 var ok = false;
827824
828825 fn doTheTest() void {
829 var ptr: async fn () i32 = undefined;
826 var ptr: fn () callconv(.Async) i32 = undefined;
830827 ptr = func;
831828 var buf: [100]u8 align(16) = undefined;
832829 var result: i32 = undefined;
......@@ -854,7 +851,7 @@ test "cast fn to async fn when it is inferred to be async, awaited directly" {
854851 var ok = false;
855852
856853 fn doTheTest() void {
857 var ptr: async fn () i32 = undefined;
854 var ptr: fn () callconv(.Async) i32 = undefined;
858855 ptr = func;
859856 var buf: [100]u8 align(16) = undefined;
860857 var result: i32 = undefined;
......@@ -958,8 +955,7 @@ test "@asyncCall with comptime-known function, but not awaited directly" {
958955 resume global_frame;
959956 std.testing.expectError(error.Fail, result);
960957 }
961
962 async fn middle() !void {
958 fn middle() callconv(.Async) !void {
963959 var f = async middle2();
964960 return await f;
965961 }
......@@ -993,7 +989,7 @@ test "@asyncCall with actual frame instead of byte buffer" {
993989
994990test "@asyncCall using the result location inside the frame" {
995991 const S = struct {
996 async fn simple2(y: *i32) i32 {
992 fn simple2(y: *i32) callconv(.Async) i32 {
997993 defer y.* += 2;
998994 y.* += 1;
999995 suspend;
......@@ -1005,7 +1001,7 @@ test "@asyncCall using the result location inside the frame" {
10051001 };
10061002 var data: i32 = 1;
10071003 const Foo = struct {
1008 bar: async fn (*i32) i32,
1004 bar: fn (*i32) callconv(.Async) i32,
10091005 };
10101006 var foo = Foo{ .bar = S.simple2 };
10111007 var bytes: [64]u8 align(16) = undefined;
......@@ -1115,7 +1111,7 @@ test "await used in expression and awaiting fn with no suspend but async calling
11151111 const sum = (await f1) + (await f2);
11161112 expect(sum == 10);
11171113 }
1118 async fn add(a: i32, b: i32) i32 {
1114 fn add(a: i32, b: i32) callconv(.Async) i32 {
11191115 return a + b;
11201116 }
11211117 };
......@@ -1130,7 +1126,7 @@ test "await used in expression after a fn call" {
11301126 sum = foo() + await f1;
11311127 expect(sum == 8);
11321128 }
1133 async fn add(a: i32, b: i32) i32 {
1129 fn add(a: i32, b: i32) callconv(.Async) i32 {
11341130 return a + b;
11351131 }
11361132 fn foo() i32 {
......@@ -1147,7 +1143,7 @@ test "async fn call used in expression after a fn call" {
11471143 sum = foo() + add(3, 4);
11481144 expect(sum == 8);
11491145 }
1150 async fn add(a: i32, b: i32) i32 {
1146 fn add(a: i32, b: i32) callconv(.Async) i32 {
11511147 return a + b;
11521148 }
11531149 fn foo() i32 {
......@@ -1403,7 +1399,7 @@ test "async function call resolves target fn frame, runtime func" {
14031399 fn foo() anyerror!void {
14041400 const stack_size = 1000;
14051401 var stack_frame: [stack_size]u8 align(std.Target.stack_align) = undefined;
1406 var func: async fn () anyerror!void = bar;
1402 var func: fn () callconv(.Async) anyerror!void = bar;
14071403 return await @asyncCall(&stack_frame, {}, func);
14081404 }
14091405
test/stage1/behavior/await_struct.zig+2-2
......@@ -18,14 +18,14 @@ test "coroutine await struct" {
1818 expect(await_final_result.x == 1234);
1919 expect(std.mem.eql(u8, &await_points, "abcdefghi"));
2020}
21async fn await_amain() void {
21fn await_amain() callconv(.Async) void {
2222 await_seq('b');
2323 var p = async await_another();
2424 await_seq('e');
2525 await_final_result = await p;
2626 await_seq('h');
2727}
28async fn await_another() Foo {
28fn await_another() callconv(.Async) Foo {
2929 await_seq('c');
3030 suspend {
3131 await_seq('d');
test/stage1/behavior/cast.zig+1-1
......@@ -762,7 +762,7 @@ test "variable initialization uses result locations properly with regards to the
762762
763763test "cast between [*c]T and ?[*:0]T on fn parameter" {
764764 const S = struct {
765 const Handler = ?extern fn ([*c]const u8) void;
765 const Handler = ?fn ([*c]const u8) callconv(.C) void;
766766 fn addCallback(handler: Handler) void {}
767767
768768 fn myCallback(cstr: ?[*:0]const u8) callconv(.C) void {}