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 {}