Skip to content

Commit

Permalink
add const to msghdr_const iov and control pointers
Browse files Browse the repository at this point in the history
alongside the typical msghdr struct, Zig has added a msghdr_const
type that can be used with sendmsg which allows const data to
be provided.  I believe that data pointed to by the iov and control
fields in msghdr are also left unmodified, in which case they can
be marked const as well.
  • Loading branch information
marler8997 authored and andrewrk committed Jun 7, 2022
1 parent e9fc58e commit 523fae4
Show file tree
Hide file tree
Showing 14 changed files with 26 additions and 26 deletions.
4 changes: 2 additions & 2 deletions lib/std/c/netbsd.zig
Original file line number Diff line number Diff line change
Expand Up @@ -266,13 +266,13 @@ pub const msghdr_const = extern struct {
msg_namelen: socklen_t,

/// scatter/gather array
msg_iov: [*]iovec_const,
msg_iov: [*]const iovec_const,

/// # elements in msg_iov
msg_iovlen: i32,

/// ancillary data
msg_control: ?*anyopaque,
msg_control: ?*const anyopaque,

/// ancillary data buffer len
msg_controllen: socklen_t,
Expand Down
4 changes: 2 additions & 2 deletions lib/std/c/openbsd.zig
Original file line number Diff line number Diff line change
Expand Up @@ -279,13 +279,13 @@ pub const msghdr_const = extern struct {
msg_namelen: socklen_t,

/// scatter/gather array
msg_iov: [*]iovec_const,
msg_iov: [*]const iovec_const,

/// # elements in msg_iov
msg_iovlen: c_uint,

/// ancillary data
msg_control: ?*anyopaque,
msg_control: ?*const anyopaque,

/// ancillary data buffer len
msg_controllen: socklen_t,
Expand Down
4 changes: 2 additions & 2 deletions lib/std/c/solaris.zig
Original file line number Diff line number Diff line change
Expand Up @@ -202,11 +202,11 @@ pub const msghdr_const = extern struct {
/// size of address
msg_namelen: socklen_t,
/// scatter/gather array
msg_iov: [*]iovec_const,
msg_iov: [*]const iovec_const,
/// # elements in msg_iov
msg_iovlen: i32,
/// ancillary data
msg_control: ?*anyopaque,
msg_control: ?*const anyopaque,
/// ancillary data buffer len
msg_controllen: socklen_t,
/// flags on received message
Expand Down
4 changes: 2 additions & 2 deletions lib/std/os/linux/arm-eabi.zig
Original file line number Diff line number Diff line change
Expand Up @@ -253,9 +253,9 @@ pub const msghdr = extern struct {
pub const msghdr_const = extern struct {
name: ?*const sockaddr,
namelen: socklen_t,
iov: [*]iovec_const,
iov: [*]const iovec_const,
iovlen: i32,
control: ?*anyopaque,
control: ?*const anyopaque,
controllen: socklen_t,
flags: i32,
};
Expand Down
4 changes: 2 additions & 2 deletions lib/std/os/linux/arm64.zig
Original file line number Diff line number Diff line change
Expand Up @@ -209,10 +209,10 @@ pub const msghdr = extern struct {
pub const msghdr_const = extern struct {
name: ?*const sockaddr,
namelen: socklen_t,
iov: [*]iovec_const,
iov: [*]const iovec_const,
iovlen: i32,
__pad1: i32 = 0,
control: ?*anyopaque,
control: ?*const anyopaque,
controllen: socklen_t,
__pad2: socklen_t = 0,
flags: i32,
Expand Down
4 changes: 2 additions & 2 deletions lib/std/os/linux/i386.zig
Original file line number Diff line number Diff line change
Expand Up @@ -228,9 +228,9 @@ pub const msghdr = extern struct {
pub const msghdr_const = extern struct {
name: ?*const sockaddr,
namelen: socklen_t,
iov: [*]iovec_const,
iov: [*]const iovec_const,
iovlen: i32,
control: ?*anyopaque,
control: ?*const anyopaque,
controllen: socklen_t,
flags: i32,
};
Expand Down
2 changes: 1 addition & 1 deletion lib/std/os/linux/io_uring.zig
Original file line number Diff line number Diff line change
Expand Up @@ -2029,7 +2029,7 @@ test "sendmsg/recvmsg" {
defer os.close(client);

const buffer_send = [_]u8{42} ** 128;
var iovecs_send = [_]os.iovec_const{
const iovecs_send = [_]os.iovec_const{
os.iovec_const{ .iov_base = &buffer_send, .iov_len = buffer_send.len },
};
const msg_send = os.msghdr_const{
Expand Down
4 changes: 2 additions & 2 deletions lib/std/os/linux/mips.zig
Original file line number Diff line number Diff line change
Expand Up @@ -304,9 +304,9 @@ pub const msghdr = extern struct {
pub const msghdr_const = extern struct {
name: ?*const sockaddr,
namelen: socklen_t,
iov: [*]iovec_const,
iov: [*]const iovec_const,
iovlen: i32,
control: ?*anyopaque,
control: ?*const anyopaque,
controllen: socklen_t,
flags: i32,
};
Expand Down
4 changes: 2 additions & 2 deletions lib/std/os/linux/powerpc.zig
Original file line number Diff line number Diff line change
Expand Up @@ -234,9 +234,9 @@ pub const msghdr = extern struct {
pub const msghdr_const = extern struct {
name: ?*const sockaddr,
namelen: socklen_t,
iov: [*]iovec_const,
iov: [*]const iovec_const,
iovlen: usize,
control: ?*anyopaque,
control: ?*const anyopaque,
controllen: socklen_t,
flags: i32,
};
Expand Down
4 changes: 2 additions & 2 deletions lib/std/os/linux/powerpc64.zig
Original file line number Diff line number Diff line change
Expand Up @@ -235,9 +235,9 @@ pub const msghdr = extern struct {
pub const msghdr_const = extern struct {
name: ?*const sockaddr,
namelen: socklen_t,
iov: [*]iovec_const,
iov: [*]const iovec_const,
iovlen: usize,
control: ?*anyopaque,
control: ?*const anyopaque,
controllen: usize,
flags: i32,
};
Expand Down
4 changes: 2 additions & 2 deletions lib/std/os/linux/riscv64.zig
Original file line number Diff line number Diff line change
Expand Up @@ -199,10 +199,10 @@ pub const msghdr = extern struct {
pub const msghdr_const = extern struct {
name: ?*const sockaddr,
namelen: socklen_t,
iov: [*]iovec_const,
iov: [*]const iovec_const,
iovlen: i32,
__pad1: i32 = 0,
control: ?*anyopaque,
control: ?*const anyopaque,
controllen: socklen_t,
__pad2: socklen_t = 0,
flags: i32,
Expand Down
4 changes: 2 additions & 2 deletions lib/std/os/linux/sparc64.zig
Original file line number Diff line number Diff line change
Expand Up @@ -285,9 +285,9 @@ pub const msghdr = extern struct {
pub const msghdr_const = extern struct {
name: ?*const sockaddr,
namelen: socklen_t,
iov: [*]iovec_const,
iov: [*]const iovec_const,
iovlen: u64,
control: ?*anyopaque,
control: ?*const anyopaque,
controllen: u64,
flags: i32,
};
Expand Down
4 changes: 2 additions & 2 deletions lib/std/os/linux/x86_64.zig
Original file line number Diff line number Diff line change
Expand Up @@ -256,10 +256,10 @@ pub const msghdr = extern struct {
pub const msghdr_const = extern struct {
name: ?*const sockaddr,
namelen: socklen_t,
iov: [*]iovec_const,
iov: [*]const iovec_const,
iovlen: i32,
__pad1: i32 = 0,
control: ?*anyopaque,
control: ?*const anyopaque,
controllen: socklen_t,
__pad2: socklen_t = 0,
flags: i32,
Expand Down
2 changes: 1 addition & 1 deletion lib/std/os/windows/ws2_32.zig
Original file line number Diff line number Diff line change
Expand Up @@ -1143,7 +1143,7 @@ pub const msghdr_const = WSAMSG_const;
pub const WSAMSG_const = extern struct {
name: *const sockaddr,
namelen: INT,
lpBuffers: [*]WSABUF,
lpBuffers: [*]const WSABUF,
dwBufferCount: DWORD,
Control: WSABUF,
dwFlags: DWORD,
Expand Down

0 comments on commit 523fae4

Please sign in to comment.