@@ -88,8 +88,6 @@ pub fn clone(
8888}
8989
9090pub const ARCH = arch_bits .ARCH ;
91- pub const F = arch_bits .F ;
92- pub const Flock = arch_bits .Flock ;
9391pub const HWCAP = arch_bits .HWCAP ;
9492pub const SC = arch_bits .SC ;
9593pub const Stat = arch_bits .Stat ;
@@ -110,7 +108,7 @@ pub const IOCTL = @import("linux/ioctl.zig");
110108pub const SECCOMP = @import ("linux/seccomp.zig" );
111109
112110pub const syscalls = @import ("linux/syscalls.zig" );
113- pub const SYS = switch (@import ( "builtin" ). cpu . arch ) {
111+ pub const SYS = switch (native_arch ) {
114112 .arc = > syscalls .Arc ,
115113 .arm , .armeb , .thumb , .thumbeb = > syscalls .Arm ,
116114 .aarch64 , .aarch64_be = > syscalls .Arm64 ,
@@ -1596,6 +1594,70 @@ pub fn waitid(id_type: P, id: i32, infop: *siginfo_t, flags: u32) usize {
15961594 return syscall5 (.waitid , @intFromEnum (id_type ), @as (usize , @bitCast (@as (isize , id ))), @intFromPtr (infop ), flags , 0 );
15971595}
15981596
1597+ pub const F = struct {
1598+ pub const DUPFD = 0 ;
1599+ pub const GETFD = 1 ;
1600+ pub const SETFD = 2 ;
1601+ pub const GETFL = 3 ;
1602+ pub const SETFL = 4 ;
1603+
1604+ pub const GETLK = GET_SET_LK .GETLK ;
1605+ pub const SETLK = GET_SET_LK .SETLK ;
1606+ pub const SETLKW = GET_SET_LK .SETLKW ;
1607+
1608+ const GET_SET_LK = if (@sizeOf (usize ) == 64 ) extern struct {
1609+ pub const GETLK = if (is_mips ) 14 else if (is_sparc ) 7 else 5 ;
1610+ pub const SETLK = if (is_mips ) 6 else if (is_sparc ) 8 else 6 ;
1611+ pub const SETLKW = if (is_mips ) 7 else if (is_sparc ) 9 else 7 ;
1612+ } else extern struct {
1613+ // Ensure that 32-bit code uses the large-file variants (GETLK64, etc).
1614+
1615+ pub const GETLK = if (is_mips ) 33 else 12 ;
1616+ pub const SETLK = if (is_mips ) 34 else 13 ;
1617+ pub const SETLKW = if (is_mips ) 35 else 14 ;
1618+ };
1619+
1620+ pub const SETOWN = if (is_mips ) 24 else if (is_sparc ) 6 else 8 ;
1621+ pub const GETOWN = if (is_mips ) 23 else if (is_sparc ) 5 else 9 ;
1622+
1623+ pub const SETSIG = 10 ;
1624+ pub const GETSIG = 11 ;
1625+
1626+ pub const SETOWN_EX = 15 ;
1627+ pub const GETOWN_EX = 16 ;
1628+
1629+ pub const GETOWNER_UIDS = 17 ;
1630+
1631+ pub const OFD_GETLK = 36 ;
1632+ pub const OFD_SETLK = 37 ;
1633+ pub const OFD_SETLKW = 38 ;
1634+
1635+ pub const RDLCK = if (is_sparc ) 1 else 0 ;
1636+ pub const WRLCK = if (is_sparc ) 2 else 1 ;
1637+ pub const UNLCK = if (is_sparc ) 3 else 2 ;
1638+ };
1639+
1640+ pub const F_OWNER = enum (i32 ) {
1641+ TID = 0 ,
1642+ PID = 1 ,
1643+ PGRP = 2 ,
1644+ _ ,
1645+ };
1646+
1647+ pub const f_owner_ex = extern struct {
1648+ type : F_OWNER ,
1649+ pid : pid_t ,
1650+ };
1651+
1652+ pub const Flock = extern struct {
1653+ type : i16 ,
1654+ whence : i16 ,
1655+ start : off_t ,
1656+ len : off_t ,
1657+ pid : pid_t ,
1658+ _unused : if (is_sparc ) i16 else void ,
1659+ };
1660+
15991661pub fn fcntl (fd : fd_t , cmd : i32 , arg : usize ) usize {
16001662 if (@hasField (SYS , "fcntl64" )) {
16011663 return syscall3 (.fcntl64 , @as (usize , @bitCast (@as (isize , fd ))), @as (usize , @bitCast (@as (isize , cmd ))), arg );
0 commit comments