From 7ada59f873738931b4d162372dff0a33442112b6 Mon Sep 17 00:00:00 2001 From: Tadeo Kondrak Date: Mon, 4 May 2020 09:06:20 -0600 Subject: [PATCH 1/4] remove nakedcc/stdcallcc/async fn/extern fn fnproto --- doc/docgen.zig | 2 -- doc/langref.html.in | 7 +--- lib/std/zig/ast.zig | 2 -- lib/std/zig/parse.zig | 53 ++---------------------------- lib/std/zig/parser_test.zig | 16 --------- lib/std/zig/render.zig | 24 +------------- lib/std/zig/tokenizer.zig | 6 ---- src-self-hosted/translate_c.zig | 3 -- src/all_types.hpp | 1 - src/analyze.cpp | 2 -- src/parser.cpp | 58 +++------------------------------ 11 files changed, 9 insertions(+), 165 deletions(-) diff --git a/doc/docgen.zig b/doc/docgen.zig index a249a526a1..92a7353fa1 100644 --- a/doc/docgen.zig +++ b/doc/docgen.zig @@ -800,7 +800,6 @@ fn tokenizeAndPrintRaw(docgen_tokenizer: *Tokenizer, out: var, source_token: Tok .Keyword_for, .Keyword_if, .Keyword_inline, - .Keyword_nakedcc, .Keyword_noalias, .Keyword_noinline, .Keyword_nosuspend, @@ -813,7 +812,6 @@ fn tokenizeAndPrintRaw(docgen_tokenizer: *Tokenizer, out: var, source_token: Tok .Keyword_return, .Keyword_linksection, .Keyword_callconv, - .Keyword_stdcallcc, .Keyword_struct, .Keyword_suspend, .Keyword_switch, diff --git a/doc/langref.html.in b/doc/langref.html.in index 6026912893..b2e1f6e6f6 100644 --- a/doc/langref.html.in +++ b/doc/langref.html.in @@ -10088,7 +10088,7 @@ TopLevelDecl / (KEYWORD_export / KEYWORD_extern STRINGLITERALSINGLE?)? KEYWORD_threadlocal? VarDecl / KEYWORD_usingnamespace Expr SEMICOLON -FnProto <- FnCC? KEYWORD_fn IDENTIFIER? LPAREN ParamDeclList RPAREN ByteAlign? LinkSection? EXCLAMATIONMARK? (KEYWORD_var / TypeExpr) +FnProto <- KEYWORD_fn IDENTIFIER? LPAREN ParamDeclList RPAREN ByteAlign? LinkSection? EXCLAMATIONMARK? (KEYWORD_var / TypeExpr) VarDecl <- (KEYWORD_const / KEYWORD_var) IDENTIFIER (COLON TypeExpr)? ByteAlign? LinkSection? (EQUAL Expr)? SEMICOLON @@ -10255,11 +10255,6 @@ WhileContinueExpr <- COLON LPAREN AssignExpr RPAREN LinkSection <- KEYWORD_linksection LPAREN Expr RPAREN -# Fn specific -FnCC - <- KEYWORD_extern - / KEYWORD_async - ParamDecl <- (KEYWORD_noalias / KEYWORD_comptime)? (IDENTIFIER COLON)? ParamType ParamType diff --git a/lib/std/zig/ast.zig b/lib/std/zig/ast.zig index 50051040d9..220b0390f1 100644 --- a/lib/std/zig/ast.zig +++ b/lib/std/zig/ast.zig @@ -875,7 +875,6 @@ pub const Node = struct { return_type: ReturnType, var_args_token: ?TokenIndex, extern_export_inline_token: ?TokenIndex, - cc_token: ?TokenIndex, body_node: ?*Node, lib_name: ?*Node, // populated if this is an extern declaration align_expr: ?*Node, // populated if align(A) is present @@ -929,7 +928,6 @@ pub const Node = struct { if (self.visib_token) |visib_token| return visib_token; if (self.extern_export_inline_token) |extern_export_inline_token| return extern_export_inline_token; assert(self.lib_name == null); - if (self.cc_token) |cc_token| return cc_token; return self.fn_token; } diff --git a/lib/std/zig/parse.zig b/lib/std/zig/parse.zig index d7f4d76cf6..ac1c1f8b15 100644 --- a/lib/std/zig/parse.zig +++ b/lib/std/zig/parse.zig @@ -335,22 +335,9 @@ fn parseTopLevelDecl(arena: *Allocator, it: *TokenIterator, tree: *Tree) !?*Node return use_node; } -/// FnProto <- FnCC? KEYWORD_fn IDENTIFIER? LPAREN ParamDeclList RPAREN ByteAlign? LinkSection? EXCLAMATIONMARK? (KEYWORD_var / TypeExpr) +/// FnProto <- KEYWORD_fn IDENTIFIER? LPAREN ParamDeclList RPAREN ByteAlign? LinkSection? EXCLAMATIONMARK? (KEYWORD_var / TypeExpr) fn parseFnProto(arena: *Allocator, it: *TokenIterator, tree: *Tree) !?*Node { - const cc = parseFnCC(arena, it, tree); - const fn_token = eatToken(it, .Keyword_fn) orelse { - if (cc) |fnCC| { - if (fnCC == .Extern) { - putBackToken(it, fnCC.Extern); // 'extern' is also used in ContainerDecl - } else { - try tree.errors.push(.{ - .ExpectedToken = .{ .token = it.index, .expected_id = .Keyword_fn }, - }); - return error.ParseError; - } - } - return null; - }; + const fn_token = eatToken(it, .Keyword_fn) orelse return null; const name_token = eatToken(it, .Identifier); const lparen = try expectToken(it, tree, .LParen); const params = try parseParamDeclList(arena, it, tree); @@ -389,7 +376,6 @@ fn parseFnProto(arena: *Allocator, it: *TokenIterator, tree: *Tree) !?*Node { .return_type = return_type, .var_args_token = var_args_token, .extern_export_inline_token = null, - .cc_token = null, .body_node = null, .lib_name = null, .align_expr = align_expr, @@ -397,13 +383,6 @@ fn parseFnProto(arena: *Allocator, it: *TokenIterator, tree: *Tree) !?*Node { .callconv_expr = callconv_expr, }; - if (cc) |kind| { - switch (kind) { - .CC => |token| fn_proto_node.cc_token = token, - .Extern => |token| fn_proto_node.extern_export_inline_token = token, - } - } - return &fn_proto_node.base; } @@ -1196,16 +1175,6 @@ fn parseSuffixExpr(arena: *Allocator, it: *TokenIterator, tree: *Tree) !?*Node { const maybe_async = eatToken(it, .Keyword_async); if (maybe_async) |async_token| { const token_fn = eatToken(it, .Keyword_fn); - if (token_fn != null) { - // HACK: If we see the keyword `fn`, then we assume that - // we are parsing an async fn proto, and not a call. - // We therefore put back all tokens consumed by the async - // prefix... - putBackToken(it, token_fn.?); - putBackToken(it, async_token); - return parsePrimaryTypeExpr(arena, it, tree); - } - // TODO: Implement hack for parsing `async fn ...` in ast_parse_suffix_expr var res = try expectNode(arena, it, tree, parsePrimaryTypeExpr, .{ .ExpectedPrimaryTypeExpr = .{ .token = it.index }, }); @@ -1778,24 +1747,6 @@ fn parseCallconv(arena: *Allocator, it: *TokenIterator, tree: *Tree) !?*Node { return expr_node; } -/// FnCC -/// <- KEYWORD_nakedcc -/// / KEYWORD_stdcallcc -/// / KEYWORD_extern -/// / KEYWORD_async -fn parseFnCC(arena: *Allocator, it: *TokenIterator, tree: *Tree) ?FnCC { - if (eatToken(it, .Keyword_nakedcc)) |token| return FnCC{ .CC = token }; - if (eatToken(it, .Keyword_stdcallcc)) |token| return FnCC{ .CC = token }; - if (eatToken(it, .Keyword_extern)) |token| return FnCC{ .Extern = token }; - if (eatToken(it, .Keyword_async)) |token| return FnCC{ .CC = token }; - return null; -} - -const FnCC = union(enum) { - CC: TokenIndex, - Extern: TokenIndex, -}; - /// ParamDecl <- (KEYWORD_noalias / KEYWORD_comptime)? (IDENTIFIER COLON)? ParamType fn parseParamDecl(arena: *Allocator, it: *TokenIterator, tree: *Tree) !?*Node { const doc_comments = try parseDocComment(arena, it, tree); diff --git a/lib/std/zig/parser_test.zig b/lib/std/zig/parser_test.zig index ebc6b92b78..198ce1ad94 100644 --- a/lib/std/zig/parser_test.zig +++ b/lib/std/zig/parser_test.zig @@ -123,22 +123,6 @@ test "zig fmt: trailing comma in fn parameter list" { ); } -// TODO: Remove nakedcc/stdcallcc once zig 0.6.0 is released. See https://github.com/ziglang/zig/pull/3977 -test "zig fmt: convert extern/nakedcc/stdcallcc into callconv(...)" { - try testTransform( - \\nakedcc fn foo1() void {} - \\stdcallcc fn foo2() void {} - \\extern fn foo3() void {} - \\extern "mylib" fn foo4() void {} - , - \\fn foo1() callconv(.Naked) void {} - \\fn foo2() callconv(.Stdcall) void {} - \\fn foo3() callconv(.C) void {} - \\fn foo4() callconv(.C) void {} - \\ - ); -} - test "zig fmt: comptime struct field" { try testCanonical( \\const Foo = struct { diff --git a/lib/std/zig/render.zig b/lib/std/zig/render.zig index 441a91a28a..3e2cebcd8a 100644 --- a/lib/std/zig/render.zig +++ b/lib/std/zig/render.zig @@ -1413,32 +1413,14 @@ fn renderExpression( try renderToken(tree, stream, visib_token_index, indent, start_col, Space.Space); // pub } - // Some extra machinery is needed to rewrite the old-style cc - // notation to the new callconv one - var cc_rewrite_str: ?[*:0]const u8 = null; if (fn_proto.extern_export_inline_token) |extern_export_inline_token| { - const tok = tree.tokens.at(extern_export_inline_token); - if (tok.id != .Keyword_extern or fn_proto.body_node == null) { - try renderToken(tree, stream, extern_export_inline_token, indent, start_col, Space.Space); // extern/export - } else { - cc_rewrite_str = ".C"; - fn_proto.lib_name = null; - } + try renderToken(tree, stream, extern_export_inline_token, indent, start_col, Space.Space); // extern/export } if (fn_proto.lib_name) |lib_name| { try renderExpression(allocator, stream, tree, indent, start_col, lib_name, Space.Space); } - if (fn_proto.cc_token) |cc_token| { - var str = tree.tokenSlicePtr(tree.tokens.at(cc_token)); - if (mem.eql(u8, str, "stdcallcc")) { - cc_rewrite_str = ".Stdcall"; - } else if (mem.eql(u8, str, "nakedcc")) { - cc_rewrite_str = ".Naked"; - } else try renderToken(tree, stream, cc_token, indent, start_col, Space.Space); // stdcallcc - } - const lparen = if (fn_proto.name_token) |name_token| blk: { try renderToken(tree, stream, fn_proto.fn_token, indent, start_col, Space.Space); // fn try renderToken(tree, stream, name_token, indent, start_col, Space.None); // name @@ -1528,10 +1510,6 @@ fn renderExpression( try renderToken(tree, stream, callconv_lparen, indent, start_col, Space.None); // ( try renderExpression(allocator, stream, tree, indent, start_col, callconv_expr, Space.None); try renderToken(tree, stream, callconv_rparen, indent, start_col, Space.Space); // ) - } else if (cc_rewrite_str) |str| { - try stream.writeAll("callconv("); - try stream.writeAll(mem.spanZ(str)); - try stream.writeAll(") "); } switch (fn_proto.return_type) { diff --git a/lib/std/zig/tokenizer.zig b/lib/std/zig/tokenizer.zig index b6c1a06276..089711871e 100644 --- a/lib/std/zig/tokenizer.zig +++ b/lib/std/zig/tokenizer.zig @@ -47,7 +47,6 @@ pub const Token = struct { Keyword.init("for", .Keyword_for), Keyword.init("if", .Keyword_if), Keyword.init("inline", .Keyword_inline), - Keyword.init("nakedcc", .Keyword_nakedcc), Keyword.init("noalias", .Keyword_noalias), Keyword.init("noasync", .Keyword_nosuspend), // TODO: remove this Keyword.init("noinline", .Keyword_noinline), @@ -60,7 +59,6 @@ pub const Token = struct { Keyword.init("resume", .Keyword_resume), Keyword.init("return", .Keyword_return), Keyword.init("linksection", .Keyword_linksection), - Keyword.init("stdcallcc", .Keyword_stdcallcc), Keyword.init("struct", .Keyword_struct), Keyword.init("suspend", .Keyword_suspend), Keyword.init("switch", .Keyword_switch), @@ -181,7 +179,6 @@ pub const Token = struct { Keyword_for, Keyword_if, Keyword_inline, - Keyword_nakedcc, Keyword_noalias, Keyword_noinline, Keyword_nosuspend, @@ -194,7 +191,6 @@ pub const Token = struct { Keyword_resume, Keyword_return, Keyword_linksection, - Keyword_stdcallcc, Keyword_struct, Keyword_suspend, Keyword_switch, @@ -306,7 +302,6 @@ pub const Token = struct { .Keyword_for => "for", .Keyword_if => "if", .Keyword_inline => "inline", - .Keyword_nakedcc => "nakedcc", .Keyword_noalias => "noalias", .Keyword_noinline => "noinline", .Keyword_nosuspend => "nosuspend", @@ -318,7 +313,6 @@ pub const Token = struct { .Keyword_resume => "resume", .Keyword_return => "return", .Keyword_linksection => "linksection", - .Keyword_stdcallcc => "stdcallcc", .Keyword_struct => "struct", .Keyword_suspend => "suspend", .Keyword_switch => "switch", diff --git a/src-self-hosted/translate_c.zig b/src-self-hosted/translate_c.zig index 1c689e9f76..6bbb133bb1 100644 --- a/src-self-hosted/translate_c.zig +++ b/src-self-hosted/translate_c.zig @@ -4094,7 +4094,6 @@ fn transCreateNodeMacroFn(c: *Context, name: []const u8, ref: *ast.Node, proto_a .return_type = proto_alias.return_type, .var_args_token = null, .extern_export_inline_token = inline_tok, - .cc_token = null, .body_node = null, .lib_name = null, .align_expr = null, @@ -4753,7 +4752,6 @@ fn finishTransFnProto( .return_type = .{ .Explicit = return_type_node }, .var_args_token = null, // TODO this field is broken in the AST data model .extern_export_inline_token = extern_export_inline_tok, - .cc_token = null, .body_node = null, .lib_name = null, .align_expr = align_expr, @@ -5119,7 +5117,6 @@ fn transMacroFnDefine(c: *Context, it: *CTokenList.Iterator, source: []const u8, .return_type = .{ .Explicit = &type_of.base }, .doc_comments = null, .var_args_token = null, - .cc_token = null, .body_node = null, .lib_name = null, .align_expr = null, diff --git a/src/all_types.hpp b/src/all_types.hpp index aeffa440ab..61b6cbd74a 100644 --- a/src/all_types.hpp +++ b/src/all_types.hpp @@ -718,7 +718,6 @@ struct AstNodeFnProto { Buf doc_comments; FnInline fn_inline; - bool is_async; VisibMod visib_mod; bool auto_err_set; diff --git a/src/analyze.cpp b/src/analyze.cpp index 4c3103c48c..39f797a9ec 100644 --- a/src/analyze.cpp +++ b/src/analyze.cpp @@ -1528,8 +1528,6 @@ ZigType *get_generic_fn_type(CodeGen *g, FnTypeId *fn_type_id) { } CallingConvention cc_from_fn_proto(AstNodeFnProto *fn_proto) { - if (fn_proto->is_async) - return CallingConventionAsync; // Compatible with the C ABI if (fn_proto->is_extern || fn_proto->is_export) return CallingConventionC; diff --git a/src/parser.cpp b/src/parser.cpp index 71f7adf7d1..1a929cd1b1 100644 --- a/src/parser.cpp +++ b/src/parser.cpp @@ -93,7 +93,6 @@ static AstNode *ast_parse_field_init(ParseContext *pc); static AstNode *ast_parse_while_continue_expr(ParseContext *pc); static AstNode *ast_parse_link_section(ParseContext *pc); static AstNode *ast_parse_callconv(ParseContext *pc); -static Optional ast_parse_fn_cc(ParseContext *pc); static AstNode *ast_parse_param_decl(ParseContext *pc); static AstNode *ast_parse_param_type(ParseContext *pc); static AstNode *ast_parse_if_prefix(ParseContext *pc); @@ -707,7 +706,6 @@ static AstNode *ast_parse_top_level_decl(ParseContext *pc, VisibMod visib_mod, B fn_proto->column = first->start_column; fn_proto->data.fn_proto.visib_mod = visib_mod; fn_proto->data.fn_proto.doc_comments = *doc_comments; - // ast_parse_fn_cc may set it if (!fn_proto->data.fn_proto.is_extern) fn_proto->data.fn_proto.is_extern = first->id == TokenIdKeywordExtern; 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 return nullptr; } -// FnProto <- FnCC? KEYWORD_fn IDENTIFIER? LPAREN ParamDeclList RPAREN ByteAlign? LinkSection? EXCLAMATIONMARK? (KEYWORD_var / TypeExpr) +// FnProto <- KEYWORD_fn IDENTIFIER? LPAREN ParamDeclList RPAREN ByteAlign? LinkSection? EXCLAMATIONMARK? (KEYWORD_var / TypeExpr) static AstNode *ast_parse_fn_proto(ParseContext *pc) { - Token *first = peek_token(pc); - AstNodeFnProto fn_cc; - Token *fn; - if (ast_parse_fn_cc(pc).unwrap(&fn_cc)) { - // The extern keyword for fn CC is also used for container decls. - // We therefore put it back, as allow container decl to consume it - // later. - if (fn_cc.is_extern) { - fn = eat_token_if(pc, TokenIdKeywordFn); - if (fn == nullptr) { - put_back_token(pc); - return nullptr; - } - } else { - fn = expect_token(pc, TokenIdKeywordFn); - } - } else { - fn_cc = {}; - fn = eat_token_if(pc, TokenIdKeywordFn); - if (fn == nullptr) - return nullptr; + Token *first = eat_token_if(pc, TokenIdKeywordFn); + if (first == nullptr) { + return nullptr; } Token *identifier = eat_token_if(pc, TokenIdSymbol); @@ -830,7 +810,7 @@ static AstNode *ast_parse_fn_proto(ParseContext *pc) { } AstNode *res = ast_create_node(pc, NodeTypeFnProto, first); - res->data.fn_proto = fn_cc; + res->data.fn_proto = {}; res->data.fn_proto.name = token_buf(identifier); res->data.fn_proto.params = params; res->data.fn_proto.align_expr = align_expr; @@ -1524,17 +1504,6 @@ static AstNode *ast_parse_error_union_expr(ParseContext *pc) { static AstNode *ast_parse_suffix_expr(ParseContext *pc) { Token *async_token = eat_token_if(pc, TokenIdKeywordAsync); if (async_token) { - if (eat_token_if(pc, TokenIdKeywordFn) != nullptr) { - // HACK: If we see the keyword `fn`, then we assume that - // we are parsing an async fn proto, and not a call. - // We therefore put back all tokens consumed by the async - // prefix... - put_back_token(pc); - put_back_token(pc); - - return ast_parse_primary_type_expr(pc); - } - AstNode *child = ast_expect(pc, ast_parse_primary_type_expr); while (true) { AstNode *suffix = ast_parse_suffix_op(pc); @@ -2187,23 +2156,6 @@ static AstNode *ast_parse_callconv(ParseContext *pc) { return res; } -// FnCC -// <- KEYWORD_extern -// / KEYWORD_async -static Optional ast_parse_fn_cc(ParseContext *pc) { - AstNodeFnProto res = {}; - if (eat_token_if(pc, TokenIdKeywordAsync) != nullptr) { - res.is_async = true; - return Optional::some(res); - } - if (eat_token_if(pc, TokenIdKeywordExtern) != nullptr) { - res.is_extern = true; - return Optional::some(res); - } - - return Optional::none(); -} - // ParamDecl <- (KEYWORD_noalias / KEYWORD_comptime)? (IDENTIFIER COLON)? ParamType static AstNode *ast_parse_param_decl(ParseContext *pc) { Buf doc_comments = BUF_INIT; From d0e996405bff4352c78c570b4944b369d642d058 Mon Sep 17 00:00:00 2001 From: Tadeo Kondrak Date: Mon, 4 May 2020 09:24:46 -0600 Subject: [PATCH 2/4] add zig fmt fix for async/extern fn --- lib/std/zig/ast.zig | 2 ++ lib/std/zig/parse.zig | 32 +++++++++++++++++++++++++++- lib/std/zig/parser_test.zig | 42 +++++++++++++++++++++---------------- lib/std/zig/render.zig | 7 ++++++- 4 files changed, 63 insertions(+), 20 deletions(-) diff --git a/lib/std/zig/ast.zig b/lib/std/zig/ast.zig index 220b0390f1..8dec2de15c 100644 --- a/lib/std/zig/ast.zig +++ b/lib/std/zig/ast.zig @@ -880,6 +880,8 @@ pub const Node = struct { align_expr: ?*Node, // populated if align(A) is present section_expr: ?*Node, // populated if linksection(A) is present callconv_expr: ?*Node, // populated if callconv(A) is present + is_extern_prototype: bool = false, // TODO: Remove once extern fn rewriting is + is_async: bool = false, // TODO: remove once async fn rewriting is pub const ParamList = SegmentedList(*Node, 2); diff --git a/lib/std/zig/parse.zig b/lib/std/zig/parse.zig index ac1c1f8b15..031fd9c160 100644 --- a/lib/std/zig/parse.zig +++ b/lib/std/zig/parse.zig @@ -337,7 +337,25 @@ fn parseTopLevelDecl(arena: *Allocator, it: *TokenIterator, tree: *Tree) !?*Node /// FnProto <- KEYWORD_fn IDENTIFIER? LPAREN ParamDeclList RPAREN ByteAlign? LinkSection? EXCLAMATIONMARK? (KEYWORD_var / TypeExpr) fn parseFnProto(arena: *Allocator, it: *TokenIterator, tree: *Tree) !?*Node { - const fn_token = eatToken(it, .Keyword_fn) orelse return null; + // TODO: Remove once extern/async fn rewriting is + var is_async = false; + var is_extern = false; + const cc_token: ?usize = blk: { + if (eatToken(it, .Keyword_extern)) |token| { + is_extern = true; + break :blk token; + } + if (eatToken(it, .Keyword_async)) |token| { + is_async = true; + break :blk token; + } + break :blk null; + }; + const fn_token = eatToken(it, .Keyword_fn) orelse { + if (cc_token) |token| + putBackToken(it, token); + return null; + }; const name_token = eatToken(it, .Identifier); const lparen = try expectToken(it, tree, .LParen); const params = try parseParamDeclList(arena, it, tree); @@ -381,6 +399,8 @@ fn parseFnProto(arena: *Allocator, it: *TokenIterator, tree: *Tree) !?*Node { .align_expr = align_expr, .section_expr = section_expr, .callconv_expr = callconv_expr, + .is_extern_prototype = is_extern, + .is_async = is_async, }; return &fn_proto_node.base; @@ -1175,6 +1195,16 @@ fn parseSuffixExpr(arena: *Allocator, it: *TokenIterator, tree: *Tree) !?*Node { const maybe_async = eatToken(it, .Keyword_async); if (maybe_async) |async_token| { const token_fn = eatToken(it, .Keyword_fn); + if (token_fn != null) { + // TODO: remove this hack when async fn rewriting is + // HACK: If we see the keyword `fn`, then we assume that + // we are parsing an async fn proto, and not a call. + // We therefore put back all tokens consumed by the async + // prefix... + putBackToken(it, token_fn.?); + putBackToken(it, async_token); + return parsePrimaryTypeExpr(arena, it, tree); + } var res = try expectNode(arena, it, tree, parsePrimaryTypeExpr, .{ .ExpectedPrimaryTypeExpr = .{ .token = it.index }, }); diff --git a/lib/std/zig/parser_test.zig b/lib/std/zig/parser_test.zig index 198ce1ad94..7ab3e86b1a 100644 --- a/lib/std/zig/parser_test.zig +++ b/lib/std/zig/parser_test.zig @@ -236,10 +236,10 @@ test "zig fmt: anon list literal syntax" { test "zig fmt: async function" { try testCanonical( \\pub const Server = struct { - \\ handleRequestFn: async fn (*Server, *const std.net.Address, File) void, + \\ handleRequestFn: fn (*Server, *const std.net.Address, File) callconv(.Async) void, \\}; \\test "hi" { - \\ var ptr = @ptrCast(async fn (i32) void, other); + \\ var ptr = @ptrCast(fn (i32) callconv(.Async) void, other); \\} \\ ); @@ -435,15 +435,6 @@ test "zig fmt: aligned struct field" { ); } -test "zig fmt: preserve space between async fn definitions" { - try testCanonical( - \\async fn a() void {} - \\ - \\async fn b() void {} - \\ - ); -} - test "zig fmt: comment to disable/enable zig fmt first" { try testCanonical( \\// Test trailing comma syntax @@ -1499,7 +1490,7 @@ test "zig fmt: line comments in struct initializer" { test "zig fmt: first line comment in struct initializer" { try testCanonical( - \\pub async fn acquire(self: *Self) HeldLock { + \\pub fn acquire(self: *Self) HeldLock { \\ return HeldLock{ \\ // guaranteed allocation elision \\ .held = self.lock.acquire(), @@ -2461,8 +2452,7 @@ test "zig fmt: fn type" { \\} \\ \\const a: fn (u8) u8 = undefined; - \\const b: extern fn (u8) u8 = undefined; - \\const c: fn (u8) callconv(.Naked) u8 = undefined; + \\const b: fn (u8) callconv(.Naked) u8 = undefined; \\const ap: fn (u8) u8 = a; \\ ); @@ -2484,7 +2474,7 @@ test "zig fmt: inline asm" { test "zig fmt: async functions" { try testCanonical( - \\async fn simpleAsyncFn() void { + \\fn simpleAsyncFn() void { \\ const a = async a.b(); \\ x += 1; \\ suspend; @@ -2920,6 +2910,25 @@ test "zig fmt: noasync to nosuspend" { \\pub fn main() void { \\ nosuspend call(); \\} + ); +} + +test "zig fmt: convert async fn into callconv(.Async)" { + try testTransform( + \\async fn foo() void {} + , + \\fn foo() callconv(.Async) void {} + \\ + ); +} + +test "zig fmt: convert extern fn proto into callconv(.C)" { + try testTransform( + \\extern fn foo0() void {} + \\const foo1 = extern fn () void; + , + \\extern fn foo0() void {} + \\const foo1 = fn () callconv(.C) void; \\ ); } @@ -2970,7 +2979,6 @@ fn testParse(source: []const u8, allocator: *mem.Allocator, anything_changed: *b anything_changed.* = try std.zig.render(allocator, buffer.outStream(), tree); return buffer.toOwnedSlice(); } - fn testTransform(source: []const u8, expected_source: []const u8) !void { const needed_alloc_count = x: { // Try it once with unlimited memory, make sure it works @@ -3018,11 +3026,9 @@ fn testTransform(source: []const u8, expected_source: []const u8) !void { } } } - fn testCanonical(source: []const u8) !void { return testTransform(source, source); } - fn testError(source: []const u8) !void { const tree = try std.zig.parse(std.testing.allocator, source); defer tree.deinit(); diff --git a/lib/std/zig/render.zig b/lib/std/zig/render.zig index 3e2cebcd8a..bcdc08d43a 100644 --- a/lib/std/zig/render.zig +++ b/lib/std/zig/render.zig @@ -1414,7 +1414,8 @@ fn renderExpression( } if (fn_proto.extern_export_inline_token) |extern_export_inline_token| { - try renderToken(tree, stream, extern_export_inline_token, indent, start_col, Space.Space); // extern/export + if (!fn_proto.is_extern_prototype) + try renderToken(tree, stream, extern_export_inline_token, indent, start_col, Space.Space); // extern/export/inline } if (fn_proto.lib_name) |lib_name| { @@ -1510,6 +1511,10 @@ fn renderExpression( try renderToken(tree, stream, callconv_lparen, indent, start_col, Space.None); // ( try renderExpression(allocator, stream, tree, indent, start_col, callconv_expr, Space.None); try renderToken(tree, stream, callconv_rparen, indent, start_col, Space.Space); // ) + } else if (fn_proto.is_extern_prototype) { + try stream.writeAll("callconv(.C) "); + } else if (fn_proto.is_async) { + try stream.writeAll("callconv(.Async) "); } switch (fn_proto.return_type) { From 6745a6f6f6f2b8d4473f00bed03a6cf1af117890 Mon Sep 17 00:00:00 2001 From: Tadeo Kondrak Date: Mon, 4 May 2020 09:49:27 -0600 Subject: [PATCH 3/4] zig fmt --- lib/std/c.zig | 2 +- lib/std/c/dragonfly.zig | 2 +- lib/std/c/freebsd.zig | 2 +- lib/std/c/linux.zig | 2 +- lib/std/c/netbsd.zig | 2 +- lib/std/event/channel.zig | 11 ++-- lib/std/event/future.zig | 4 +- lib/std/event/group.zig | 16 ++--- lib/std/event/lock.zig | 8 +-- lib/std/event/locked.zig | 2 +- lib/std/event/loop.zig | 2 +- lib/std/event/rwlock.zig | 13 ++-- lib/std/event/rwlocked.zig | 4 +- lib/std/os/bits/darwin.zig | 2 +- lib/std/os/bits/dragonfly.zig | 12 ++-- lib/std/os/bits/freebsd.zig | 10 +-- lib/std/os/bits/linux.zig | 10 +-- lib/std/os/linux.zig | 4 +- lib/std/os/linux/arm-eabi.zig | 2 +- lib/std/os/linux/arm64.zig | 2 +- lib/std/os/linux/i386.zig | 2 +- lib/std/os/linux/mips.zig | 2 +- lib/std/os/linux/riscv64.zig | 2 +- lib/std/os/linux/x86_64.zig | 2 +- .../protocols/absolute_pointer_protocol.zig | 4 +- .../uefi/protocols/edid_override_protocol.zig | 2 +- lib/std/os/uefi/protocols/file_protocol.zig | 20 +++--- .../protocols/graphics_output_protocol.zig | 6 +- .../uefi/protocols/hii_database_protocol.zig | 8 +-- .../os/uefi/protocols/hii_popup_protocol.zig | 2 +- .../os/uefi/protocols/ip6_config_protocol.zig | 8 +-- lib/std/os/uefi/protocols/ip6_protocol.zig | 18 +++--- .../ip6_service_binding_protocol.zig | 4 +- .../uefi/protocols/loaded_image_protocol.zig | 2 +- .../protocols/managed_network_protocol.zig | 16 ++--- ...naged_network_service_binding_protocol.zig | 4 +- lib/std/os/uefi/protocols/rng_protocol.zig | 4 +- .../protocols/simple_file_system_protocol.zig | 2 +- .../protocols/simple_network_protocol.zig | 26 ++++---- .../protocols/simple_pointer_protocol.zig | 4 +- .../simple_text_input_ex_protocol.zig | 12 ++-- .../protocols/simple_text_input_protocol.zig | 4 +- .../protocols/simple_text_output_protocol.zig | 18 +++--- lib/std/os/uefi/protocols/udp6_protocol.zig | 14 ++-- .../udp6_service_binding_protocol.zig | 4 +- lib/std/os/uefi/tables/boot_services.zig | 64 +++++++++---------- lib/std/os/uefi/tables/runtime_services.zig | 10 +-- lib/std/os/windows/bits.zig | 12 ++-- lib/std/os/windows/ws2_32.zig | 2 +- lib/std/special/test_runner.zig | 2 +- lib/std/start.zig | 3 +- src-self-hosted/clang.zig | 2 +- src-self-hosted/main.zig | 5 +- test/stage1/behavior/async_fn.zig | 54 ++++++++-------- test/stage1/behavior/await_struct.zig | 4 +- test/stage1/behavior/cast.zig | 2 +- 56 files changed, 222 insertions(+), 240 deletions(-) diff --git a/lib/std/c.zig b/lib/std/c.zig index 9f1114b9c1..0f166b7e59 100644 --- a/lib/std/c.zig +++ b/lib/std/c.zig @@ -217,7 +217,7 @@ pub extern "c" fn utimes(path: [*:0]const u8, times: *[2]timeval) c_int; pub extern "c" fn utimensat(dirfd: fd_t, pathname: [*:0]const u8, times: *[2]timespec, flags: u32) c_int; pub extern "c" fn futimens(fd: fd_t, times: *const [2]timespec) c_int; -pub 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; +pub 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; pub extern "c" fn pthread_attr_init(attr: *pthread_attr_t) c_int; pub extern "c" fn pthread_attr_setstack(attr: *pthread_attr_t, stackaddr: *c_void, stacksize: usize) c_int; pub extern "c" fn pthread_attr_setguardsize(attr: *pthread_attr_t, guardsize: usize) c_int; diff --git a/lib/std/c/dragonfly.zig b/lib/std/c/dragonfly.zig index a271b2e869..0c859018be 100644 --- a/lib/std/c/dragonfly.zig +++ b/lib/std/c/dragonfly.zig @@ -9,7 +9,7 @@ pub extern "c" fn getdents(fd: c_int, buf_ptr: [*]u8, nbytes: usize) usize; pub extern "c" fn sigaltstack(ss: ?*stack_t, old_ss: ?*stack_t) c_int; pub extern "c" fn getrandom(buf_ptr: [*]u8, buf_len: usize, flags: c_uint) isize; -pub const dl_iterate_phdr_callback = extern fn (info: *dl_phdr_info, size: usize, data: ?*c_void) c_int; +pub const dl_iterate_phdr_callback = fn (info: *dl_phdr_info, size: usize, data: ?*c_void) callconv(.C) c_int; pub extern "c" fn dl_iterate_phdr(callback: dl_iterate_phdr_callback, data: ?*c_void) c_int; pub const pthread_mutex_t = extern struct { diff --git a/lib/std/c/freebsd.zig b/lib/std/c/freebsd.zig index 3a0634dbb7..ea52c05f0b 100644 --- a/lib/std/c/freebsd.zig +++ b/lib/std/c/freebsd.zig @@ -24,7 +24,7 @@ pub extern "c" fn sendfile( flags: u32, ) c_int; -pub const dl_iterate_phdr_callback = extern fn (info: *dl_phdr_info, size: usize, data: ?*c_void) c_int; +pub const dl_iterate_phdr_callback = fn (info: *dl_phdr_info, size: usize, data: ?*c_void) callconv(.C) c_int; pub extern "c" fn dl_iterate_phdr(callback: dl_iterate_phdr_callback, data: ?*c_void) c_int; pub const pthread_mutex_t = extern struct { diff --git a/lib/std/c/linux.zig b/lib/std/c/linux.zig index 1da0db57d6..4ceeb5a773 100644 --- a/lib/std/c/linux.zig +++ b/lib/std/c/linux.zig @@ -75,7 +75,7 @@ pub extern "c" fn inotify_add_watch(fd: fd_t, pathname: [*]const u8, mask: u32) /// See std.elf for constants for this pub extern "c" fn getauxval(__type: c_ulong) c_ulong; -pub const dl_iterate_phdr_callback = extern fn (info: *dl_phdr_info, size: usize, data: ?*c_void) c_int; +pub const dl_iterate_phdr_callback = fn (info: *dl_phdr_info, size: usize, data: ?*c_void) callconv(.C) c_int; pub extern "c" fn dl_iterate_phdr(callback: dl_iterate_phdr_callback, data: ?*c_void) c_int; pub extern "c" fn sigaltstack(ss: ?*stack_t, old_ss: ?*stack_t) c_int; diff --git a/lib/std/c/netbsd.zig b/lib/std/c/netbsd.zig index 20960b3f77..31adbb1f59 100644 --- a/lib/std/c/netbsd.zig +++ b/lib/std/c/netbsd.zig @@ -6,7 +6,7 @@ usingnamespace std.c; extern "c" fn __errno() *c_int; pub const _errno = __errno; -pub const dl_iterate_phdr_callback = extern fn (info: *dl_phdr_info, size: usize, data: ?*c_void) c_int; +pub const dl_iterate_phdr_callback = fn (info: *dl_phdr_info, size: usize, data: ?*c_void) callconv(.C) c_int; pub extern "c" fn dl_iterate_phdr(callback: dl_iterate_phdr_callback, data: ?*c_void) c_int; pub extern "c" fn arc4random_buf(buf: [*]u8, len: usize) void; diff --git a/lib/std/event/channel.zig b/lib/std/event/channel.zig index 83c77bcac5..5aef0bb3ba 100644 --- a/lib/std/event/channel.zig +++ b/lib/std/event/channel.zig @@ -105,7 +105,7 @@ pub fn Channel(comptime T: type) type { /// await this function to get an item from the channel. If the buffer is empty, the frame will /// complete when the next item is put in the channel. - pub async fn get(self: *SelfChannel) T { + pub fn get(self: *SelfChannel) callconv(.Async) T { // TODO https://github.com/ziglang/zig/issues/2765 var result: T = undefined; var my_tick_node = Loop.NextTickNode.init(@frame()); @@ -305,8 +305,7 @@ test "std.event.Channel wraparound" { channel.put(7); testing.expectEqual(@as(i32, 7), channel.get()); } - -async fn testChannelGetter(channel: *Channel(i32)) void { +fn testChannelGetter(channel: *Channel(i32)) callconv(.Async) void { const value1 = channel.get(); testing.expect(value1 == 1234); @@ -321,12 +320,10 @@ async fn testChannelGetter(channel: *Channel(i32)) void { testing.expect(value4.? == 4444); await last_put; } - -async fn testChannelPutter(channel: *Channel(i32)) void { +fn testChannelPutter(channel: *Channel(i32)) callconv(.Async) void { channel.put(1234); channel.put(4567); } - -async fn testPut(channel: *Channel(i32), value: i32) void { +fn testPut(channel: *Channel(i32), value: i32) callconv(.Async) void { channel.put(value); } diff --git a/lib/std/event/future.zig b/lib/std/event/future.zig index 51a63e90ee..5de22c574c 100644 --- a/lib/std/event/future.zig +++ b/lib/std/event/future.zig @@ -34,7 +34,7 @@ pub fn Future(comptime T: type) type { /// Obtain the value. If it's not available, wait until it becomes /// available. /// Thread-safe. - pub async fn get(self: *Self) *T { + pub fn get(self: *Self) callconv(.Async) *T { if (@atomicLoad(Available, &self.available, .SeqCst) == .Finished) { return &self.data; } @@ -59,7 +59,7 @@ pub fn Future(comptime T: type) type { /// should start working on the data. /// It's not required to call start() before resolve() but it can be useful since /// this method is thread-safe. - pub async fn start(self: *Self) ?*T { + pub fn start(self: *Self) callconv(.Async) ?*T { const state = @cmpxchgStrong(Available, &self.available, .NotStarted, .Started, .SeqCst, .SeqCst) orelse return null; switch (state) { .Started => { diff --git a/lib/std/event/group.zig b/lib/std/event/group.zig index 5eebb7ffbc..155a9486b7 100644 --- a/lib/std/event/group.zig +++ b/lib/std/event/group.zig @@ -84,7 +84,7 @@ pub fn Group(comptime ReturnType: type) type { /// Wait for all the calls and promises of the group to complete. /// Thread-safe. /// Safe to call any number of times. - pub async fn wait(self: *Self) ReturnType { + pub fn wait(self: *Self) callconv(.Async) ReturnType { const held = self.lock.acquire(); defer held.release(); @@ -127,8 +127,7 @@ test "std.event.Group" { const handle = async testGroup(std.heap.page_allocator); } - -async fn testGroup(allocator: *Allocator) void { +fn testGroup(allocator: *Allocator) callconv(.Async) void { var count: usize = 0; var group = Group(void).init(allocator); var sleep_a_little_frame = async sleepALittle(&count); @@ -145,20 +144,17 @@ async fn testGroup(allocator: *Allocator) void { another.add(&something_that_fails_frame) catch @panic("memory"); testing.expectError(error.ItBroke, another.wait()); } - -async fn sleepALittle(count: *usize) void { +fn sleepALittle(count: *usize) callconv(.Async) void { std.time.sleep(1 * std.time.millisecond); _ = @atomicRmw(usize, count, .Add, 1, .SeqCst); } - -async fn increaseByTen(count: *usize) void { +fn increaseByTen(count: *usize) callconv(.Async) void { var i: usize = 0; while (i < 10) : (i += 1) { _ = @atomicRmw(usize, count, .Add, 1, .SeqCst); } } - -async fn doSomethingThatFails() anyerror!void {} -async fn somethingElse() anyerror!void { +fn doSomethingThatFails() callconv(.Async) anyerror!void {} +fn somethingElse() callconv(.Async) anyerror!void { return error.ItBroke; } diff --git a/lib/std/event/lock.zig b/lib/std/event/lock.zig index ff1f738c5e..179b881c9c 100644 --- a/lib/std/event/lock.zig +++ b/lib/std/event/lock.zig @@ -89,7 +89,7 @@ pub const Lock = struct { while (self.queue.get()) |node| resume node.data; } - pub async fn acquire(self: *Lock) Held { + pub fn acquire(self: *Lock) callconv(.Async) Held { var my_tick_node = Loop.NextTickNode.init(@frame()); errdefer _ = self.queue.remove(&my_tick_node); // TODO test canceling an acquire @@ -134,8 +134,7 @@ test "std.event.Lock" { const expected_result = [1]i32{3 * @intCast(i32, shared_test_data.len)} ** shared_test_data.len; testing.expectEqualSlices(i32, &expected_result, &shared_test_data); } - -async fn testLock(lock: *Lock) void { +fn testLock(lock: *Lock) callconv(.Async) void { var handle1 = async lockRunner(lock); var tick_node1 = Loop.NextTickNode{ .prev = undefined, @@ -167,8 +166,7 @@ async fn testLock(lock: *Lock) void { var shared_test_data = [1]i32{0} ** 10; var shared_test_index: usize = 0; - -async fn lockRunner(lock: *Lock) void { +fn lockRunner(lock: *Lock) callconv(.Async) void { suspend; // resumed by onNextTick var i: usize = 0; diff --git a/lib/std/event/locked.zig b/lib/std/event/locked.zig index 5e9c0ea10e..e921803447 100644 --- a/lib/std/event/locked.zig +++ b/lib/std/event/locked.zig @@ -31,7 +31,7 @@ pub fn Locked(comptime T: type) type { self.lock.deinit(); } - pub async fn acquire(self: *Self) HeldLock { + pub fn acquire(self: *Self) callconv(.Async) HeldLock { return HeldLock{ // TODO guaranteed allocation elision .held = self.lock.acquire(), diff --git a/lib/std/event/loop.zig b/lib/std/event/loop.zig index 15e7a3481c..e55d5116b9 100644 --- a/lib/std/event/loop.zig +++ b/lib/std/event/loop.zig @@ -503,7 +503,7 @@ pub const Loop = struct { } } - pub async fn bsdWaitKev(self: *Loop, ident: usize, filter: i16, fflags: u32) void { + pub fn bsdWaitKev(self: *Loop, ident: usize, filter: i16, fflags: u32) callconv(.Async) void { var resume_node = ResumeNode.Basic{ .base = ResumeNode{ .id = ResumeNode.Id.Basic, diff --git a/lib/std/event/rwlock.zig b/lib/std/event/rwlock.zig index 425088063f..7a47c27dd8 100644 --- a/lib/std/event/rwlock.zig +++ b/lib/std/event/rwlock.zig @@ -97,7 +97,7 @@ pub const RwLock = struct { while (self.reader_queue.get()) |node| resume node.data; } - pub async fn acquireRead(self: *RwLock) HeldRead { + pub fn acquireRead(self: *RwLock) callconv(.Async) HeldRead { _ = @atomicRmw(usize, &self.reader_lock_count, .Add, 1, .SeqCst); suspend { @@ -130,7 +130,7 @@ pub const RwLock = struct { return HeldRead{ .lock = self }; } - pub async fn acquireWrite(self: *RwLock) HeldWrite { + pub fn acquireWrite(self: *RwLock) callconv(.Async) HeldWrite { suspend { var my_tick_node = Loop.NextTickNode{ .data = @frame(), @@ -225,8 +225,7 @@ test "std.event.RwLock" { const expected_result = [1]i32{shared_it_count * @intCast(i32, shared_test_data.len)} ** shared_test_data.len; testing.expectEqualSlices(i32, expected_result, shared_test_data); } - -async fn testLock(allocator: *Allocator, lock: *RwLock) void { +fn testLock(allocator: *Allocator, lock: *RwLock) callconv(.Async) void { var read_nodes: [100]Loop.NextTickNode = undefined; for (read_nodes) |*read_node| { const frame = allocator.create(@Frame(readRunner)) catch @panic("memory"); @@ -259,8 +258,7 @@ const shared_it_count = 10; var shared_test_data = [1]i32{0} ** 10; var shared_test_index: usize = 0; var shared_count: usize = 0; - -async fn writeRunner(lock: *RwLock) void { +fn writeRunner(lock: *RwLock) callconv(.Async) void { suspend; // resumed by onNextTick var i: usize = 0; @@ -277,8 +275,7 @@ async fn writeRunner(lock: *RwLock) void { shared_test_index = 0; } } - -async fn readRunner(lock: *RwLock) void { +fn readRunner(lock: *RwLock) callconv(.Async) void { suspend; // resumed by onNextTick std.time.sleep(1); diff --git a/lib/std/event/rwlocked.zig b/lib/std/event/rwlocked.zig index 3f4c6ddbf8..9a569e8f1f 100644 --- a/lib/std/event/rwlocked.zig +++ b/lib/std/event/rwlocked.zig @@ -40,14 +40,14 @@ pub fn RwLocked(comptime T: type) type { self.lock.deinit(); } - pub async fn acquireRead(self: *Self) HeldReadLock { + pub fn acquireRead(self: *Self) callconv(.Async) HeldReadLock { return HeldReadLock{ .held = self.lock.acquireRead(), .value = &self.locked_data, }; } - pub async fn acquireWrite(self: *Self) HeldWriteLock { + pub fn acquireWrite(self: *Self) callconv(.Async) HeldWriteLock { return HeldWriteLock{ .held = self.lock.acquireWrite(), .value = &self.locked_data, diff --git a/lib/std/os/bits/darwin.zig b/lib/std/os/bits/darwin.zig index d116d6157a..8a596331a6 100644 --- a/lib/std/os/bits/darwin.zig +++ b/lib/std/os/bits/darwin.zig @@ -125,7 +125,7 @@ pub const empty_sigset = sigset_t(0); /// Renamed from `sigaction` to `Sigaction` to avoid conflict with function name. pub const Sigaction = extern struct { - handler: extern fn (c_int) void, + handler: fn (c_int) callconv(.C) void, sa_mask: sigset_t, sa_flags: c_int, }; diff --git a/lib/std/os/bits/dragonfly.zig b/lib/std/os/bits/dragonfly.zig index 6a6c871fc5..df22678323 100644 --- a/lib/std/os/bits/dragonfly.zig +++ b/lib/std/os/bits/dragonfly.zig @@ -458,9 +458,9 @@ pub const S_IFSOCK = 49152; pub const S_IFWHT = 57344; pub const S_IFMT = 61440; -pub const SIG_ERR = @intToPtr(extern fn (i32) void, maxInt(usize)); -pub const SIG_DFL = @intToPtr(extern fn (i32) void, 0); -pub const SIG_IGN = @intToPtr(extern fn (i32) void, 1); +pub const SIG_ERR = @intToPtr(fn (i32) callconv(.C) void, maxInt(usize)); +pub const SIG_DFL = @intToPtr(fn (i32) callconv(.C) void, 0); +pub const SIG_IGN = @intToPtr(fn (i32) callconv(.C) void, 1); pub const BADSIG = SIG_ERR; pub const SIG_BLOCK = 1; pub const SIG_UNBLOCK = 2; @@ -519,13 +519,13 @@ pub const sigset_t = extern struct { pub const sig_atomic_t = c_int; pub const Sigaction = extern struct { __sigaction_u: extern union { - __sa_handler: ?extern fn (c_int) void, - __sa_sigaction: ?extern fn (c_int, [*c]siginfo_t, ?*c_void) void, + __sa_handler: ?fn (c_int) callconv(.C) void, + __sa_sigaction: ?fn (c_int, [*c]siginfo_t, ?*c_void) callconv(.C) void, }, sa_flags: c_int, sa_mask: sigset_t, }; -pub const sig_t = [*c]extern fn (c_int) void; +pub const sig_t = [*c]fn (c_int) callconv(.C) void; pub const sigvec = extern struct { sv_handler: [*c]__sighandler_t, diff --git a/lib/std/os/bits/freebsd.zig b/lib/std/os/bits/freebsd.zig index 9999dca62f..eee7504366 100644 --- a/lib/std/os/bits/freebsd.zig +++ b/lib/std/os/bits/freebsd.zig @@ -725,16 +725,16 @@ pub const winsize = extern struct { const NSIG = 32; -pub const SIG_ERR = @intToPtr(extern fn (i32) void, maxInt(usize)); -pub const SIG_DFL = @intToPtr(extern fn (i32) void, 0); -pub const SIG_IGN = @intToPtr(extern fn (i32) void, 1); +pub const SIG_ERR = @intToPtr(fn (i32) callconv(.C) void, maxInt(usize)); +pub const SIG_DFL = @intToPtr(fn (i32) callconv(.C) void, 0); +pub const SIG_IGN = @intToPtr(fn (i32) callconv(.C) void, 1); /// Renamed from `sigaction` to `Sigaction` to avoid conflict with the syscall. pub const Sigaction = extern struct { /// signal handler __sigaction_u: extern union { - __sa_handler: extern fn (i32) void, - __sa_sigaction: extern fn (i32, *__siginfo, usize) void, + __sa_handler: fn (i32) callconv(.C) void, + __sa_sigaction: fn (i32, *__siginfo, usize) callconv(.C) void, }, /// see signal options diff --git a/lib/std/os/bits/linux.zig b/lib/std/os/bits/linux.zig index 750b487754..438be2299b 100644 --- a/lib/std/os/bits/linux.zig +++ b/lib/std/os/bits/linux.zig @@ -813,15 +813,15 @@ pub const app_mask: sigset_t = [2]u32{ 0xfffffffc, 0x7fffffff } ++ [_]u32{0xffff pub const k_sigaction = if (is_mips) extern struct { flags: usize, - sigaction: ?extern fn (i32, *siginfo_t, ?*c_void) void, + sigaction: ?fn (i32, *siginfo_t, ?*c_void) callconv(.C) void, mask: [4]u32, - restorer: extern fn () void, + restorer: fn () callconv(.C) void, } else extern struct { - sigaction: ?extern fn (i32, *siginfo_t, ?*c_void) void, + sigaction: ?fn (i32, *siginfo_t, ?*c_void) callconv(.C) void, flags: usize, - restorer: extern fn () void, + restorer: fn () callconv(.C) void, mask: [2]u32, }; @@ -831,7 +831,7 @@ pub const Sigaction = extern struct { sigaction: ?sigaction_fn, mask: sigset_t, flags: u32, - restorer: ?extern fn () void = null, + restorer: ?fn () callconv(.C) void = null, }; pub const SIG_ERR = @intToPtr(?Sigaction.sigaction_fn, maxInt(usize)); diff --git a/lib/std/os/linux.zig b/lib/std/os/linux.zig index 15f9bf9b62..6653293e59 100644 --- a/lib/std/os/linux.zig +++ b/lib/std/os/linux.zig @@ -599,7 +599,7 @@ pub fn flock(fd: fd_t, operation: i32) usize { var vdso_clock_gettime = @ptrCast(?*const c_void, init_vdso_clock_gettime); // We must follow the C calling convention when we call into the VDSO -const vdso_clock_gettime_ty = extern fn (i32, *timespec) usize; +const vdso_clock_gettime_ty = fn (i32, *timespec) callconv(.C) usize; pub fn clock_gettime(clk_id: i32, tp: *timespec) usize { if (@hasDecl(@This(), "VDSO_CGT_SYM")) { @@ -791,7 +791,7 @@ pub fn sigaction(sig: u6, noalias act: *const Sigaction, noalias oact: ?*Sigacti .sigaction = act.sigaction, .flags = act.flags | SA_RESTORER, .mask = undefined, - .restorer = @ptrCast(extern fn () void, restorer_fn), + .restorer = @ptrCast(fn () callconv(.C) void, restorer_fn), }; var ksa_old: k_sigaction = undefined; const ksa_mask_size = @sizeOf(@TypeOf(ksa_old.mask)); diff --git a/lib/std/os/linux/arm-eabi.zig b/lib/std/os/linux/arm-eabi.zig index c052aeab4e..352afeeb04 100644 --- a/lib/std/os/linux/arm-eabi.zig +++ b/lib/std/os/linux/arm-eabi.zig @@ -86,7 +86,7 @@ pub fn syscall6( } /// This matches the libc clone function. -pub extern fn clone(func: extern fn (arg: usize) u8, stack: usize, flags: u32, arg: usize, ptid: *i32, tls: usize, ctid: *i32) usize; +pub extern fn clone(func: fn (arg: usize) callconv(.C) u8, stack: usize, flags: u32, arg: usize, ptid: *i32, tls: usize, ctid: *i32) usize; pub fn restore() callconv(.Naked) void { return asm volatile ("svc #0" diff --git a/lib/std/os/linux/arm64.zig b/lib/std/os/linux/arm64.zig index 52ab3656e0..49548522ec 100644 --- a/lib/std/os/linux/arm64.zig +++ b/lib/std/os/linux/arm64.zig @@ -86,7 +86,7 @@ pub fn syscall6( } /// This matches the libc clone function. -pub extern fn clone(func: extern fn (arg: usize) u8, stack: usize, flags: u32, arg: usize, ptid: *i32, tls: usize, ctid: *i32) usize; +pub extern fn clone(func: fn (arg: usize) callconv(.C) u8, stack: usize, flags: u32, arg: usize, ptid: *i32, tls: usize, ctid: *i32) usize; pub const restore = restore_rt; diff --git a/lib/std/os/linux/i386.zig b/lib/std/os/linux/i386.zig index 0342f0754e..a4fdf8a346 100644 --- a/lib/std/os/linux/i386.zig +++ b/lib/std/os/linux/i386.zig @@ -106,7 +106,7 @@ pub fn socketcall(call: usize, args: [*]usize) usize { } /// This matches the libc clone function. -pub extern fn clone(func: extern fn (arg: usize) u8, stack: usize, flags: u32, arg: usize, ptid: *i32, tls: usize, ctid: *i32) usize; +pub extern fn clone(func: fn (arg: usize) callconv(.C) u8, stack: usize, flags: u32, arg: usize, ptid: *i32, tls: usize, ctid: *i32) usize; pub fn restore() callconv(.Naked) void { return asm volatile ("int $0x80" diff --git a/lib/std/os/linux/mips.zig b/lib/std/os/linux/mips.zig index 87c55db9f6..5b5c1e1f34 100644 --- a/lib/std/os/linux/mips.zig +++ b/lib/std/os/linux/mips.zig @@ -142,7 +142,7 @@ pub fn syscall6( } /// This matches the libc clone function. -pub extern fn clone(func: extern fn (arg: usize) u8, stack: usize, flags: u32, arg: usize, ptid: *i32, tls: usize, ctid: *i32) usize; +pub extern fn clone(func: fn (arg: usize) callconv(.C) u8, stack: usize, flags: u32, arg: usize, ptid: *i32, tls: usize, ctid: *i32) usize; pub fn restore() callconv(.Naked) void { return asm volatile ("syscall" diff --git a/lib/std/os/linux/riscv64.zig b/lib/std/os/linux/riscv64.zig index 3832bfbcca..39cc13f5b6 100644 --- a/lib/std/os/linux/riscv64.zig +++ b/lib/std/os/linux/riscv64.zig @@ -85,7 +85,7 @@ pub fn syscall6( ); } -pub extern fn clone(func: extern fn (arg: usize) u8, stack: usize, flags: u32, arg: usize, ptid: *i32, tls: usize, ctid: *i32) usize; +pub extern fn clone(func: fn (arg: usize) callconv(.C) u8, stack: usize, flags: u32, arg: usize, ptid: *i32, tls: usize, ctid: *i32) usize; pub const restore = restore_rt; diff --git a/lib/std/os/linux/x86_64.zig b/lib/std/os/linux/x86_64.zig index b60dcd80e9..33d2b66670 100644 --- a/lib/std/os/linux/x86_64.zig +++ b/lib/std/os/linux/x86_64.zig @@ -86,7 +86,7 @@ pub fn syscall6( } /// This matches the libc clone function. -pub extern fn clone(func: extern fn (arg: usize) u8, stack: usize, flags: usize, arg: usize, ptid: *i32, tls: usize, ctid: *i32) usize; +pub extern fn clone(func: fn (arg: usize) callconv(.C) u8, stack: usize, flags: usize, arg: usize, ptid: *i32, tls: usize, ctid: *i32) usize; pub const restore = restore_rt; diff --git a/lib/std/os/uefi/protocols/absolute_pointer_protocol.zig b/lib/std/os/uefi/protocols/absolute_pointer_protocol.zig index 1a46b9cf2c..a06a19c1a4 100644 --- a/lib/std/os/uefi/protocols/absolute_pointer_protocol.zig +++ b/lib/std/os/uefi/protocols/absolute_pointer_protocol.zig @@ -5,8 +5,8 @@ const Status = uefi.Status; /// Protocol for touchscreens pub const AbsolutePointerProtocol = extern struct { - _reset: extern fn (*const AbsolutePointerProtocol, bool) Status, - _get_state: extern fn (*const AbsolutePointerProtocol, *AbsolutePointerState) Status, + _reset: fn (*const AbsolutePointerProtocol, bool) callconv(.C) Status, + _get_state: fn (*const AbsolutePointerProtocol, *AbsolutePointerState) callconv(.C) Status, wait_for_input: Event, mode: *AbsolutePointerMode, diff --git a/lib/std/os/uefi/protocols/edid_override_protocol.zig b/lib/std/os/uefi/protocols/edid_override_protocol.zig index 2c37baa7a4..efe73982e9 100644 --- a/lib/std/os/uefi/protocols/edid_override_protocol.zig +++ b/lib/std/os/uefi/protocols/edid_override_protocol.zig @@ -5,7 +5,7 @@ const Status = uefi.Status; /// Override EDID information pub const EdidOverrideProtocol = extern struct { - _get_edid: extern fn (*const EdidOverrideProtocol, Handle, *u32, *usize, *?[*]u8) Status, + _get_edid: fn (*const EdidOverrideProtocol, Handle, *u32, *usize, *?[*]u8) callconv(.C) Status, /// Returns policy information and potentially a replacement EDID for the specified video output device. /// attributes must be align(4) diff --git a/lib/std/os/uefi/protocols/file_protocol.zig b/lib/std/os/uefi/protocols/file_protocol.zig index 4331d9a38c..eacd777008 100644 --- a/lib/std/os/uefi/protocols/file_protocol.zig +++ b/lib/std/os/uefi/protocols/file_protocol.zig @@ -5,16 +5,16 @@ const Status = uefi.Status; pub const FileProtocol = extern struct { revision: u64, - _open: extern fn (*const FileProtocol, **const FileProtocol, [*:0]const u16, u64, u64) Status, - _close: extern fn (*const FileProtocol) Status, - _delete: extern fn (*const FileProtocol) Status, - _read: extern fn (*const FileProtocol, *usize, [*]u8) Status, - _write: extern fn (*const FileProtocol, *usize, [*]const u8) Status, - _get_position: extern fn (*const FileProtocol, *u64) Status, - _set_position: extern fn (*const FileProtocol, *const u64) Status, - _get_info: extern fn (*const FileProtocol, *align(8) const Guid, *const usize, [*]u8) Status, - _set_info: extern fn (*const FileProtocol, *align(8) const Guid, usize, [*]const u8) Status, - _flush: extern fn (*const FileProtocol) Status, + _open: fn (*const FileProtocol, **const FileProtocol, [*:0]const u16, u64, u64) callconv(.C) Status, + _close: fn (*const FileProtocol) callconv(.C) Status, + _delete: fn (*const FileProtocol) callconv(.C) Status, + _read: fn (*const FileProtocol, *usize, [*]u8) callconv(.C) Status, + _write: fn (*const FileProtocol, *usize, [*]const u8) callconv(.C) Status, + _get_position: fn (*const FileProtocol, *u64) callconv(.C) Status, + _set_position: fn (*const FileProtocol, *const u64) callconv(.C) Status, + _get_info: fn (*const FileProtocol, *align(8) const Guid, *const usize, [*]u8) callconv(.C) Status, + _set_info: fn (*const FileProtocol, *align(8) const Guid, usize, [*]const u8) callconv(.C) Status, + _flush: fn (*const FileProtocol) callconv(.C) Status, pub fn open(self: *const FileProtocol, new_handle: **const FileProtocol, file_name: [*:0]const u16, open_mode: u64, attributes: u64) Status { return self._open(self, new_handle, file_name, open_mode, attributes); diff --git a/lib/std/os/uefi/protocols/graphics_output_protocol.zig b/lib/std/os/uefi/protocols/graphics_output_protocol.zig index 7370f537bf..1ceccce0bf 100644 --- a/lib/std/os/uefi/protocols/graphics_output_protocol.zig +++ b/lib/std/os/uefi/protocols/graphics_output_protocol.zig @@ -4,9 +4,9 @@ const Status = uefi.Status; /// Graphics output pub const GraphicsOutputProtocol = extern struct { - _query_mode: extern fn (*const GraphicsOutputProtocol, u32, *usize, **GraphicsOutputModeInformation) Status, - _set_mode: extern fn (*const GraphicsOutputProtocol, u32) Status, - _blt: extern fn (*const GraphicsOutputProtocol, ?[*]GraphicsOutputBltPixel, GraphicsOutputBltOperation, usize, usize, usize, usize, usize, usize, usize) Status, + _query_mode: fn (*const GraphicsOutputProtocol, u32, *usize, **GraphicsOutputModeInformation) callconv(.C) Status, + _set_mode: fn (*const GraphicsOutputProtocol, u32) callconv(.C) Status, + _blt: fn (*const GraphicsOutputProtocol, ?[*]GraphicsOutputBltPixel, GraphicsOutputBltOperation, usize, usize, usize, usize, usize, usize, usize) callconv(.C) Status, mode: *GraphicsOutputProtocolMode, /// Returns information for an available graphics mode that the graphics device and the set of active video output devices supports. diff --git a/lib/std/os/uefi/protocols/hii_database_protocol.zig b/lib/std/os/uefi/protocols/hii_database_protocol.zig index c79f693f6f..e34f72c2f3 100644 --- a/lib/std/os/uefi/protocols/hii_database_protocol.zig +++ b/lib/std/os/uefi/protocols/hii_database_protocol.zig @@ -6,10 +6,10 @@ const hii = uefi.protocols.hii; /// Database manager for HII-related data structures. pub const HIIDatabaseProtocol = extern struct { _new_package_list: Status, // TODO - _remove_package_list: extern fn (*const HIIDatabaseProtocol, hii.HIIHandle) Status, - _update_package_list: extern fn (*const HIIDatabaseProtocol, hii.HIIHandle, *const hii.HIIPackageList) Status, - _list_package_lists: extern fn (*const HIIDatabaseProtocol, u8, ?*const Guid, *usize, [*]hii.HIIHandle) Status, - _export_package_lists: extern fn (*const HIIDatabaseProtocol, ?hii.HIIHandle, *usize, *hii.HIIPackageList) Status, + _remove_package_list: fn (*const HIIDatabaseProtocol, hii.HIIHandle) callconv(.C) Status, + _update_package_list: fn (*const HIIDatabaseProtocol, hii.HIIHandle, *const hii.HIIPackageList) callconv(.C) Status, + _list_package_lists: fn (*const HIIDatabaseProtocol, u8, ?*const Guid, *usize, [*]hii.HIIHandle) callconv(.C) Status, + _export_package_lists: fn (*const HIIDatabaseProtocol, ?hii.HIIHandle, *usize, *hii.HIIPackageList) callconv(.C) Status, _register_package_notify: Status, // TODO _unregister_package_notify: Status, // TODO _find_keyboard_layouts: Status, // TODO diff --git a/lib/std/os/uefi/protocols/hii_popup_protocol.zig b/lib/std/os/uefi/protocols/hii_popup_protocol.zig index 96afe21fbc..2e4f621b41 100644 --- a/lib/std/os/uefi/protocols/hii_popup_protocol.zig +++ b/lib/std/os/uefi/protocols/hii_popup_protocol.zig @@ -6,7 +6,7 @@ const hii = uefi.protocols.hii; /// Display a popup window pub const HIIPopupProtocol = extern struct { revision: u64, - _create_popup: extern fn (*const HIIPopupProtocol, HIIPopupStyle, HIIPopupType, hii.HIIHandle, u16, ?*HIIPopupSelection) Status, + _create_popup: fn (*const HIIPopupProtocol, HIIPopupStyle, HIIPopupType, hii.HIIHandle, u16, ?*HIIPopupSelection) callconv(.C) Status, /// Displays a popup window. pub fn createPopup(self: *const HIIPopupProtocol, style: HIIPopupStyle, popup_type: HIIPopupType, handle: hii.HIIHandle, msg: u16, user_selection: ?*HIIPopupSelection) Status { diff --git a/lib/std/os/uefi/protocols/ip6_config_protocol.zig b/lib/std/os/uefi/protocols/ip6_config_protocol.zig index 89ff39e8d1..99ba76aa17 100644 --- a/lib/std/os/uefi/protocols/ip6_config_protocol.zig +++ b/lib/std/os/uefi/protocols/ip6_config_protocol.zig @@ -4,10 +4,10 @@ const Event = uefi.Event; const Status = uefi.Status; pub const Ip6ConfigProtocol = extern struct { - _set_data: extern fn (*const Ip6ConfigProtocol, Ip6ConfigDataType, usize, *const c_void) Status, - _get_data: extern fn (*const Ip6ConfigProtocol, Ip6ConfigDataType, *usize, ?*const c_void) Status, - _register_data_notify: extern fn (*const Ip6ConfigProtocol, Ip6ConfigDataType, Event) Status, - _unregister_data_notify: extern fn (*const Ip6ConfigProtocol, Ip6ConfigDataType, Event) Status, + _set_data: fn (*const Ip6ConfigProtocol, Ip6ConfigDataType, usize, *const c_void) callconv(.C) Status, + _get_data: fn (*const Ip6ConfigProtocol, Ip6ConfigDataType, *usize, ?*const c_void) callconv(.C) Status, + _register_data_notify: fn (*const Ip6ConfigProtocol, Ip6ConfigDataType, Event) callconv(.C) Status, + _unregister_data_notify: fn (*const Ip6ConfigProtocol, Ip6ConfigDataType, Event) callconv(.C) Status, pub fn setData(self: *const Ip6ConfigProtocol, data_type: Ip6ConfigDataType, data_size: usize, data: *const c_void) Status { return self._set_data(self, data_type, data_size, data); diff --git a/lib/std/os/uefi/protocols/ip6_protocol.zig b/lib/std/os/uefi/protocols/ip6_protocol.zig index f9a5c23d3c..b39ae60b2a 100644 --- a/lib/std/os/uefi/protocols/ip6_protocol.zig +++ b/lib/std/os/uefi/protocols/ip6_protocol.zig @@ -7,15 +7,15 @@ const ManagedNetworkConfigData = uefi.protocols.ManagedNetworkConfigData; const SimpleNetworkMode = uefi.protocols.SimpleNetworkMode; pub const Ip6Protocol = extern struct { - _get_mode_data: extern fn (*const Ip6Protocol, ?*Ip6ModeData, ?*ManagedNetworkConfigData, ?*SimpleNetworkMode) Status, - _configure: extern fn (*const Ip6Protocol, ?*const Ip6ConfigData) Status, - _groups: extern fn (*const Ip6Protocol, bool, ?*const Ip6Address) Status, - _routes: extern fn (*const Ip6Protocol, bool, ?*const Ip6Address, u8, ?*const Ip6Address) Status, - _neighbors: extern fn (*const Ip6Protocol, bool, *const Ip6Address, ?*const MacAddress, u32, bool) Status, - _transmit: extern fn (*const Ip6Protocol, *Ip6CompletionToken) Status, - _receive: extern fn (*const Ip6Protocol, *Ip6CompletionToken) Status, - _cancel: extern fn (*const Ip6Protocol, ?*Ip6CompletionToken) Status, - _poll: extern fn (*const Ip6Protocol) Status, + _get_mode_data: fn (*const Ip6Protocol, ?*Ip6ModeData, ?*ManagedNetworkConfigData, ?*SimpleNetworkMode) callconv(.C) Status, + _configure: fn (*const Ip6Protocol, ?*const Ip6ConfigData) callconv(.C) Status, + _groups: fn (*const Ip6Protocol, bool, ?*const Ip6Address) callconv(.C) Status, + _routes: fn (*const Ip6Protocol, bool, ?*const Ip6Address, u8, ?*const Ip6Address) callconv(.C) Status, + _neighbors: fn (*const Ip6Protocol, bool, *const Ip6Address, ?*const MacAddress, u32, bool) callconv(.C) Status, + _transmit: fn (*const Ip6Protocol, *Ip6CompletionToken) callconv(.C) Status, + _receive: fn (*const Ip6Protocol, *Ip6CompletionToken) callconv(.C) Status, + _cancel: fn (*const Ip6Protocol, ?*Ip6CompletionToken) callconv(.C) Status, + _poll: fn (*const Ip6Protocol) callconv(.C) Status, /// Gets the current operational settings for this instance of the EFI IPv6 Protocol driver. pub fn getModeData(self: *const Ip6Protocol, ip6_mode_data: ?*Ip6ModeData, mnp_config_data: ?*ManagedNetworkConfigData, snp_mode_data: ?*SimpleNetworkMode) Status { diff --git a/lib/std/os/uefi/protocols/ip6_service_binding_protocol.zig b/lib/std/os/uefi/protocols/ip6_service_binding_protocol.zig index 030ae5cae2..97ab1a431c 100644 --- a/lib/std/os/uefi/protocols/ip6_service_binding_protocol.zig +++ b/lib/std/os/uefi/protocols/ip6_service_binding_protocol.zig @@ -4,8 +4,8 @@ const Guid = uefi.Guid; const Status = uefi.Status; pub const Ip6ServiceBindingProtocol = extern struct { - _create_child: extern fn (*const Ip6ServiceBindingProtocol, *?Handle) Status, - _destroy_child: extern fn (*const Ip6ServiceBindingProtocol, Handle) Status, + _create_child: fn (*const Ip6ServiceBindingProtocol, *?Handle) callconv(.C) Status, + _destroy_child: fn (*const Ip6ServiceBindingProtocol, Handle) callconv(.C) Status, pub fn createChild(self: *const Ip6ServiceBindingProtocol, handle: *?Handle) Status { return self._create_child(self, handle); diff --git a/lib/std/os/uefi/protocols/loaded_image_protocol.zig b/lib/std/os/uefi/protocols/loaded_image_protocol.zig index cff2bdccc0..b8afcb1063 100644 --- a/lib/std/os/uefi/protocols/loaded_image_protocol.zig +++ b/lib/std/os/uefi/protocols/loaded_image_protocol.zig @@ -19,7 +19,7 @@ pub const LoadedImageProtocol = extern struct { image_size: u64, image_code_type: MemoryType, image_data_type: MemoryType, - _unload: extern fn (*const LoadedImageProtocol, Handle) Status, + _unload: fn (*const LoadedImageProtocol, Handle) callconv(.C) Status, /// Unloads an image from memory. pub fn unload(self: *const LoadedImageProtocol, handle: Handle) Status { diff --git a/lib/std/os/uefi/protocols/managed_network_protocol.zig b/lib/std/os/uefi/protocols/managed_network_protocol.zig index 60dc6996ad..34ef6c40fa 100644 --- a/lib/std/os/uefi/protocols/managed_network_protocol.zig +++ b/lib/std/os/uefi/protocols/managed_network_protocol.zig @@ -7,14 +7,14 @@ const SimpleNetworkMode = uefi.protocols.SimpleNetworkMode; const MacAddress = uefi.protocols.MacAddress; pub const ManagedNetworkProtocol = extern struct { - _get_mode_data: extern fn (*const ManagedNetworkProtocol, ?*ManagedNetworkConfigData, ?*SimpleNetworkMode) Status, - _configure: extern fn (*const ManagedNetworkProtocol, ?*const ManagedNetworkConfigData) Status, - _mcast_ip_to_mac: extern fn (*const ManagedNetworkProtocol, bool, *const c_void, *MacAddress) Status, - _groups: extern fn (*const ManagedNetworkProtocol, bool, ?*const MacAddress) Status, - _transmit: extern fn (*const ManagedNetworkProtocol, *const ManagedNetworkCompletionToken) Status, - _receive: extern fn (*const ManagedNetworkProtocol, *const ManagedNetworkCompletionToken) Status, - _cancel: extern fn (*const ManagedNetworkProtocol, ?*const ManagedNetworkCompletionToken) Status, - _poll: extern fn (*const ManagedNetworkProtocol) usize, + _get_mode_data: fn (*const ManagedNetworkProtocol, ?*ManagedNetworkConfigData, ?*SimpleNetworkMode) callconv(.C) Status, + _configure: fn (*const ManagedNetworkProtocol, ?*const ManagedNetworkConfigData) callconv(.C) Status, + _mcast_ip_to_mac: fn (*const ManagedNetworkProtocol, bool, *const c_void, *MacAddress) callconv(.C) Status, + _groups: fn (*const ManagedNetworkProtocol, bool, ?*const MacAddress) callconv(.C) Status, + _transmit: fn (*const ManagedNetworkProtocol, *const ManagedNetworkCompletionToken) callconv(.C) Status, + _receive: fn (*const ManagedNetworkProtocol, *const ManagedNetworkCompletionToken) callconv(.C) Status, + _cancel: fn (*const ManagedNetworkProtocol, ?*const ManagedNetworkCompletionToken) callconv(.C) Status, + _poll: fn (*const ManagedNetworkProtocol) callconv(.C) usize, /// Returns the operational parameters for the current MNP child driver. /// May also support returning the underlying SNP driver mode data. diff --git a/lib/std/os/uefi/protocols/managed_network_service_binding_protocol.zig b/lib/std/os/uefi/protocols/managed_network_service_binding_protocol.zig index ea8bd470c3..e9657e4456 100644 --- a/lib/std/os/uefi/protocols/managed_network_service_binding_protocol.zig +++ b/lib/std/os/uefi/protocols/managed_network_service_binding_protocol.zig @@ -4,8 +4,8 @@ const Guid = uefi.Guid; const Status = uefi.Status; pub const ManagedNetworkServiceBindingProtocol = extern struct { - _create_child: extern fn (*const ManagedNetworkServiceBindingProtocol, *?Handle) Status, - _destroy_child: extern fn (*const ManagedNetworkServiceBindingProtocol, Handle) Status, + _create_child: fn (*const ManagedNetworkServiceBindingProtocol, *?Handle) callconv(.C) Status, + _destroy_child: fn (*const ManagedNetworkServiceBindingProtocol, Handle) callconv(.C) Status, pub fn createChild(self: *const ManagedNetworkServiceBindingProtocol, handle: *?Handle) Status { return self._create_child(self, handle); diff --git a/lib/std/os/uefi/protocols/rng_protocol.zig b/lib/std/os/uefi/protocols/rng_protocol.zig index 4d5dd496af..a32b202f44 100644 --- a/lib/std/os/uefi/protocols/rng_protocol.zig +++ b/lib/std/os/uefi/protocols/rng_protocol.zig @@ -4,8 +4,8 @@ const Status = uefi.Status; /// Random Number Generator protocol pub const RNGProtocol = extern struct { - _get_info: extern fn (*const RNGProtocol, *usize, [*]align(8) Guid) Status, - _get_rng: extern fn (*const RNGProtocol, ?*align(8) const Guid, usize, [*]u8) Status, + _get_info: fn (*const RNGProtocol, *usize, [*]align(8) Guid) callconv(.C) Status, + _get_rng: fn (*const RNGProtocol, ?*align(8) const Guid, usize, [*]u8) callconv(.C) Status, /// Returns information about the random number generation implementation. pub fn getInfo(self: *const RNGProtocol, list_size: *usize, list: [*]align(8) Guid) Status { diff --git a/lib/std/os/uefi/protocols/simple_file_system_protocol.zig b/lib/std/os/uefi/protocols/simple_file_system_protocol.zig index 31da02595a..119c1e6587 100644 --- a/lib/std/os/uefi/protocols/simple_file_system_protocol.zig +++ b/lib/std/os/uefi/protocols/simple_file_system_protocol.zig @@ -5,7 +5,7 @@ const Status = uefi.Status; pub const SimpleFileSystemProtocol = extern struct { revision: u64, - _open_volume: extern fn (*const SimpleFileSystemProtocol, **const FileProtocol) Status, + _open_volume: fn (*const SimpleFileSystemProtocol, **const FileProtocol) callconv(.C) Status, pub fn openVolume(self: *const SimpleFileSystemProtocol, root: **const FileProtocol) Status { return self._open_volume(self, root); diff --git a/lib/std/os/uefi/protocols/simple_network_protocol.zig b/lib/std/os/uefi/protocols/simple_network_protocol.zig index a0d85b06d1..ac7446036e 100644 --- a/lib/std/os/uefi/protocols/simple_network_protocol.zig +++ b/lib/std/os/uefi/protocols/simple_network_protocol.zig @@ -5,19 +5,19 @@ const Status = uefi.Status; pub const SimpleNetworkProtocol = extern struct { revision: u64, - _start: extern fn (*const SimpleNetworkProtocol) Status, - _stop: extern fn (*const SimpleNetworkProtocol) Status, - _initialize: extern fn (*const SimpleNetworkProtocol, usize, usize) Status, - _reset: extern fn (*const SimpleNetworkProtocol, bool) Status, - _shutdown: extern fn (*const SimpleNetworkProtocol) Status, - _receive_filters: extern fn (*const SimpleNetworkProtocol, SimpleNetworkReceiveFilter, SimpleNetworkReceiveFilter, bool, usize, ?[*]const MacAddress) Status, - _station_address: extern fn (*const SimpleNetworkProtocol, bool, ?*const MacAddress) Status, - _statistics: extern fn (*const SimpleNetworkProtocol, bool, ?*usize, ?*NetworkStatistics) Status, - _mcast_ip_to_mac: extern fn (*const SimpleNetworkProtocol, bool, *const c_void, *MacAddress) Status, - _nvdata: extern fn (*const SimpleNetworkProtocol, bool, usize, usize, [*]u8) Status, - _get_status: extern fn (*const SimpleNetworkProtocol, *SimpleNetworkInterruptStatus, ?*?[*]u8) Status, - _transmit: extern fn (*const SimpleNetworkProtocol, usize, usize, [*]const u8, ?*const MacAddress, ?*const MacAddress, ?*const u16) Status, - _receive: extern fn (*const SimpleNetworkProtocol, ?*usize, *usize, [*]u8, ?*MacAddress, ?*MacAddress, ?*u16) Status, + _start: fn (*const SimpleNetworkProtocol) callconv(.C) Status, + _stop: fn (*const SimpleNetworkProtocol) callconv(.C) Status, + _initialize: fn (*const SimpleNetworkProtocol, usize, usize) callconv(.C) Status, + _reset: fn (*const SimpleNetworkProtocol, bool) callconv(.C) Status, + _shutdown: fn (*const SimpleNetworkProtocol) callconv(.C) Status, + _receive_filters: fn (*const SimpleNetworkProtocol, SimpleNetworkReceiveFilter, SimpleNetworkReceiveFilter, bool, usize, ?[*]const MacAddress) callconv(.C) Status, + _station_address: fn (*const SimpleNetworkProtocol, bool, ?*const MacAddress) callconv(.C) Status, + _statistics: fn (*const SimpleNetworkProtocol, bool, ?*usize, ?*NetworkStatistics) callconv(.C) Status, + _mcast_ip_to_mac: fn (*const SimpleNetworkProtocol, bool, *const c_void, *MacAddress) callconv(.C) Status, + _nvdata: fn (*const SimpleNetworkProtocol, bool, usize, usize, [*]u8) callconv(.C) Status, + _get_status: fn (*const SimpleNetworkProtocol, *SimpleNetworkInterruptStatus, ?*?[*]u8) callconv(.C) Status, + _transmit: fn (*const SimpleNetworkProtocol, usize, usize, [*]const u8, ?*const MacAddress, ?*const MacAddress, ?*const u16) callconv(.C) Status, + _receive: fn (*const SimpleNetworkProtocol, ?*usize, *usize, [*]u8, ?*MacAddress, ?*MacAddress, ?*u16) callconv(.C) Status, wait_for_packet: Event, mode: *SimpleNetworkMode, diff --git a/lib/std/os/uefi/protocols/simple_pointer_protocol.zig b/lib/std/os/uefi/protocols/simple_pointer_protocol.zig index 2d1c7d4504..d217ab5930 100644 --- a/lib/std/os/uefi/protocols/simple_pointer_protocol.zig +++ b/lib/std/os/uefi/protocols/simple_pointer_protocol.zig @@ -5,8 +5,8 @@ const Status = uefi.Status; /// Protocol for mice pub const SimplePointerProtocol = struct { - _reset: extern fn (*const SimplePointerProtocol, bool) Status, - _get_state: extern fn (*const SimplePointerProtocol, *SimplePointerState) Status, + _reset: fn (*const SimplePointerProtocol, bool) callconv(.C) Status, + _get_state: fn (*const SimplePointerProtocol, *SimplePointerState) callconv(.C) Status, wait_for_input: Event, mode: *SimplePointerMode, diff --git a/lib/std/os/uefi/protocols/simple_text_input_ex_protocol.zig b/lib/std/os/uefi/protocols/simple_text_input_ex_protocol.zig index c361ffa9a1..4a2b098e61 100644 --- a/lib/std/os/uefi/protocols/simple_text_input_ex_protocol.zig +++ b/lib/std/os/uefi/protocols/simple_text_input_ex_protocol.zig @@ -5,12 +5,12 @@ const Status = uefi.Status; /// Character input devices, e.g. Keyboard pub const SimpleTextInputExProtocol = extern struct { - _reset: extern fn (*const SimpleTextInputExProtocol, bool) Status, - _read_key_stroke_ex: extern fn (*const SimpleTextInputExProtocol, *KeyData) Status, + _reset: fn (*const SimpleTextInputExProtocol, bool) callconv(.C) Status, + _read_key_stroke_ex: fn (*const SimpleTextInputExProtocol, *KeyData) callconv(.C) Status, wait_for_key_ex: Event, - _set_state: extern fn (*const SimpleTextInputExProtocol, *const u8) Status, - _register_key_notify: extern fn (*const SimpleTextInputExProtocol, *const KeyData, extern fn (*const KeyData) usize, **c_void) Status, - _unregister_key_notify: extern fn (*const SimpleTextInputExProtocol, *const c_void) Status, + _set_state: fn (*const SimpleTextInputExProtocol, *const u8) callconv(.C) Status, + _register_key_notify: fn (*const SimpleTextInputExProtocol, *const KeyData, fn (*const KeyData) callconv(.C) usize, **c_void) callconv(.C) Status, + _unregister_key_notify: fn (*const SimpleTextInputExProtocol, *const c_void) callconv(.C) Status, /// Resets the input device hardware. pub fn reset(self: *const SimpleTextInputExProtocol, verify: bool) Status { @@ -28,7 +28,7 @@ pub const SimpleTextInputExProtocol = extern struct { } /// Register a notification function for a particular keystroke for the input device. - pub fn registerKeyNotify(self: *const SimpleTextInputExProtocol, key_data: *const KeyData, notify: extern fn (*const KeyData) usize, handle: **c_void) Status { + pub fn registerKeyNotify(self: *const SimpleTextInputExProtocol, key_data: *const KeyData, notify: fn (*const KeyData) callconv(.C) usize, handle: **c_void) Status { return self._register_key_notify(self, key_data, notify, handle); } diff --git a/lib/std/os/uefi/protocols/simple_text_input_protocol.zig b/lib/std/os/uefi/protocols/simple_text_input_protocol.zig index fdae001145..58ed071331 100644 --- a/lib/std/os/uefi/protocols/simple_text_input_protocol.zig +++ b/lib/std/os/uefi/protocols/simple_text_input_protocol.zig @@ -6,8 +6,8 @@ const Status = uefi.Status; /// Character input devices, e.g. Keyboard pub const SimpleTextInputProtocol = extern struct { - _reset: extern fn (*const SimpleTextInputProtocol, bool) usize, - _read_key_stroke: extern fn (*const SimpleTextInputProtocol, *InputKey) Status, + _reset: fn (*const SimpleTextInputProtocol, bool) callconv(.C) usize, + _read_key_stroke: fn (*const SimpleTextInputProtocol, *InputKey) callconv(.C) Status, wait_for_key: Event, /// Resets the input device hardware. diff --git a/lib/std/os/uefi/protocols/simple_text_output_protocol.zig b/lib/std/os/uefi/protocols/simple_text_output_protocol.zig index 09f3cb1cd2..84f540cb78 100644 --- a/lib/std/os/uefi/protocols/simple_text_output_protocol.zig +++ b/lib/std/os/uefi/protocols/simple_text_output_protocol.zig @@ -4,15 +4,15 @@ const Status = uefi.Status; /// Character output devices pub const SimpleTextOutputProtocol = extern struct { - _reset: extern fn (*const SimpleTextOutputProtocol, bool) Status, - _output_string: extern fn (*const SimpleTextOutputProtocol, [*:0]const u16) Status, - _test_string: extern fn (*const SimpleTextOutputProtocol, [*:0]const u16) Status, - _query_mode: extern fn (*const SimpleTextOutputProtocol, usize, *usize, *usize) Status, - _set_mode: extern fn (*const SimpleTextOutputProtocol, usize) Status, - _set_attribute: extern fn (*const SimpleTextOutputProtocol, usize) Status, - _clear_screen: extern fn (*const SimpleTextOutputProtocol) Status, - _set_cursor_position: extern fn (*const SimpleTextOutputProtocol, usize, usize) Status, - _enable_cursor: extern fn (*const SimpleTextOutputProtocol, bool) Status, + _reset: fn (*const SimpleTextOutputProtocol, bool) callconv(.C) Status, + _output_string: fn (*const SimpleTextOutputProtocol, [*:0]const u16) callconv(.C) Status, + _test_string: fn (*const SimpleTextOutputProtocol, [*:0]const u16) callconv(.C) Status, + _query_mode: fn (*const SimpleTextOutputProtocol, usize, *usize, *usize) callconv(.C) Status, + _set_mode: fn (*const SimpleTextOutputProtocol, usize) callconv(.C) Status, + _set_attribute: fn (*const SimpleTextOutputProtocol, usize) callconv(.C) Status, + _clear_screen: fn (*const SimpleTextOutputProtocol) callconv(.C) Status, + _set_cursor_position: fn (*const SimpleTextOutputProtocol, usize, usize) callconv(.C) Status, + _enable_cursor: fn (*const SimpleTextOutputProtocol, bool) callconv(.C) Status, mode: *SimpleTextOutputMode, /// Resets the text output device hardware. diff --git a/lib/std/os/uefi/protocols/udp6_protocol.zig b/lib/std/os/uefi/protocols/udp6_protocol.zig index f0ab2789f3..46c76beaa6 100644 --- a/lib/std/os/uefi/protocols/udp6_protocol.zig +++ b/lib/std/os/uefi/protocols/udp6_protocol.zig @@ -9,13 +9,13 @@ const ManagedNetworkConfigData = uefi.protocols.ManagedNetworkConfigData; const SimpleNetworkMode = uefi.protocols.SimpleNetworkMode; pub const Udp6Protocol = extern struct { - _get_mode_data: extern fn (*const Udp6Protocol, ?*Udp6ConfigData, ?*Ip6ModeData, ?*ManagedNetworkConfigData, ?*SimpleNetworkMode) Status, - _configure: extern fn (*const Udp6Protocol, ?*const Udp6ConfigData) Status, - _groups: extern fn (*const Udp6Protocol, bool, ?*const Ip6Address) Status, - _transmit: extern fn (*const Udp6Protocol, *Udp6CompletionToken) Status, - _receive: extern fn (*const Udp6Protocol, *Udp6CompletionToken) Status, - _cancel: extern fn (*const Udp6Protocol, ?*Udp6CompletionToken) Status, - _poll: extern fn (*const Udp6Protocol) Status, + _get_mode_data: fn (*const Udp6Protocol, ?*Udp6ConfigData, ?*Ip6ModeData, ?*ManagedNetworkConfigData, ?*SimpleNetworkMode) callconv(.C) Status, + _configure: fn (*const Udp6Protocol, ?*const Udp6ConfigData) callconv(.C) Status, + _groups: fn (*const Udp6Protocol, bool, ?*const Ip6Address) callconv(.C) Status, + _transmit: fn (*const Udp6Protocol, *Udp6CompletionToken) callconv(.C) Status, + _receive: fn (*const Udp6Protocol, *Udp6CompletionToken) callconv(.C) Status, + _cancel: fn (*const Udp6Protocol, ?*Udp6CompletionToken) callconv(.C) Status, + _poll: fn (*const Udp6Protocol) callconv(.C) Status, pub fn getModeData(self: *const Udp6Protocol, udp6_config_data: ?*Udp6ConfigData, ip6_mode_data: ?*Ip6ModeData, mnp_config_data: ?*ManagedNetworkConfigData, snp_mode_data: ?*SimpleNetworkMode) Status { return self._get_mode_data(self, udp6_config_data, ip6_mode_data, mnp_config_data, snp_mode_data); diff --git a/lib/std/os/uefi/protocols/udp6_service_binding_protocol.zig b/lib/std/os/uefi/protocols/udp6_service_binding_protocol.zig index 9a7a67807c..811692adc3 100644 --- a/lib/std/os/uefi/protocols/udp6_service_binding_protocol.zig +++ b/lib/std/os/uefi/protocols/udp6_service_binding_protocol.zig @@ -4,8 +4,8 @@ const Guid = uefi.Guid; const Status = uefi.Status; pub const Udp6ServiceBindingProtocol = extern struct { - _create_child: extern fn (*const Udp6ServiceBindingProtocol, *?Handle) Status, - _destroy_child: extern fn (*const Udp6ServiceBindingProtocol, Handle) Status, + _create_child: fn (*const Udp6ServiceBindingProtocol, *?Handle) callconv(.C) Status, + _destroy_child: fn (*const Udp6ServiceBindingProtocol, Handle) callconv(.C) Status, pub fn createChild(self: *const Udp6ServiceBindingProtocol, handle: *?Handle) Status { return self._create_child(self, handle); diff --git a/lib/std/os/uefi/tables/boot_services.zig b/lib/std/os/uefi/tables/boot_services.zig index 1969b46403..a1d2c1ca59 100644 --- a/lib/std/os/uefi/tables/boot_services.zig +++ b/lib/std/os/uefi/tables/boot_services.zig @@ -21,117 +21,117 @@ pub const BootServices = extern struct { hdr: TableHeader, /// Raises a task's priority level and returns its previous level. - raiseTpl: extern fn (usize) usize, + raiseTpl: fn (usize) callconv(.C) usize, /// Restores a task's priority level to its previous value. - restoreTpl: extern fn (usize) void, + restoreTpl: fn (usize) callconv(.C) void, /// Allocates memory pages from the system. - allocatePages: extern fn (AllocateType, MemoryType, usize, *[*]align(4096) u8) Status, + allocatePages: fn (AllocateType, MemoryType, usize, *[*]align(4096) u8) callconv(.C) Status, /// Frees memory pages. - freePages: extern fn ([*]align(4096) u8, usize) Status, + freePages: fn ([*]align(4096) u8, usize) callconv(.C) Status, /// Returns the current memory map. - getMemoryMap: extern fn (*usize, [*]MemoryDescriptor, *usize, *usize, *u32) Status, + getMemoryMap: fn (*usize, [*]MemoryDescriptor, *usize, *usize, *u32) callconv(.C) Status, /// Allocates pool memory. - allocatePool: extern fn (MemoryType, usize, *[*]align(8) u8) Status, + allocatePool: fn (MemoryType, usize, *[*]align(8) u8) callconv(.C) Status, /// Returns pool memory to the system. - freePool: extern fn ([*]align(8) u8) Status, + freePool: fn ([*]align(8) u8) callconv(.C) Status, /// Creates an event. - createEvent: extern fn (u32, usize, ?extern fn (Event, ?*c_void) void, ?*const c_void, *Event) Status, + createEvent: fn (u32, usize, ?fn (Event, ?*c_void) callconv(.C) void, ?*const c_void, *Event) callconv(.C) Status, /// Sets the type of timer and the trigger time for a timer event. - setTimer: extern fn (Event, TimerDelay, u64) Status, + setTimer: fn (Event, TimerDelay, u64) callconv(.C) Status, /// Stops execution until an event is signaled. - waitForEvent: extern fn (usize, [*]const Event, *usize) Status, + waitForEvent: fn (usize, [*]const Event, *usize) callconv(.C) Status, /// Signals an event. - signalEvent: extern fn (Event) Status, + signalEvent: fn (Event) callconv(.C) Status, /// Closes an event. - closeEvent: extern fn (Event) Status, + closeEvent: fn (Event) callconv(.C) Status, /// Checks whether an event is in the signaled state. - checkEvent: extern fn (Event) Status, + checkEvent: fn (Event) callconv(.C) Status, installProtocolInterface: Status, // TODO reinstallProtocolInterface: Status, // TODO uninstallProtocolInterface: Status, // TODO /// Queries a handle to determine if it supports a specified protocol. - handleProtocol: extern fn (Handle, *align(8) const Guid, *?*c_void) Status, + handleProtocol: fn (Handle, *align(8) const Guid, *?*c_void) callconv(.C) Status, reserved: *c_void, registerProtocolNotify: Status, // TODO /// Returns an array of handles that support a specified protocol. - locateHandle: extern fn (LocateSearchType, ?*align(8) const Guid, ?*const c_void, *usize, [*]Handle) Status, + locateHandle: fn (LocateSearchType, ?*align(8) const Guid, ?*const c_void, *usize, [*]Handle) callconv(.C) Status, locateDevicePath: Status, // TODO installConfigurationTable: Status, // TODO /// Loads an EFI image into memory. - loadImage: extern fn (bool, Handle, ?*const DevicePathProtocol, ?[*]const u8, usize, *?Handle) Status, + loadImage: fn (bool, Handle, ?*const DevicePathProtocol, ?[*]const u8, usize, *?Handle) callconv(.C) Status, /// Transfers control to a loaded image's entry point. - startImage: extern fn (Handle, ?*usize, ?*[*]u16) Status, + startImage: fn (Handle, ?*usize, ?*[*]u16) callconv(.C) Status, /// Terminates a loaded EFI image and returns control to boot services. - exit: extern fn (Handle, Status, usize, ?*const c_void) Status, + exit: fn (Handle, Status, usize, ?*const c_void) callconv(.C) Status, /// Unloads an image. - unloadImage: extern fn (Handle) Status, + unloadImage: fn (Handle) callconv(.C) Status, /// Terminates all boot services. - exitBootServices: extern fn (Handle, usize) Status, + exitBootServices: fn (Handle, usize) callconv(.C) Status, /// Returns a monotonically increasing count for the platform. - getNextMonotonicCount: extern fn (*u64) Status, + getNextMonotonicCount: fn (*u64) callconv(.C) Status, /// Induces a fine-grained stall. - stall: extern fn (usize) Status, + stall: fn (usize) callconv(.C) Status, /// Sets the system's watchdog timer. - setWatchdogTimer: extern fn (usize, u64, usize, ?[*]const u16) Status, + setWatchdogTimer: fn (usize, u64, usize, ?[*]const u16) callconv(.C) Status, connectController: Status, // TODO disconnectController: Status, // TODO /// Queries a handle to determine if it supports a specified protocol. - openProtocol: extern fn (Handle, *align(8) const Guid, *?*c_void, ?Handle, ?Handle, OpenProtocolAttributes) Status, + openProtocol: fn (Handle, *align(8) const Guid, *?*c_void, ?Handle, ?Handle, OpenProtocolAttributes) callconv(.C) Status, /// Closes a protocol on a handle that was opened using openProtocol(). - closeProtocol: extern fn (Handle, *align(8) const Guid, Handle, ?Handle) Status, + closeProtocol: fn (Handle, *align(8) const Guid, Handle, ?Handle) callconv(.C) Status, /// Retrieves the list of agents that currently have a protocol interface opened. - openProtocolInformation: extern fn (Handle, *align(8) const Guid, *[*]ProtocolInformationEntry, *usize) Status, + openProtocolInformation: fn (Handle, *align(8) const Guid, *[*]ProtocolInformationEntry, *usize) callconv(.C) Status, /// Retrieves the list of protocol interface GUIDs that are installed on a handle in a buffer allocated from pool. - protocolsPerHandle: extern fn (Handle, *[*]*align(8) const Guid, *usize) Status, + protocolsPerHandle: fn (Handle, *[*]*align(8) const Guid, *usize) callconv(.C) Status, /// Returns an array of handles that support the requested protocol in a buffer allocated from pool. - locateHandleBuffer: extern fn (LocateSearchType, ?*align(8) const Guid, ?*const c_void, *usize, *[*]Handle) Status, + locateHandleBuffer: fn (LocateSearchType, ?*align(8) const Guid, ?*const c_void, *usize, *[*]Handle) callconv(.C) Status, /// Returns the first protocol instance that matches the given protocol. - locateProtocol: extern fn (*align(8) const Guid, ?*const c_void, *?*c_void) Status, + locateProtocol: fn (*align(8) const Guid, ?*const c_void, *?*c_void) callconv(.C) Status, installMultipleProtocolInterfaces: Status, // TODO uninstallMultipleProtocolInterfaces: Status, // TODO /// Computes and returns a 32-bit CRC for a data buffer. - calculateCrc32: extern fn ([*]const u8, usize, *u32) Status, + calculateCrc32: fn ([*]const u8, usize, *u32) callconv(.C) Status, /// Copies the contents of one buffer to another buffer - copyMem: extern fn ([*]u8, [*]const u8, usize) void, + copyMem: fn ([*]u8, [*]const u8, usize) callconv(.C) void, /// Fills a buffer with a specified value - setMem: extern fn ([*]u8, usize, u8) void, + setMem: fn ([*]u8, usize, u8) callconv(.C) void, createEventEx: Status, // TODO diff --git a/lib/std/os/uefi/tables/runtime_services.zig b/lib/std/os/uefi/tables/runtime_services.zig index 1f0c7efad4..981e07275b 100644 --- a/lib/std/os/uefi/tables/runtime_services.zig +++ b/lib/std/os/uefi/tables/runtime_services.zig @@ -17,7 +17,7 @@ pub const RuntimeServices = extern struct { hdr: TableHeader, /// Returns the current time and date information, and the time-keeping capabilities of the hardware platform. - getTime: extern fn (*uefi.Time, ?*TimeCapabilities) Status, + getTime: fn (*uefi.Time, ?*TimeCapabilities) callconv(.C) Status, setTime: Status, // TODO getWakeupTime: Status, // TODO @@ -26,18 +26,18 @@ pub const RuntimeServices = extern struct { convertPointer: Status, // TODO /// Returns the value of a variable. - getVariable: extern fn ([*:0]const u16, *align(8) const Guid, ?*u32, *usize, ?*c_void) Status, + getVariable: fn ([*:0]const u16, *align(8) const Guid, ?*u32, *usize, ?*c_void) callconv(.C) Status, /// Enumerates the current variable names. - getNextVariableName: extern fn (*usize, [*:0]u16, *align(8) Guid) Status, + getNextVariableName: fn (*usize, [*:0]u16, *align(8) Guid) callconv(.C) Status, /// Sets the value of a variable. - setVariable: extern fn ([*:0]const u16, *align(8) const Guid, u32, usize, *c_void) Status, + setVariable: fn ([*:0]const u16, *align(8) const Guid, u32, usize, *c_void) callconv(.C) Status, getNextHighMonotonicCount: Status, // TODO /// Resets the entire platform. - resetSystem: extern fn (ResetType, Status, usize, ?*const c_void) noreturn, + resetSystem: fn (ResetType, Status, usize, ?*const c_void) callconv(.C) noreturn, updateCapsule: Status, // TODO queryCapsuleCapabilities: Status, // TODO diff --git a/lib/std/os/windows/bits.zig b/lib/std/os/windows/bits.zig index a1a60b1798..191e8deded 100644 --- a/lib/std/os/windows/bits.zig +++ b/lib/std/os/windows/bits.zig @@ -627,7 +627,7 @@ pub const MEM_RESERVE_PLACEHOLDERS = 0x2; pub const MEM_DECOMMIT = 0x4000; pub const MEM_RELEASE = 0x8000; -pub const PTHREAD_START_ROUTINE = extern fn (LPVOID) DWORD; +pub const PTHREAD_START_ROUTINE = fn (LPVOID) callconv(.C) DWORD; pub const LPTHREAD_START_ROUTINE = PTHREAD_START_ROUTINE; pub const WIN32_FIND_DATAW = extern struct { @@ -784,7 +784,7 @@ pub const IMAGE_TLS_DIRECTORY = extern struct { pub const IMAGE_TLS_DIRECTORY64 = IMAGE_TLS_DIRECTORY; pub const IMAGE_TLS_DIRECTORY32 = IMAGE_TLS_DIRECTORY; -pub const PIMAGE_TLS_CALLBACK = ?extern fn (PVOID, DWORD, PVOID) void; +pub const PIMAGE_TLS_CALLBACK = ?fn (PVOID, DWORD, PVOID) callconv(.C) void; pub const PROV_RSA_FULL = 1; @@ -810,7 +810,7 @@ pub const FILE_ACTION_MODIFIED = 0x00000003; pub const FILE_ACTION_RENAMED_OLD_NAME = 0x00000004; pub const FILE_ACTION_RENAMED_NEW_NAME = 0x00000005; -pub const LPOVERLAPPED_COMPLETION_ROUTINE = ?extern fn (DWORD, DWORD, *OVERLAPPED) void; +pub const LPOVERLAPPED_COMPLETION_ROUTINE = ?fn (DWORD, DWORD, *OVERLAPPED) callconv(.C) void; pub const FILE_NOTIFY_CHANGE_CREATION = 64; pub const FILE_NOTIFY_CHANGE_SIZE = 8; @@ -863,7 +863,7 @@ pub const RTL_CRITICAL_SECTION = extern struct { pub const CRITICAL_SECTION = RTL_CRITICAL_SECTION; pub const INIT_ONCE = RTL_RUN_ONCE; pub const INIT_ONCE_STATIC_INIT = RTL_RUN_ONCE_INIT; -pub const INIT_ONCE_FN = extern fn (InitOnce: *INIT_ONCE, Parameter: ?*c_void, Context: ?*c_void) BOOL; +pub const INIT_ONCE_FN = fn (InitOnce: *INIT_ONCE, Parameter: ?*c_void, Context: ?*c_void) callconv(.C) BOOL; pub const RTL_RUN_ONCE = extern struct { Ptr: ?*c_void, @@ -1418,7 +1418,7 @@ pub const RTL_DRIVE_LETTER_CURDIR = extern struct { DosPath: UNICODE_STRING, }; -pub const PPS_POST_PROCESS_INIT_ROUTINE = ?extern fn () void; +pub const PPS_POST_PROCESS_INIT_ROUTINE = ?fn () callconv(.C) void; pub const FILE_BOTH_DIR_INFORMATION = extern struct { NextEntryOffset: ULONG, @@ -1438,7 +1438,7 @@ pub const FILE_BOTH_DIR_INFORMATION = extern struct { }; pub const FILE_BOTH_DIRECTORY_INFORMATION = FILE_BOTH_DIR_INFORMATION; -pub const IO_APC_ROUTINE = extern fn (PVOID, *IO_STATUS_BLOCK, ULONG) void; +pub const IO_APC_ROUTINE = fn (PVOID, *IO_STATUS_BLOCK, ULONG) callconv(.C) void; pub const CURDIR = extern struct { DosPath: UNICODE_STRING, diff --git a/lib/std/os/windows/ws2_32.zig b/lib/std/os/windows/ws2_32.zig index 31547036ae..d467a60d17 100644 --- a/lib/std/os/windows/ws2_32.zig +++ b/lib/std/os/windows/ws2_32.zig @@ -106,7 +106,7 @@ pub const WSAOVERLAPPED = extern struct { hEvent: ?WSAEVENT, }; -pub const WSAOVERLAPPED_COMPLETION_ROUTINE = extern fn (dwError: DWORD, cbTransferred: DWORD, lpOverlapped: *WSAOVERLAPPED, dwFlags: DWORD) void; +pub const WSAOVERLAPPED_COMPLETION_ROUTINE = fn (dwError: DWORD, cbTransferred: DWORD, lpOverlapped: *WSAOVERLAPPED, dwFlags: DWORD) callconv(.C) void; pub const ADDRESS_FAMILY = u16; diff --git a/lib/std/special/test_runner.zig b/lib/std/special/test_runner.zig index 6dd208e3b4..7403cca9c2 100644 --- a/lib/std/special/test_runner.zig +++ b/lib/std/special/test_runner.zig @@ -34,7 +34,7 @@ pub fn main() anyerror!void { std.heap.page_allocator.free(async_frame_buffer); async_frame_buffer = try std.heap.page_allocator.alignedAlloc(u8, std.Target.stack_align, size); } - const casted_fn = @ptrCast(async fn () anyerror!void, test_fn.func); + const casted_fn = @ptrCast(fn () callconv(.Async) anyerror!void, test_fn.func); break :blk await @asyncCall(async_frame_buffer, {}, casted_fn); }, .blocking => { diff --git a/lib/std/start.zig b/lib/std/start.zig index 631bb2e9f8..604c22101c 100644 --- a/lib/std/start.zig +++ b/lib/std/start.zig @@ -224,8 +224,7 @@ inline fn initEventLoopAndCallMain() u8 { // and we want fewer call frames in stack traces. return @call(.{ .modifier = .always_inline }, callMain, .{}); } - -async fn callMainAsync(loop: *std.event.Loop) u8 { +fn callMainAsync(loop: *std.event.Loop) callconv(.Async) u8 { // This prevents the event loop from terminating at least until main() has returned. loop.beginOneEvent(); defer loop.finishOneEvent(); diff --git a/src-self-hosted/clang.zig b/src-self-hosted/clang.zig index 57c8496c6f..b3d67aab25 100644 --- a/src-self-hosted/clang.zig +++ b/src-self-hosted/clang.zig @@ -781,7 +781,7 @@ pub extern fn ZigClangSourceManager_getCharacterData(self: ?*const struct_ZigCla pub extern fn ZigClangASTContext_getPointerType(self: ?*const struct_ZigClangASTContext, T: struct_ZigClangQualType) struct_ZigClangQualType; pub extern fn ZigClangASTUnit_getASTContext(self: ?*struct_ZigClangASTUnit) ?*struct_ZigClangASTContext; pub extern fn ZigClangASTUnit_getSourceManager(self: *struct_ZigClangASTUnit) *struct_ZigClangSourceManager; -pub extern fn ZigClangASTUnit_visitLocalTopLevelDecls(self: *struct_ZigClangASTUnit, context: ?*c_void, Fn: ?extern fn (?*c_void, *const struct_ZigClangDecl) bool) bool; +pub extern fn ZigClangASTUnit_visitLocalTopLevelDecls(self: *struct_ZigClangASTUnit, context: ?*c_void, Fn: ?fn (?*c_void, *const struct_ZigClangDecl) callconv(.C) bool) bool; pub extern fn ZigClangRecordType_getDecl(record_ty: ?*const struct_ZigClangRecordType) *const struct_ZigClangRecordDecl; pub extern fn ZigClangTagDecl_isThisDeclarationADefinition(self: *const ZigClangTagDecl) bool; pub extern fn ZigClangEnumType_getDecl(record_ty: ?*const struct_ZigClangEnumType) *const struct_ZigClangEnumDecl; diff --git a/src-self-hosted/main.zig b/src-self-hosted/main.zig index b7535fca6f..05eb7212dd 100644 --- a/src-self-hosted/main.zig +++ b/src-self-hosted/main.zig @@ -41,7 +41,7 @@ const usage = const Command = struct { name: []const u8, - exec: async fn (*Allocator, []const []const u8) anyerror!void, + exec: fn (*Allocator, []const []const u8) callconv(.Async) anyerror!void, }; pub fn main() !void { @@ -713,8 +713,7 @@ const FmtError = error{ FileBusy, CurrentWorkingDirectoryUnlinked, } || fs.File.OpenError; - -async fn fmtPath(fmt: *Fmt, file_path_ref: []const u8, check_mode: bool) FmtError!void { +fn fmtPath(fmt: *Fmt, file_path_ref: []const u8, check_mode: bool) callconv(.Async) FmtError!void { const stderr_file = io.getStdErr(); const stderr = stderr_file.outStream(); diff --git a/test/stage1/behavior/async_fn.zig b/test/stage1/behavior/async_fn.zig index 4f6ace9899..30df7f64aa 100644 --- a/test/stage1/behavior/async_fn.zig +++ b/test/stage1/behavior/async_fn.zig @@ -112,12 +112,12 @@ test "@frameSize" { const S = struct { fn doTheTest() void { { - var ptr = @ptrCast(async fn (i32) void, other); + var ptr = @ptrCast(fn (i32) callconv(.Async) void, other); const size = @frameSize(ptr); expect(size == @sizeOf(@Frame(other))); } { - var ptr = @ptrCast(async fn () void, first); + var ptr = @ptrCast(fn () callconv(.Async) void, first); const size = @frameSize(ptr); expect(size == @sizeOf(@Frame(first))); } @@ -184,7 +184,7 @@ test "coroutine suspend with block" { var a_promise: anyframe = undefined; var global_result = false; -async fn testSuspendBlock() void { +fn testSuspendBlock() callconv(.Async) void { suspend { comptime expect(@TypeOf(@frame()) == *@Frame(testSuspendBlock)); a_promise = @frame(); @@ -209,14 +209,14 @@ test "coroutine await" { expect(await_final_result == 1234); expect(std.mem.eql(u8, &await_points, "abcdefghi")); } -async fn await_amain() void { +fn await_amain() callconv(.Async) void { await_seq('b'); var p = async await_another(); await_seq('e'); await_final_result = await p; await_seq('h'); } -async fn await_another() i32 { +fn await_another() callconv(.Async) i32 { await_seq('c'); suspend { await_seq('d'); @@ -243,14 +243,14 @@ test "coroutine await early return" { expect(early_final_result == 1234); expect(std.mem.eql(u8, &early_points, "abcdef")); } -async fn early_amain() void { +fn early_amain() callconv(.Async) void { early_seq('b'); var p = async early_another(); early_seq('d'); early_final_result = await p; early_seq('e'); } -async fn early_another() i32 { +fn early_another() callconv(.Async) i32 { early_seq('c'); return 1234; } @@ -266,7 +266,7 @@ fn early_seq(c: u8) void { test "async function with dot syntax" { const S = struct { var y: i32 = 1; - async fn foo() void { + fn foo() callconv(.Async) void { y += 1; suspend; } @@ -278,7 +278,7 @@ test "async function with dot syntax" { test "async fn pointer in a struct field" { var data: i32 = 1; const Foo = struct { - bar: async fn (*i32) void, + bar: fn (*i32) callconv(.Async) void, }; var foo = Foo{ .bar = simpleAsyncFn2 }; var bytes: [64]u8 align(16) = undefined; @@ -294,8 +294,7 @@ test "async fn pointer in a struct field" { fn doTheAwait(f: anyframe->void) void { await f; } - -async fn simpleAsyncFn2(y: *i32) void { +fn simpleAsyncFn2(y: *i32) callconv(.Async) void { defer y.* += 2; y.* += 1; suspend; @@ -303,11 +302,10 @@ async fn simpleAsyncFn2(y: *i32) void { test "@asyncCall with return type" { const Foo = struct { - bar: async fn () i32, + bar: fn () callconv(.Async) i32, var global_frame: anyframe = undefined; - - async fn middle() i32 { + fn middle() callconv(.Async) i32 { return afunc(); } @@ -338,8 +336,7 @@ test "async fn with inferred error set" { resume global_frame; std.testing.expectError(error.Fail, result); } - - async fn middle() !void { + fn middle() callconv(.Async) !void { var f = async middle2(); return await f; } @@ -376,11 +373,11 @@ fn nonFailing() (anyframe->anyerror!void) { Static.frame = async suspendThenFail(); return &Static.frame; } -async fn suspendThenFail() anyerror!void { +fn suspendThenFail() callconv(.Async) anyerror!void { suspend; return error.Fail; } -async fn printTrace(p: anyframe->(anyerror!void)) void { +fn printTrace(p: anyframe->(anyerror!void)) callconv(.Async) void { (await p) catch |e| { std.testing.expect(e == error.Fail); if (@errorReturnTrace()) |trace| { @@ -397,7 +394,7 @@ test "break from suspend" { const p = async testBreakFromSuspend(&my_result); std.testing.expect(my_result == 2); } -async fn testBreakFromSuspend(my_result: *i32) void { +fn testBreakFromSuspend(my_result: *i32) callconv(.Async) void { suspend { resume @frame(); } @@ -826,7 +823,7 @@ test "cast fn to async fn when it is inferred to be async" { var ok = false; fn doTheTest() void { - var ptr: async fn () i32 = undefined; + var ptr: fn () callconv(.Async) i32 = undefined; ptr = func; var buf: [100]u8 align(16) = undefined; var result: i32 = undefined; @@ -854,7 +851,7 @@ test "cast fn to async fn when it is inferred to be async, awaited directly" { var ok = false; fn doTheTest() void { - var ptr: async fn () i32 = undefined; + var ptr: fn () callconv(.Async) i32 = undefined; ptr = func; var buf: [100]u8 align(16) = undefined; var result: i32 = undefined; @@ -958,8 +955,7 @@ test "@asyncCall with comptime-known function, but not awaited directly" { resume global_frame; std.testing.expectError(error.Fail, result); } - - async fn middle() !void { + fn middle() callconv(.Async) !void { var f = async middle2(); return await f; } @@ -993,7 +989,7 @@ test "@asyncCall with actual frame instead of byte buffer" { test "@asyncCall using the result location inside the frame" { const S = struct { - async fn simple2(y: *i32) i32 { + fn simple2(y: *i32) callconv(.Async) i32 { defer y.* += 2; y.* += 1; suspend; @@ -1005,7 +1001,7 @@ test "@asyncCall using the result location inside the frame" { }; var data: i32 = 1; const Foo = struct { - bar: async fn (*i32) i32, + bar: fn (*i32) callconv(.Async) i32, }; var foo = Foo{ .bar = S.simple2 }; 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 const sum = (await f1) + (await f2); expect(sum == 10); } - async fn add(a: i32, b: i32) i32 { + fn add(a: i32, b: i32) callconv(.Async) i32 { return a + b; } }; @@ -1130,7 +1126,7 @@ test "await used in expression after a fn call" { sum = foo() + await f1; expect(sum == 8); } - async fn add(a: i32, b: i32) i32 { + fn add(a: i32, b: i32) callconv(.Async) i32 { return a + b; } fn foo() i32 { @@ -1147,7 +1143,7 @@ test "async fn call used in expression after a fn call" { sum = foo() + add(3, 4); expect(sum == 8); } - async fn add(a: i32, b: i32) i32 { + fn add(a: i32, b: i32) callconv(.Async) i32 { return a + b; } fn foo() i32 { @@ -1403,7 +1399,7 @@ test "async function call resolves target fn frame, runtime func" { fn foo() anyerror!void { const stack_size = 1000; var stack_frame: [stack_size]u8 align(std.Target.stack_align) = undefined; - var func: async fn () anyerror!void = bar; + var func: fn () callconv(.Async) anyerror!void = bar; return await @asyncCall(&stack_frame, {}, func); } diff --git a/test/stage1/behavior/await_struct.zig b/test/stage1/behavior/await_struct.zig index 2d4faadc27..328f8f87fd 100644 --- a/test/stage1/behavior/await_struct.zig +++ b/test/stage1/behavior/await_struct.zig @@ -18,14 +18,14 @@ test "coroutine await struct" { expect(await_final_result.x == 1234); expect(std.mem.eql(u8, &await_points, "abcdefghi")); } -async fn await_amain() void { +fn await_amain() callconv(.Async) void { await_seq('b'); var p = async await_another(); await_seq('e'); await_final_result = await p; await_seq('h'); } -async fn await_another() Foo { +fn await_another() callconv(.Async) Foo { await_seq('c'); suspend { await_seq('d'); diff --git a/test/stage1/behavior/cast.zig b/test/stage1/behavior/cast.zig index 63bf055aca..8717c8e619 100644 --- a/test/stage1/behavior/cast.zig +++ b/test/stage1/behavior/cast.zig @@ -762,7 +762,7 @@ test "variable initialization uses result locations properly with regards to the test "cast between [*c]T and ?[*:0]T on fn parameter" { const S = struct { - const Handler = ?extern fn ([*c]const u8) void; + const Handler = ?fn ([*c]const u8) callconv(.C) void; fn addCallback(handler: Handler) void {} fn myCallback(cstr: ?[*:0]const u8) callconv(.C) void {} From 84a0a9688caea0f7cfe19bac07d5b5d46a06d470 Mon Sep 17 00:00:00 2001 From: Tadeo Kondrak Date: Mon, 4 May 2020 10:50:11 -0600 Subject: [PATCH 4/4] update docs/tests for async/extern fn removal --- doc/langref.html.in | 4 ++-- lib/std/zig/parser_test.zig | 1 + test/compile_errors.zig | 22 +++++++++++----------- test/runtime_safety.zig | 8 ++++---- test/stack_traces.zig | 2 +- 5 files changed, 19 insertions(+), 18 deletions(-) diff --git a/doc/langref.html.in b/doc/langref.html.in index b2e1f6e6f6..91665604f7 100644 --- a/doc/langref.html.in +++ b/doc/langref.html.in @@ -6713,7 +6713,7 @@ const assert = std.debug.assert; test "async fn pointer in a struct field" { var data: i32 = 1; const Foo = struct { - bar: async fn (*i32) void, + bar: fn (*i32) callconv(.Async) void, }; var foo = Foo{ .bar = func }; var bytes: [64]u8 align(@alignOf(@Frame(func))) = undefined; @@ -6723,7 +6723,7 @@ test "async fn pointer in a struct field" { assert(data == 4); } -async fn func(y: *i32) void { +fn func(y: *i32) void { defer y.* += 2; y.* += 1; suspend; diff --git a/lib/std/zig/parser_test.zig b/lib/std/zig/parser_test.zig index 7ab3e86b1a..b98e8c69c3 100644 --- a/lib/std/zig/parser_test.zig +++ b/lib/std/zig/parser_test.zig @@ -2910,6 +2910,7 @@ test "zig fmt: noasync to nosuspend" { \\pub fn main() void { \\ nosuspend call(); \\} + \\ ); } diff --git a/test/compile_errors.zig b/test/compile_errors.zig index 19ec55d9e6..a79c8825a1 100644 --- a/test/compile_errors.zig +++ b/test/compile_errors.zig @@ -802,7 +802,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void { }); cases.add("exported async function", - \\export async fn foo() void {} + \\export fn foo() callconv(.Async) void {} , &[_][]const u8{ "tmp.zig:1:1: error: exported function cannot be async", }); @@ -1281,11 +1281,11 @@ pub fn addCases(cases: *tests.CompileErrorContext) void { cases.add("bad alignment in @asyncCall", \\export fn entry() void { - \\ var ptr: async fn () void = func; + \\ var ptr: fn () callconv(.Async) void = func; \\ var bytes: [64]u8 = undefined; \\ _ = @asyncCall(&bytes, {}, ptr); \\} - \\async fn func() void {} + \\fn func() callconv(.Async) void {} , &[_][]const u8{ "tmp.zig:4:21: error: expected type '[]align(16) u8', found '*[64]u8'", }); @@ -1431,7 +1431,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void { \\export fn entry() void { \\ _ = async amain(); \\} - \\async fn amain() void { + \\fn amain() callconv(.Async) void { \\ other(); \\} \\fn other() void { @@ -1447,7 +1447,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void { \\export fn entry() void { \\ _ = async amain(); \\} - \\async fn amain() void { + \\fn amain() callconv(.Async) void { \\ var x: [@sizeOf(@Frame(amain))]u8 = undefined; \\} , &[_][]const u8{ @@ -1474,7 +1474,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void { \\ var ptr = afunc; \\ _ = ptr(); \\} - \\async fn afunc() void {} + \\fn afunc() callconv(.Async) void {} , &[_][]const u8{ "tmp.zig:6:12: error: function is not comptime-known; @asyncCall required", }); @@ -1485,7 +1485,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void { \\ _ = async ptr(); \\} \\ - \\async fn afunc() void { } + \\fn afunc() callconv(.Async) void { } , &[_][]const u8{ "tmp.zig:3:15: error: function is not comptime-known; @asyncCall required", }); @@ -3074,7 +3074,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void { \\export fn entry() void { \\ _ = async foo(); \\} - \\async fn foo() void { + \\fn foo() void { \\ suspend { \\ suspend { \\ } @@ -3122,7 +3122,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void { \\export fn entry() void { \\ _ = async amain(); \\} - \\async fn amain() void { + \\fn amain() callconv(.Async) void { \\ return error.ShouldBeCompileError; \\} , &[_][]const u8{ @@ -3592,7 +3592,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void { }); cases.add("attempt to use 0 bit type in extern fn", - \\extern fn foo(ptr: extern fn(*void) void) void; + \\extern fn foo(ptr: fn(*void) callconv(.C) void) void; \\ \\export fn entry() void { \\ foo(bar); @@ -3603,7 +3603,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void { \\ bar(&{}); \\} , &[_][]const u8{ - "tmp.zig:1:30: error: parameter of type '*void' has 0 bits; not allowed in function with calling convention 'C'", + "tmp.zig:1:23: error: parameter of type '*void' has 0 bits; not allowed in function with calling convention 'C'", "tmp.zig:7:11: error: parameter of type '*void' has 0 bits; not allowed in function with calling convention 'C'", }); diff --git a/test/runtime_safety.zig b/test/runtime_safety.zig index 6837efe2d2..2e50c3a84c 100644 --- a/test/runtime_safety.zig +++ b/test/runtime_safety.zig @@ -282,7 +282,7 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { \\ var ptr = other; \\ var frame = @asyncCall(&bytes, {}, ptr); \\} - \\async fn other() void { + \\fn other() callconv(.Async) void { \\ suspend; \\} ); @@ -874,16 +874,16 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { \\ return &failing_frame; \\} \\ - \\async fn failing() anyerror!void { + \\fn failing() anyerror!void { \\ suspend; \\ return second(); \\} \\ - \\async fn second() anyerror!void { + \\fn second() callconv(.Async) anyerror!void { \\ return error.Fail; \\} \\ - \\async fn printTrace(p: anyframe->anyerror!void) void { + \\fn printTrace(p: anyframe->anyerror!void) void { \\ (await p) catch unreachable; \\} ); diff --git a/test/stack_traces.zig b/test/stack_traces.zig index 2f7201e71d..616136b9ee 100644 --- a/test/stack_traces.zig +++ b/test/stack_traces.zig @@ -282,7 +282,7 @@ pub fn addCases(cases: *tests.StackTracesContext) void { \\source.zig:10:8: [address] in main (test) \\ foo(); \\ ^ - \\start.zig:250:29: [address] in std.start.posixCallMainAndExit (test) + \\start.zig:249:29: [address] in std.start.posixCallMainAndExit (test) \\ return root.main(); \\ ^ \\start.zig:123:5: [address] in std.start._start (test)