authorgravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2024-10-28 22:15:44+01:00
committergravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2024-11-02 10:44:18+01:00
log8a2d960627dc5362da2aa4093f58665adb6b9b4b
treee2eab1f2bf47efa5fcf3487220f503fc051b9ee8
parentbaf60426d48adbd938406f07bbbd0dfdf012943b
signaturebadge-check Signed by SSH key SHA256:7B/LJ7bpR1eX8aCXSr4mtd5M45VMPKcx9zY8e95b5QM

start: Fix a calling convention check to use eql().

Also modernize some callconv uses. Closes #21813.

1 files changed, 15 insertions(+), 15 deletions(-)

lib/std/start.zig+15-15
......@@ -29,7 +29,7 @@ comptime {
2929 if (simplified_logic) {
3030 if (builtin.output_mode == .Exe) {
3131 if ((builtin.link_libc or builtin.object_format == .c) and @hasDecl(root, "main")) {
32 if (@typeInfo(@TypeOf(root.main)).@"fn".calling_convention != .C) {
32 if (!@typeInfo(@TypeOf(root.main)).@"fn".calling_convention.eql(.c)) {
3333 @export(&main2, .{ .name = "main" });
3434 }
3535 } else if (builtin.os.tag == .windows) {
......@@ -96,7 +96,7 @@ comptime {
9696
9797// Simplified start code for stage2 until it supports more language features ///
9898
99fn main2() callconv(.C) c_int {
99fn main2() callconv(.c) c_int {
100100 root.main();
101101 return 0;
102102}
......@@ -110,11 +110,11 @@ fn callMain2() noreturn {
110110 exit2(0);
111111}
112112
113fn spirvMain2() callconv(.Kernel) void {
113fn spirvMain2() callconv(.kernel) void {
114114 root.main();
115115}
116116
117fn wWinMainCRTStartup2() callconv(.C) noreturn {
117fn wWinMainCRTStartup2() callconv(.c) noreturn {
118118 root.main();
119119 exit2(0);
120120}
......@@ -172,7 +172,7 @@ fn _DllMainCRTStartup(
172172 hinstDLL: std.os.windows.HINSTANCE,
173173 fdwReason: std.os.windows.DWORD,
174174 lpReserved: std.os.windows.LPVOID,
175) callconv(std.os.windows.WINAPI) std.os.windows.BOOL {
175) callconv(.winapi) std.os.windows.BOOL {
176176 if (!builtin.single_threaded and !builtin.link_libc) {
177177 _ = @import("os/windows/tls.zig");
178178 }
......@@ -184,13 +184,13 @@ fn _DllMainCRTStartup(
184184 return std.os.windows.TRUE;
185185}
186186
187fn wasm_freestanding_start() callconv(.C) void {
187fn wasm_freestanding_start() callconv(.c) void {
188188 // This is marked inline because for some reason LLVM in
189189 // release mode fails to inline it, and we want fewer call frames in stack traces.
190190 _ = @call(.always_inline, callMain, .{});
191191}
192192
193fn wasi_start() callconv(.C) void {
193fn wasi_start() callconv(.c) void {
194194 // The function call is marked inline because for some reason LLVM in
195195 // release mode fails to inline it, and we want fewer call frames in stack traces.
196196 switch (builtin.wasi_exec_model) {
......@@ -199,7 +199,7 @@ fn wasi_start() callconv(.C) void {
199199 }
200200}
201201
202fn EfiMain(handle: uefi.Handle, system_table: *uefi.tables.SystemTable) callconv(.C) usize {
202fn EfiMain(handle: uefi.Handle, system_table: *uefi.tables.SystemTable) callconv(.c) usize {
203203 uefi.handle = handle;
204204 uefi.system_table = system_table;
205205
......@@ -221,7 +221,7 @@ fn EfiMain(handle: uefi.Handle, system_table: *uefi.tables.SystemTable) callconv
221221 }
222222}
223223
224fn _start() callconv(.Naked) noreturn {
224fn _start() callconv(.naked) noreturn {
225225 // TODO set Top of Stack on non x86_64-plan9
226226 if (native_os == .plan9 and native_arch == .x86_64) {
227227 // from /sys/src/libc/amd64/main9.s
......@@ -447,7 +447,7 @@ fn wWinMainCRTStartup() callconv(.withStackAlign(.winapi, 1)) noreturn {
447447 std.os.windows.ntdll.RtlExitUserProcess(@as(std.os.windows.UINT, @bitCast(result)));
448448}
449449
450fn posixCallMainAndExit(argc_argv_ptr: [*]usize) callconv(.C) noreturn {
450fn posixCallMainAndExit(argc_argv_ptr: [*]usize) callconv(.c) noreturn {
451451 // We're not ready to panic until thread local storage is initialized.
452452 @setRuntimeSafety(false);
453453 // Code coverage instrumentation might try to use thread local variables.
......@@ -514,11 +514,11 @@ fn posixCallMainAndExit(argc_argv_ptr: [*]usize) callconv(.C) noreturn {
514514 // to ask for more stack space.
515515 expandStackSize(phdrs);
516516
517 const opt_init_array_start = @extern([*]*const fn () callconv(.C) void, .{
517 const opt_init_array_start = @extern([*]*const fn () callconv(.c) void, .{
518518 .name = "__init_array_start",
519519 .linkage = .weak,
520520 });
521 const opt_init_array_end = @extern([*]*const fn () callconv(.C) void, .{
521 const opt_init_array_end = @extern([*]*const fn () callconv(.c) void, .{
522522 .name = "__init_array_end",
523523 .linkage = .weak,
524524 });
......@@ -577,7 +577,7 @@ inline fn callMainWithArgs(argc: usize, argv: [*][*:0]u8, envp: [][*:0]u8) u8 {
577577 return callMain();
578578}
579579
580fn main(c_argc: c_int, c_argv: [*][*:0]c_char, c_envp: [*:null]?[*:0]c_char) callconv(.C) c_int {
580fn main(c_argc: c_int, c_argv: [*][*:0]c_char, c_envp: [*:null]?[*:0]c_char) callconv(.c) c_int {
581581 var env_count: usize = 0;
582582 while (c_envp[env_count] != null) : (env_count += 1) {}
583583 const envp = @as([*][*:0]u8, @ptrCast(c_envp))[0..env_count];
......@@ -592,7 +592,7 @@ fn main(c_argc: c_int, c_argv: [*][*:0]c_char, c_envp: [*:null]?[*:0]c_char) cal
592592 return callMainWithArgs(@as(usize, @intCast(c_argc)), @as([*][*:0]u8, @ptrCast(c_argv)), envp);
593593}
594594
595fn mainWithoutEnv(c_argc: c_int, c_argv: [*][*:0]c_char) callconv(.C) c_int {
595fn mainWithoutEnv(c_argc: c_int, c_argv: [*][*:0]c_char) callconv(.c) c_int {
596596 std.os.argv = @as([*][*:0]u8, @ptrCast(c_argv))[0..@as(usize, @intCast(c_argc))];
597597 return callMain();
598598}
......@@ -702,4 +702,4 @@ fn maybeIgnoreSigpipe() void {
702702 }
703703}
704704
705fn noopSigHandler(_: i32) callconv(.C) void {}
705fn noopSigHandler(_: i32) callconv(.c) void {}