From 94720a6d68507e12251b95d963b5060bfca9160c Mon Sep 17 00:00:00 2001 From: David Rubin <87927264+Rexicon226@users.noreply.github.com> Date: Thu, 6 Feb 2025 07:28:24 -0800 Subject: [PATCH] correct the `msghdr_const` definition for the quic client (#547) --- src/net/send_msg.zig | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/src/net/send_msg.zig b/src/net/send_msg.zig index afaaea12b..6384f3e1b 100644 --- a/src/net/send_msg.zig +++ b/src/net/send_msg.zig @@ -1,14 +1,25 @@ const std = @import("std"); +const builtin = @import("builtin"); -// zig stdlib does not define the msghdr{_const} for macos. -pub const msghdr_const = extern struct { - name: ?*const std.posix.sockaddr, - namelen: std.posix.socklen_t, - iov: [*]const std.posix.iovec_const, - iovlen: usize, - control: ?*const anyopaque, - controllen: usize, - flags: i32, +// Zig 0.13 does not define the msghdr{_const} for macos. +pub const msghdr_const = switch (builtin.os.tag) { + .macos => extern struct { + /// optional address + name: ?*const std.posix.sockaddr, + /// size of address + namelen: std.posix.socklen_t, + /// scatter/gather array + iov: [*]const std.posix.iovec_const, + /// # elements in iov + iovlen: i32, + /// ancillary data + control: ?*const anyopaque, + /// ancillary data buffer len + controllen: std.posix.socklen_t, + /// flags on received message + flags: i32, + }, + else => std.posix.msghdr_const, }; extern "c" fn sendmsg(sockfd: std.posix.fd_t, msg: *const msghdr_const, flags: u32) isize;