@@ -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
@@ -7050,9 +7064,18 @@ pub const Rename = packed struct(u32) {
70507064 _ : u29 = 0 ,
70517065};
70527066
7067+ /// By default (i.e, flags is .{}), the extended attribute will be created
7068+ /// if it does not exist, or the value will be replaced if the attribute
7069+ /// already exists. To modify this semantics, one of the fields in `SetXattr`
7070+ /// can be specified in flags. Matches XATTR_* in kernel
70537071pub const SetXattr = packed struct (u32 ) {
7054- _ : u32 = 0 , // TODO: add flags
7072+ /// set value, fail if attr already exists
7073+ create : bool = false ,
7074+ /// set value, fail if attr does not exist
7075+ replace : bool = false ,
7076+ _ : u30 = 0 ,
70557077};
7078+
70567079pub const statx_timestamp = extern struct {
70577080 sec : i64 ,
70587081 nsec : u32 ,
@@ -8600,60 +8623,142 @@ pub const rlimit = extern struct {
86008623 max : rlim_t ,
86018624};
86028625
8603- pub const MADV = struct {
8604- pub const NORMAL = 0 ;
8605- pub const RANDOM = 1 ;
8606- pub const SEQUENTIAL = 2 ;
8607- pub const WILLNEED = 3 ;
8608- pub const DONTNEED = 4 ;
8609- pub const FREE = 8 ;
8610- pub const REMOVE = 9 ;
8611- pub const DONTFORK = 10 ;
8612- pub const DOFORK = 11 ;
8613- pub const MERGEABLE = 12 ;
8614- pub const UNMERGEABLE = 13 ;
8615- pub const HUGEPAGE = 14 ;
8616- pub const NOHUGEPAGE = 15 ;
8617- pub const DONTDUMP = 16 ;
8618- pub const DODUMP = 17 ;
8619- pub const WIPEONFORK = 18 ;
8620- pub const KEEPONFORK = 19 ;
8621- pub const COLD = 20 ;
8622- pub const PAGEOUT = 21 ;
8623- pub const HWPOISON = 100 ;
8624- pub const SOFT_OFFLINE = 101 ;
8625- };
8626-
8627- pub const Madvice = enum (u32 ) {
8628- _ , // TODO: add options
8629- };
8630- pub const Fadvice = enum (u32 ) {
8631- _ , // TODO: add options
8632- };
8633-
8634- pub const POSIX_FADV = switch (native_arch ) {
8635- .s390x = > if (@typeInfo (usize ).int .bits == 64 ) struct {
8636- pub const NORMAL = 0 ;
8637- pub const RANDOM = 1 ;
8638- pub const SEQUENTIAL = 2 ;
8639- pub const WILLNEED = 3 ;
8640- pub const DONTNEED = 6 ;
8641- pub const NOREUSE = 7 ;
8642- } else struct {
8643- pub const NORMAL = 0 ;
8644- pub const RANDOM = 1 ;
8645- pub const SEQUENTIAL = 2 ;
8646- pub const WILLNEED = 3 ;
8647- pub const DONTNEED = 4 ;
8648- pub const NOREUSE = 5 ;
8626+ /// DEPRECATED alias for Madvise
8627+ pub const MADV = Madvise ;
8628+
8629+ // COMMIT: update MADV_* flags and type as enum
8630+ /// advice flags for `madvise`
8631+ /// matches MADV_* in kernel
8632+ pub const Madvise = enum (u32 ) {
8633+ /// no further special treatment
8634+ normal = 0 ,
8635+ /// expect random page references
8636+ random = 1 ,
8637+ /// expect sequential page references
8638+ sequential = 2 ,
8639+ /// will need these pages
8640+ willneed = 3 ,
8641+ /// don't need these pages
8642+ dontneed = 4 ,
8643+ /// free pages only if memory pressure
8644+ free = 8 ,
8645+ /// remove these pages & resources
8646+ remove = 9 ,
8647+ /// don't inherit across fork
8648+ dontfork = 10 ,
8649+ /// do inherit across fork
8650+ dofork = 11 ,
8651+ /// KSM may merge identical pages
8652+ mergeable = 12 ,
8653+ /// KSM may not merge identical pages
8654+ unmergeable = 13 ,
8655+ /// Worth backing with hugepages
8656+ hugepage = 14 ,
8657+ /// Not worth backing with hugepages
8658+ nohugepage = 15 ,
8659+ /// Explicity exclude from the core dump, overrides the coredump filter bits
8660+ dontdump = 16 ,
8661+ /// Clear the MADV_DONTDUMP flag
8662+ dodump = 17 ,
8663+ /// Zero memory on fork, child only
8664+ wipeonfork = 18 ,
8665+ /// Undo MADV_WIPEONFORK
8666+ keeponfork = 19 ,
8667+ /// deactivate these pages
8668+ cold = 20 ,
8669+ /// reclaim these pages
8670+ pageout = 21 ,
8671+ /// populate (prefault) page tables readable
8672+ populate_read = 22 ,
8673+ /// populate (prefault) page tables writable
8674+ populate_write = 23 ,
8675+ /// like DONTNEED, but drop locked pages too
8676+ dontneed_locked = 24 ,
8677+ /// Synchronous hugepage collapse
8678+ collapse = 25 ,
8679+ /// poison a page for testing
8680+ hwpoison = 100 ,
8681+ /// soft offline page for testing
8682+ soft_offline = 101 ,
8683+ /// fatal signal on access to range
8684+ guard_install = 102 ,
8685+ /// unguard range
8686+ guard_remove = 103 ,
8687+ _ ,
8688+
8689+ // DEPRECATED aliases for `Madvise`
8690+ pub const NORMAL : u32 = @intFromEnum (Madvise .normal );
8691+ pub const RANDOM : u32 = @intFromEnum (Madvise .random );
8692+ pub const SEQUENTIAL : u32 = @intFromEnum (Madvise .sequential );
8693+ pub const WILLNEED : u32 = @intFromEnum (Madvise .willneed );
8694+ pub const DONTNEED : u32 = @intFromEnum (Madvise .dontneed );
8695+ pub const FREE : u32 = @intFromEnum (Madvise .free );
8696+ pub const REMOVE : u32 = @intFromEnum (Madvise .remove );
8697+ pub const DONTFORK : u32 = @intFromEnum (Madvise .dontfork );
8698+ pub const DOFORK : u32 = @intFromEnum (Madvise .dofork );
8699+ pub const MERGEABLE : u32 = @intFromEnum (Madvise .mergeable );
8700+ pub const UNMERGEABLE : u32 = @intFromEnum (Madvise .unmergeable );
8701+ pub const HUGEPAGE : u32 = @intFromEnum (Madvise .hugepage );
8702+ pub const NOHUGEPAGE : u32 = @intFromEnum (Madvise .nohugepage );
8703+ pub const DONTDUMP : u32 = @intFromEnum (Madvise .dontdump );
8704+ pub const DODUMP : u32 = @intFromEnum (Madvise .dodump );
8705+ pub const WIPEONFORK : u32 = @intFromEnum (Madvise .wipeonfork );
8706+ pub const KEEPONFORK : u32 = @intFromEnum (Madvise .keeponfork );
8707+ pub const COLD : u32 = @intFromEnum (Madvise .cold );
8708+ pub const PAGEOUT : u32 = @intFromEnum (Madvise .pageout );
8709+ pub const HWPOISON : u32 = @intFromEnum (Madvise .hwpoison );
8710+ pub const SOFT_OFFLINE : u32 = @intFromEnum (Madvise .soft_offline );
8711+ };
8712+
8713+ /// DEPRECATED alias to Fadvice
8714+ pub const POSIX_FADV = Fadvise ;
8715+
8716+ /// advice flags for `posix_fadvise`
8717+ /// matches POSIX_FADV_* in kernel
8718+ pub const Fadvise = switch (native_arch ) {
8719+ .s390x = > if (@typeInfo (usize ).int .bits == 64 ) enum (u32 ) {
8720+ /// No further special treatment
8721+ normal = 0 ,
8722+ /// Expect random page references
8723+ random = 1 ,
8724+ /// Expect sequential page references
8725+ sequential = 2 ,
8726+ /// Will need these pages
8727+ willneed = 3 ,
8728+ /// Don't need these pages
8729+ dontneed = 6 ,
8730+ /// Data will be accessed once
8731+ noreuse = 7 ,
8732+ _ ,
8733+
8734+ pub const NORMAL : u32 = @intFromEnum (Fadvise .normal );
8735+ pub const RANDOM : u32 = @intFromEnum (Fadvise .random );
8736+ pub const SEQUENTIAL : u32 = @intFromEnum (Fadvise .sequential );
8737+ pub const WILLNEED : u32 = @intFromEnum (Fadvise .willneed );
8738+ pub const DONTNEED : u32 = @intFromEnum (Fadvise .dontneed );
8739+ pub const NOREUSE : u32 = @intFromEnum (Fadvise .noreuse );
86498740 },
8650- else = > struct {
8651- pub const NORMAL = 0 ;
8652- pub const RANDOM = 1 ;
8653- pub const SEQUENTIAL = 2 ;
8654- pub const WILLNEED = 3 ;
8655- pub const DONTNEED = 4 ;
8656- pub const NOREUSE = 5 ;
8741+ else = > enum (u32 ) {
8742+ /// No further special treatment
8743+ normal = 0 ,
8744+ /// Expect random page references
8745+ random = 1 ,
8746+ /// Expect sequential page references
8747+ sequential = 2 ,
8748+ /// Will need these pages
8749+ willneed = 3 ,
8750+ /// Don't need these pages
8751+ dontneed = 4 ,
8752+ /// Data will be accessed once
8753+ noreuse = 5 ,
8754+ _ ,
8755+
8756+ pub const NORMAL : u32 = @intFromEnum (Fadvise .normal );
8757+ pub const RANDOM : u32 = @intFromEnum (Fadvise .random );
8758+ pub const SEQUENTIAL : u32 = @intFromEnum (Fadvise .sequential );
8759+ pub const WILLNEED : u32 = @intFromEnum (Fadvise .willneed );
8760+ pub const DONTNEED : u32 = @intFromEnum (Fadvise .dontneed );
8761+ pub const NOREUSE : u32 = @intFromEnum (Fadvise .noreuse );
86578762 },
86588763};
86598764
0 commit comments