| ... | ... | @@ -630,12 +630,13 @@ pub fn futex2_waitv( |
| 630 | 630 | nr_futexes, |
| 631 | 631 | flags, |
| 632 | 632 | @intFromPtr(timeout), |
| 633 | | @bitCast(@as(isize, clockid)), |
| 633 | @bitCast(@as(isize, @intFromEnum(clockid))), |
| 634 | 634 | ); |
| 635 | 635 | } |
| 636 | 636 | |
| 637 | 637 | /// Wait on a futex. |
| 638 | | /// Identical to `FUTEX.WAIT`, except it is part of the futex2 family of calls. |
| 638 | /// Identical to the traditional `FUTEX.FUTEX_WAIT_BITSET` op, except it is part of the |
| 639 | /// futex2 familiy of calls. |
| 639 | 640 | pub fn futex2_wait( |
| 640 | 641 | /// Address of the futex to wait on. |
| 641 | 642 | uaddr: *const anyopaque, |
| ... | ... | @@ -646,7 +647,7 @@ pub fn futex2_wait( |
| 646 | 647 | /// `FUTEX2` flags. |
| 647 | 648 | flags: u32, |
| 648 | 649 | /// Optional absolute timeout. |
| 649 | | timeout: *const timespec, |
| 650 | timeout: ?*const timespec, |
| 650 | 651 | /// Clock to be used for the timeout, realtime or monotonic. |
| 651 | 652 | clockid: clockid_t, |
| 652 | 653 | ) usize { |
| ... | ... | @@ -657,15 +658,16 @@ pub fn futex2_wait( |
| 657 | 658 | mask, |
| 658 | 659 | flags, |
| 659 | 660 | @intFromPtr(timeout), |
| 660 | | @bitCast(@as(isize, clockid)), |
| 661 | @bitCast(@as(isize, @intFromEnum(clockid))), |
| 661 | 662 | ); |
| 662 | 663 | } |
| 663 | 664 | |
| 664 | 665 | /// Wake a number of futexes. |
| 665 | | /// Identical to `FUTEX.WAKE`, except it is part of the futex2 family of calls. |
| 666 | /// Identical to the traditional `FUTEX.FUTEX_WAIT_BITSET` op, except it is part of the |
| 667 | /// futex2 family of calls. |
| 666 | 668 | pub fn futex2_wake( |
| 667 | 669 | /// Address of the futex(es) to wake. |
| 668 | | uaddr: [*]const anyopaque, |
| 670 | uaddr: *const anyopaque, |
| 669 | 671 | /// Bitmask |
| 670 | 672 | mask: usize, |
| 671 | 673 | /// Number of the futexes to wake. |
| ... | ... | @@ -1683,7 +1685,7 @@ pub fn sigaddset(set: *sigset_t, sig: u6) void { |
| 1683 | 1685 | |
| 1684 | 1686 | pub fn sigismember(set: *const sigset_t, sig: u6) bool { |
| 1685 | 1687 | const s = sig - 1; |
| 1686 | | return ((set.*)[@as(usize, @intCast(s)) / usize_bits] & (@as(usize, @intCast(1)) << (s & (usize_bits - 1)))) != 0; |
| 1688 | return ((set.*)[@as(usize, @intCast(s)) / usize_bits] & (@as(usize, @intCast(1)) << @intCast(s & (usize_bits - 1)))) != 0; |
| 1687 | 1689 | } |
| 1688 | 1690 | |
| 1689 | 1691 | pub fn getsockname(fd: i32, noalias addr: *sockaddr, noalias len: *socklen_t) usize { |
| ... | ... | @@ -1740,31 +1742,31 @@ pub fn sendmmsg(fd: i32, msgvec: [*]mmsghdr_const, vlen: u32, flags: u32) usize |
| 1740 | 1742 | var next_unsent: usize = 0; |
| 1741 | 1743 | for (msgvec[0..kvlen], 0..) |*msg, i| { |
| 1742 | 1744 | var size: i32 = 0; |
| 1743 | | const msg_iovlen = @as(usize, @intCast(msg.msg_hdr.msg_iovlen)); // kernel side this is treated as unsigned |
| 1744 | | for (msg.msg_hdr.msg_iov[0..msg_iovlen]) |iov| { |
| 1745 | const msg_iovlen = @as(usize, @intCast(msg.hdr.iovlen)); // kernel side this is treated as unsigned |
| 1746 | for (msg.hdr.iov[0..msg_iovlen]) |iov| { |
| 1745 | 1747 | if (iov.len > std.math.maxInt(i32) or @addWithOverflow(size, @as(i32, @intCast(iov.len)))[1] != 0) { |
| 1746 | 1748 | // batch-send all messages up to the current message |
| 1747 | 1749 | if (next_unsent < i) { |
| 1748 | 1750 | const batch_size = i - next_unsent; |
| 1749 | 1751 | const r = syscall4(.sendmmsg, @as(usize, @bitCast(@as(isize, fd))), @intFromPtr(&msgvec[next_unsent]), batch_size, flags); |
| 1750 | | if (E.init(r) != 0) return next_unsent; |
| 1752 | if (E.init(r) != .SUCCESS) return next_unsent; |
| 1751 | 1753 | if (r < batch_size) return next_unsent + r; |
| 1752 | 1754 | } |
| 1753 | 1755 | // send current message as own packet |
| 1754 | | const r = sendmsg(fd, &msg.msg_hdr, flags); |
| 1755 | | if (E.init(r) != 0) return r; |
| 1756 | const r = sendmsg(fd, &msg.hdr, flags); |
| 1757 | if (E.init(r) != .SUCCESS) return r; |
| 1756 | 1758 | // Linux limits the total bytes sent by sendmsg to INT_MAX, so this cast is safe. |
| 1757 | | msg.msg_len = @as(u32, @intCast(r)); |
| 1759 | msg.len = @as(u32, @intCast(r)); |
| 1758 | 1760 | next_unsent = i + 1; |
| 1759 | 1761 | break; |
| 1760 | 1762 | } |
| 1761 | | size += iov.len; |
| 1763 | size += @intCast(iov.len); |
| 1762 | 1764 | } |
| 1763 | 1765 | } |
| 1764 | 1766 | if (next_unsent < kvlen or next_unsent == 0) { // want to make sure at least one syscall occurs (e.g. to trigger MSG.EOR) |
| 1765 | 1767 | const batch_size = kvlen - next_unsent; |
| 1766 | 1768 | const r = syscall4(.sendmmsg, @as(usize, @bitCast(@as(isize, fd))), @intFromPtr(&msgvec[next_unsent]), batch_size, flags); |
| 1767 | | if (E.init(r) != 0) return r; |
| 1769 | if (E.init(r) != .SUCCESS) return r; |
| 1768 | 1770 | return next_unsent + r; |
| 1769 | 1771 | } |
| 1770 | 1772 | return kvlen; |
| ... | ... | @@ -5095,7 +5097,7 @@ pub const epoll_event = extern struct { |
| 5095 | 5097 | |
| 5096 | 5098 | pub const VFS_CAP_REVISION_MASK = 0xFF000000; |
| 5097 | 5099 | pub const VFS_CAP_REVISION_SHIFT = 24; |
| 5098 | | pub const VFS_CAP_FLAGS_MASK = ~VFS_CAP_REVISION_MASK; |
| 5100 | pub const VFS_CAP_FLAGS_MASK = ~@as(u32, VFS_CAP_REVISION_MASK); |
| 5099 | 5101 | pub const VFS_CAP_FLAGS_EFFECTIVE = 0x000001; |
| 5100 | 5102 | |
| 5101 | 5103 | pub const VFS_CAP_REVISION_1 = 0x01000000; |
| ... | ... | @@ -5113,7 +5115,7 @@ pub const VFS_CAP_REVISION = VFS_CAP_REVISION_2; |
| 5113 | 5115 | pub const vfs_cap_data = extern struct { |
| 5114 | 5116 | //all of these are mandated as little endian |
| 5115 | 5117 | //when on disk. |
| 5116 | | const Data = struct { |
| 5118 | const Data = extern struct { |
| 5117 | 5119 | permitted: u32, |
| 5118 | 5120 | inheritable: u32, |
| 5119 | 5121 | }; |