@@ -501,6 +501,7 @@ pub const O = switch (native_arch) {
501501pub const Pipe2 = switch (native_arch ) {
502502 .x86_64 , .x86 , .riscv32 , .riscv64 , .loongarch64 , .hexagon , .or1k , .s390x = > packed struct (u32 ) {
503503 _ : u7 = 0 ,
504+ /// Parameter to `pipe2` selecting notification pipe
504505 notification_pipe : bool = false ,
505506 _9 : u3 = 0 ,
506507 nonblock : bool = false ,
@@ -512,6 +513,7 @@ pub const Pipe2 = switch (native_arch) {
512513 },
513514 .aarch64 , .aarch64_be , .arm , .armeb , .thumb , .thumbeb , .m68k = > packed struct (u32 ) {
514515 _ : u7 = 0 ,
516+ /// Parameter to `pipe2` selecting notification pipe
515517 notification_pipe : bool = false ,
516518 _9 : u3 = 0 ,
517519 nonblock : bool = false ,
@@ -523,6 +525,7 @@ pub const Pipe2 = switch (native_arch) {
523525 },
524526 .sparc64 = > packed struct (u32 ) {
525527 _ : u11 = 0 ,
528+ /// Parameter to `pipe2` selecting notification pipe
526529 notification_pipe : bool = false ,
527530 _13 : u2 = 0 ,
528531 nonblock : bool = false ,
@@ -536,6 +539,7 @@ pub const Pipe2 = switch (native_arch) {
536539 _ : u7 = 0 ,
537540 nonblock : bool = false ,
538541 _9 : u2 = 0 ,
542+ /// Parameter to `pipe2` selecting notification pipe
539543 notification_pipe : bool = false ,
540544 _12 : u4 = 0 ,
541545 direct : bool = false ,
@@ -545,6 +549,7 @@ pub const Pipe2 = switch (native_arch) {
545549 },
546550 .powerpc , .powerpcle , .powerpc64 , .powerpc64le = > packed struct (u32 ) {
547551 _ : u7 = 0 ,
552+ /// Parameter to `pipe2` selecting notification pipe
548553 notification_pipe : bool = false ,
549554 _9 : u3 = 0 ,
550555 nonblock : bool = false ,
@@ -885,7 +890,6 @@ pub fn futex2_wake(
885890/// Identical to `FUTEX.CMP_REQUEUE`, except it is part of the futex2 family of calls.
886891///
887892/// Requires at least kernel v6.7.
888- // TODO: test to ensure I didn't break it
889893pub fn futex2_requeue (
890894 /// The source and destination futexes. Must be a 2-element array.
891895 waiters : * const [2 ]Futex2.WaitOne ,
@@ -4226,9 +4230,19 @@ pub const Shut = enum(u32) {
42264230 pub const RDWR : u32 = @intFromEnum (Shut .rdwr );
42274231};
42284232
4229- /// SYNC_FILE_RANGE_* flags
4233+ /// flags for `sync_file_range(2)` syscall
4234+ /// matches SYNC_FILE_RANGE_* in kernel
42304235pub const SyncFileRange = packed struct (u32 ) {
4231- _ : u32 = 0 , // TODO: fill out
4236+ wait_before : bool = false ,
4237+ write : bool = false ,
4238+ wait_after : bool = false ,
4239+ _ : u29 = 0 ,
4240+
4241+ pub const write_and_wait : SyncFileRange = .{
4242+ .wait_before = true ,
4243+ .write = true ,
4244+ .wait_after = true ,
4245+ };
42324246};
42334247
42344248/// Deprecated alias to Sock
@@ -7054,9 +7068,18 @@ pub const Rename = packed struct(u32) {
70547068 _ : u29 = 0 ,
70557069};
70567070
7071+ /// By default (i.e, flags is .{}), the extended attribute will be created
7072+ /// if it does not exist, or the value will be replaced if the attribute
7073+ /// already exists. To modify this semantics, one of the fields in `SetXattr`
7074+ /// can be specified in flags. Matches XATTR_* in kernel
70577075pub const SetXattr = packed struct (u32 ) {
7058- _ : u32 = 0 , // TODO: add flags
7076+ /// set value, fail if attr already exists
7077+ create : bool = false ,
7078+ /// set value, fail if attr does not exist
7079+ replace : bool = false ,
7080+ _ : u30 = 0 ,
70597081};
7082+
70607083pub const statx_timestamp = extern struct {
70617084 sec : i64 ,
70627085 nsec : u32 ,
@@ -8604,60 +8627,142 @@ pub const rlimit = extern struct {
86048627 max : rlim_t ,
86058628};
86068629
8607- pub const MADV = struct {
8608- pub const NORMAL = 0 ;
8609- pub const RANDOM = 1 ;
8610- pub const SEQUENTIAL = 2 ;
8611- pub const WILLNEED = 3 ;
8612- pub const DONTNEED = 4 ;
8613- pub const FREE = 8 ;
8614- pub const REMOVE = 9 ;
8615- pub const DONTFORK = 10 ;
8616- pub const DOFORK = 11 ;
8617- pub const MERGEABLE = 12 ;
8618- pub const UNMERGEABLE = 13 ;
8619- pub const HUGEPAGE = 14 ;
8620- pub const NOHUGEPAGE = 15 ;
8621- pub const DONTDUMP = 16 ;
8622- pub const DODUMP = 17 ;
8623- pub const WIPEONFORK = 18 ;
8624- pub const KEEPONFORK = 19 ;
8625- pub const COLD = 20 ;
8626- pub const PAGEOUT = 21 ;
8627- pub const HWPOISON = 100 ;
8628- pub const SOFT_OFFLINE = 101 ;
8629- };
8630-
8631- pub const Madvice = enum (u32 ) {
8632- _ , // TODO: add options
8633- };
8634- pub const Fadvice = enum (u32 ) {
8635- _ , // TODO: add options
8636- };
8637-
8638- pub const POSIX_FADV = switch (native_arch ) {
8639- .s390x = > if (@typeInfo (usize ).int .bits == 64 ) struct {
8640- pub const NORMAL = 0 ;
8641- pub const RANDOM = 1 ;
8642- pub const SEQUENTIAL = 2 ;
8643- pub const WILLNEED = 3 ;
8644- pub const DONTNEED = 6 ;
8645- pub const NOREUSE = 7 ;
8646- } else struct {
8647- pub const NORMAL = 0 ;
8648- pub const RANDOM = 1 ;
8649- pub const SEQUENTIAL = 2 ;
8650- pub const WILLNEED = 3 ;
8651- pub const DONTNEED = 4 ;
8652- pub const NOREUSE = 5 ;
8630+ /// DEPRECATED alias for Madvise
8631+ pub const MADV = Madvise ;
8632+
8633+ // COMMIT: update MADV_* flags and type as enum
8634+ /// advice flags for `madvise`
8635+ /// matches MADV_* in kernel
8636+ pub const Madvise = enum (u32 ) {
8637+ /// no further special treatment
8638+ normal = 0 ,
8639+ /// expect random page references
8640+ random = 1 ,
8641+ /// expect sequential page references
8642+ sequential = 2 ,
8643+ /// will need these pages
8644+ willneed = 3 ,
8645+ /// don't need these pages
8646+ dontneed = 4 ,
8647+ /// free pages only if memory pressure
8648+ free = 8 ,
8649+ /// remove these pages & resources
8650+ remove = 9 ,
8651+ /// don't inherit across fork
8652+ dontfork = 10 ,
8653+ /// do inherit across fork
8654+ dofork = 11 ,
8655+ /// KSM may merge identical pages
8656+ mergeable = 12 ,
8657+ /// KSM may not merge identical pages
8658+ unmergeable = 13 ,
8659+ /// Worth backing with hugepages
8660+ hugepage = 14 ,
8661+ /// Not worth backing with hugepages
8662+ nohugepage = 15 ,
8663+ /// Explicity exclude from the core dump, overrides the coredump filter bits
8664+ dontdump = 16 ,
8665+ /// Clear the MADV_DONTDUMP flag
8666+ dodump = 17 ,
8667+ /// Zero memory on fork, child only
8668+ wipeonfork = 18 ,
8669+ /// Undo MADV_WIPEONFORK
8670+ keeponfork = 19 ,
8671+ /// deactivate these pages
8672+ cold = 20 ,
8673+ /// reclaim these pages
8674+ pageout = 21 ,
8675+ /// populate (prefault) page tables readable
8676+ populate_read = 22 ,
8677+ /// populate (prefault) page tables writable
8678+ populate_write = 23 ,
8679+ /// like DONTNEED, but drop locked pages too
8680+ dontneed_locked = 24 ,
8681+ /// Synchronous hugepage collapse
8682+ collapse = 25 ,
8683+ /// poison a page for testing
8684+ hwpoison = 100 ,
8685+ /// soft offline page for testing
8686+ soft_offline = 101 ,
8687+ /// fatal signal on access to range
8688+ guard_install = 102 ,
8689+ /// unguard range
8690+ guard_remove = 103 ,
8691+ _ ,
8692+
8693+ // DEPRECATED aliases for `Madvise`
8694+ pub const NORMAL : u32 = @intFromEnum (Madvise .normal );
8695+ pub const RANDOM : u32 = @intFromEnum (Madvise .random );
8696+ pub const SEQUENTIAL : u32 = @intFromEnum (Madvise .sequential );
8697+ pub const WILLNEED : u32 = @intFromEnum (Madvise .willneed );
8698+ pub const DONTNEED : u32 = @intFromEnum (Madvise .dontneed );
8699+ pub const FREE : u32 = @intFromEnum (Madvise .free );
8700+ pub const REMOVE : u32 = @intFromEnum (Madvise .remove );
8701+ pub const DONTFORK : u32 = @intFromEnum (Madvise .dontfork );
8702+ pub const DOFORK : u32 = @intFromEnum (Madvise .dofork );
8703+ pub const MERGEABLE : u32 = @intFromEnum (Madvise .mergeable );
8704+ pub const UNMERGEABLE : u32 = @intFromEnum (Madvise .unmergeable );
8705+ pub const HUGEPAGE : u32 = @intFromEnum (Madvise .hugepage );
8706+ pub const NOHUGEPAGE : u32 = @intFromEnum (Madvise .nohugepage );
8707+ pub const DONTDUMP : u32 = @intFromEnum (Madvise .dontdump );
8708+ pub const DODUMP : u32 = @intFromEnum (Madvise .dodump );
8709+ pub const WIPEONFORK : u32 = @intFromEnum (Madvise .wipeonfork );
8710+ pub const KEEPONFORK : u32 = @intFromEnum (Madvise .keeponfork );
8711+ pub const COLD : u32 = @intFromEnum (Madvise .cold );
8712+ pub const PAGEOUT : u32 = @intFromEnum (Madvise .pageout );
8713+ pub const HWPOISON : u32 = @intFromEnum (Madvise .hwpoison );
8714+ pub const SOFT_OFFLINE : u32 = @intFromEnum (Madvise .soft_offline );
8715+ };
8716+
8717+ /// DEPRECATED alias to Fadvice
8718+ pub const POSIX_FADV = Fadvise ;
8719+
8720+ /// advice flags for `posix_fadvise`
8721+ /// matches POSIX_FADV_* in kernel
8722+ pub const Fadvise = switch (native_arch ) {
8723+ .s390x = > if (@typeInfo (usize ).int .bits == 64 ) enum (u32 ) {
8724+ /// No further special treatment
8725+ normal = 0 ,
8726+ /// Expect random page references
8727+ random = 1 ,
8728+ /// Expect sequential page references
8729+ sequential = 2 ,
8730+ /// Will need these pages
8731+ willneed = 3 ,
8732+ /// Don't need these pages
8733+ dontneed = 6 ,
8734+ /// Data will be accessed once
8735+ noreuse = 7 ,
8736+ _ ,
8737+
8738+ pub const NORMAL : u32 = @intFromEnum (Fadvise .normal );
8739+ pub const RANDOM : u32 = @intFromEnum (Fadvise .random );
8740+ pub const SEQUENTIAL : u32 = @intFromEnum (Fadvise .sequential );
8741+ pub const WILLNEED : u32 = @intFromEnum (Fadvise .willneed );
8742+ pub const DONTNEED : u32 = @intFromEnum (Fadvise .dontneed );
8743+ pub const NOREUSE : u32 = @intFromEnum (Fadvise .noreuse );
86538744 },
8654- else = > struct {
8655- pub const NORMAL = 0 ;
8656- pub const RANDOM = 1 ;
8657- pub const SEQUENTIAL = 2 ;
8658- pub const WILLNEED = 3 ;
8659- pub const DONTNEED = 4 ;
8660- pub const NOREUSE = 5 ;
8745+ else = > enum (u32 ) {
8746+ /// No further special treatment
8747+ normal = 0 ,
8748+ /// Expect random page references
8749+ random = 1 ,
8750+ /// Expect sequential page references
8751+ sequential = 2 ,
8752+ /// Will need these pages
8753+ willneed = 3 ,
8754+ /// Don't need these pages
8755+ dontneed = 4 ,
8756+ /// Data will be accessed once
8757+ noreuse = 5 ,
8758+ _ ,
8759+
8760+ pub const NORMAL : u32 = @intFromEnum (Fadvise .normal );
8761+ pub const RANDOM : u32 = @intFromEnum (Fadvise .random );
8762+ pub const SEQUENTIAL : u32 = @intFromEnum (Fadvise .sequential );
8763+ pub const WILLNEED : u32 = @intFromEnum (Fadvise .willneed );
8764+ pub const DONTNEED : u32 = @intFromEnum (Fadvise .dontneed );
8765+ pub const NOREUSE : u32 = @intFromEnum (Fadvise .noreuse );
86618766 },
86628767};
86638768
0 commit comments