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
signaturebadge-question-mark 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...@@ -800,7 +800,6 @@ fn tokenizeAndPrintRaw(docgen_tokenizer: *Tokenizer, out: var, source_token: Tok
800 .Keyword_for,800 .Keyword_for,
801 .Keyword_if,801 .Keyword_if,
802 .Keyword_inline,802 .Keyword_inline,
803 .Keyword_nakedcc,
804 .Keyword_noalias,803 .Keyword_noalias,
805 .Keyword_noinline,804 .Keyword_noinline,
806 .Keyword_nosuspend,805 .Keyword_nosuspend,
...@@ -813,7 +812,6 @@ fn tokenizeAndPrintRaw(docgen_tokenizer: *Tokenizer, out: var, source_token: Tok...@@ -813,7 +812,6 @@ fn tokenizeAndPrintRaw(docgen_tokenizer: *Tokenizer, out: var, source_token: Tok
813 .Keyword_return,812 .Keyword_return,
814 .Keyword_linksection,813 .Keyword_linksection,
815 .Keyword_callconv,814 .Keyword_callconv,
816 .Keyword_stdcallcc,
817 .Keyword_struct,815 .Keyword_struct,
818 .Keyword_suspend,816 .Keyword_suspend,
819 .Keyword_switch,817 .Keyword_switch,
doc/langref.html.in+3-8
...@@ -6713,7 +6713,7 @@ const assert = std.debug.assert;...@@ -6713,7 +6713,7 @@ const assert = std.debug.assert;
6713test "async fn pointer in a struct field" {6713test "async fn pointer in a struct field" {
6714 var data: i32 = 1;6714 var data: i32 = 1;
6715 const Foo = struct {6715 const Foo = struct {
6716 bar: async fn (*i32) void,6716 bar: fn (*i32) callconv(.Async) void,
6717 };6717 };
6718 var foo = Foo{ .bar = func };6718 var foo = Foo{ .bar = func };
6719 var bytes: [64]u8 align(@alignOf(@Frame(func))) = undefined;6719 var bytes: [64]u8 align(@alignOf(@Frame(func))) = undefined;
...@@ -6723,7 +6723,7 @@ test "async fn pointer in a struct field" {...@@ -6723,7 +6723,7 @@ test "async fn pointer in a struct field" {
6723 assert(data == 4);6723 assert(data == 4);
6724}6724}
67256725
6726async fn func(y: *i32) void {6726fn func(y: *i32) void {
6727 defer y.* += 2;6727 defer y.* += 2;
6728 y.* += 1;6728 y.* += 1;
6729 suspend;6729 suspend;
...@@ -10086,7 +10086,7 @@ TopLevelDecl...@@ -10086,7 +10086,7 @@ TopLevelDecl
10086 / (KEYWORD_export / KEYWORD_extern STRINGLITERALSINGLE?)? KEYWORD_threadlocal? VarDecl10086 / (KEYWORD_export / KEYWORD_extern STRINGLITERALSINGLE?)? KEYWORD_threadlocal? VarDecl
10087 / KEYWORD_usingnamespace Expr SEMICOLON10087 / 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
10091VarDecl &lt;- (KEYWORD_const / KEYWORD_var) IDENTIFIER (COLON TypeExpr)? ByteAlign? LinkSection? (EQUAL Expr)? SEMICOLON10091VarDecl &lt;- (KEYWORD_const / KEYWORD_var) IDENTIFIER (COLON TypeExpr)? ByteAlign? LinkSection? (EQUAL Expr)? SEMICOLON
1009210092
...@@ -10253,11 +10253,6 @@ WhileContinueExpr &lt;- COLON LPAREN AssignExpr RPAREN...@@ -10253,11 +10253,6 @@ WhileContinueExpr &lt;- COLON LPAREN AssignExpr RPAREN
1025310253
10254LinkSection &lt;- KEYWORD_linksection LPAREN Expr RPAREN10254LinkSection &lt;- KEYWORD_linksection LPAREN Expr RPAREN
1025510255
10256# Fn specific
10257FnCC
10258 &lt;- KEYWORD_extern
10259 / KEYWORD_async
10260
10261ParamDecl &lt;- (KEYWORD_noalias / KEYWORD_comptime)? (IDENTIFIER COLON)? ParamType10256ParamDecl &lt;- (KEYWORD_noalias / KEYWORD_comptime)? (IDENTIFIER COLON)? ParamType
1026210257
10263ParamType10258ParamType
lib/std/c.zig+1-1
...@@ -217,7 +217,7 @@ pub extern "c" fn utimes(path: [*:0]const u8, times: *[2]timeval) c_int;...@@ -217,7 +217,7 @@ pub extern "c" fn utimes(path: [*:0]const u8, times: *[2]timeval) c_int;
217pub extern "c" fn utimensat(dirfd: fd_t, pathname: [*:0]const u8, times: *[2]timespec, flags: u32) c_int;217pub extern "c" fn utimensat(dirfd: fd_t, pathname: [*:0]const u8, times: *[2]timespec, flags: u32) c_int;
218pub extern "c" fn futimens(fd: fd_t, times: *const [2]timespec) c_int;218pub 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;
221pub extern "c" fn pthread_attr_init(attr: *pthread_attr_t) c_int;221pub extern "c" fn pthread_attr_init(attr: *pthread_attr_t) c_int;
222pub extern "c" fn pthread_attr_setstack(attr: *pthread_attr_t, stackaddr: *c_void, stacksize: usize) c_int;222pub extern "c" fn pthread_attr_setstack(attr: *pthread_attr_t, stackaddr: *c_void, stacksize: usize) c_int;
223pub extern "c" fn pthread_attr_setguardsize(attr: *pthread_attr_t, guardsize: usize) c_int;223pub 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;...@@ -9,7 +9,7 @@ pub extern "c" fn getdents(fd: c_int, buf_ptr: [*]u8, nbytes: usize) usize;
9pub extern "c" fn sigaltstack(ss: ?*stack_t, old_ss: ?*stack_t) c_int;9pub extern "c" fn sigaltstack(ss: ?*stack_t, old_ss: ?*stack_t) c_int;
10pub extern "c" fn getrandom(buf_ptr: [*]u8, buf_len: usize, flags: c_uint) isize;10pub 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;
13pub extern "c" fn dl_iterate_phdr(callback: dl_iterate_phdr_callback, data: ?*c_void) c_int;13pub extern "c" fn dl_iterate_phdr(callback: dl_iterate_phdr_callback, data: ?*c_void) c_int;
1414
15pub const pthread_mutex_t = extern struct {15pub const pthread_mutex_t = extern struct {
lib/std/c/freebsd.zig+1-1
...@@ -24,7 +24,7 @@ pub extern "c" fn sendfile(...@@ -24,7 +24,7 @@ pub extern "c" fn sendfile(
24 flags: u32,24 flags: u32,
25) c_int;25) 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;
28pub extern "c" fn dl_iterate_phdr(callback: dl_iterate_phdr_callback, data: ?*c_void) c_int;28pub extern "c" fn dl_iterate_phdr(callback: dl_iterate_phdr_callback, data: ?*c_void) c_int;
2929
30pub const pthread_mutex_t = extern struct {30pub 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)...@@ -75,7 +75,7 @@ pub extern "c" fn inotify_add_watch(fd: fd_t, pathname: [*]const u8, mask: u32)
75/// See std.elf for constants for this75/// See std.elf for constants for this
76pub extern "c" fn getauxval(__type: c_ulong) c_ulong;76pub 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;
79pub extern "c" fn dl_iterate_phdr(callback: dl_iterate_phdr_callback, data: ?*c_void) c_int;79pub extern "c" fn dl_iterate_phdr(callback: dl_iterate_phdr_callback, data: ?*c_void) c_int;
8080
81pub extern "c" fn sigaltstack(ss: ?*stack_t, old_ss: ?*stack_t) c_int;81pub 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;...@@ -6,7 +6,7 @@ usingnamespace std.c;
6extern "c" fn __errno() *c_int;6extern "c" fn __errno() *c_int;
7pub const _errno = __errno;7pub 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;
10pub extern "c" fn dl_iterate_phdr(callback: dl_iterate_phdr_callback, data: ?*c_void) c_int;10pub extern "c" fn dl_iterate_phdr(callback: dl_iterate_phdr_callback, data: ?*c_void) c_int;
1111
12pub extern "c" fn arc4random_buf(buf: [*]u8, len: usize) void;12pub 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 {...@@ -105,7 +105,7 @@ pub fn Channel(comptime T: type) type {
105105
106 /// await this function to get an item from the channel. If the buffer is empty, the frame will106 /// await this function to get an item from the channel. If the buffer is empty, the frame will
107 /// complete when the next item is put in the channel.107 /// 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 {
109 // TODO https://github.com/ziglang/zig/issues/2765109 // TODO https://github.com/ziglang/zig/issues/2765
110 var result: T = undefined;110 var result: T = undefined;
111 var my_tick_node = Loop.NextTickNode.init(@frame());111 var my_tick_node = Loop.NextTickNode.init(@frame());
...@@ -305,8 +305,7 @@ test "std.event.Channel wraparound" {...@@ -305,8 +305,7 @@ test "std.event.Channel wraparound" {
305 channel.put(7);305 channel.put(7);
306 testing.expectEqual(@as(i32, 7), channel.get());306 testing.expectEqual(@as(i32, 7), channel.get());
307}307}
308308fn testChannelGetter(channel: *Channel(i32)) callconv(.Async) void {
309async fn testChannelGetter(channel: *Channel(i32)) void {
310 const value1 = channel.get();309 const value1 = channel.get();
311 testing.expect(value1 == 1234);310 testing.expect(value1 == 1234);
312311
...@@ -321,12 +320,10 @@ async fn testChannelGetter(channel: *Channel(i32)) void {...@@ -321,12 +320,10 @@ async fn testChannelGetter(channel: *Channel(i32)) void {
321 testing.expect(value4.? == 4444);320 testing.expect(value4.? == 4444);
322 await last_put;321 await last_put;
323}322}
324323fn testChannelPutter(channel: *Channel(i32)) callconv(.Async) void {
325async fn testChannelPutter(channel: *Channel(i32)) void {
326 channel.put(1234);324 channel.put(1234);
327 channel.put(4567);325 channel.put(4567);
328}326}
329327fn testPut(channel: *Channel(i32), value: i32) callconv(.Async) void {
330async fn testPut(channel: *Channel(i32), value: i32) void {
331 channel.put(value);328 channel.put(value);
332}329}
lib/std/event/future.zig+2-2
...@@ -34,7 +34,7 @@ pub fn Future(comptime T: type) type {...@@ -34,7 +34,7 @@ pub fn Future(comptime T: type) type {
34 /// Obtain the value. If it's not available, wait until it becomes34 /// Obtain the value. If it's not available, wait until it becomes
35 /// available.35 /// available.
36 /// Thread-safe.36 /// Thread-safe.
37 pub async fn get(self: *Self) *T {37 pub fn get(self: *Self) callconv(.Async) *T {
38 if (@atomicLoad(Available, &self.available, .SeqCst) == .Finished) {38 if (@atomicLoad(Available, &self.available, .SeqCst) == .Finished) {
39 return &self.data;39 return &self.data;
40 }40 }
...@@ -59,7 +59,7 @@ pub fn Future(comptime T: type) type {...@@ -59,7 +59,7 @@ pub fn Future(comptime T: type) type {
59 /// should start working on the data.59 /// should start working on the data.
60 /// It's not required to call start() before resolve() but it can be useful since60 /// It's not required to call start() before resolve() but it can be useful since
61 /// this method is thread-safe.61 /// this method is thread-safe.
62 pub async fn start(self: *Self) ?*T {62 pub fn start(self: *Self) callconv(.Async) ?*T {
63 const state = @cmpxchgStrong(Available, &self.available, .NotStarted, .Started, .SeqCst, .SeqCst) orelse return null;63 const state = @cmpxchgStrong(Available, &self.available, .NotStarted, .Started, .SeqCst, .SeqCst) orelse return null;
64 switch (state) {64 switch (state) {
65 .Started => {65 .Started => {
lib/std/event/group.zig+6-10
...@@ -84,7 +84,7 @@ pub fn Group(comptime ReturnType: type) type {...@@ -84,7 +84,7 @@ pub fn Group(comptime ReturnType: type) type {
84 /// Wait for all the calls and promises of the group to complete.84 /// Wait for all the calls and promises of the group to complete.
85 /// Thread-safe.85 /// Thread-safe.
86 /// Safe to call any number of times.86 /// Safe to call any number of times.
87 pub async fn wait(self: *Self) ReturnType {87 pub fn wait(self: *Self) callconv(.Async) ReturnType {
88 const held = self.lock.acquire();88 const held = self.lock.acquire();
89 defer held.release();89 defer held.release();
9090
...@@ -127,8 +127,7 @@ test "std.event.Group" {...@@ -127,8 +127,7 @@ test "std.event.Group" {
127127
128 const handle = async testGroup(std.heap.page_allocator);128 const handle = async testGroup(std.heap.page_allocator);
129}129}
130130fn testGroup(allocator: *Allocator) callconv(.Async) void {
131async fn testGroup(allocator: *Allocator) void {
132 var count: usize = 0;131 var count: usize = 0;
133 var group = Group(void).init(allocator);132 var group = Group(void).init(allocator);
134 var sleep_a_little_frame = async sleepALittle(&count);133 var sleep_a_little_frame = async sleepALittle(&count);
...@@ -145,20 +144,17 @@ async fn testGroup(allocator: *Allocator) void {...@@ -145,20 +144,17 @@ async fn testGroup(allocator: *Allocator) void {
145 another.add(&something_that_fails_frame) catch @panic("memory");144 another.add(&something_that_fails_frame) catch @panic("memory");
146 testing.expectError(error.ItBroke, another.wait());145 testing.expectError(error.ItBroke, another.wait());
147}146}
148147fn sleepALittle(count: *usize) callconv(.Async) void {
149async fn sleepALittle(count: *usize) void {
150 std.time.sleep(1 * std.time.millisecond);148 std.time.sleep(1 * std.time.millisecond);
151 _ = @atomicRmw(usize, count, .Add, 1, .SeqCst);149 _ = @atomicRmw(usize, count, .Add, 1, .SeqCst);
152}150}
153151fn increaseByTen(count: *usize) callconv(.Async) void {
154async fn increaseByTen(count: *usize) void {
155 var i: usize = 0;152 var i: usize = 0;
156 while (i < 10) : (i += 1) {153 while (i < 10) : (i += 1) {
157 _ = @atomicRmw(usize, count, .Add, 1, .SeqCst);154 _ = @atomicRmw(usize, count, .Add, 1, .SeqCst);
158 }155 }
159}156}
160157fn doSomethingThatFails() callconv(.Async) anyerror!void {}
161async fn doSomethingThatFails() anyerror!void {}158fn somethingElse() callconv(.Async) anyerror!void {
162async fn somethingElse() anyerror!void {
163 return error.ItBroke;159 return error.ItBroke;
164}160}
lib/std/event/lock.zig+3-5
...@@ -89,7 +89,7 @@ pub const Lock = struct {...@@ -89,7 +89,7 @@ pub const Lock = struct {
89 while (self.queue.get()) |node| resume node.data;89 while (self.queue.get()) |node| resume node.data;
90 }90 }
9191
92 pub async fn acquire(self: *Lock) Held {92 pub fn acquire(self: *Lock) callconv(.Async) Held {
93 var my_tick_node = Loop.NextTickNode.init(@frame());93 var my_tick_node = Loop.NextTickNode.init(@frame());
9494
95 errdefer _ = self.queue.remove(&my_tick_node); // TODO test canceling an acquire95 errdefer _ = self.queue.remove(&my_tick_node); // TODO test canceling an acquire
...@@ -134,8 +134,7 @@ test "std.event.Lock" {...@@ -134,8 +134,7 @@ test "std.event.Lock" {
134 const expected_result = [1]i32{3 * @intCast(i32, shared_test_data.len)} ** shared_test_data.len;134 const expected_result = [1]i32{3 * @intCast(i32, shared_test_data.len)} ** shared_test_data.len;
135 testing.expectEqualSlices(i32, &expected_result, &shared_test_data);135 testing.expectEqualSlices(i32, &expected_result, &shared_test_data);
136}136}
137137fn testLock(lock: *Lock) callconv(.Async) void {
138async fn testLock(lock: *Lock) void {
139 var handle1 = async lockRunner(lock);138 var handle1 = async lockRunner(lock);
140 var tick_node1 = Loop.NextTickNode{139 var tick_node1 = Loop.NextTickNode{
141 .prev = undefined,140 .prev = undefined,
...@@ -167,8 +166,7 @@ async fn testLock(lock: *Lock) void {...@@ -167,8 +166,7 @@ async fn testLock(lock: *Lock) void {
167166
168var shared_test_data = [1]i32{0} ** 10;167var shared_test_data = [1]i32{0} ** 10;
169var shared_test_index: usize = 0;168var shared_test_index: usize = 0;
170169fn lockRunner(lock: *Lock) callconv(.Async) void {
171async fn lockRunner(lock: *Lock) void {
172 suspend; // resumed by onNextTick170 suspend; // resumed by onNextTick
173171
174 var i: usize = 0;172 var i: usize = 0;
lib/std/event/locked.zig+1-1
...@@ -31,7 +31,7 @@ pub fn Locked(comptime T: type) type {...@@ -31,7 +31,7 @@ pub fn Locked(comptime T: type) type {
31 self.lock.deinit();31 self.lock.deinit();
32 }32 }
3333
34 pub async fn acquire(self: *Self) HeldLock {34 pub fn acquire(self: *Self) callconv(.Async) HeldLock {
35 return HeldLock{35 return HeldLock{
36 // TODO guaranteed allocation elision36 // TODO guaranteed allocation elision
37 .held = self.lock.acquire(),37 .held = self.lock.acquire(),
lib/std/event/loop.zig+1-1
...@@ -503,7 +503,7 @@ pub const Loop = struct {...@@ -503,7 +503,7 @@ pub const Loop = struct {
503 }503 }
504 }504 }
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 {
507 var resume_node = ResumeNode.Basic{507 var resume_node = ResumeNode.Basic{
508 .base = ResumeNode{508 .base = ResumeNode{
509 .id = ResumeNode.Id.Basic,509 .id = ResumeNode.Id.Basic,
lib/std/event/rwlock.zig+5-8
...@@ -97,7 +97,7 @@ pub const RwLock = struct {...@@ -97,7 +97,7 @@ pub const RwLock = struct {
97 while (self.reader_queue.get()) |node| resume node.data;97 while (self.reader_queue.get()) |node| resume node.data;
98 }98 }
9999
100 pub async fn acquireRead(self: *RwLock) HeldRead {100 pub fn acquireRead(self: *RwLock) callconv(.Async) HeldRead {
101 _ = @atomicRmw(usize, &self.reader_lock_count, .Add, 1, .SeqCst);101 _ = @atomicRmw(usize, &self.reader_lock_count, .Add, 1, .SeqCst);
102102
103 suspend {103 suspend {
...@@ -130,7 +130,7 @@ pub const RwLock = struct {...@@ -130,7 +130,7 @@ pub const RwLock = struct {
130 return HeldRead{ .lock = self };130 return HeldRead{ .lock = self };
131 }131 }
132132
133 pub async fn acquireWrite(self: *RwLock) HeldWrite {133 pub fn acquireWrite(self: *RwLock) callconv(.Async) HeldWrite {
134 suspend {134 suspend {
135 var my_tick_node = Loop.NextTickNode{135 var my_tick_node = Loop.NextTickNode{
136 .data = @frame(),136 .data = @frame(),
...@@ -225,8 +225,7 @@ test "std.event.RwLock" {...@@ -225,8 +225,7 @@ test "std.event.RwLock" {
225 const expected_result = [1]i32{shared_it_count * @intCast(i32, shared_test_data.len)} ** shared_test_data.len;225 const expected_result = [1]i32{shared_it_count * @intCast(i32, shared_test_data.len)} ** shared_test_data.len;
226 testing.expectEqualSlices(i32, expected_result, shared_test_data);226 testing.expectEqualSlices(i32, expected_result, shared_test_data);
227}227}
228228fn testLock(allocator: *Allocator, lock: *RwLock) callconv(.Async) void {
229async fn testLock(allocator: *Allocator, lock: *RwLock) void {
230 var read_nodes: [100]Loop.NextTickNode = undefined;229 var read_nodes: [100]Loop.NextTickNode = undefined;
231 for (read_nodes) |*read_node| {230 for (read_nodes) |*read_node| {
232 const frame = allocator.create(@Frame(readRunner)) catch @panic("memory");231 const frame = allocator.create(@Frame(readRunner)) catch @panic("memory");
...@@ -259,8 +258,7 @@ const shared_it_count = 10;...@@ -259,8 +258,7 @@ const shared_it_count = 10;
259var shared_test_data = [1]i32{0} ** 10;258var shared_test_data = [1]i32{0} ** 10;
260var shared_test_index: usize = 0;259var shared_test_index: usize = 0;
261var shared_count: usize = 0;260var shared_count: usize = 0;
262261fn writeRunner(lock: *RwLock) callconv(.Async) void {
263async fn writeRunner(lock: *RwLock) void {
264 suspend; // resumed by onNextTick262 suspend; // resumed by onNextTick
265263
266 var i: usize = 0;264 var i: usize = 0;
...@@ -277,8 +275,7 @@ async fn writeRunner(lock: *RwLock) void {...@@ -277,8 +275,7 @@ async fn writeRunner(lock: *RwLock) void {
277 shared_test_index = 0;275 shared_test_index = 0;
278 }276 }
279}277}
280278fn readRunner(lock: *RwLock) callconv(.Async) void {
281async fn readRunner(lock: *RwLock) void {
282 suspend; // resumed by onNextTick279 suspend; // resumed by onNextTick
283 std.time.sleep(1);280 std.time.sleep(1);
284281
lib/std/event/rwlocked.zig+2-2
...@@ -40,14 +40,14 @@ pub fn RwLocked(comptime T: type) type {...@@ -40,14 +40,14 @@ pub fn RwLocked(comptime T: type) type {
40 self.lock.deinit();40 self.lock.deinit();
41 }41 }
4242
43 pub async fn acquireRead(self: *Self) HeldReadLock {43 pub fn acquireRead(self: *Self) callconv(.Async) HeldReadLock {
44 return HeldReadLock{44 return HeldReadLock{
45 .held = self.lock.acquireRead(),45 .held = self.lock.acquireRead(),
46 .value = &self.locked_data,46 .value = &self.locked_data,
47 };47 };
48 }48 }
4949
50 pub async fn acquireWrite(self: *Self) HeldWriteLock {50 pub fn acquireWrite(self: *Self) callconv(.Async) HeldWriteLock {
51 return HeldWriteLock{51 return HeldWriteLock{
52 .held = self.lock.acquireWrite(),52 .held = self.lock.acquireWrite(),
53 .value = &self.locked_data,53 .value = &self.locked_data,
lib/std/os/bits/darwin.zig+1-1
...@@ -125,7 +125,7 @@ pub const empty_sigset = sigset_t(0);...@@ -125,7 +125,7 @@ pub const empty_sigset = sigset_t(0);
125125
126/// Renamed from `sigaction` to `Sigaction` to avoid conflict with function name.126/// Renamed from `sigaction` to `Sigaction` to avoid conflict with function name.
127pub const Sigaction = extern struct {127pub const Sigaction = extern struct {
128 handler: extern fn (c_int) void,128 handler: fn (c_int) callconv(.C) void,
129 sa_mask: sigset_t,129 sa_mask: sigset_t,
130 sa_flags: c_int,130 sa_flags: c_int,
131};131};
lib/std/os/bits/dragonfly.zig+6-6
...@@ -458,9 +458,9 @@ pub const S_IFSOCK = 49152;...@@ -458,9 +458,9 @@ pub const S_IFSOCK = 49152;
458pub const S_IFWHT = 57344;458pub const S_IFWHT = 57344;
459pub const S_IFMT = 61440;459pub const S_IFMT = 61440;
460460
461pub const SIG_ERR = @intToPtr(extern fn (i32) void, maxInt(usize));461pub const SIG_ERR = @intToPtr(fn (i32) callconv(.C) void, maxInt(usize));
462pub const SIG_DFL = @intToPtr(extern fn (i32) void, 0);462pub const SIG_DFL = @intToPtr(fn (i32) callconv(.C) void, 0);
463pub const SIG_IGN = @intToPtr(extern fn (i32) void, 1);463pub const SIG_IGN = @intToPtr(fn (i32) callconv(.C) void, 1);
464pub const BADSIG = SIG_ERR;464pub const BADSIG = SIG_ERR;
465pub const SIG_BLOCK = 1;465pub const SIG_BLOCK = 1;
466pub const SIG_UNBLOCK = 2;466pub const SIG_UNBLOCK = 2;
...@@ -519,13 +519,13 @@ pub const sigset_t = extern struct {...@@ -519,13 +519,13 @@ pub const sigset_t = extern struct {
519pub const sig_atomic_t = c_int;519pub const sig_atomic_t = c_int;
520pub const Sigaction = extern struct {520pub const Sigaction = extern struct {
521 __sigaction_u: extern union {521 __sigaction_u: extern union {
522 __sa_handler: ?extern fn (c_int) void,522 __sa_handler: ?fn (c_int) callconv(.C) void,
523 __sa_sigaction: ?extern fn (c_int, [*c]siginfo_t, ?*c_void) void,523 __sa_sigaction: ?fn (c_int, [*c]siginfo_t, ?*c_void) callconv(.C) void,
524 },524 },
525 sa_flags: c_int,525 sa_flags: c_int,
526 sa_mask: sigset_t,526 sa_mask: sigset_t,
527};527};
528pub const sig_t = [*c]extern fn (c_int) void;528pub const sig_t = [*c]fn (c_int) callconv(.C) void;
529529
530pub const sigvec = extern struct {530pub const sigvec = extern struct {
531 sv_handler: [*c]__sighandler_t,531 sv_handler: [*c]__sighandler_t,
lib/std/os/bits/freebsd.zig+5-5
...@@ -725,16 +725,16 @@ pub const winsize = extern struct {...@@ -725,16 +725,16 @@ pub const winsize = extern struct {
725725
726const NSIG = 32;726const NSIG = 32;
727727
728pub const SIG_ERR = @intToPtr(extern fn (i32) void, maxInt(usize));728pub const SIG_ERR = @intToPtr(fn (i32) callconv(.C) void, maxInt(usize));
729pub const SIG_DFL = @intToPtr(extern fn (i32) void, 0);729pub const SIG_DFL = @intToPtr(fn (i32) callconv(.C) void, 0);
730pub const SIG_IGN = @intToPtr(extern fn (i32) void, 1);730pub const SIG_IGN = @intToPtr(fn (i32) callconv(.C) void, 1);
731731
732/// Renamed from `sigaction` to `Sigaction` to avoid conflict with the syscall.732/// Renamed from `sigaction` to `Sigaction` to avoid conflict with the syscall.
733pub const Sigaction = extern struct {733pub const Sigaction = extern struct {
734 /// signal handler734 /// signal handler
735 __sigaction_u: extern union {735 __sigaction_u: extern union {
736 __sa_handler: extern fn (i32) void,736 __sa_handler: fn (i32) callconv(.C) void,
737 __sa_sigaction: extern fn (i32, *__siginfo, usize) void,737 __sa_sigaction: fn (i32, *__siginfo, usize) callconv(.C) void,
738 },738 },
739739
740 /// see signal options740 /// 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...@@ -813,15 +813,15 @@ pub const app_mask: sigset_t = [2]u32{ 0xfffffffc, 0x7fffffff } ++ [_]u32{0xffff
813pub const k_sigaction = if (is_mips)813pub const k_sigaction = if (is_mips)
814 extern struct {814 extern struct {
815 flags: usize,815 flags: usize,
816 sigaction: ?extern fn (i32, *siginfo_t, ?*c_void) void,816 sigaction: ?fn (i32, *siginfo_t, ?*c_void) callconv(.C) void,
817 mask: [4]u32,817 mask: [4]u32,
818 restorer: extern fn () void,818 restorer: fn () callconv(.C) void,
819 }819 }
820else820else
821 extern struct {821 extern struct {
822 sigaction: ?extern fn (i32, *siginfo_t, ?*c_void) void,822 sigaction: ?fn (i32, *siginfo_t, ?*c_void) callconv(.C) void,
823 flags: usize,823 flags: usize,
824 restorer: extern fn () void,824 restorer: fn () callconv(.C) void,
825 mask: [2]u32,825 mask: [2]u32,
826 };826 };
827827
...@@ -831,7 +831,7 @@ pub const Sigaction = extern struct {...@@ -831,7 +831,7 @@ pub const Sigaction = extern struct {
831 sigaction: ?sigaction_fn,831 sigaction: ?sigaction_fn,
832 mask: sigset_t,832 mask: sigset_t,
833 flags: u32,833 flags: u32,
834 restorer: ?extern fn () void = null,834 restorer: ?fn () callconv(.C) void = null,
835};835};
836836
837pub const SIG_ERR = @intToPtr(?Sigaction.sigaction_fn, maxInt(usize));837pub 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 {...@@ -599,7 +599,7 @@ pub fn flock(fd: fd_t, operation: i32) usize {
599var vdso_clock_gettime = @ptrCast(?*const c_void, init_vdso_clock_gettime);599var vdso_clock_gettime = @ptrCast(?*const c_void, init_vdso_clock_gettime);
600600
601// We must follow the C calling convention when we call into the VDSO601// 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
604pub fn clock_gettime(clk_id: i32, tp: *timespec) usize {604pub fn clock_gettime(clk_id: i32, tp: *timespec) usize {
605 if (@hasDecl(@This(), "VDSO_CGT_SYM")) {605 if (@hasDecl(@This(), "VDSO_CGT_SYM")) {
...@@ -791,7 +791,7 @@ pub fn sigaction(sig: u6, noalias act: *const Sigaction, noalias oact: ?*Sigacti...@@ -791,7 +791,7 @@ pub fn sigaction(sig: u6, noalias act: *const Sigaction, noalias oact: ?*Sigacti
791 .sigaction = act.sigaction,791 .sigaction = act.sigaction,
792 .flags = act.flags | SA_RESTORER,792 .flags = act.flags | SA_RESTORER,
793 .mask = undefined,793 .mask = undefined,
794 .restorer = @ptrCast(extern fn () void, restorer_fn),794 .restorer = @ptrCast(fn () callconv(.C) void, restorer_fn),
795 };795 };
796 var ksa_old: k_sigaction = undefined;796 var ksa_old: k_sigaction = undefined;
797 const ksa_mask_size = @sizeOf(@TypeOf(ksa_old.mask));797 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(...@@ -86,7 +86,7 @@ pub fn syscall6(
86}86}
8787
88/// This matches the libc clone function.88/// 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
91pub fn restore() callconv(.Naked) void {91pub fn restore() callconv(.Naked) void {
92 return asm volatile ("svc #0"92 return asm volatile ("svc #0"
lib/std/os/linux/arm64.zig+1-1
...@@ -86,7 +86,7 @@ pub fn syscall6(...@@ -86,7 +86,7 @@ pub fn syscall6(
86}86}
8787
88/// This matches the libc clone function.88/// 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
91pub const restore = restore_rt;91pub 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 {...@@ -106,7 +106,7 @@ pub fn socketcall(call: usize, args: [*]usize) usize {
106}106}
107107
108/// This matches the libc clone function.108/// 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
111pub fn restore() callconv(.Naked) void {111pub fn restore() callconv(.Naked) void {
112 return asm volatile ("int $0x80"112 return asm volatile ("int $0x80"
lib/std/os/linux/mips.zig+1-1
...@@ -142,7 +142,7 @@ pub fn syscall6(...@@ -142,7 +142,7 @@ pub fn syscall6(
142}142}
143143
144/// This matches the libc clone function.144/// 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
147pub fn restore() callconv(.Naked) void {147pub fn restore() callconv(.Naked) void {
148 return asm volatile ("syscall"148 return asm volatile ("syscall"
lib/std/os/linux/riscv64.zig+1-1
...@@ -85,7 +85,7 @@ pub fn syscall6(...@@ -85,7 +85,7 @@ pub fn syscall6(
85 );85 );
86}86}
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
90pub const restore = restore_rt;90pub const restore = restore_rt;
9191
lib/std/os/linux/x86_64.zig+1-1
...@@ -86,7 +86,7 @@ pub fn syscall6(...@@ -86,7 +86,7 @@ pub fn syscall6(
86}86}
8787
88/// This matches the libc clone function.88/// 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
91pub const restore = restore_rt;91pub const restore = restore_rt;
9292
lib/std/os/uefi/protocols/absolute_pointer_protocol.zig+2-2
...@@ -5,8 +5,8 @@ const Status = uefi.Status;...@@ -5,8 +5,8 @@ const Status = uefi.Status;
55
6/// Protocol for touchscreens6/// Protocol for touchscreens
7pub const AbsolutePointerProtocol = extern struct {7pub const AbsolutePointerProtocol = extern struct {
8 _reset: extern fn (*const AbsolutePointerProtocol, bool) Status,8 _reset: fn (*const AbsolutePointerProtocol, bool) callconv(.C) Status,
9 _get_state: extern fn (*const AbsolutePointerProtocol, *AbsolutePointerState) Status,9 _get_state: fn (*const AbsolutePointerProtocol, *AbsolutePointerState) callconv(.C) Status,
10 wait_for_input: Event,10 wait_for_input: Event,
11 mode: *AbsolutePointerMode,11 mode: *AbsolutePointerMode,
1212
lib/std/os/uefi/protocols/edid_override_protocol.zig+1-1
...@@ -5,7 +5,7 @@ const Status = uefi.Status;...@@ -5,7 +5,7 @@ const Status = uefi.Status;
55
6/// Override EDID information6/// Override EDID information
7pub const EdidOverrideProtocol = extern struct {7pub 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
10 /// Returns policy information and potentially a replacement EDID for the specified video output device.10 /// Returns policy information and potentially a replacement EDID for the specified video output device.
11 /// attributes must be align(4)11 /// attributes must be align(4)
lib/std/os/uefi/protocols/file_protocol.zig+10-10
...@@ -5,16 +5,16 @@ const Status = uefi.Status;...@@ -5,16 +5,16 @@ const Status = uefi.Status;
55
6pub const FileProtocol = extern struct {6pub const FileProtocol = extern struct {
7 revision: u64,7 revision: u64,
8 _open: extern fn (*const FileProtocol, **const FileProtocol, [*:0]const u16, u64, u64) Status,8 _open: fn (*const FileProtocol, **const FileProtocol, [*:0]const u16, u64, u64) callconv(.C) Status,
9 _close: extern fn (*const FileProtocol) Status,9 _close: fn (*const FileProtocol) callconv(.C) Status,
10 _delete: extern fn (*const FileProtocol) Status,10 _delete: fn (*const FileProtocol) callconv(.C) Status,
11 _read: extern fn (*const FileProtocol, *usize, [*]u8) Status,11 _read: fn (*const FileProtocol, *usize, [*]u8) callconv(.C) Status,
12 _write: extern fn (*const FileProtocol, *usize, [*]const u8) Status,12 _write: fn (*const FileProtocol, *usize, [*]const u8) callconv(.C) Status,
13 _get_position: extern fn (*const FileProtocol, *u64) Status,13 _get_position: fn (*const FileProtocol, *u64) callconv(.C) Status,
14 _set_position: extern fn (*const FileProtocol, *const u64) Status,14 _set_position: fn (*const FileProtocol, *const u64) callconv(.C) Status,
15 _get_info: extern fn (*const FileProtocol, *align(8) const Guid, *const usize, [*]u8) Status,15 _get_info: fn (*const FileProtocol, *align(8) const Guid, *const usize, [*]u8) callconv(.C) Status,
16 _set_info: extern fn (*const FileProtocol, *align(8) const Guid, usize, [*]const u8) Status,16 _set_info: fn (*const FileProtocol, *align(8) const Guid, usize, [*]const u8) callconv(.C) Status,
17 _flush: extern fn (*const FileProtocol) Status,17 _flush: fn (*const FileProtocol) callconv(.C) Status,
1818
19 pub fn open(self: *const FileProtocol, new_handle: **const FileProtocol, file_name: [*:0]const u16, open_mode: u64, attributes: u64) Status {19 pub fn open(self: *const FileProtocol, new_handle: **const FileProtocol, file_name: [*:0]const u16, open_mode: u64, attributes: u64) Status {
20 return self._open(self, new_handle, file_name, open_mode, attributes);20 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;...@@ -4,9 +4,9 @@ const Status = uefi.Status;
44
5/// Graphics output5/// Graphics output
6pub const GraphicsOutputProtocol = extern struct {6pub const GraphicsOutputProtocol = extern struct {
7 _query_mode: extern fn (*const GraphicsOutputProtocol, u32, *usize, **GraphicsOutputModeInformation) Status,7 _query_mode: fn (*const GraphicsOutputProtocol, u32, *usize, **GraphicsOutputModeInformation) callconv(.C) Status,
8 _set_mode: extern fn (*const GraphicsOutputProtocol, u32) Status,8 _set_mode: fn (*const GraphicsOutputProtocol, u32) callconv(.C) Status,
9 _blt: extern fn (*const GraphicsOutputProtocol, ?[*]GraphicsOutputBltPixel, GraphicsOutputBltOperation, usize, usize, usize, usize, usize, usize, usize) Status,9 _blt: fn (*const GraphicsOutputProtocol, ?[*]GraphicsOutputBltPixel, GraphicsOutputBltOperation, usize, usize, usize, usize, usize, usize, usize) callconv(.C) Status,
10 mode: *GraphicsOutputProtocolMode,10 mode: *GraphicsOutputProtocolMode,
1111
12 /// Returns information for an available graphics mode that the graphics device and the set of active video output devices supports.12 /// 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;...@@ -6,10 +6,10 @@ const hii = uefi.protocols.hii;
6/// Database manager for HII-related data structures.6/// Database manager for HII-related data structures.
7pub const HIIDatabaseProtocol = extern struct {7pub const HIIDatabaseProtocol = extern struct {
8 _new_package_list: Status, // TODO8 _new_package_list: Status, // TODO
9 _remove_package_list: extern fn (*const HIIDatabaseProtocol, hii.HIIHandle) Status,9 _remove_package_list: fn (*const HIIDatabaseProtocol, hii.HIIHandle) callconv(.C) Status,
10 _update_package_list: extern fn (*const HIIDatabaseProtocol, hii.HIIHandle, *const hii.HIIPackageList) Status,10 _update_package_list: fn (*const HIIDatabaseProtocol, hii.HIIHandle, *const hii.HIIPackageList) callconv(.C) Status,
11 _list_package_lists: extern fn (*const HIIDatabaseProtocol, u8, ?*const Guid, *usize, [*]hii.HIIHandle) Status,11 _list_package_lists: fn (*const HIIDatabaseProtocol, u8, ?*const Guid, *usize, [*]hii.HIIHandle) callconv(.C) Status,
12 _export_package_lists: extern fn (*const HIIDatabaseProtocol, ?hii.HIIHandle, *usize, *hii.HIIPackageList) Status,12 _export_package_lists: fn (*const HIIDatabaseProtocol, ?hii.HIIHandle, *usize, *hii.HIIPackageList) callconv(.C) Status,
13 _register_package_notify: Status, // TODO13 _register_package_notify: Status, // TODO
14 _unregister_package_notify: Status, // TODO14 _unregister_package_notify: Status, // TODO
15 _find_keyboard_layouts: Status, // TODO15 _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;...@@ -6,7 +6,7 @@ const hii = uefi.protocols.hii;
6/// Display a popup window6/// Display a popup window
7pub const HIIPopupProtocol = extern struct {7pub const HIIPopupProtocol = extern struct {
8 revision: u64,8 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
11 /// Displays a popup window.11 /// Displays a popup window.
12 pub fn createPopup(self: *const HIIPopupProtocol, style: HIIPopupStyle, popup_type: HIIPopupType, handle: hii.HIIHandle, msg: u16, user_selection: ?*HIIPopupSelection) Status {12 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;...@@ -4,10 +4,10 @@ const Event = uefi.Event;
4const Status = uefi.Status;4const Status = uefi.Status;
55
6pub const Ip6ConfigProtocol = extern struct {6pub const Ip6ConfigProtocol = extern struct {
7 _set_data: extern fn (*const Ip6ConfigProtocol, Ip6ConfigDataType, usize, *const c_void) Status,7 _set_data: fn (*const Ip6ConfigProtocol, Ip6ConfigDataType, usize, *const c_void) callconv(.C) Status,
8 _get_data: extern fn (*const Ip6ConfigProtocol, Ip6ConfigDataType, *usize, ?*const c_void) Status,8 _get_data: fn (*const Ip6ConfigProtocol, Ip6ConfigDataType, *usize, ?*const c_void) callconv(.C) Status,
9 _register_data_notify: extern fn (*const Ip6ConfigProtocol, Ip6ConfigDataType, Event) Status,9 _register_data_notify: fn (*const Ip6ConfigProtocol, Ip6ConfigDataType, Event) callconv(.C) Status,
10 _unregister_data_notify: extern fn (*const Ip6ConfigProtocol, Ip6ConfigDataType, Event) Status,10 _unregister_data_notify: fn (*const Ip6ConfigProtocol, Ip6ConfigDataType, Event) callconv(.C) Status,
1111
12 pub fn setData(self: *const Ip6ConfigProtocol, data_type: Ip6ConfigDataType, data_size: usize, data: *const c_void) Status {12 pub fn setData(self: *const Ip6ConfigProtocol, data_type: Ip6ConfigDataType, data_size: usize, data: *const c_void) Status {
13 return self._set_data(self, data_type, data_size, data);13 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;...@@ -7,15 +7,15 @@ const ManagedNetworkConfigData = uefi.protocols.ManagedNetworkConfigData;
7const SimpleNetworkMode = uefi.protocols.SimpleNetworkMode;7const SimpleNetworkMode = uefi.protocols.SimpleNetworkMode;
88
9pub const Ip6Protocol = extern struct {9pub const Ip6Protocol = extern struct {
10 _get_mode_data: extern fn (*const Ip6Protocol, ?*Ip6ModeData, ?*ManagedNetworkConfigData, ?*SimpleNetworkMode) Status,10 _get_mode_data: fn (*const Ip6Protocol, ?*Ip6ModeData, ?*ManagedNetworkConfigData, ?*SimpleNetworkMode) callconv(.C) Status,
11 _configure: extern fn (*const Ip6Protocol, ?*const Ip6ConfigData) Status,11 _configure: fn (*const Ip6Protocol, ?*const Ip6ConfigData) callconv(.C) Status,
12 _groups: extern fn (*const Ip6Protocol, bool, ?*const Ip6Address) Status,12 _groups: fn (*const Ip6Protocol, bool, ?*const Ip6Address) callconv(.C) Status,
13 _routes: extern fn (*const Ip6Protocol, bool, ?*const Ip6Address, u8, ?*const Ip6Address) Status,13 _routes: fn (*const Ip6Protocol, bool, ?*const Ip6Address, u8, ?*const Ip6Address) callconv(.C) Status,
14 _neighbors: extern fn (*const Ip6Protocol, bool, *const Ip6Address, ?*const MacAddress, u32, bool) Status,14 _neighbors: fn (*const Ip6Protocol, bool, *const Ip6Address, ?*const MacAddress, u32, bool) callconv(.C) Status,
15 _transmit: extern fn (*const Ip6Protocol, *Ip6CompletionToken) Status,15 _transmit: fn (*const Ip6Protocol, *Ip6CompletionToken) callconv(.C) Status,
16 _receive: extern fn (*const Ip6Protocol, *Ip6CompletionToken) Status,16 _receive: fn (*const Ip6Protocol, *Ip6CompletionToken) callconv(.C) Status,
17 _cancel: extern fn (*const Ip6Protocol, ?*Ip6CompletionToken) Status,17 _cancel: fn (*const Ip6Protocol, ?*Ip6CompletionToken) callconv(.C) Status,
18 _poll: extern fn (*const Ip6Protocol) Status,18 _poll: fn (*const Ip6Protocol) callconv(.C) Status,
1919
20 /// Gets the current operational settings for this instance of the EFI IPv6 Protocol driver.20 /// Gets the current operational settings for this instance of the EFI IPv6 Protocol driver.
21 pub fn getModeData(self: *const Ip6Protocol, ip6_mode_data: ?*Ip6ModeData, mnp_config_data: ?*ManagedNetworkConfigData, snp_mode_data: ?*SimpleNetworkMode) Status {21 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;...@@ -4,8 +4,8 @@ const Guid = uefi.Guid;
4const Status = uefi.Status;4const Status = uefi.Status;
55
6pub const Ip6ServiceBindingProtocol = extern struct {6pub const Ip6ServiceBindingProtocol = extern struct {
7 _create_child: extern fn (*const Ip6ServiceBindingProtocol, *?Handle) Status,7 _create_child: fn (*const Ip6ServiceBindingProtocol, *?Handle) callconv(.C) Status,
8 _destroy_child: extern fn (*const Ip6ServiceBindingProtocol, Handle) Status,8 _destroy_child: fn (*const Ip6ServiceBindingProtocol, Handle) callconv(.C) Status,
99
10 pub fn createChild(self: *const Ip6ServiceBindingProtocol, handle: *?Handle) Status {10 pub fn createChild(self: *const Ip6ServiceBindingProtocol, handle: *?Handle) Status {
11 return self._create_child(self, handle);11 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 {...@@ -19,7 +19,7 @@ pub const LoadedImageProtocol = extern struct {
19 image_size: u64,19 image_size: u64,
20 image_code_type: MemoryType,20 image_code_type: MemoryType,
21 image_data_type: MemoryType,21 image_data_type: MemoryType,
22 _unload: extern fn (*const LoadedImageProtocol, Handle) Status,22 _unload: fn (*const LoadedImageProtocol, Handle) callconv(.C) Status,
2323
24 /// Unloads an image from memory.24 /// Unloads an image from memory.
25 pub fn unload(self: *const LoadedImageProtocol, handle: Handle) Status {25 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;...@@ -7,14 +7,14 @@ const SimpleNetworkMode = uefi.protocols.SimpleNetworkMode;
7const MacAddress = uefi.protocols.MacAddress;7const MacAddress = uefi.protocols.MacAddress;
88
9pub const ManagedNetworkProtocol = extern struct {9pub const ManagedNetworkProtocol = extern struct {
10 _get_mode_data: extern fn (*const ManagedNetworkProtocol, ?*ManagedNetworkConfigData, ?*SimpleNetworkMode) Status,10 _get_mode_data: fn (*const ManagedNetworkProtocol, ?*ManagedNetworkConfigData, ?*SimpleNetworkMode) callconv(.C) Status,
11 _configure: extern fn (*const ManagedNetworkProtocol, ?*const ManagedNetworkConfigData) Status,11 _configure: fn (*const ManagedNetworkProtocol, ?*const ManagedNetworkConfigData) callconv(.C) Status,
12 _mcast_ip_to_mac: extern fn (*const ManagedNetworkProtocol, bool, *const c_void, *MacAddress) Status,12 _mcast_ip_to_mac: fn (*const ManagedNetworkProtocol, bool, *const c_void, *MacAddress) callconv(.C) Status,
13 _groups: extern fn (*const ManagedNetworkProtocol, bool, ?*const MacAddress) Status,13 _groups: fn (*const ManagedNetworkProtocol, bool, ?*const MacAddress) callconv(.C) Status,
14 _transmit: extern fn (*const ManagedNetworkProtocol, *const ManagedNetworkCompletionToken) Status,14 _transmit: fn (*const ManagedNetworkProtocol, *const ManagedNetworkCompletionToken) callconv(.C) Status,
15 _receive: extern fn (*const ManagedNetworkProtocol, *const ManagedNetworkCompletionToken) Status,15 _receive: fn (*const ManagedNetworkProtocol, *const ManagedNetworkCompletionToken) callconv(.C) Status,
16 _cancel: extern fn (*const ManagedNetworkProtocol, ?*const ManagedNetworkCompletionToken) Status,16 _cancel: fn (*const ManagedNetworkProtocol, ?*const ManagedNetworkCompletionToken) callconv(.C) Status,
17 _poll: extern fn (*const ManagedNetworkProtocol) usize,17 _poll: fn (*const ManagedNetworkProtocol) callconv(.C) usize,
1818
19 /// Returns the operational parameters for the current MNP child driver.19 /// Returns the operational parameters for the current MNP child driver.
20 /// May also support returning the underlying SNP driver mode data.20 /// 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;...@@ -4,8 +4,8 @@ const Guid = uefi.Guid;
4const Status = uefi.Status;4const Status = uefi.Status;
55
6pub const ManagedNetworkServiceBindingProtocol = extern struct {6pub const ManagedNetworkServiceBindingProtocol = extern struct {
7 _create_child: extern fn (*const ManagedNetworkServiceBindingProtocol, *?Handle) Status,7 _create_child: fn (*const ManagedNetworkServiceBindingProtocol, *?Handle) callconv(.C) Status,
8 _destroy_child: extern fn (*const ManagedNetworkServiceBindingProtocol, Handle) Status,8 _destroy_child: fn (*const ManagedNetworkServiceBindingProtocol, Handle) callconv(.C) Status,
99
10 pub fn createChild(self: *const ManagedNetworkServiceBindingProtocol, handle: *?Handle) Status {10 pub fn createChild(self: *const ManagedNetworkServiceBindingProtocol, handle: *?Handle) Status {
11 return self._create_child(self, handle);11 return self._create_child(self, handle);
lib/std/os/uefi/protocols/rng_protocol.zig+2-2
...@@ -4,8 +4,8 @@ const Status = uefi.Status;...@@ -4,8 +4,8 @@ const Status = uefi.Status;
44
5/// Random Number Generator protocol5/// Random Number Generator protocol
6pub const RNGProtocol = extern struct {6pub const RNGProtocol = extern struct {
7 _get_info: extern fn (*const RNGProtocol, *usize, [*]align(8) Guid) Status,7 _get_info: fn (*const RNGProtocol, *usize, [*]align(8) Guid) callconv(.C) Status,
8 _get_rng: extern fn (*const RNGProtocol, ?*align(8) const Guid, usize, [*]u8) Status,8 _get_rng: fn (*const RNGProtocol, ?*align(8) const Guid, usize, [*]u8) callconv(.C) Status,
99
10 /// Returns information about the random number generation implementation.10 /// Returns information about the random number generation implementation.
11 pub fn getInfo(self: *const RNGProtocol, list_size: *usize, list: [*]align(8) Guid) Status {11 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;...@@ -5,7 +5,7 @@ const Status = uefi.Status;
55
6pub const SimpleFileSystemProtocol = extern struct {6pub const SimpleFileSystemProtocol = extern struct {
7 revision: u64,7 revision: u64,
8 _open_volume: extern fn (*const SimpleFileSystemProtocol, **const FileProtocol) Status,8 _open_volume: fn (*const SimpleFileSystemProtocol, **const FileProtocol) callconv(.C) Status,
99
10 pub fn openVolume(self: *const SimpleFileSystemProtocol, root: **const FileProtocol) Status {10 pub fn openVolume(self: *const SimpleFileSystemProtocol, root: **const FileProtocol) Status {
11 return self._open_volume(self, root);11 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;...@@ -5,19 +5,19 @@ const Status = uefi.Status;
55
6pub const SimpleNetworkProtocol = extern struct {6pub const SimpleNetworkProtocol = extern struct {
7 revision: u64,7 revision: u64,
8 _start: extern fn (*const SimpleNetworkProtocol) Status,8 _start: fn (*const SimpleNetworkProtocol) callconv(.C) Status,
9 _stop: extern fn (*const SimpleNetworkProtocol) Status,9 _stop: fn (*const SimpleNetworkProtocol) callconv(.C) Status,
10 _initialize: extern fn (*const SimpleNetworkProtocol, usize, usize) Status,10 _initialize: fn (*const SimpleNetworkProtocol, usize, usize) callconv(.C) Status,
11 _reset: extern fn (*const SimpleNetworkProtocol, bool) Status,11 _reset: fn (*const SimpleNetworkProtocol, bool) callconv(.C) Status,
12 _shutdown: extern fn (*const SimpleNetworkProtocol) Status,12 _shutdown: fn (*const SimpleNetworkProtocol) callconv(.C) Status,
13 _receive_filters: extern fn (*const SimpleNetworkProtocol, SimpleNetworkReceiveFilter, SimpleNetworkReceiveFilter, bool, usize, ?[*]const MacAddress) Status,13 _receive_filters: fn (*const SimpleNetworkProtocol, SimpleNetworkReceiveFilter, SimpleNetworkReceiveFilter, bool, usize, ?[*]const MacAddress) callconv(.C) Status,
14 _station_address: extern fn (*const SimpleNetworkProtocol, bool, ?*const MacAddress) Status,14 _station_address: fn (*const SimpleNetworkProtocol, bool, ?*const MacAddress) callconv(.C) Status,
15 _statistics: extern fn (*const SimpleNetworkProtocol, bool, ?*usize, ?*NetworkStatistics) Status,15 _statistics: fn (*const SimpleNetworkProtocol, bool, ?*usize, ?*NetworkStatistics) callconv(.C) Status,
16 _mcast_ip_to_mac: extern fn (*const SimpleNetworkProtocol, bool, *const c_void, *MacAddress) Status,16 _mcast_ip_to_mac: fn (*const SimpleNetworkProtocol, bool, *const c_void, *MacAddress) callconv(.C) Status,
17 _nvdata: extern fn (*const SimpleNetworkProtocol, bool, usize, usize, [*]u8) Status,17 _nvdata: fn (*const SimpleNetworkProtocol, bool, usize, usize, [*]u8) callconv(.C) Status,
18 _get_status: extern fn (*const SimpleNetworkProtocol, *SimpleNetworkInterruptStatus, ?*?[*]u8) Status,18 _get_status: fn (*const SimpleNetworkProtocol, *SimpleNetworkInterruptStatus, ?*?[*]u8) callconv(.C) Status,
19 _transmit: extern fn (*const SimpleNetworkProtocol, usize, usize, [*]const u8, ?*const MacAddress, ?*const MacAddress, ?*const u16) Status,19 _transmit: fn (*const SimpleNetworkProtocol, usize, usize, [*]const u8, ?*const MacAddress, ?*const MacAddress, ?*const u16) callconv(.C) Status,
20 _receive: extern fn (*const SimpleNetworkProtocol, ?*usize, *usize, [*]u8, ?*MacAddress, ?*MacAddress, ?*u16) Status,20 _receive: fn (*const SimpleNetworkProtocol, ?*usize, *usize, [*]u8, ?*MacAddress, ?*MacAddress, ?*u16) callconv(.C) Status,
21 wait_for_packet: Event,21 wait_for_packet: Event,
22 mode: *SimpleNetworkMode,22 mode: *SimpleNetworkMode,
2323
lib/std/os/uefi/protocols/simple_pointer_protocol.zig+2-2
...@@ -5,8 +5,8 @@ const Status = uefi.Status;...@@ -5,8 +5,8 @@ const Status = uefi.Status;
55
6/// Protocol for mice6/// Protocol for mice
7pub const SimplePointerProtocol = struct {7pub const SimplePointerProtocol = struct {
8 _reset: extern fn (*const SimplePointerProtocol, bool) Status,8 _reset: fn (*const SimplePointerProtocol, bool) callconv(.C) Status,
9 _get_state: extern fn (*const SimplePointerProtocol, *SimplePointerState) Status,9 _get_state: fn (*const SimplePointerProtocol, *SimplePointerState) callconv(.C) Status,
10 wait_for_input: Event,10 wait_for_input: Event,
11 mode: *SimplePointerMode,11 mode: *SimplePointerMode,
1212
lib/std/os/uefi/protocols/simple_text_input_ex_protocol.zig+6-6
...@@ -5,12 +5,12 @@ const Status = uefi.Status;...@@ -5,12 +5,12 @@ const Status = uefi.Status;
55
6/// Character input devices, e.g. Keyboard6/// Character input devices, e.g. Keyboard
7pub const SimpleTextInputExProtocol = extern struct {7pub const SimpleTextInputExProtocol = extern struct {
8 _reset: extern fn (*const SimpleTextInputExProtocol, bool) Status,8 _reset: fn (*const SimpleTextInputExProtocol, bool) callconv(.C) Status,
9 _read_key_stroke_ex: extern fn (*const SimpleTextInputExProtocol, *KeyData) Status,9 _read_key_stroke_ex: fn (*const SimpleTextInputExProtocol, *KeyData) callconv(.C) Status,
10 wait_for_key_ex: Event,10 wait_for_key_ex: Event,
11 _set_state: extern fn (*const SimpleTextInputExProtocol, *const u8) Status,11 _set_state: fn (*const SimpleTextInputExProtocol, *const u8) callconv(.C) Status,
12 _register_key_notify: extern fn (*const SimpleTextInputExProtocol, *const KeyData, extern fn (*const KeyData) usize, **c_void) 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: extern fn (*const SimpleTextInputExProtocol, *const c_void) Status,13 _unregister_key_notify: fn (*const SimpleTextInputExProtocol, *const c_void) callconv(.C) Status,
1414
15 /// Resets the input device hardware.15 /// Resets the input device hardware.
16 pub fn reset(self: *const SimpleTextInputExProtocol, verify: bool) Status {16 pub fn reset(self: *const SimpleTextInputExProtocol, verify: bool) Status {
...@@ -28,7 +28,7 @@ pub const SimpleTextInputExProtocol = extern struct {...@@ -28,7 +28,7 @@ pub const SimpleTextInputExProtocol = extern struct {
28 }28 }
2929
30 /// Register a notification function for a particular keystroke for the input device.30 /// 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 {
32 return self._register_key_notify(self, key_data, notify, handle);32 return self._register_key_notify(self, key_data, notify, handle);
33 }33 }
3434
lib/std/os/uefi/protocols/simple_text_input_protocol.zig+2-2
...@@ -6,8 +6,8 @@ const Status = uefi.Status;...@@ -6,8 +6,8 @@ const Status = uefi.Status;
66
7/// Character input devices, e.g. Keyboard7/// Character input devices, e.g. Keyboard
8pub const SimpleTextInputProtocol = extern struct {8pub const SimpleTextInputProtocol = extern struct {
9 _reset: extern fn (*const SimpleTextInputProtocol, bool) usize,9 _reset: fn (*const SimpleTextInputProtocol, bool) callconv(.C) usize,
10 _read_key_stroke: extern fn (*const SimpleTextInputProtocol, *InputKey) Status,10 _read_key_stroke: fn (*const SimpleTextInputProtocol, *InputKey) callconv(.C) Status,
11 wait_for_key: Event,11 wait_for_key: Event,
1212
13 /// Resets the input device hardware.13 /// 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;...@@ -4,15 +4,15 @@ const Status = uefi.Status;
44
5/// Character output devices5/// Character output devices
6pub const SimpleTextOutputProtocol = extern struct {6pub const SimpleTextOutputProtocol = extern struct {
7 _reset: extern fn (*const SimpleTextOutputProtocol, bool) Status,7 _reset: fn (*const SimpleTextOutputProtocol, bool) callconv(.C) Status,
8 _output_string: extern fn (*const SimpleTextOutputProtocol, [*:0]const u16) Status,8 _output_string: fn (*const SimpleTextOutputProtocol, [*:0]const u16) callconv(.C) Status,
9 _test_string: extern fn (*const SimpleTextOutputProtocol, [*:0]const u16) Status,9 _test_string: fn (*const SimpleTextOutputProtocol, [*:0]const u16) callconv(.C) Status,
10 _query_mode: extern fn (*const SimpleTextOutputProtocol, usize, *usize, *usize) Status,10 _query_mode: fn (*const SimpleTextOutputProtocol, usize, *usize, *usize) callconv(.C) Status,
11 _set_mode: extern fn (*const SimpleTextOutputProtocol, usize) Status,11 _set_mode: fn (*const SimpleTextOutputProtocol, usize) callconv(.C) Status,
12 _set_attribute: extern fn (*const SimpleTextOutputProtocol, usize) Status,12 _set_attribute: fn (*const SimpleTextOutputProtocol, usize) callconv(.C) Status,
13 _clear_screen: extern fn (*const SimpleTextOutputProtocol) Status,13 _clear_screen: fn (*const SimpleTextOutputProtocol) callconv(.C) Status,
14 _set_cursor_position: extern fn (*const SimpleTextOutputProtocol, usize, usize) Status,14 _set_cursor_position: fn (*const SimpleTextOutputProtocol, usize, usize) callconv(.C) Status,
15 _enable_cursor: extern fn (*const SimpleTextOutputProtocol, bool) Status,15 _enable_cursor: fn (*const SimpleTextOutputProtocol, bool) callconv(.C) Status,
16 mode: *SimpleTextOutputMode,16 mode: *SimpleTextOutputMode,
1717
18 /// Resets the text output device hardware.18 /// 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;...@@ -9,13 +9,13 @@ const ManagedNetworkConfigData = uefi.protocols.ManagedNetworkConfigData;
9const SimpleNetworkMode = uefi.protocols.SimpleNetworkMode;9const SimpleNetworkMode = uefi.protocols.SimpleNetworkMode;
1010
11pub const Udp6Protocol = extern struct {11pub const Udp6Protocol = extern struct {
12 _get_mode_data: extern fn (*const Udp6Protocol, ?*Udp6ConfigData, ?*Ip6ModeData, ?*ManagedNetworkConfigData, ?*SimpleNetworkMode) Status,12 _get_mode_data: fn (*const Udp6Protocol, ?*Udp6ConfigData, ?*Ip6ModeData, ?*ManagedNetworkConfigData, ?*SimpleNetworkMode) callconv(.C) Status,
13 _configure: extern fn (*const Udp6Protocol, ?*const Udp6ConfigData) Status,13 _configure: fn (*const Udp6Protocol, ?*const Udp6ConfigData) callconv(.C) Status,
14 _groups: extern fn (*const Udp6Protocol, bool, ?*const Ip6Address) Status,14 _groups: fn (*const Udp6Protocol, bool, ?*const Ip6Address) callconv(.C) Status,
15 _transmit: extern fn (*const Udp6Protocol, *Udp6CompletionToken) Status,15 _transmit: fn (*const Udp6Protocol, *Udp6CompletionToken) callconv(.C) Status,
16 _receive: extern fn (*const Udp6Protocol, *Udp6CompletionToken) Status,16 _receive: fn (*const Udp6Protocol, *Udp6CompletionToken) callconv(.C) Status,
17 _cancel: extern fn (*const Udp6Protocol, ?*Udp6CompletionToken) Status,17 _cancel: fn (*const Udp6Protocol, ?*Udp6CompletionToken) callconv(.C) Status,
18 _poll: extern fn (*const Udp6Protocol) Status,18 _poll: fn (*const Udp6Protocol) callconv(.C) Status,
1919
20 pub fn getModeData(self: *const Udp6Protocol, udp6_config_data: ?*Udp6ConfigData, ip6_mode_data: ?*Ip6ModeData, mnp_config_data: ?*ManagedNetworkConfigData, snp_mode_data: ?*SimpleNetworkMode) Status {20 pub fn getModeData(self: *const Udp6Protocol, udp6_config_data: ?*Udp6ConfigData, ip6_mode_data: ?*Ip6ModeData, mnp_config_data: ?*ManagedNetworkConfigData, snp_mode_data: ?*SimpleNetworkMode) Status {
21 return self._get_mode_data(self, udp6_config_data, ip6_mode_data, mnp_config_data, snp_mode_data);21 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;...@@ -4,8 +4,8 @@ const Guid = uefi.Guid;
4const Status = uefi.Status;4const Status = uefi.Status;
55
6pub const Udp6ServiceBindingProtocol = extern struct {6pub const Udp6ServiceBindingProtocol = extern struct {
7 _create_child: extern fn (*const Udp6ServiceBindingProtocol, *?Handle) Status,7 _create_child: fn (*const Udp6ServiceBindingProtocol, *?Handle) callconv(.C) Status,
8 _destroy_child: extern fn (*const Udp6ServiceBindingProtocol, Handle) Status,8 _destroy_child: fn (*const Udp6ServiceBindingProtocol, Handle) callconv(.C) Status,
99
10 pub fn createChild(self: *const Udp6ServiceBindingProtocol, handle: *?Handle) Status {10 pub fn createChild(self: *const Udp6ServiceBindingProtocol, handle: *?Handle) Status {
11 return self._create_child(self, handle);11 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 {...@@ -21,117 +21,117 @@ pub const BootServices = extern struct {
21 hdr: TableHeader,21 hdr: TableHeader,
2222
23 /// Raises a task's priority level and returns its previous level.23 /// 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
26 /// Restores a task's priority level to its previous value.26 /// Restores a task's priority level to its previous value.
27 restoreTpl: extern fn (usize) void,27 restoreTpl: fn (usize) callconv(.C) void,
2828
29 /// Allocates memory pages from the system.29 /// 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
32 /// Frees memory pages.32 /// Frees memory pages.
33 freePages: extern fn ([*]align(4096) u8, usize) Status,33 freePages: fn ([*]align(4096) u8, usize) callconv(.C) Status,
3434
35 /// Returns the current memory map.35 /// 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
38 /// Allocates pool memory.38 /// 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
41 /// Returns pool memory to the system.41 /// Returns pool memory to the system.
42 freePool: extern fn ([*]align(8) u8) Status,42 freePool: fn ([*]align(8) u8) callconv(.C) Status,
4343
44 /// Creates an event.44 /// 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
47 /// Sets the type of timer and the trigger time for a timer event.47 /// 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
50 /// Stops execution until an event is signaled.50 /// 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
53 /// Signals an event.53 /// Signals an event.
54 signalEvent: extern fn (Event) Status,54 signalEvent: fn (Event) callconv(.C) Status,
5555
56 /// Closes an event.56 /// Closes an event.
57 closeEvent: extern fn (Event) Status,57 closeEvent: fn (Event) callconv(.C) Status,
5858
59 /// Checks whether an event is in the signaled state.59 /// Checks whether an event is in the signaled state.
60 checkEvent: extern fn (Event) Status,60 checkEvent: fn (Event) callconv(.C) Status,
6161
62 installProtocolInterface: Status, // TODO62 installProtocolInterface: Status, // TODO
63 reinstallProtocolInterface: Status, // TODO63 reinstallProtocolInterface: Status, // TODO
64 uninstallProtocolInterface: Status, // TODO64 uninstallProtocolInterface: Status, // TODO
6565
66 /// Queries a handle to determine if it supports a specified protocol.66 /// 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
69 reserved: *c_void,69 reserved: *c_void,
7070
71 registerProtocolNotify: Status, // TODO71 registerProtocolNotify: Status, // TODO
7272
73 /// Returns an array of handles that support a specified protocol.73 /// 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
76 locateDevicePath: Status, // TODO76 locateDevicePath: Status, // TODO
77 installConfigurationTable: Status, // TODO77 installConfigurationTable: Status, // TODO
7878
79 /// Loads an EFI image into memory.79 /// 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
82 /// Transfers control to a loaded image's entry point.82 /// 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
85 /// Terminates a loaded EFI image and returns control to boot services.85 /// 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
88 /// Unloads an image.88 /// Unloads an image.
89 unloadImage: extern fn (Handle) Status,89 unloadImage: fn (Handle) callconv(.C) Status,
9090
91 /// Terminates all boot services.91 /// Terminates all boot services.
92 exitBootServices: extern fn (Handle, usize) Status,92 exitBootServices: fn (Handle, usize) callconv(.C) Status,
9393
94 /// Returns a monotonically increasing count for the platform.94 /// Returns a monotonically increasing count for the platform.
95 getNextMonotonicCount: extern fn (*u64) Status,95 getNextMonotonicCount: fn (*u64) callconv(.C) Status,
9696
97 /// Induces a fine-grained stall.97 /// Induces a fine-grained stall.
98 stall: extern fn (usize) Status,98 stall: fn (usize) callconv(.C) Status,
9999
100 /// Sets the system's watchdog timer.100 /// 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
103 connectController: Status, // TODO103 connectController: Status, // TODO
104 disconnectController: Status, // TODO104 disconnectController: Status, // TODO
105105
106 /// Queries a handle to determine if it supports a specified protocol.106 /// 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
109 /// Closes a protocol on a handle that was opened using openProtocol().109 /// 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
112 /// Retrieves the list of agents that currently have a protocol interface opened.112 /// 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
115 /// Retrieves the list of protocol interface GUIDs that are installed on a handle in a buffer allocated from pool.115 /// 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
118 /// Returns an array of handles that support the requested protocol in a buffer allocated from pool.118 /// 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
121 /// Returns the first protocol instance that matches the given protocol.121 /// 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
124 installMultipleProtocolInterfaces: Status, // TODO124 installMultipleProtocolInterfaces: Status, // TODO
125 uninstallMultipleProtocolInterfaces: Status, // TODO125 uninstallMultipleProtocolInterfaces: Status, // TODO
126126
127 /// Computes and returns a 32-bit CRC for a data buffer.127 /// 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
130 /// Copies the contents of one buffer to another buffer130 /// 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
133 /// Fills a buffer with a specified value133 /// 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
136 createEventEx: Status, // TODO136 createEventEx: Status, // TODO
137137
lib/std/os/uefi/tables/runtime_services.zig+5-5
...@@ -17,7 +17,7 @@ pub const RuntimeServices = extern struct {...@@ -17,7 +17,7 @@ pub const RuntimeServices = extern struct {
17 hdr: TableHeader,17 hdr: TableHeader,
1818
19 /// Returns the current time and date information, and the time-keeping capabilities of the hardware platform.19 /// 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
22 setTime: Status, // TODO22 setTime: Status, // TODO
23 getWakeupTime: Status, // TODO23 getWakeupTime: Status, // TODO
...@@ -26,18 +26,18 @@ pub const RuntimeServices = extern struct {...@@ -26,18 +26,18 @@ pub const RuntimeServices = extern struct {
26 convertPointer: Status, // TODO26 convertPointer: Status, // TODO
2727
28 /// Returns the value of a variable.28 /// 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
31 /// Enumerates the current variable names.31 /// 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
34 /// Sets the value of a variable.34 /// 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
37 getNextHighMonotonicCount: Status, // TODO37 getNextHighMonotonicCount: Status, // TODO
3838
39 /// Resets the entire platform.39 /// 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
42 updateCapsule: Status, // TODO42 updateCapsule: Status, // TODO
43 queryCapsuleCapabilities: Status, // TODO43 queryCapsuleCapabilities: Status, // TODO
lib/std/os/windows/bits.zig+6-6
...@@ -627,7 +627,7 @@ pub const MEM_RESERVE_PLACEHOLDERS = 0x2;...@@ -627,7 +627,7 @@ pub const MEM_RESERVE_PLACEHOLDERS = 0x2;
627pub const MEM_DECOMMIT = 0x4000;627pub const MEM_DECOMMIT = 0x4000;
628pub const MEM_RELEASE = 0x8000;628pub const MEM_RELEASE = 0x8000;
629629
630pub const PTHREAD_START_ROUTINE = extern fn (LPVOID) DWORD;630pub const PTHREAD_START_ROUTINE = fn (LPVOID) callconv(.C) DWORD;
631pub const LPTHREAD_START_ROUTINE = PTHREAD_START_ROUTINE;631pub const LPTHREAD_START_ROUTINE = PTHREAD_START_ROUTINE;
632632
633pub const WIN32_FIND_DATAW = extern struct {633pub const WIN32_FIND_DATAW = extern struct {
...@@ -784,7 +784,7 @@ pub const IMAGE_TLS_DIRECTORY = extern struct {...@@ -784,7 +784,7 @@ pub const IMAGE_TLS_DIRECTORY = extern struct {
784pub const IMAGE_TLS_DIRECTORY64 = IMAGE_TLS_DIRECTORY;784pub const IMAGE_TLS_DIRECTORY64 = IMAGE_TLS_DIRECTORY;
785pub const IMAGE_TLS_DIRECTORY32 = IMAGE_TLS_DIRECTORY;785pub 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
789pub const PROV_RSA_FULL = 1;789pub const PROV_RSA_FULL = 1;
790790
...@@ -810,7 +810,7 @@ pub const FILE_ACTION_MODIFIED = 0x00000003;...@@ -810,7 +810,7 @@ pub const FILE_ACTION_MODIFIED = 0x00000003;
810pub const FILE_ACTION_RENAMED_OLD_NAME = 0x00000004;810pub const FILE_ACTION_RENAMED_OLD_NAME = 0x00000004;
811pub const FILE_ACTION_RENAMED_NEW_NAME = 0x00000005;811pub 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
815pub const FILE_NOTIFY_CHANGE_CREATION = 64;815pub const FILE_NOTIFY_CHANGE_CREATION = 64;
816pub const FILE_NOTIFY_CHANGE_SIZE = 8;816pub const FILE_NOTIFY_CHANGE_SIZE = 8;
...@@ -863,7 +863,7 @@ pub const RTL_CRITICAL_SECTION = extern struct {...@@ -863,7 +863,7 @@ pub const RTL_CRITICAL_SECTION = extern struct {
863pub const CRITICAL_SECTION = RTL_CRITICAL_SECTION;863pub const CRITICAL_SECTION = RTL_CRITICAL_SECTION;
864pub const INIT_ONCE = RTL_RUN_ONCE;864pub const INIT_ONCE = RTL_RUN_ONCE;
865pub const INIT_ONCE_STATIC_INIT = RTL_RUN_ONCE_INIT;865pub 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
868pub const RTL_RUN_ONCE = extern struct {868pub const RTL_RUN_ONCE = extern struct {
869 Ptr: ?*c_void,869 Ptr: ?*c_void,
...@@ -1418,7 +1418,7 @@ pub const RTL_DRIVE_LETTER_CURDIR = extern struct {...@@ -1418,7 +1418,7 @@ pub const RTL_DRIVE_LETTER_CURDIR = extern struct {
1418 DosPath: UNICODE_STRING,1418 DosPath: UNICODE_STRING,
1419};1419};
14201420
1421pub const PPS_POST_PROCESS_INIT_ROUTINE = ?extern fn () void;1421pub const PPS_POST_PROCESS_INIT_ROUTINE = ?fn () callconv(.C) void;
14221422
1423pub const FILE_BOTH_DIR_INFORMATION = extern struct {1423pub const FILE_BOTH_DIR_INFORMATION = extern struct {
1424 NextEntryOffset: ULONG,1424 NextEntryOffset: ULONG,
...@@ -1438,7 +1438,7 @@ pub const FILE_BOTH_DIR_INFORMATION = extern struct {...@@ -1438,7 +1438,7 @@ pub const FILE_BOTH_DIR_INFORMATION = extern struct {
1438};1438};
1439pub const FILE_BOTH_DIRECTORY_INFORMATION = FILE_BOTH_DIR_INFORMATION;1439pub 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
1443pub const CURDIR = extern struct {1443pub const CURDIR = extern struct {
1444 DosPath: UNICODE_STRING,1444 DosPath: UNICODE_STRING,
lib/std/os/windows/ws2_32.zig+1-1
...@@ -106,7 +106,7 @@ pub const WSAOVERLAPPED = extern struct {...@@ -106,7 +106,7 @@ pub const WSAOVERLAPPED = extern struct {
106 hEvent: ?WSAEVENT,106 hEvent: ?WSAEVENT,
107};107};
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
111pub const ADDRESS_FAMILY = u16;111pub const ADDRESS_FAMILY = u16;
112112
lib/std/special/test_runner.zig+1-1
...@@ -34,7 +34,7 @@ pub fn main() anyerror!void {...@@ -34,7 +34,7 @@ pub fn main() anyerror!void {
34 std.heap.page_allocator.free(async_frame_buffer);34 std.heap.page_allocator.free(async_frame_buffer);
35 async_frame_buffer = try std.heap.page_allocator.alignedAlloc(u8, std.Target.stack_align, size);35 async_frame_buffer = try std.heap.page_allocator.alignedAlloc(u8, std.Target.stack_align, size);
36 }36 }
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);
38 break :blk await @asyncCall(async_frame_buffer, {}, casted_fn);38 break :blk await @asyncCall(async_frame_buffer, {}, casted_fn);
39 },39 },
40 .blocking => {40 .blocking => {
lib/std/start.zig+1-2
...@@ -224,8 +224,7 @@ inline fn initEventLoopAndCallMain() u8 {...@@ -224,8 +224,7 @@ inline fn initEventLoopAndCallMain() u8 {
224 // and we want fewer call frames in stack traces.224 // and we want fewer call frames in stack traces.
225 return @call(.{ .modifier = .always_inline }, callMain, .{});225 return @call(.{ .modifier = .always_inline }, callMain, .{});
226}226}
227227fn callMainAsync(loop: *std.event.Loop) callconv(.Async) u8 {
228async fn callMainAsync(loop: *std.event.Loop) u8 {
229 // This prevents the event loop from terminating at least until main() has returned.228 // This prevents the event loop from terminating at least until main() has returned.
230 loop.beginOneEvent();229 loop.beginOneEvent();
231 defer loop.finishOneEvent();230 defer loop.finishOneEvent();
lib/std/zig/ast.zig+2-2
...@@ -875,12 +875,13 @@ pub const Node = struct {...@@ -875,12 +875,13 @@ pub const Node = struct {
875 return_type: ReturnType,875 return_type: ReturnType,
876 var_args_token: ?TokenIndex,876 var_args_token: ?TokenIndex,
877 extern_export_inline_token: ?TokenIndex,877 extern_export_inline_token: ?TokenIndex,
878 cc_token: ?TokenIndex,
879 body_node: ?*Node,878 body_node: ?*Node,
880 lib_name: ?*Node, // populated if this is an extern declaration879 lib_name: ?*Node, // populated if this is an extern declaration
881 align_expr: ?*Node, // populated if align(A) is present880 align_expr: ?*Node, // populated if align(A) is present
882 section_expr: ?*Node, // populated if linksection(A) is present881 section_expr: ?*Node, // populated if linksection(A) is present
883 callconv_expr: ?*Node, // populated if callconv(A) is present882 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
885 pub const ParamList = SegmentedList(*Node, 2);886 pub const ParamList = SegmentedList(*Node, 2);
886887
...@@ -929,7 +930,6 @@ pub const Node = struct {...@@ -929,7 +930,6 @@ pub const Node = struct {
929 if (self.visib_token) |visib_token| return visib_token;930 if (self.visib_token) |visib_token| return visib_token;
930 if (self.extern_export_inline_token) |extern_export_inline_token| return extern_export_inline_token;931 if (self.extern_export_inline_token) |extern_export_inline_token| return extern_export_inline_token;
931 assert(self.lib_name == null);932 assert(self.lib_name == null);
932 if (self.cc_token) |cc_token| return cc_token;
933 return self.fn_token;933 return self.fn_token;
934 }934 }
935935
lib/std/zig/parse.zig+20-39
...@@ -335,20 +335,25 @@ fn parseTopLevelDecl(arena: *Allocator, it: *TokenIterator, tree: *Tree) !?*Node...@@ -335,20 +335,25 @@ fn parseTopLevelDecl(arena: *Allocator, it: *TokenIterator, tree: *Tree) !?*Node
335 return use_node;335 return use_node;
336}336}
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)
339fn parseFnProto(arena: *Allocator, it: *TokenIterator, tree: *Tree) !?*Node {339fn parseFnProto(arena: *Allocator, it: *TokenIterator, tree: *Tree) !?*Node {
340 const cc = parseFnCC(arena, it, tree);340 // TODO: Remove once extern/async fn rewriting is
341 const fn_token = eatToken(it, .Keyword_fn) orelse {341 var is_async = false;
342 if (cc) |fnCC| {342 var is_extern = false;
343 if (fnCC == .Extern) {343 const cc_token: ?usize = blk: {
344 putBackToken(it, fnCC.Extern); // 'extern' is also used in ContainerDecl344 if (eatToken(it, .Keyword_extern)) |token| {
345 } else {345 is_extern = true;
346 try tree.errors.push(.{346 break :blk token;
347 .ExpectedToken = .{ .token = it.index, .expected_id = .Keyword_fn },347 }
348 });348 if (eatToken(it, .Keyword_async)) |token| {
349 return error.ParseError;349 is_async = true;
350 }350 break :blk token;
351 }351 }
352 break :blk null;
353 };
354 const fn_token = eatToken(it, .Keyword_fn) orelse {
355 if (cc_token) |token|
356 putBackToken(it, token);
352 return null;357 return null;
353 };358 };
354 const name_token = eatToken(it, .Identifier);359 const name_token = eatToken(it, .Identifier);
...@@ -389,21 +394,15 @@ fn parseFnProto(arena: *Allocator, it: *TokenIterator, tree: *Tree) !?*Node {...@@ -389,21 +394,15 @@ fn parseFnProto(arena: *Allocator, it: *TokenIterator, tree: *Tree) !?*Node {
389 .return_type = return_type,394 .return_type = return_type,
390 .var_args_token = var_args_token,395 .var_args_token = var_args_token,
391 .extern_export_inline_token = null,396 .extern_export_inline_token = null,
392 .cc_token = null,
393 .body_node = null,397 .body_node = null,
394 .lib_name = null,398 .lib_name = null,
395 .align_expr = align_expr,399 .align_expr = align_expr,
396 .section_expr = section_expr,400 .section_expr = section_expr,
397 .callconv_expr = callconv_expr,401 .callconv_expr = callconv_expr,
402 .is_extern_prototype = is_extern,
403 .is_async = is_async,
398 };404 };
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
407 return &fn_proto_node.base;406 return &fn_proto_node.base;
408}407}
409408
...@@ -1197,6 +1196,7 @@ fn parseSuffixExpr(arena: *Allocator, it: *TokenIterator, tree: *Tree) !?*Node {...@@ -1197,6 +1196,7 @@ fn parseSuffixExpr(arena: *Allocator, it: *TokenIterator, tree: *Tree) !?*Node {
1197 if (maybe_async) |async_token| {1196 if (maybe_async) |async_token| {
1198 const token_fn = eatToken(it, .Keyword_fn);1197 const token_fn = eatToken(it, .Keyword_fn);
1199 if (token_fn != null) {1198 if (token_fn != null) {
1199 // TODO: remove this hack when async fn rewriting is
1200 // HACK: If we see the keyword `fn`, then we assume that1200 // HACK: If we see the keyword `fn`, then we assume that
1201 // we are parsing an async fn proto, and not a call.1201 // we are parsing an async fn proto, and not a call.
1202 // We therefore put back all tokens consumed by the async1202 // We therefore put back all tokens consumed by the async
...@@ -1205,7 +1205,6 @@ fn parseSuffixExpr(arena: *Allocator, it: *TokenIterator, tree: *Tree) !?*Node {...@@ -1205,7 +1205,6 @@ fn parseSuffixExpr(arena: *Allocator, it: *TokenIterator, tree: *Tree) !?*Node {
1205 putBackToken(it, async_token);1205 putBackToken(it, async_token);
1206 return parsePrimaryTypeExpr(arena, it, tree);1206 return parsePrimaryTypeExpr(arena, it, tree);
1207 }1207 }
1208 // TODO: Implement hack for parsing `async fn ...` in ast_parse_suffix_expr
1209 var res = try expectNode(arena, it, tree, parsePrimaryTypeExpr, .{1208 var res = try expectNode(arena, it, tree, parsePrimaryTypeExpr, .{
1210 .ExpectedPrimaryTypeExpr = .{ .token = it.index },1209 .ExpectedPrimaryTypeExpr = .{ .token = it.index },
1211 });1210 });
...@@ -1778,24 +1777,6 @@ fn parseCallconv(arena: *Allocator, it: *TokenIterator, tree: *Tree) !?*Node {...@@ -1778,24 +1777,6 @@ fn parseCallconv(arena: *Allocator, it: *TokenIterator, tree: *Tree) !?*Node {
1778 return expr_node;1777 return expr_node;
1779}1778}
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
1799/// ParamDecl <- (KEYWORD_noalias / KEYWORD_comptime)? (IDENTIFIER COLON)? ParamType1780/// ParamDecl <- (KEYWORD_noalias / KEYWORD_comptime)? (IDENTIFIER COLON)? ParamType
1800fn parseParamDecl(arena: *Allocator, it: *TokenIterator, tree: *Tree) !?*Node {1781fn parseParamDecl(arena: *Allocator, it: *TokenIterator, tree: *Tree) !?*Node {
1801 const doc_comments = try parseDocComment(arena, it, tree);1782 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" {...@@ -123,22 +123,6 @@ test "zig fmt: trailing comma in fn parameter list" {
123 );123 );
124}124}
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
142test "zig fmt: comptime struct field" {126test "zig fmt: comptime struct field" {
143 try testCanonical(127 try testCanonical(
144 \\const Foo = struct {128 \\const Foo = struct {
...@@ -252,10 +236,10 @@ test "zig fmt: anon list literal syntax" {...@@ -252,10 +236,10 @@ test "zig fmt: anon list literal syntax" {
252test "zig fmt: async function" {236test "zig fmt: async function" {
253 try testCanonical(237 try testCanonical(
254 \\pub const Server = struct {238 \\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,
256 \\};240 \\};
257 \\test "hi" {241 \\test "hi" {
258 \\ var ptr = @ptrCast(async fn (i32) void, other);242 \\ var ptr = @ptrCast(fn (i32) callconv(.Async) void, other);
259 \\}243 \\}
260 \\244 \\
261 );245 );
...@@ -451,15 +435,6 @@ test "zig fmt: aligned struct field" {...@@ -451,15 +435,6 @@ test "zig fmt: aligned struct field" {
451 );435 );
452}436}
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
463test "zig fmt: comment to disable/enable zig fmt first" {438test "zig fmt: comment to disable/enable zig fmt first" {
464 try testCanonical(439 try testCanonical(
465 \\// Test trailing comma syntax440 \\// Test trailing comma syntax
...@@ -1515,7 +1490,7 @@ test "zig fmt: line comments in struct initializer" {...@@ -1515,7 +1490,7 @@ test "zig fmt: line comments in struct initializer" {
15151490
1516test "zig fmt: first line comment in struct initializer" {1491test "zig fmt: first line comment in struct initializer" {
1517 try testCanonical(1492 try testCanonical(
1518 \\pub async fn acquire(self: *Self) HeldLock {1493 \\pub fn acquire(self: *Self) HeldLock {
1519 \\ return HeldLock{1494 \\ return HeldLock{
1520 \\ // guaranteed allocation elision1495 \\ // guaranteed allocation elision
1521 \\ .held = self.lock.acquire(),1496 \\ .held = self.lock.acquire(),
...@@ -2477,8 +2452,7 @@ test "zig fmt: fn type" {...@@ -2477,8 +2452,7 @@ test "zig fmt: fn type" {
2477 \\}2452 \\}
2478 \\2453 \\
2479 \\const a: fn (u8) u8 = undefined;2454 \\const a: fn (u8) u8 = undefined;
2480 \\const b: extern fn (u8) u8 = undefined;2455 \\const b: fn (u8) callconv(.Naked) u8 = undefined;
2481 \\const c: fn (u8) callconv(.Naked) u8 = undefined;
2482 \\const ap: fn (u8) u8 = a;2456 \\const ap: fn (u8) u8 = a;
2483 \\2457 \\
2484 );2458 );
...@@ -2500,7 +2474,7 @@ test "zig fmt: inline asm" {...@@ -2500,7 +2474,7 @@ test "zig fmt: inline asm" {
25002474
2501test "zig fmt: async functions" {2475test "zig fmt: async functions" {
2502 try testCanonical(2476 try testCanonical(
2503 \\async fn simpleAsyncFn() void {2477 \\fn simpleAsyncFn() void {
2504 \\ const a = async a.b();2478 \\ const a = async a.b();
2505 \\ x += 1;2479 \\ x += 1;
2506 \\ suspend;2480 \\ suspend;
...@@ -2940,6 +2914,26 @@ test "zig fmt: noasync to nosuspend" {...@@ -2940,6 +2914,26 @@ test "zig fmt: noasync to nosuspend" {
2940 );2914 );
2941}2915}
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
2943const std = @import("std");2937const std = @import("std");
2944const mem = std.mem;2938const mem = std.mem;
2945const warn = std.debug.warn;2939const warn = std.debug.warn;
...@@ -2986,7 +2980,6 @@ fn testParse(source: []const u8, allocator: *mem.Allocator, anything_changed: *b...@@ -2986,7 +2980,6 @@ fn testParse(source: []const u8, allocator: *mem.Allocator, anything_changed: *b
2986 anything_changed.* = try std.zig.render(allocator, buffer.outStream(), tree);2980 anything_changed.* = try std.zig.render(allocator, buffer.outStream(), tree);
2987 return buffer.toOwnedSlice();2981 return buffer.toOwnedSlice();
2988}2982}
2989
2990fn testTransform(source: []const u8, expected_source: []const u8) !void {2983fn testTransform(source: []const u8, expected_source: []const u8) !void {
2991 const needed_alloc_count = x: {2984 const needed_alloc_count = x: {
2992 // Try it once with unlimited memory, make sure it works2985 // Try it once with unlimited memory, make sure it works
...@@ -3034,11 +3027,9 @@ fn testTransform(source: []const u8, expected_source: []const u8) !void {...@@ -3034,11 +3027,9 @@ fn testTransform(source: []const u8, expected_source: []const u8) !void {
3034 }3027 }
3035 }3028 }
3036}3029}
3037
3038fn testCanonical(source: []const u8) !void {3030fn testCanonical(source: []const u8) !void {
3039 return testTransform(source, source);3031 return testTransform(source, source);
3040}3032}
3041
3042fn testError(source: []const u8) !void {3033fn testError(source: []const u8) !void {
3043 const tree = try std.zig.parse(std.testing.allocator, source);3034 const tree = try std.zig.parse(std.testing.allocator, source);
3044 defer tree.deinit();3035 defer tree.deinit();
lib/std/zig/render.zig+6-23
...@@ -1413,32 +1413,15 @@ fn renderExpression(...@@ -1413,32 +1413,15 @@ fn renderExpression(
1413 try renderToken(tree, stream, visib_token_index, indent, start_col, Space.Space); // pub1413 try renderToken(tree, stream, visib_token_index, indent, start_col, Space.Space); // pub
1414 }1414 }
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;
1419 if (fn_proto.extern_export_inline_token) |extern_export_inline_token| {1416 if (fn_proto.extern_export_inline_token) |extern_export_inline_token| {
1420 const tok = tree.tokens.at(extern_export_inline_token);1417 if (!fn_proto.is_extern_prototype)
1421 if (tok.id != .Keyword_extern or fn_proto.body_node == null) {1418 try renderToken(tree, stream, extern_export_inline_token, indent, start_col, Space.Space); // extern/export/inline
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 }
1427 }1419 }
14281420
1429 if (fn_proto.lib_name) |lib_name| {1421 if (fn_proto.lib_name) |lib_name| {
1430 try renderExpression(allocator, stream, tree, indent, start_col, lib_name, Space.Space);1422 try renderExpression(allocator, stream, tree, indent, start_col, lib_name, Space.Space);
1431 }1423 }
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
1442 const lparen = if (fn_proto.name_token) |name_token| blk: {1425 const lparen = if (fn_proto.name_token) |name_token| blk: {
1443 try renderToken(tree, stream, fn_proto.fn_token, indent, start_col, Space.Space); // fn1426 try renderToken(tree, stream, fn_proto.fn_token, indent, start_col, Space.Space); // fn
1444 try renderToken(tree, stream, name_token, indent, start_col, Space.None); // name1427 try renderToken(tree, stream, name_token, indent, start_col, Space.None); // name
...@@ -1528,10 +1511,10 @@ fn renderExpression(...@@ -1528,10 +1511,10 @@ fn renderExpression(
1528 try renderToken(tree, stream, callconv_lparen, indent, start_col, Space.None); // (1511 try renderToken(tree, stream, callconv_lparen, indent, start_col, Space.None); // (
1529 try renderExpression(allocator, stream, tree, indent, start_col, callconv_expr, Space.None);1512 try renderExpression(allocator, stream, tree, indent, start_col, callconv_expr, Space.None);
1530 try renderToken(tree, stream, callconv_rparen, indent, start_col, Space.Space); // )1513 try renderToken(tree, stream, callconv_rparen, indent, start_col, Space.Space); // )
1531 } else if (cc_rewrite_str) |str| {1514 } else if (fn_proto.is_extern_prototype) {
1532 try stream.writeAll("callconv(");1515 try stream.writeAll("callconv(.C) ");
1533 try stream.writeAll(mem.spanZ(str));1516 } else if (fn_proto.is_async) {
1534 try stream.writeAll(") ");1517 try stream.writeAll("callconv(.Async) ");
1535 }1518 }
15361519
1537 switch (fn_proto.return_type) {1520 switch (fn_proto.return_type) {
lib/std/zig/tokenizer.zig-6
...@@ -47,7 +47,6 @@ pub const Token = struct {...@@ -47,7 +47,6 @@ pub const Token = struct {
47 Keyword.init("for", .Keyword_for),47 Keyword.init("for", .Keyword_for),
48 Keyword.init("if", .Keyword_if),48 Keyword.init("if", .Keyword_if),
49 Keyword.init("inline", .Keyword_inline),49 Keyword.init("inline", .Keyword_inline),
50 Keyword.init("nakedcc", .Keyword_nakedcc),
51 Keyword.init("noalias", .Keyword_noalias),50 Keyword.init("noalias", .Keyword_noalias),
52 Keyword.init("noasync", .Keyword_nosuspend), // TODO: remove this51 Keyword.init("noasync", .Keyword_nosuspend), // TODO: remove this
53 Keyword.init("noinline", .Keyword_noinline),52 Keyword.init("noinline", .Keyword_noinline),
...@@ -60,7 +59,6 @@ pub const Token = struct {...@@ -60,7 +59,6 @@ pub const Token = struct {
60 Keyword.init("resume", .Keyword_resume),59 Keyword.init("resume", .Keyword_resume),
61 Keyword.init("return", .Keyword_return),60 Keyword.init("return", .Keyword_return),
62 Keyword.init("linksection", .Keyword_linksection),61 Keyword.init("linksection", .Keyword_linksection),
63 Keyword.init("stdcallcc", .Keyword_stdcallcc),
64 Keyword.init("struct", .Keyword_struct),62 Keyword.init("struct", .Keyword_struct),
65 Keyword.init("suspend", .Keyword_suspend),63 Keyword.init("suspend", .Keyword_suspend),
66 Keyword.init("switch", .Keyword_switch),64 Keyword.init("switch", .Keyword_switch),
...@@ -181,7 +179,6 @@ pub const Token = struct {...@@ -181,7 +179,6 @@ pub const Token = struct {
181 Keyword_for,179 Keyword_for,
182 Keyword_if,180 Keyword_if,
183 Keyword_inline,181 Keyword_inline,
184 Keyword_nakedcc,
185 Keyword_noalias,182 Keyword_noalias,
186 Keyword_noinline,183 Keyword_noinline,
187 Keyword_nosuspend,184 Keyword_nosuspend,
...@@ -194,7 +191,6 @@ pub const Token = struct {...@@ -194,7 +191,6 @@ pub const Token = struct {
194 Keyword_resume,191 Keyword_resume,
195 Keyword_return,192 Keyword_return,
196 Keyword_linksection,193 Keyword_linksection,
197 Keyword_stdcallcc,
198 Keyword_struct,194 Keyword_struct,
199 Keyword_suspend,195 Keyword_suspend,
200 Keyword_switch,196 Keyword_switch,
...@@ -306,7 +302,6 @@ pub const Token = struct {...@@ -306,7 +302,6 @@ pub const Token = struct {
306 .Keyword_for => "for",302 .Keyword_for => "for",
307 .Keyword_if => "if",303 .Keyword_if => "if",
308 .Keyword_inline => "inline",304 .Keyword_inline => "inline",
309 .Keyword_nakedcc => "nakedcc",
310 .Keyword_noalias => "noalias",305 .Keyword_noalias => "noalias",
311 .Keyword_noinline => "noinline",306 .Keyword_noinline => "noinline",
312 .Keyword_nosuspend => "nosuspend",307 .Keyword_nosuspend => "nosuspend",
...@@ -318,7 +313,6 @@ pub const Token = struct {...@@ -318,7 +313,6 @@ pub const Token = struct {
318 .Keyword_resume => "resume",313 .Keyword_resume => "resume",
319 .Keyword_return => "return",314 .Keyword_return => "return",
320 .Keyword_linksection => "linksection",315 .Keyword_linksection => "linksection",
321 .Keyword_stdcallcc => "stdcallcc",
322 .Keyword_struct => "struct",316 .Keyword_struct => "struct",
323 .Keyword_suspend => "suspend",317 .Keyword_suspend => "suspend",
324 .Keyword_switch => "switch",318 .Keyword_switch => "switch",
src-self-hosted/clang.zig+1-1
...@@ -781,7 +781,7 @@ pub extern fn ZigClangSourceManager_getCharacterData(self: ?*const struct_ZigCla...@@ -781,7 +781,7 @@ pub extern fn ZigClangSourceManager_getCharacterData(self: ?*const struct_ZigCla
781pub extern fn ZigClangASTContext_getPointerType(self: ?*const struct_ZigClangASTContext, T: struct_ZigClangQualType) struct_ZigClangQualType;781pub extern fn ZigClangASTContext_getPointerType(self: ?*const struct_ZigClangASTContext, T: struct_ZigClangQualType) struct_ZigClangQualType;
782pub extern fn ZigClangASTUnit_getASTContext(self: ?*struct_ZigClangASTUnit) ?*struct_ZigClangASTContext;782pub extern fn ZigClangASTUnit_getASTContext(self: ?*struct_ZigClangASTUnit) ?*struct_ZigClangASTContext;
783pub extern fn ZigClangASTUnit_getSourceManager(self: *struct_ZigClangASTUnit) *struct_ZigClangSourceManager;783pub 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;
785pub extern fn ZigClangRecordType_getDecl(record_ty: ?*const struct_ZigClangRecordType) *const struct_ZigClangRecordDecl;785pub extern fn ZigClangRecordType_getDecl(record_ty: ?*const struct_ZigClangRecordType) *const struct_ZigClangRecordDecl;
786pub extern fn ZigClangTagDecl_isThisDeclarationADefinition(self: *const ZigClangTagDecl) bool;786pub extern fn ZigClangTagDecl_isThisDeclarationADefinition(self: *const ZigClangTagDecl) bool;
787pub extern fn ZigClangEnumType_getDecl(record_ty: ?*const struct_ZigClangEnumType) *const struct_ZigClangEnumDecl;787pub 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 =...@@ -41,7 +41,7 @@ const usage =
4141
42const Command = struct {42const Command = struct {
43 name: []const u8,43 name: []const u8,
44 exec: async fn (*Allocator, []const []const u8) anyerror!void,44 exec: fn (*Allocator, []const []const u8) callconv(.Async) anyerror!void,
45};45};
4646
47pub fn main() !void {47pub fn main() !void {
...@@ -713,8 +713,7 @@ const FmtError = error{...@@ -713,8 +713,7 @@ const FmtError = error{
713 FileBusy,713 FileBusy,
714 CurrentWorkingDirectoryUnlinked,714 CurrentWorkingDirectoryUnlinked,
715} || fs.File.OpenError;715} || fs.File.OpenError;
716716fn fmtPath(fmt: *Fmt, file_path_ref: []const u8, check_mode: bool) callconv(.Async) FmtError!void {
717async fn fmtPath(fmt: *Fmt, file_path_ref: []const u8, check_mode: bool) FmtError!void {
718 const stderr_file = io.getStdErr();717 const stderr_file = io.getStdErr();
719 const stderr = stderr_file.outStream();718 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...@@ -4121,7 +4121,6 @@ fn transCreateNodeMacroFn(c: *Context, name: []const u8, ref: *ast.Node, proto_a
4121 .return_type = proto_alias.return_type,4121 .return_type = proto_alias.return_type,
4122 .var_args_token = null,4122 .var_args_token = null,
4123 .extern_export_inline_token = inline_tok,4123 .extern_export_inline_token = inline_tok,
4124 .cc_token = null,
4125 .body_node = null,4124 .body_node = null,
4126 .lib_name = null,4125 .lib_name = null,
4127 .align_expr = null,4126 .align_expr = null,
...@@ -4780,7 +4779,6 @@ fn finishTransFnProto(...@@ -4780,7 +4779,6 @@ fn finishTransFnProto(
4780 .return_type = .{ .Explicit = return_type_node },4779 .return_type = .{ .Explicit = return_type_node },
4781 .var_args_token = null, // TODO this field is broken in the AST data model4780 .var_args_token = null, // TODO this field is broken in the AST data model
4782 .extern_export_inline_token = extern_export_inline_tok,4781 .extern_export_inline_token = extern_export_inline_tok,
4783 .cc_token = null,
4784 .body_node = null,4782 .body_node = null,
4785 .lib_name = null,4783 .lib_name = null,
4786 .align_expr = align_expr,4784 .align_expr = align_expr,
...@@ -5146,7 +5144,6 @@ fn transMacroFnDefine(c: *Context, it: *CTokenList.Iterator, source: []const u8,...@@ -5146,7 +5144,6 @@ fn transMacroFnDefine(c: *Context, it: *CTokenList.Iterator, source: []const u8,
5146 .return_type = .{ .Explicit = &type_of.base },5144 .return_type = .{ .Explicit = &type_of.base },
5147 .doc_comments = null,5145 .doc_comments = null,
5148 .var_args_token = null,5146 .var_args_token = null,
5149 .cc_token = null,
5150 .body_node = null,5147 .body_node = null,
5151 .lib_name = null,5148 .lib_name = null,
5152 .align_expr = null,5149 .align_expr = null,
src/all_types.hpp-1
...@@ -718,7 +718,6 @@ struct AstNodeFnProto {...@@ -718,7 +718,6 @@ struct AstNodeFnProto {
718 Buf doc_comments;718 Buf doc_comments;
719719
720 FnInline fn_inline;720 FnInline fn_inline;
721 bool is_async;
722721
723 VisibMod visib_mod;722 VisibMod visib_mod;
724 bool auto_err_set;723 bool auto_err_set;
src/analyze.cpp-2
...@@ -1528,8 +1528,6 @@ ZigType *get_generic_fn_type(CodeGen *g, FnTypeId *fn_type_id) {...@@ -1528,8 +1528,6 @@ ZigType *get_generic_fn_type(CodeGen *g, FnTypeId *fn_type_id) {
1528}1528}
15291529
1530CallingConvention cc_from_fn_proto(AstNodeFnProto *fn_proto) {1530CallingConvention cc_from_fn_proto(AstNodeFnProto *fn_proto) {
1531 if (fn_proto->is_async)
1532 return CallingConventionAsync;
1533 // Compatible with the C ABI1531 // Compatible with the C ABI
1534 if (fn_proto->is_extern || fn_proto->is_export)1532 if (fn_proto->is_extern || fn_proto->is_export)
1535 return CallingConventionC;1533 return CallingConventionC;
src/parser.cpp+5-53
...@@ -93,7 +93,6 @@ static AstNode *ast_parse_field_init(ParseContext *pc);...@@ -93,7 +93,6 @@ static AstNode *ast_parse_field_init(ParseContext *pc);
93static AstNode *ast_parse_while_continue_expr(ParseContext *pc);93static AstNode *ast_parse_while_continue_expr(ParseContext *pc);
94static AstNode *ast_parse_link_section(ParseContext *pc);94static AstNode *ast_parse_link_section(ParseContext *pc);
95static AstNode *ast_parse_callconv(ParseContext *pc);95static AstNode *ast_parse_callconv(ParseContext *pc);
96static Optional<AstNodeFnProto> ast_parse_fn_cc(ParseContext *pc);
97static AstNode *ast_parse_param_decl(ParseContext *pc);96static AstNode *ast_parse_param_decl(ParseContext *pc);
98static AstNode *ast_parse_param_type(ParseContext *pc);97static AstNode *ast_parse_param_type(ParseContext *pc);
99static AstNode *ast_parse_if_prefix(ParseContext *pc);98static AstNode *ast_parse_if_prefix(ParseContext *pc);
...@@ -707,7 +706,6 @@ static AstNode *ast_parse_top_level_decl(ParseContext *pc, VisibMod visib_mod, B...@@ -707,7 +706,6 @@ static AstNode *ast_parse_top_level_decl(ParseContext *pc, VisibMod visib_mod, B
707 fn_proto->column = first->start_column;706 fn_proto->column = first->start_column;
708 fn_proto->data.fn_proto.visib_mod = visib_mod;707 fn_proto->data.fn_proto.visib_mod = visib_mod;
709 fn_proto->data.fn_proto.doc_comments = *doc_comments;708 fn_proto->data.fn_proto.doc_comments = *doc_comments;
710 // ast_parse_fn_cc may set it
711 if (!fn_proto->data.fn_proto.is_extern)709 if (!fn_proto->data.fn_proto.is_extern)
712 fn_proto->data.fn_proto.is_extern = first->id == TokenIdKeywordExtern;710 fn_proto->data.fn_proto.is_extern = first->id == TokenIdKeywordExtern;
713 fn_proto->data.fn_proto.is_export = first->id == TokenIdKeywordExport;711 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...@@ -788,29 +786,11 @@ static AstNode *ast_parse_top_level_decl(ParseContext *pc, VisibMod visib_mod, B
788 return nullptr;786 return nullptr;
789}787}
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)
792static AstNode *ast_parse_fn_proto(ParseContext *pc) {790static AstNode *ast_parse_fn_proto(ParseContext *pc) {
793 Token *first = peek_token(pc);791 Token *first = eat_token_if(pc, TokenIdKeywordFn);
794 AstNodeFnProto fn_cc;792 if (first == nullptr) {
795 Token *fn;793 return nullptr;
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;
814 }794 }
815795
816 Token *identifier = eat_token_if(pc, TokenIdSymbol);796 Token *identifier = eat_token_if(pc, TokenIdSymbol);
...@@ -830,7 +810,7 @@ static AstNode *ast_parse_fn_proto(ParseContext *pc) {...@@ -830,7 +810,7 @@ static AstNode *ast_parse_fn_proto(ParseContext *pc) {
830 }810 }
831811
832 AstNode *res = ast_create_node(pc, NodeTypeFnProto, first);812 AstNode *res = ast_create_node(pc, NodeTypeFnProto, first);
833 res->data.fn_proto = fn_cc;813 res->data.fn_proto = {};
834 res->data.fn_proto.name = token_buf(identifier);814 res->data.fn_proto.name = token_buf(identifier);
835 res->data.fn_proto.params = params;815 res->data.fn_proto.params = params;
836 res->data.fn_proto.align_expr = align_expr;816 res->data.fn_proto.align_expr = align_expr;
...@@ -1524,17 +1504,6 @@ static AstNode *ast_parse_error_union_expr(ParseContext *pc) {...@@ -1524,17 +1504,6 @@ static AstNode *ast_parse_error_union_expr(ParseContext *pc) {
1524static AstNode *ast_parse_suffix_expr(ParseContext *pc) {1504static AstNode *ast_parse_suffix_expr(ParseContext *pc) {
1525 Token *async_token = eat_token_if(pc, TokenIdKeywordAsync);1505 Token *async_token = eat_token_if(pc, TokenIdKeywordAsync);
1526 if (async_token) {1506 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
1538 AstNode *child = ast_expect(pc, ast_parse_primary_type_expr);1507 AstNode *child = ast_expect(pc, ast_parse_primary_type_expr);
1539 while (true) {1508 while (true) {
1540 AstNode *suffix = ast_parse_suffix_op(pc);1509 AstNode *suffix = ast_parse_suffix_op(pc);
...@@ -2187,23 +2156,6 @@ static AstNode *ast_parse_callconv(ParseContext *pc) {...@@ -2187,23 +2156,6 @@ static AstNode *ast_parse_callconv(ParseContext *pc) {
2187 return res;2156 return res;
2188}2157}
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
2207// ParamDecl <- (KEYWORD_noalias / KEYWORD_comptime)? (IDENTIFIER COLON)? ParamType2159// ParamDecl <- (KEYWORD_noalias / KEYWORD_comptime)? (IDENTIFIER COLON)? ParamType
2208static AstNode *ast_parse_param_decl(ParseContext *pc) {2160static AstNode *ast_parse_param_decl(ParseContext *pc) {
2209 Buf doc_comments = BUF_INIT;2161 Buf doc_comments = BUF_INIT;
test/compile_errors.zig+11-11
...@@ -802,7 +802,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {...@@ -802,7 +802,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
802 });802 });
803803
804 cases.add("exported async function",804 cases.add("exported async function",
805 \\export async fn foo() void {}805 \\export fn foo() callconv(.Async) void {}
806 , &[_][]const u8{806 , &[_][]const u8{
807 "tmp.zig:1:1: error: exported function cannot be async",807 "tmp.zig:1:1: error: exported function cannot be async",
808 });808 });
...@@ -1281,11 +1281,11 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {...@@ -1281,11 +1281,11 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
12811281
1282 cases.add("bad alignment in @asyncCall",1282 cases.add("bad alignment in @asyncCall",
1283 \\export fn entry() void {1283 \\export fn entry() void {
1284 \\ var ptr: async fn () void = func;1284 \\ var ptr: fn () callconv(.Async) void = func;
1285 \\ var bytes: [64]u8 = undefined;1285 \\ var bytes: [64]u8 = undefined;
1286 \\ _ = @asyncCall(&bytes, {}, ptr);1286 \\ _ = @asyncCall(&bytes, {}, ptr);
1287 \\}1287 \\}
1288 \\async fn func() void {}1288 \\fn func() callconv(.Async) void {}
1289 , &[_][]const u8{1289 , &[_][]const u8{
1290 "tmp.zig:4:21: error: expected type '[]align(16) u8', found '*[64]u8'",1290 "tmp.zig:4:21: error: expected type '[]align(16) u8', found '*[64]u8'",
1291 });1291 });
...@@ -1431,7 +1431,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {...@@ -1431,7 +1431,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
1431 \\export fn entry() void {1431 \\export fn entry() void {
1432 \\ _ = async amain();1432 \\ _ = async amain();
1433 \\}1433 \\}
1434 \\async fn amain() void {1434 \\fn amain() callconv(.Async) void {
1435 \\ other();1435 \\ other();
1436 \\}1436 \\}
1437 \\fn other() void {1437 \\fn other() void {
...@@ -1447,7 +1447,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {...@@ -1447,7 +1447,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
1447 \\export fn entry() void {1447 \\export fn entry() void {
1448 \\ _ = async amain();1448 \\ _ = async amain();
1449 \\}1449 \\}
1450 \\async fn amain() void {1450 \\fn amain() callconv(.Async) void {
1451 \\ var x: [@sizeOf(@Frame(amain))]u8 = undefined;1451 \\ var x: [@sizeOf(@Frame(amain))]u8 = undefined;
1452 \\}1452 \\}
1453 , &[_][]const u8{1453 , &[_][]const u8{
...@@ -1474,7 +1474,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {...@@ -1474,7 +1474,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
1474 \\ var ptr = afunc;1474 \\ var ptr = afunc;
1475 \\ _ = ptr();1475 \\ _ = ptr();
1476 \\}1476 \\}
1477 \\async fn afunc() void {}1477 \\fn afunc() callconv(.Async) void {}
1478 , &[_][]const u8{1478 , &[_][]const u8{
1479 "tmp.zig:6:12: error: function is not comptime-known; @asyncCall required",1479 "tmp.zig:6:12: error: function is not comptime-known; @asyncCall required",
1480 });1480 });
...@@ -1485,7 +1485,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {...@@ -1485,7 +1485,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
1485 \\ _ = async ptr();1485 \\ _ = async ptr();
1486 \\}1486 \\}
1487 \\1487 \\
1488 \\async fn afunc() void { }1488 \\fn afunc() callconv(.Async) void { }
1489 , &[_][]const u8{1489 , &[_][]const u8{
1490 "tmp.zig:3:15: error: function is not comptime-known; @asyncCall required",1490 "tmp.zig:3:15: error: function is not comptime-known; @asyncCall required",
1491 });1491 });
...@@ -3074,7 +3074,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {...@@ -3074,7 +3074,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
3074 \\export fn entry() void {3074 \\export fn entry() void {
3075 \\ _ = async foo();3075 \\ _ = async foo();
3076 \\}3076 \\}
3077 \\async fn foo() void {3077 \\fn foo() void {
3078 \\ suspend {3078 \\ suspend {
3079 \\ suspend {3079 \\ suspend {
3080 \\ }3080 \\ }
...@@ -3122,7 +3122,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {...@@ -3122,7 +3122,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
3122 \\export fn entry() void {3122 \\export fn entry() void {
3123 \\ _ = async amain();3123 \\ _ = async amain();
3124 \\}3124 \\}
3125 \\async fn amain() void {3125 \\fn amain() callconv(.Async) void {
3126 \\ return error.ShouldBeCompileError;3126 \\ return error.ShouldBeCompileError;
3127 \\}3127 \\}
3128 , &[_][]const u8{3128 , &[_][]const u8{
...@@ -3592,7 +3592,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {...@@ -3592,7 +3592,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
3592 });3592 });
35933593
3594 cases.add("attempt to use 0 bit type in extern fn",3594 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;
3596 \\3596 \\
3597 \\export fn entry() void {3597 \\export fn entry() void {
3598 \\ foo(bar);3598 \\ foo(bar);
...@@ -3603,7 +3603,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {...@@ -3603,7 +3603,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
3603 \\ bar(&{});3603 \\ bar(&{});
3604 \\}3604 \\}
3605 , &[_][]const u8{3605 , &[_][]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'",
3607 "tmp.zig:7:11: error: parameter of type '*void' has 0 bits; not allowed in function with calling convention 'C'",3607 "tmp.zig:7:11: error: parameter of type '*void' has 0 bits; not allowed in function with calling convention 'C'",
3608 });3608 });
36093609
test/runtime_safety.zig+4-4
...@@ -282,7 +282,7 @@ pub fn addCases(cases: *tests.CompareOutputContext) void {...@@ -282,7 +282,7 @@ pub fn addCases(cases: *tests.CompareOutputContext) void {
282 \\ var ptr = other;282 \\ var ptr = other;
283 \\ var frame = @asyncCall(&bytes, {}, ptr);283 \\ var frame = @asyncCall(&bytes, {}, ptr);
284 \\}284 \\}
285 \\async fn other() void {285 \\fn other() callconv(.Async) void {
286 \\ suspend;286 \\ suspend;
287 \\}287 \\}
288 );288 );
...@@ -874,16 +874,16 @@ pub fn addCases(cases: *tests.CompareOutputContext) void {...@@ -874,16 +874,16 @@ pub fn addCases(cases: *tests.CompareOutputContext) void {
874 \\ return &failing_frame;874 \\ return &failing_frame;
875 \\}875 \\}
876 \\876 \\
877 \\async fn failing() anyerror!void {877 \\fn failing() anyerror!void {
878 \\ suspend;878 \\ suspend;
879 \\ return second();879 \\ return second();
880 \\}880 \\}
881 \\881 \\
882 \\async fn second() anyerror!void {882 \\fn second() callconv(.Async) anyerror!void {
883 \\ return error.Fail;883 \\ return error.Fail;
884 \\}884 \\}
885 \\885 \\
886 \\async fn printTrace(p: anyframe->anyerror!void) void {886 \\fn printTrace(p: anyframe->anyerror!void) void {
887 \\ (await p) catch unreachable;887 \\ (await p) catch unreachable;
888 \\}888 \\}
889 );889 );
test/stack_traces.zig+1-1
...@@ -282,7 +282,7 @@ pub fn addCases(cases: *tests.StackTracesContext) void {...@@ -282,7 +282,7 @@ pub fn addCases(cases: *tests.StackTracesContext) void {
282 \\source.zig:10:8: [address] in main (test)282 \\source.zig:10:8: [address] in main (test)
283 \\ foo();283 \\ foo();
284 \\ ^284 \\ ^
285 \\start.zig:250:29: [address] in std.start.posixCallMainAndExit (test)285 \\start.zig:249:29: [address] in std.start.posixCallMainAndExit (test)
286 \\ return root.main();286 \\ return root.main();
287 \\ ^287 \\ ^
288 \\start.zig:123:5: [address] in std.start._start (test)288 \\start.zig:123:5: [address] in std.start._start (test)
test/stage1/behavior/async_fn.zig+25-29
...@@ -112,12 +112,12 @@ test "@frameSize" {...@@ -112,12 +112,12 @@ test "@frameSize" {
112 const S = struct {112 const S = struct {
113 fn doTheTest() void {113 fn doTheTest() void {
114 {114 {
115 var ptr = @ptrCast(async fn (i32) void, other);115 var ptr = @ptrCast(fn (i32) callconv(.Async) void, other);
116 const size = @frameSize(ptr);116 const size = @frameSize(ptr);
117 expect(size == @sizeOf(@Frame(other)));117 expect(size == @sizeOf(@Frame(other)));
118 }118 }
119 {119 {
120 var ptr = @ptrCast(async fn () void, first);120 var ptr = @ptrCast(fn () callconv(.Async) void, first);
121 const size = @frameSize(ptr);121 const size = @frameSize(ptr);
122 expect(size == @sizeOf(@Frame(first)));122 expect(size == @sizeOf(@Frame(first)));
123 }123 }
...@@ -184,7 +184,7 @@ test "coroutine suspend with block" {...@@ -184,7 +184,7 @@ test "coroutine suspend with block" {
184184
185var a_promise: anyframe = undefined;185var a_promise: anyframe = undefined;
186var global_result = false;186var global_result = false;
187async fn testSuspendBlock() void {187fn testSuspendBlock() callconv(.Async) void {
188 suspend {188 suspend {
189 comptime expect(@TypeOf(@frame()) == *@Frame(testSuspendBlock));189 comptime expect(@TypeOf(@frame()) == *@Frame(testSuspendBlock));
190 a_promise = @frame();190 a_promise = @frame();
...@@ -209,14 +209,14 @@ test "coroutine await" {...@@ -209,14 +209,14 @@ test "coroutine await" {
209 expect(await_final_result == 1234);209 expect(await_final_result == 1234);
210 expect(std.mem.eql(u8, &await_points, "abcdefghi"));210 expect(std.mem.eql(u8, &await_points, "abcdefghi"));
211}211}
212async fn await_amain() void {212fn await_amain() callconv(.Async) void {
213 await_seq('b');213 await_seq('b');
214 var p = async await_another();214 var p = async await_another();
215 await_seq('e');215 await_seq('e');
216 await_final_result = await p;216 await_final_result = await p;
217 await_seq('h');217 await_seq('h');
218}218}
219async fn await_another() i32 {219fn await_another() callconv(.Async) i32 {
220 await_seq('c');220 await_seq('c');
221 suspend {221 suspend {
222 await_seq('d');222 await_seq('d');
...@@ -243,14 +243,14 @@ test "coroutine await early return" {...@@ -243,14 +243,14 @@ test "coroutine await early return" {
243 expect(early_final_result == 1234);243 expect(early_final_result == 1234);
244 expect(std.mem.eql(u8, &early_points, "abcdef"));244 expect(std.mem.eql(u8, &early_points, "abcdef"));
245}245}
246async fn early_amain() void {246fn early_amain() callconv(.Async) void {
247 early_seq('b');247 early_seq('b');
248 var p = async early_another();248 var p = async early_another();
249 early_seq('d');249 early_seq('d');
250 early_final_result = await p;250 early_final_result = await p;
251 early_seq('e');251 early_seq('e');
252}252}
253async fn early_another() i32 {253fn early_another() callconv(.Async) i32 {
254 early_seq('c');254 early_seq('c');
255 return 1234;255 return 1234;
256}256}
...@@ -266,7 +266,7 @@ fn early_seq(c: u8) void {...@@ -266,7 +266,7 @@ fn early_seq(c: u8) void {
266test "async function with dot syntax" {266test "async function with dot syntax" {
267 const S = struct {267 const S = struct {
268 var y: i32 = 1;268 var y: i32 = 1;
269 async fn foo() void {269 fn foo() callconv(.Async) void {
270 y += 1;270 y += 1;
271 suspend;271 suspend;
272 }272 }
...@@ -278,7 +278,7 @@ test "async function with dot syntax" {...@@ -278,7 +278,7 @@ test "async function with dot syntax" {
278test "async fn pointer in a struct field" {278test "async fn pointer in a struct field" {
279 var data: i32 = 1;279 var data: i32 = 1;
280 const Foo = struct {280 const Foo = struct {
281 bar: async fn (*i32) void,281 bar: fn (*i32) callconv(.Async) void,
282 };282 };
283 var foo = Foo{ .bar = simpleAsyncFn2 };283 var foo = Foo{ .bar = simpleAsyncFn2 };
284 var bytes: [64]u8 align(16) = undefined;284 var bytes: [64]u8 align(16) = undefined;
...@@ -294,8 +294,7 @@ test "async fn pointer in a struct field" {...@@ -294,8 +294,7 @@ test "async fn pointer in a struct field" {
294fn doTheAwait(f: anyframe->void) void {294fn doTheAwait(f: anyframe->void) void {
295 await f;295 await f;
296}296}
297297fn simpleAsyncFn2(y: *i32) callconv(.Async) void {
298async fn simpleAsyncFn2(y: *i32) void {
299 defer y.* += 2;298 defer y.* += 2;
300 y.* += 1;299 y.* += 1;
301 suspend;300 suspend;
...@@ -303,11 +302,10 @@ async fn simpleAsyncFn2(y: *i32) void {...@@ -303,11 +302,10 @@ async fn simpleAsyncFn2(y: *i32) void {
303302
304test "@asyncCall with return type" {303test "@asyncCall with return type" {
305 const Foo = struct {304 const Foo = struct {
306 bar: async fn () i32,305 bar: fn () callconv(.Async) i32,
307306
308 var global_frame: anyframe = undefined;307 var global_frame: anyframe = undefined;
309308 fn middle() callconv(.Async) i32 {
310 async fn middle() i32 {
311 return afunc();309 return afunc();
312 }310 }
313311
...@@ -338,8 +336,7 @@ test "async fn with inferred error set" {...@@ -338,8 +336,7 @@ test "async fn with inferred error set" {
338 resume global_frame;336 resume global_frame;
339 std.testing.expectError(error.Fail, result);337 std.testing.expectError(error.Fail, result);
340 }338 }
341339 fn middle() callconv(.Async) !void {
342 async fn middle() !void {
343 var f = async middle2();340 var f = async middle2();
344 return await f;341 return await f;
345 }342 }
...@@ -376,11 +373,11 @@ fn nonFailing() (anyframe->anyerror!void) {...@@ -376,11 +373,11 @@ fn nonFailing() (anyframe->anyerror!void) {
376 Static.frame = async suspendThenFail();373 Static.frame = async suspendThenFail();
377 return &Static.frame;374 return &Static.frame;
378}375}
379async fn suspendThenFail() anyerror!void {376fn suspendThenFail() callconv(.Async) anyerror!void {
380 suspend;377 suspend;
381 return error.Fail;378 return error.Fail;
382}379}
383async fn printTrace(p: anyframe->(anyerror!void)) void {380fn printTrace(p: anyframe->(anyerror!void)) callconv(.Async) void {
384 (await p) catch |e| {381 (await p) catch |e| {
385 std.testing.expect(e == error.Fail);382 std.testing.expect(e == error.Fail);
386 if (@errorReturnTrace()) |trace| {383 if (@errorReturnTrace()) |trace| {
...@@ -397,7 +394,7 @@ test "break from suspend" {...@@ -397,7 +394,7 @@ test "break from suspend" {
397 const p = async testBreakFromSuspend(&my_result);394 const p = async testBreakFromSuspend(&my_result);
398 std.testing.expect(my_result == 2);395 std.testing.expect(my_result == 2);
399}396}
400async fn testBreakFromSuspend(my_result: *i32) void {397fn testBreakFromSuspend(my_result: *i32) callconv(.Async) void {
401 suspend {398 suspend {
402 resume @frame();399 resume @frame();
403 }400 }
...@@ -826,7 +823,7 @@ test "cast fn to async fn when it is inferred to be async" {...@@ -826,7 +823,7 @@ test "cast fn to async fn when it is inferred to be async" {
826 var ok = false;823 var ok = false;
827824
828 fn doTheTest() void {825 fn doTheTest() void {
829 var ptr: async fn () i32 = undefined;826 var ptr: fn () callconv(.Async) i32 = undefined;
830 ptr = func;827 ptr = func;
831 var buf: [100]u8 align(16) = undefined;828 var buf: [100]u8 align(16) = undefined;
832 var result: i32 = undefined;829 var result: i32 = undefined;
...@@ -854,7 +851,7 @@ test "cast fn to async fn when it is inferred to be async, awaited directly" {...@@ -854,7 +851,7 @@ test "cast fn to async fn when it is inferred to be async, awaited directly" {
854 var ok = false;851 var ok = false;
855852
856 fn doTheTest() void {853 fn doTheTest() void {
857 var ptr: async fn () i32 = undefined;854 var ptr: fn () callconv(.Async) i32 = undefined;
858 ptr = func;855 ptr = func;
859 var buf: [100]u8 align(16) = undefined;856 var buf: [100]u8 align(16) = undefined;
860 var result: i32 = undefined;857 var result: i32 = undefined;
...@@ -958,8 +955,7 @@ test "@asyncCall with comptime-known function, but not awaited directly" {...@@ -958,8 +955,7 @@ test "@asyncCall with comptime-known function, but not awaited directly" {
958 resume global_frame;955 resume global_frame;
959 std.testing.expectError(error.Fail, result);956 std.testing.expectError(error.Fail, result);
960 }957 }
961958 fn middle() callconv(.Async) !void {
962 async fn middle() !void {
963 var f = async middle2();959 var f = async middle2();
964 return await f;960 return await f;
965 }961 }
...@@ -993,7 +989,7 @@ test "@asyncCall with actual frame instead of byte buffer" {...@@ -993,7 +989,7 @@ test "@asyncCall with actual frame instead of byte buffer" {
993989
994test "@asyncCall using the result location inside the frame" {990test "@asyncCall using the result location inside the frame" {
995 const S = struct {991 const S = struct {
996 async fn simple2(y: *i32) i32 {992 fn simple2(y: *i32) callconv(.Async) i32 {
997 defer y.* += 2;993 defer y.* += 2;
998 y.* += 1;994 y.* += 1;
999 suspend;995 suspend;
...@@ -1005,7 +1001,7 @@ test "@asyncCall using the result location inside the frame" {...@@ -1005,7 +1001,7 @@ test "@asyncCall using the result location inside the frame" {
1005 };1001 };
1006 var data: i32 = 1;1002 var data: i32 = 1;
1007 const Foo = struct {1003 const Foo = struct {
1008 bar: async fn (*i32) i32,1004 bar: fn (*i32) callconv(.Async) i32,
1009 };1005 };
1010 var foo = Foo{ .bar = S.simple2 };1006 var foo = Foo{ .bar = S.simple2 };
1011 var bytes: [64]u8 align(16) = undefined;1007 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...@@ -1115,7 +1111,7 @@ test "await used in expression and awaiting fn with no suspend but async calling
1115 const sum = (await f1) + (await f2);1111 const sum = (await f1) + (await f2);
1116 expect(sum == 10);1112 expect(sum == 10);
1117 }1113 }
1118 async fn add(a: i32, b: i32) i32 {1114 fn add(a: i32, b: i32) callconv(.Async) i32 {
1119 return a + b;1115 return a + b;
1120 }1116 }
1121 };1117 };
...@@ -1130,7 +1126,7 @@ test "await used in expression after a fn call" {...@@ -1130,7 +1126,7 @@ test "await used in expression after a fn call" {
1130 sum = foo() + await f1;1126 sum = foo() + await f1;
1131 expect(sum == 8);1127 expect(sum == 8);
1132 }1128 }
1133 async fn add(a: i32, b: i32) i32 {1129 fn add(a: i32, b: i32) callconv(.Async) i32 {
1134 return a + b;1130 return a + b;
1135 }1131 }
1136 fn foo() i32 {1132 fn foo() i32 {
...@@ -1147,7 +1143,7 @@ test "async fn call used in expression after a fn call" {...@@ -1147,7 +1143,7 @@ test "async fn call used in expression after a fn call" {
1147 sum = foo() + add(3, 4);1143 sum = foo() + add(3, 4);
1148 expect(sum == 8);1144 expect(sum == 8);
1149 }1145 }
1150 async fn add(a: i32, b: i32) i32 {1146 fn add(a: i32, b: i32) callconv(.Async) i32 {
1151 return a + b;1147 return a + b;
1152 }1148 }
1153 fn foo() i32 {1149 fn foo() i32 {
...@@ -1403,7 +1399,7 @@ test "async function call resolves target fn frame, runtime func" {...@@ -1403,7 +1399,7 @@ test "async function call resolves target fn frame, runtime func" {
1403 fn foo() anyerror!void {1399 fn foo() anyerror!void {
1404 const stack_size = 1000;1400 const stack_size = 1000;
1405 var stack_frame: [stack_size]u8 align(std.Target.stack_align) = undefined;1401 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;
1407 return await @asyncCall(&stack_frame, {}, func);1403 return await @asyncCall(&stack_frame, {}, func);
1408 }1404 }
14091405
test/stage1/behavior/await_struct.zig+2-2
...@@ -18,14 +18,14 @@ test "coroutine await struct" {...@@ -18,14 +18,14 @@ test "coroutine await struct" {
18 expect(await_final_result.x == 1234);18 expect(await_final_result.x == 1234);
19 expect(std.mem.eql(u8, &await_points, "abcdefghi"));19 expect(std.mem.eql(u8, &await_points, "abcdefghi"));
20}20}
21async fn await_amain() void {21fn await_amain() callconv(.Async) void {
22 await_seq('b');22 await_seq('b');
23 var p = async await_another();23 var p = async await_another();
24 await_seq('e');24 await_seq('e');
25 await_final_result = await p;25 await_final_result = await p;
26 await_seq('h');26 await_seq('h');
27}27}
28async fn await_another() Foo {28fn await_another() callconv(.Async) Foo {
29 await_seq('c');29 await_seq('c');
30 suspend {30 suspend {
31 await_seq('d');31 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...@@ -762,7 +762,7 @@ test "variable initialization uses result locations properly with regards to the
762762
763test "cast between [*c]T and ?[*:0]T on fn parameter" {763test "cast between [*c]T and ?[*:0]T on fn parameter" {
764 const S = struct {764 const S = struct {
765 const Handler = ?extern fn ([*c]const u8) void;765 const Handler = ?fn ([*c]const u8) callconv(.C) void;
766 fn addCallback(handler: Handler) void {}766 fn addCallback(handler: Handler) void {}
767767
768 fn myCallback(cstr: ?[*:0]const u8) callconv(.C) void {}768 fn myCallback(cstr: ?[*:0]const u8) callconv(.C) void {}