diff options
Diffstat (limited to 'libc/src/unix/bsd/freebsdlike')
| -rw-r--r-- | libc/src/unix/bsd/freebsdlike/dragonfly/mod.rs | 51 | ||||
| -rw-r--r-- | libc/src/unix/bsd/freebsdlike/freebsd/mod.rs | 261 | ||||
| -rw-r--r-- | libc/src/unix/bsd/freebsdlike/mod.rs | 322 | 
3 files changed, 509 insertions, 125 deletions
| diff --git a/libc/src/unix/bsd/freebsdlike/dragonfly/mod.rs b/libc/src/unix/bsd/freebsdlike/dragonfly/mod.rs index 620fad4..0414380 100644 --- a/libc/src/unix/bsd/freebsdlike/dragonfly/mod.rs +++ b/libc/src/unix/bsd/freebsdlike/dragonfly/mod.rs @@ -1,5 +1,6 @@  pub type clock_t = u64;  pub type ino_t = u64; +pub type lwpid_t = i32;  pub type nlink_t = u32;  pub type blksize_t = i64;  pub type clockid_t = ::c_ulong; @@ -114,6 +115,27 @@ s! {          pub f_uid_uuid: ::uuid_t,      } +    pub struct statfs { +        pub f_bsize: ::c_long, +        pub f_iosize: ::c_long, +        pub f_blocks: ::c_long, +        pub f_bfree: ::c_long, +        pub f_bavail: ::c_long, +        pub f_files: ::c_long, +        pub f_ffree: ::c_long, +        pub f_fsid: ::fsid_t, +        pub f_owner: ::uid_t, +        pub f_type: ::int32_t, +        pub f_flags: ::int32_t, +        pub f_syncwrites: ::c_long, +        pub f_asyncwrites: ::c_long, +        pub f_fstypename: [::c_char; 16], +        pub f_mntonname: [::c_char; 90], +        pub f_syncreads: ::c_long, +        pub f_asyncreads: ::c_long, +        pub f_mntfromname: [::c_char; 90], +    } +      pub struct stat {          pub st_ino: ::ino_t,          pub st_nlink: ::nlink_t, @@ -200,6 +222,8 @@ pub const O_DIRECTORY: ::c_int = 0x08000000;  pub const F_GETLK: ::c_int = 7;  pub const F_SETLK: ::c_int = 8;  pub const F_SETLKW: ::c_int = 9; +pub const ENOMEDIUM: ::c_int = 93; +pub const EASYNC: ::c_int = 99;  pub const ELAST: ::c_int = 99;  pub const RLIMIT_POSIXLOCKS: ::c_int = 11;  pub const RLIM_NLIMITS: ::rlim_t = 12; @@ -407,6 +431,8 @@ pub const NOTE_CHILD: ::uint32_t = 0x00000004;  pub const SO_SNDSPACE: ::c_int = 0x100a;  pub const SO_CPUHINT: ::c_int = 0x1030; +pub const PT_FIRSTMACH: ::c_int = 32; +  // https://github.com/DragonFlyBSD/DragonFlyBSD/blob/master/sys/net/if.h#L101  pub const IFF_UP: ::c_int = 0x1; // interface is up  pub const IFF_BROADCAST: ::c_int = 0x2; // broadcast address valid @@ -658,6 +684,11 @@ pub const IPPROTO_DONE: ::c_int = 257;  /// Used by RSS: the layer3 protocol is unknown  pub const IPPROTO_UNKNOWN: ::c_int = 258; +// sys/netinet/tcp.h +pub const TCP_SIGNATURE_ENABLE:   ::c_int = 16; +pub const TCP_KEEPINIT:   ::c_int = 32; +pub const TCP_FASTKEEP:   ::c_int = 128; +  pub const AF_BLUETOOTH: ::c_int = 33;  pub const AF_MPLS: ::c_int = 34;  pub const AF_IEEE80211: ::c_int = 35; @@ -737,6 +768,20 @@ pub const _SC_THREAD_ROBUST_PRIO_PROTECT: ::c_int = 127;  pub const WCONTINUED: ::c_int = 4;  pub const WSTOPPED: ::c_int = 0o177; +// Values for struct rtprio (type_ field) +pub const RTP_PRIO_REALTIME: ::c_ushort = 0; +pub const RTP_PRIO_NORMAL: ::c_ushort = 1; +pub const RTP_PRIO_IDLE: ::c_ushort = 2; +pub const RTP_PRIO_THREAD: ::c_ushort = 3; + +// Flags for chflags(2) +pub const UF_NOHISTORY: ::c_ulong = 0x00000040; +pub const UF_CACHE:     ::c_ulong = 0x00000080; +pub const UF_XLINK:     ::c_ulong = 0x00000100; +pub const SF_NOHISTORY: ::c_ulong = 0x00400000; +pub const SF_CACHE:     ::c_ulong = 0x00800000; +pub const SF_XLINK:     ::c_ulong = 0x01000000; +  extern {      pub fn mprotect(addr: *mut ::c_void, len: ::size_t, prot: ::c_int)                      -> ::c_int; @@ -750,4 +795,10 @@ extern {                              timeout: *mut ::timespec) -> ::c_int;      pub fn freelocale(loc: ::locale_t); + +    pub fn lwp_rtprio(function: ::c_int, pid: ::pid_t, lwpid: lwpid_t, +                      rtp: *mut super::rtprio) -> ::c_int; + +    pub fn statfs(path: *const ::c_char, buf: *mut statfs) -> ::c_int; +    pub fn fstatfs(fd: ::c_int, buf: *mut statfs) -> ::c_int;  } diff --git a/libc/src/unix/bsd/freebsdlike/freebsd/mod.rs b/libc/src/unix/bsd/freebsdlike/freebsd/mod.rs index 74f2cf8..1ead166 100644 --- a/libc/src/unix/bsd/freebsdlike/freebsd/mod.rs +++ b/libc/src/unix/bsd/freebsdlike/freebsd/mod.rs @@ -3,7 +3,7 @@ pub type clock_t = i32;  pub type ino_t = u32;  pub type lwpid_t = i32;  pub type nlink_t = u16; -pub type blksize_t = u32; +pub type blksize_t = i32;  pub type clockid_t = ::c_int;  pub type sem_t = _sem; @@ -15,6 +15,9 @@ pub type key_t = ::c_long;  pub type msglen_t = ::c_ulong;  pub type msgqnum_t = ::c_ulong; +pub type posix_spawnattr_t = *mut ::c_void; +pub type posix_spawn_file_actions_t = *mut ::c_void; +  s! {      pub struct utmpx {          pub ut_type: ::c_short, @@ -96,6 +99,31 @@ s! {          pub f_namemax: ::c_ulong,      } +    pub struct statfs { +        pub f_version: ::uint32_t, +        pub f_type: ::uint32_t, +        pub f_flags: ::uint64_t, +        pub f_bsize: ::uint64_t, +        pub f_iosize: ::uint64_t, +        pub f_blocks: ::uint64_t, +        pub f_bfree: ::uint64_t, +        pub f_bavail: ::int64_t, +        pub f_files: ::uint64_t, +        pub f_ffree: ::int64_t, +        pub f_syncwrites: ::uint64_t, +        pub f_asyncwrites: ::uint64_t, +        pub f_syncreads: ::uint64_t, +        pub f_asyncreads: ::uint64_t, +        f_spare: [::uint64_t; 10], +        pub f_namemax: ::uint32_t, +        pub f_owner: ::uid_t, +        pub f_fsid: ::fsid_t, +        f_charspare: [::c_char; 80], +        pub f_fstypename: [::c_char; 16], +        pub f_mntfromname: [::c_char; 88], +        pub f_mntonname: [::c_char; 88], +    } +      // internal structure has changed over time      pub struct _sem {          data: [u32; 4], @@ -158,6 +186,10 @@ s! {  pub const SIGEV_THREAD_ID: ::c_int = 4; +pub const EXTATTR_NAMESPACE_EMPTY: ::c_int = 0; +pub const EXTATTR_NAMESPACE_USER: ::c_int = 1; +pub const EXTATTR_NAMESPACE_SYSTEM: ::c_int = 2; +  pub const RAND_MAX: ::c_int = 0x7fff_fffd;  pub const PTHREAD_STACK_MIN: ::size_t = 2048;  pub const PTHREAD_MUTEX_ADAPTIVE_NP: ::c_int = 4; @@ -165,6 +197,8 @@ pub const SIGSTKSZ: ::size_t = 34816;  pub const SF_NODISKIO: ::c_int = 0x00000001;  pub const SF_MNOWAIT: ::c_int = 0x00000002;  pub const SF_SYNC: ::c_int = 0x00000004; +pub const SF_USER_READAHEAD: ::c_int = 0x00000008; +pub const SF_NOCACHE: ::c_int = 0x00000010;  pub const O_CLOEXEC: ::c_int = 0x00100000;  pub const O_DIRECTORY: ::c_int = 0x00020000;  pub const O_EXEC: ::c_int = 0x00040000; @@ -179,7 +213,9 @@ pub const EOWNERDEAD: ::c_int = 96;  pub const ELAST: ::c_int = 96;  pub const RLIMIT_NPTS: ::c_int = 11;  pub const RLIMIT_SWAP: ::c_int = 12; -pub const RLIM_NLIMITS: ::rlim_t = 13; +pub const RLIMIT_KQUEUES: ::c_int = 13; +pub const RLIMIT_UMTXP: ::c_int = 14; +pub const RLIM_NLIMITS: ::rlim_t = 15;  pub const Q_GETQUOTA: ::c_int = 0x700;  pub const Q_SETQUOTA: ::c_int = 0x800; @@ -200,9 +236,12 @@ pub const EVFILT_VNODE: ::int16_t = -4;  pub const EVFILT_PROC: ::int16_t = -5;  pub const EVFILT_SIGNAL: ::int16_t = -6;  pub const EVFILT_TIMER: ::int16_t = -7; +pub const EVFILT_PROCDESC: ::int16_t = -8;  pub const EVFILT_FS: ::int16_t = -9;  pub const EVFILT_LIO: ::int16_t = -10;  pub const EVFILT_USER: ::int16_t = -11; +pub const EVFILT_SENDFILE: ::int16_t = -12; +pub const EVFILT_EMPTY: ::int16_t = -13;  pub const EV_ADD: ::uint16_t = 0x1;  pub const EV_DELETE: ::uint16_t = 0x2; @@ -422,6 +461,7 @@ pub const JAIL_SYS_INHERIT: ::c_int = 2;  pub const SO_BINTIME: ::c_int = 0x2000;  pub const SO_NO_OFFLOAD: ::c_int = 0x4000;  pub const SO_NO_DDP: ::c_int = 0x8000; +pub const SO_REUSEPORT_LB: ::c_int = 0x10000;  pub const SO_LABEL: ::c_int = 0x1009;  pub const SO_PEERLABEL: ::c_int = 0x1010;  pub const SO_LISTENQLIMIT: ::c_int = 0x1011; @@ -438,6 +478,39 @@ pub const LOCAL_CREDS: ::c_int = 2;  pub const LOCAL_CONNWAIT: ::c_int = 4;  pub const LOCAL_VENDOR: ::c_int = SO_VENDOR; +pub const PT_LWPINFO: ::c_int = 13; +pub const PT_GETNUMLWPS: ::c_int = 14; +pub const PT_GETLWPLIST: ::c_int = 15; +pub const PT_CLEARSTEP: ::c_int = 16; +pub const PT_SETSTEP: ::c_int = 17; +pub const PT_SUSPEND: ::c_int = 18; +pub const PT_RESUME: ::c_int = 19; +pub const PT_TO_SCE: ::c_int = 20; +pub const PT_TO_SCX: ::c_int = 21; +pub const PT_SYSCALL: ::c_int = 22; +pub const PT_FOLLOW_FORK: ::c_int = 23; +pub const PT_LWP_EVENTS: ::c_int = 24; +pub const PT_GET_EVENT_MASK: ::c_int = 25; +pub const PT_SET_EVENT_MASK: ::c_int = 26; +pub const PT_GETREGS: ::c_int = 33; +pub const PT_SETREGS: ::c_int = 34; +pub const PT_GETFPREGS: ::c_int = 35; +pub const PT_SETFPREGS: ::c_int = 36; +pub const PT_GETDBREGS: ::c_int = 37; +pub const PT_SETDBREGS: ::c_int = 38; +pub const PT_VM_TIMESTAMP: ::c_int = 40; +pub const PT_VM_ENTRY: ::c_int = 41; +pub const PT_FIRSTMACH: ::c_int = 64; + +pub const PTRACE_EXEC: ::c_int = 0x0001; +pub const PTRACE_SCE: ::c_int = 0x0002; +pub const PTRACE_SCX: ::c_int = 0x0004; +pub const PTRACE_SYSCALL: ::c_int = PTRACE_SCE | PTRACE_SCX; +pub const PTRACE_FORK: ::c_int = 0x0008; +pub const PTRACE_LWP: ::c_int = 0x0010; +pub const PTRACE_VFORK: ::c_int = 0x0020; +pub const PTRACE_DEFAULT: ::c_int = PTRACE_EXEC; +  pub const AF_SLOW: ::c_int = 33;  pub const AF_SCLUSTER: ::c_int = 34;  pub const AF_ARP: ::c_int = 35; @@ -719,6 +792,16 @@ pub const IPPROTO_DIVERT: ::c_int = 258;  /// SeND pseudo-protocol  pub const IPPROTO_SEND: ::c_int = 259; +// sys/netinet/TCP.h +pub const TCP_MD5SIG: ::c_int = 16; +pub const TCP_INFO: ::c_int = 32; +pub const TCP_CONGESTION: ::c_int = 64; +pub const TCP_CCALGOOPT: ::c_int = 65; +pub const TCP_KEEPINIT: ::c_int = 128; +pub const TCP_FASTOPEN: ::c_int = 1025; +pub const TCP_PCAP_OUT: ::c_int = 2048; +pub const TCP_PCAP_IN: ::c_int = 4096; +  pub const IP_BINDANY: ::c_int = 24;  pub const PF_SLOW: ::c_int = AF_SLOW; @@ -795,10 +878,10 @@ pub const SHUTDOWN_TIME: ::c_short = 8;  pub const LC_COLLATE_MASK: ::c_int = (1 << 0);  pub const LC_CTYPE_MASK: ::c_int = (1 << 1); -pub const LC_MESSAGES_MASK: ::c_int = (1 << 2); -pub const LC_MONETARY_MASK: ::c_int = (1 << 3); -pub const LC_NUMERIC_MASK: ::c_int = (1 << 4); -pub const LC_TIME_MASK: ::c_int = (1 << 5); +pub const LC_MONETARY_MASK: ::c_int =(1 << 2); +pub const LC_NUMERIC_MASK: ::c_int = (1 << 3); +pub const LC_TIME_MASK: ::c_int = (1 << 4); +pub const LC_MESSAGES_MASK: ::c_int = (1 << 5);  pub const LC_ALL_MASK: ::c_int = LC_COLLATE_MASK                                 | LC_CTYPE_MASK                                 | LC_MESSAGES_MASK @@ -838,6 +921,33 @@ pub const _SC_CPUSET_SIZE: ::c_int = 122;  pub const XU_NGROUPS: ::c_int = 16;  pub const XUCRED_VERSION: ::c_uint = 0; +// Flags which can be passed to pdfork(2) +pub const PD_DAEMON: ::c_int = 0x00000001; +pub const PD_CLOEXEC: ::c_int = 0x00000002; +pub const PD_ALLOWED_AT_FORK: ::c_int = PD_DAEMON | PD_CLOEXEC; + +// Values for struct rtprio (type_ field) +pub const RTP_PRIO_REALTIME: ::c_ushort = 2; +pub const RTP_PRIO_NORMAL: ::c_ushort = 3; +pub const RTP_PRIO_IDLE: ::c_ushort = 4; + +pub const POSIX_SPAWN_RESETIDS: ::c_int = 0x01; +pub const POSIX_SPAWN_SETPGROUP: ::c_int = 0x02; +pub const POSIX_SPAWN_SETSCHEDPARAM: ::c_int = 0x04; +pub const POSIX_SPAWN_SETSCHEDULER: ::c_int = 0x08; +pub const POSIX_SPAWN_SETSIGDEF: ::c_int = 0x10; +pub const POSIX_SPAWN_SETSIGMASK: ::c_int = 0x20; + +// Flags for chflags(2) +pub const UF_SYSTEM:    ::c_ulong = 0x00000080; +pub const UF_SPARSE:    ::c_ulong = 0x00000100; +pub const UF_OFFLINE:   ::c_ulong = 0x00000200; +pub const UF_REPARSE:   ::c_ulong = 0x00000400; +pub const UF_ARCHIVE:   ::c_ulong = 0x00000800; +pub const UF_READONLY:  ::c_ulong = 0x00001000; +pub const UF_HIDDEN:    ::c_ulong = 0x00008000; +pub const SF_SNAPSHOT:  ::c_ulong = 0x00200000; +  extern {      pub fn __error() -> *mut ::c_int; @@ -848,6 +958,58 @@ extern {      pub fn clock_gettime(clk_id: ::clockid_t, tp: *mut ::timespec) -> ::c_int;      pub fn clock_settime(clk_id: ::clockid_t, tp: *const ::timespec) -> ::c_int; +    pub fn extattr_delete_fd(fd: ::c_int, +                             attrnamespace: ::c_int, +                             attrname: *const ::c_char) -> ::c_int; +    pub fn extattr_delete_file(path: *const ::c_char, +                               attrnamespace: ::c_int, +                               attrname: *const ::c_char) -> ::c_int; +    pub fn extattr_delete_link(path: *const ::c_char, +                               attrnamespace: ::c_int, +                               attrname: *const ::c_char) -> ::c_int; +    pub fn extattr_get_fd(fd: ::c_int, +                          attrnamespace: ::c_int, +                          attrname: *const ::c_char, +                          data: *mut ::c_void, +                          nbytes: ::size_t) -> ::ssize_t; +    pub fn extattr_get_file(path: *const ::c_char, +                            attrnamespace: ::c_int, +                            attrname: *const ::c_char, +                            data: *mut ::c_void, +                            nbytes: ::size_t) -> ::ssize_t; +    pub fn extattr_get_link(path: *const ::c_char, +                            attrnamespace: ::c_int, +                            attrname: *const ::c_char, +                            data: *mut ::c_void, +                            nbytes: ::size_t) -> ::ssize_t; +    pub fn extattr_list_fd(fd: ::c_int, +                           attrnamespace: ::c_int, +                           data: *mut ::c_void, +                           nbytes: ::size_t) -> ::ssize_t; +    pub fn extattr_list_file(path: *const ::c_char, +                             attrnamespace: ::c_int, +                             data: *mut ::c_void, +                             nbytes: ::size_t) -> ::ssize_t; +    pub fn extattr_list_link(path: *const ::c_char, +                             attrnamespace: ::c_int, +                             data: *mut ::c_void, +                             nbytes: ::size_t) -> ::ssize_t; +    pub fn extattr_set_fd(fd: ::c_int, +                          attrnamespace: ::c_int, +                          attrname: *const ::c_char, +                          data: *const ::c_void, +                          nbytes: ::size_t) -> ::ssize_t; +    pub fn extattr_set_file(path: *const ::c_char, +                            attrnamespace: ::c_int, +                            attrname: *const ::c_char, +                            data: *const ::c_void, +                            nbytes: ::size_t) -> ::ssize_t; +    pub fn extattr_set_link(path: *const ::c_char, +                            attrnamespace: ::c_int, +                            attrname: *const ::c_char, +                            data: *const ::c_void, +                            nbytes: ::size_t) -> ::ssize_t; +      pub fn jail(jail: *mut ::jail) -> ::c_int;      pub fn jail_attach(jid: ::c_int) -> ::c_int;      pub fn jail_remove(jid: ::c_int) -> ::c_int; @@ -856,6 +1018,7 @@ extern {      pub fn jail_set(iov: *mut ::iovec, niov: ::c_uint, flags: ::c_int)                      -> ::c_int; +    pub fn fdatasync(fd: ::c_int) -> ::c_int;      pub fn posix_fallocate(fd: ::c_int, offset: ::off_t,                             len: ::off_t) -> ::c_int;      pub fn posix_fadvise(fd: ::c_int, offset: ::off_t, len: ::off_t, @@ -893,6 +1056,92 @@ extern {      pub fn fexecve(fd: ::c_int, argv: *const *const ::c_char,                     envp: *const *const ::c_char)                     -> ::c_int; + +    pub fn pdfork(fdp: *mut ::c_int, flags: ::c_int) -> ::pid_t; +    pub fn pdgetpid(fd: ::c_int, pidp: *mut ::pid_t) -> ::c_int; +    pub fn pdkill(fd: ::c_int, signum: ::c_int) -> ::c_int; + +    pub fn rtprio_thread(function: ::c_int, lwpid: ::lwpid_t, +                         rtp: *mut super::rtprio) -> ::c_int; + +    pub fn posix_spawn(pid: *mut ::pid_t, +                       path: *const ::c_char, +                       file_actions: *const ::posix_spawn_file_actions_t, +                       attrp: *const ::posix_spawnattr_t, +                       argv: *const *mut ::c_char, +                       envp: *const *mut ::c_char) -> ::c_int; +    pub fn posix_spawnp(pid: *mut ::pid_t, +                       file: *const ::c_char, +                        file_actions: *const ::posix_spawn_file_actions_t, +                        attrp: *const ::posix_spawnattr_t, +                        argv: *const *mut ::c_char, +                        envp: *const *mut ::c_char) -> ::c_int; +    pub fn posix_spawnattr_init(attr: *mut posix_spawnattr_t) -> ::c_int; +    pub fn posix_spawnattr_destroy(attr: *mut posix_spawnattr_t) -> ::c_int; +    pub fn posix_spawnattr_getsigdefault(attr: *const posix_spawnattr_t, +                                         default: *mut ::sigset_t) -> ::c_int; +    pub fn posix_spawnattr_setsigdefault(attr: *mut posix_spawnattr_t, +                                         default: *const ::sigset_t) -> ::c_int; +    pub fn posix_spawnattr_getsigmask(attr: *const posix_spawnattr_t, +                                      default: *mut ::sigset_t) -> ::c_int; +    pub fn posix_spawnattr_setsigmask(attr: *mut posix_spawnattr_t, +                                      default: *const ::sigset_t) -> ::c_int; +    pub fn posix_spawnattr_getflags(attr: *const posix_spawnattr_t, +                                    flags: *mut ::c_short) -> ::c_int; +    pub fn posix_spawnattr_setflags(attr: *mut posix_spawnattr_t, +                                    flags: ::c_short) -> ::c_int; +    pub fn posix_spawnattr_getpgroup(attr: *const posix_spawnattr_t, +                                     flags: *mut ::pid_t) -> ::c_int; +    pub fn posix_spawnattr_setpgroup(attr: *mut posix_spawnattr_t, +                                     flags: ::pid_t) -> ::c_int; +    pub fn posix_spawnattr_getschedpolicy(attr: *const posix_spawnattr_t, +                                          flags: *mut ::c_int) -> ::c_int; +    pub fn posix_spawnattr_setschedpolicy(attr: *mut posix_spawnattr_t, +                                          flags: ::c_int) -> ::c_int; +    pub fn posix_spawnattr_getschedparam( +        attr: *const posix_spawnattr_t, +        param: *mut ::sched_param, +    ) -> ::c_int; +    pub fn posix_spawnattr_setschedparam( +        attr: *mut posix_spawnattr_t, +        param: *const ::sched_param, +    ) -> ::c_int; + +    pub fn posix_spawn_file_actions_init( +        actions: *mut posix_spawn_file_actions_t, +    ) -> ::c_int; +    pub fn posix_spawn_file_actions_destroy( +        actions: *mut posix_spawn_file_actions_t, +    ) -> ::c_int; +    pub fn posix_spawn_file_actions_addopen( +        actions: *mut posix_spawn_file_actions_t, +        fd: ::c_int, +        path: *const ::c_char, +        oflag: ::c_int, +        mode: ::mode_t, +    ) -> ::c_int; +    pub fn posix_spawn_file_actions_addclose( +        actions: *mut posix_spawn_file_actions_t, +        fd: ::c_int, +    ) -> ::c_int; +    pub fn posix_spawn_file_actions_adddup2( +        actions: *mut posix_spawn_file_actions_t, +        fd: ::c_int, +        newfd: ::c_int, +    ) -> ::c_int; + +    pub fn statfs(path: *const ::c_char, buf: *mut statfs) -> ::c_int; +    pub fn fstatfs(fd: ::c_int, buf: *mut statfs) -> ::c_int; + +    pub fn dup3(src: ::c_int, dst: ::c_int, flags: ::c_int) -> ::c_int; +} + +#[link(name = "util")] +extern { +    pub fn extattr_namespace_to_string(attrnamespace: ::c_int, +                                       string: *mut *mut ::c_char) -> ::c_int; +    pub fn extattr_string_to_namespace(string: *const ::c_char, +                                       attrnamespace: *mut ::c_int) -> ::c_int;  }  cfg_if! { diff --git a/libc/src/unix/bsd/freebsdlike/mod.rs b/libc/src/unix/bsd/freebsdlike/mod.rs index 5cea759..cb3dba4 100644 --- a/libc/src/unix/bsd/freebsdlike/mod.rs +++ b/libc/src/unix/bsd/freebsdlike/mod.rs @@ -170,6 +170,24 @@ s! {          pub cmcred_ngroups: ::c_short,          pub cmcred_groups: [::gid_t; CMGROUP_MAX],      } + +    pub struct rtprio { +        pub type_: ::c_ushort, +        pub prio: ::c_ushort, +    } + +    pub struct in6_pktinfo { +        pub ipi6_addr: ::in6_addr, +        pub ipi6_ifindex: ::c_uint, +    } + +    pub struct arphdr { +        pub ar_hrd: u16, +        pub ar_pro: u16, +        pub ar_hln: u8, +        pub ar_pln: u8, +        pub ar_op: u16, +    }  }  pub const AIO_LISTIO_MAX: ::c_int = 16; @@ -606,6 +624,18 @@ pub const PF_NATM: ::c_int = AF_NATM;  pub const PF_ATM: ::c_int = AF_ATM;  pub const PF_NETGRAPH: ::c_int = AF_NETGRAPH; +pub const PT_TRACE_ME: ::c_int = 0; +pub const PT_READ_I: ::c_int = 1; +pub const PT_READ_D: ::c_int = 2; +pub const PT_WRITE_I: ::c_int = 4; +pub const PT_WRITE_D: ::c_int = 5; +pub const PT_CONTINUE: ::c_int = 7; +pub const PT_KILL: ::c_int = 8; +pub const PT_STEP: ::c_int = 9; +pub const PT_ATTACH: ::c_int = 10; +pub const PT_DETACH: ::c_int = 11; +pub const PT_IO: ::c_int = 12; +  pub const SOMAXCONN: ::c_int = 128;  pub const MSG_OOB: ::c_int = 0x00000001; @@ -630,13 +660,21 @@ pub const SOCK_NONBLOCK: ::c_int = 0x20000000;  pub const SOCK_MAXADDRLEN: ::c_int = 255;  pub const IP_TTL: ::c_int = 4;  pub const IP_HDRINCL: ::c_int = 2; +pub const IP_RECVDSTADDR: ::c_int = 7; +pub const IP_SENDSRCADDR: ::c_int = IP_RECVDSTADDR;  pub const IP_ADD_MEMBERSHIP: ::c_int = 12;  pub const IP_DROP_MEMBERSHIP: ::c_int = 13;  pub const IPV6_JOIN_GROUP: ::c_int = 12;  pub const IPV6_LEAVE_GROUP: ::c_int = 13; +pub const IPV6_RECVPKTINFO: ::c_int = 36; +pub const IPV6_PKTINFO: ::c_int = 46; + +pub const TCP_NOPUSH:    ::c_int = 4; +pub const TCP_NOOPT:     ::c_int = 8; +pub const TCP_KEEPIDLE:  ::c_int = 256; +pub const TCP_KEEPINTVL: ::c_int = 512; +pub const TCP_KEEPCNT:   ::c_int = 1024; -pub const TCP_NODELAY: ::c_int = 1; -pub const TCP_KEEPIDLE: ::c_int = 256;  pub const SOL_SOCKET: ::c_int = 0xffff;  pub const SO_DEBUG: ::c_int = 0x01;  pub const SO_ACCEPTCONN: ::c_int = 0x0002; @@ -960,6 +998,27 @@ pub const CMGROUP_MAX: usize = 16;  // sizeof(long)  pub const BPF_ALIGNMENT: ::c_int = 8; +// Values for rtprio struct (prio field) and syscall (function argument) +pub const RTP_PRIO_MIN: ::c_ushort = 0; +pub const RTP_PRIO_MAX: ::c_ushort = 31; +pub const RTP_LOOKUP: ::c_int = 0; +pub const RTP_SET: ::c_int = 1; + +// Flags for chflags(2) +pub const UF_SETTABLE:      ::c_ulong = 0x0000ffff; +pub const UF_NODUMP:        ::c_ulong = 0x00000001; +pub const UF_IMMUTABLE:     ::c_ulong = 0x00000002; +pub const UF_APPEND:        ::c_ulong = 0x00000004; +pub const UF_OPAQUE:        ::c_ulong = 0x00000008; +pub const UF_NOUNLINK:      ::c_ulong = 0x00000010; +pub const SF_SETTABLE:      ::c_ulong = 0xffff0000; +pub const SF_ARCHIVED:      ::c_ulong = 0x00010000; +pub const SF_IMMUTABLE:     ::c_ulong = 0x00020000; +pub const SF_APPEND:        ::c_ulong = 0x00040000; +pub const SF_NOUNLINK:      ::c_ulong = 0x00100000; + +pub const TIMER_ABSTIME: ::c_int = 1; +  f! {      pub fn WIFCONTINUED(status: ::c_int) -> bool {          status == 0x13 @@ -979,24 +1038,73 @@ f! {  }  extern { -    pub fn lutimes(file: *const ::c_char, times: *const ::timeval) -> ::c_int; +    pub fn accept4(s: ::c_int, addr: *mut ::sockaddr, +                   addrlen: *mut ::socklen_t, flags: ::c_int) -> ::c_int; +    pub fn aio_read(aiocbp: *mut aiocb) -> ::c_int; +    pub fn aio_write(aiocbp: *mut aiocb) -> ::c_int; +    pub fn aio_fsync(op: ::c_int, aiocbp: *mut aiocb) -> ::c_int; +    pub fn aio_error(aiocbp: *const aiocb) -> ::c_int; +    pub fn aio_return(aiocbp: *mut aiocb) -> ::ssize_t; +    pub fn aio_suspend(aiocb_list: *const *const aiocb, nitems: ::c_int, +                       timeout: *const ::timespec) -> ::c_int; +    pub fn aio_cancel(fd: ::c_int, aiocbp: *mut aiocb) -> ::c_int; +    pub fn chflags(path: *const ::c_char, flags: ::c_ulong) -> ::c_int; +    pub fn chflagsat(fd: ::c_int, path: *const ::c_char, flags: ::c_ulong, +                     atflag: ::c_int) -> ::c_int; +    pub fn dirfd(dirp: *mut ::DIR) -> ::c_int; +    pub fn duplocale(base: ::locale_t) -> ::locale_t;      pub fn endutxent(); -    pub fn getutxent() -> *mut utmpx; -    pub fn getutxid(ut: *const utmpx) -> *mut utmpx; -    pub fn getutxline(ut: *const utmpx) -> *mut utmpx; -    pub fn pututxline(ut: *const utmpx) -> *mut utmpx; -    pub fn setutxent(); -    pub fn setresgid(rgid: ::gid_t, egid: ::gid_t, sgid: ::gid_t) -> ::c_int; -    pub fn setresuid(ruid: ::uid_t, euid: ::uid_t, suid: ::uid_t) -> ::c_int; +    pub fn fchflags(fd: ::c_int, flags: ::c_ulong) -> ::c_int; +    pub fn futimens(fd: ::c_int, times: *const ::timespec) -> ::c_int; +    pub fn getdomainname(name: *mut ::c_char, len: ::c_int) -> ::c_int; +    pub fn getgrent_r(grp: *mut ::group, +                      buf: *mut ::c_char, +                      buflen: ::size_t, +                      result: *mut *mut ::group) -> ::c_int; +    #[cfg_attr(target_os = "netbsd", link_name = "__getpwent_r50")] +    pub fn getpwent_r(pwd: *mut ::passwd, +                      buf: *mut ::c_char, +                      buflen: ::size_t, +                      result: *mut *mut ::passwd) -> ::c_int;      pub fn getgrouplist(name: *const ::c_char,                          basegid: ::gid_t,                          groups: *mut ::gid_t,                          ngroups: *mut ::c_int) -> ::c_int; +    pub fn getnameinfo(sa: *const ::sockaddr, +                       salen: ::socklen_t, +                       host: *mut ::c_char, +                       hostlen: ::size_t, +                       serv: *mut ::c_char, +                       servlen: ::size_t, +                       flags: ::c_int) -> ::c_int; +    pub fn getpriority(which: ::c_int, who: ::c_int) -> ::c_int; +    pub fn getutxent() -> *mut utmpx; +    pub fn getutxid(ut: *const utmpx) -> *mut utmpx; +    pub fn getutxline(ut: *const utmpx) -> *mut utmpx;      pub fn initgroups(name: *const ::c_char, basegid: ::gid_t) -> ::c_int; -    pub fn mq_open(name: *const ::c_char, oflag: ::c_int, ...) -> ::mqd_t; +    #[cfg_attr(target_os = "freebsd", link_name = "kevent@FBSD_1.0")] +    pub fn kevent(kq: ::c_int, +                  changelist: *const ::kevent, +                  nchanges: ::c_int, +                  eventlist: *mut ::kevent, +                  nevents: ::c_int, +                  timeout: *const ::timespec) -> ::c_int; +    pub fn lchflags(path: *const ::c_char, flags: ::c_ulong) -> ::c_int; +    pub fn lio_listio(mode: ::c_int, aiocb_list: *const *mut aiocb, +                      nitems: ::c_int, sevp: *mut sigevent) -> ::c_int; +    pub fn lutimes(file: *const ::c_char, times: *const ::timeval) -> ::c_int; +    pub fn memrchr(cx: *const ::c_void, +                   c: ::c_int, +                   n: ::size_t) -> *mut ::c_void; +    pub fn mkfifoat(dirfd: ::c_int, pathname: *const ::c_char, +                    mode: ::mode_t) -> ::c_int; +    #[cfg_attr(target_os = "freebsd", link_name = "mknodat@FBSD_1.1")] +    pub fn mknodat(dirfd: ::c_int, pathname: *const ::c_char, +                  mode: ::mode_t, dev: dev_t) -> ::c_int;      pub fn mq_close(mqd: ::mqd_t) -> ::c_int;      pub fn mq_getattr(mqd: ::mqd_t, attr: *mut ::mq_attr) -> ::c_int;      pub fn mq_notify(mqd: ::mqd_t, notification: *const ::sigevent) -> ::c_int; +    pub fn mq_open(name: *const ::c_char, oflag: ::c_int, ...) -> ::mqd_t;      pub fn mq_receive(mqd: ::mqd_t,                        msg_ptr: *mut ::c_char,                        msg_len: ::size_t, @@ -1019,70 +1127,66 @@ extern {                          msq_prio: ::c_uint,                          abs_timeout: *const ::timespec) -> ::c_int;      pub fn mq_unlink(name: *const ::c_char) -> ::c_int; -} - -#[link(name = "util")] -extern { -    pub fn aio_read(aiocbp: *mut aiocb) -> ::c_int; -    pub fn aio_write(aiocbp: *mut aiocb) -> ::c_int; -    pub fn aio_fsync(op: ::c_int, aiocbp: *mut aiocb) -> ::c_int; -    pub fn aio_error(aiocbp: *const aiocb) -> ::c_int; -    pub fn aio_return(aiocbp: *mut aiocb) -> ::ssize_t; -    pub fn aio_suspend(aiocb_list: *const *const aiocb, nitems: ::c_int, -                       timeout: *const ::timespec) -> ::c_int; -    pub fn aio_cancel(fd: ::c_int, aiocbp: *mut aiocb) -> ::c_int; -    pub fn lio_listio(mode: ::c_int, aiocb_list: *const *mut aiocb, -                      nitems: ::c_int, sevp: *mut sigevent) -> ::c_int; -    pub fn dirfd(dirp: *mut ::DIR) -> ::c_int; -    pub fn getnameinfo(sa: *const ::sockaddr, -                       salen: ::socklen_t, -                       host: *mut ::c_char, -                       hostlen: ::size_t, -                       serv: *mut ::c_char, -                       servlen: ::size_t, -                       flags: ::c_int) -> ::c_int; -    pub fn kevent(kq: ::c_int, -                  changelist: *const ::kevent, -                  nchanges: ::c_int, -                  eventlist: *mut ::kevent, -                  nevents: ::c_int, -                  timeout: *const ::timespec) -> ::c_int;      pub fn mincore(addr: *const ::c_void, len: ::size_t,                     vec: *mut ::c_char) -> ::c_int; -    pub fn pwritev(fd: ::c_int, -                   iov: *const ::iovec, -                   iovcnt: ::c_int, -                   offset: ::off_t) -> ::ssize_t; +    pub fn newlocale(mask: ::c_int, +                     locale: *const ::c_char, +                     base: ::locale_t) -> ::locale_t; +    pub fn nl_langinfo_l(item: ::nl_item, locale: ::locale_t) -> *mut ::c_char; +    pub fn pipe2(fds: *mut ::c_int, flags: ::c_int) -> ::c_int; +    pub fn ppoll(fds: *mut ::pollfd, +                 nfds: ::nfds_t, +                 timeout: *const ::timespec, +                 sigmask: *const sigset_t) -> ::c_int;      pub fn preadv(fd: ::c_int,                    iov: *const ::iovec,                    iovcnt: ::c_int,                    offset: ::off_t) -> ::ssize_t; -    pub fn sysctlnametomib(name: *const ::c_char, -                           mibp: *mut ::c_int, -                           sizep: *mut ::size_t) -                           -> ::c_int; -    pub fn shm_open(name: *const ::c_char, oflag: ::c_int, mode: ::mode_t) -                    -> ::c_int; -    pub fn sysctl(name: *const ::c_int, -                  namelen: ::c_uint, -                  oldp: *mut ::c_void, -                  oldlenp: *mut ::size_t, -                  newp: *const ::c_void, -                  newlen: ::size_t) -                  -> ::c_int; -    pub fn sysctlbyname(name: *const ::c_char, -                        oldp: *mut ::c_void, -                        oldlenp: *mut ::size_t, -                        newp: *const ::c_void, -                        newlen: ::size_t) -                        -> ::c_int; +    pub fn pthread_attr_get_np(tid: ::pthread_t, +                               attr: *mut ::pthread_attr_t) -> ::c_int; +    pub fn pthread_attr_getguardsize(attr: *const ::pthread_attr_t, +                                     guardsize: *mut ::size_t) -> ::c_int; +    pub fn pthread_attr_getstack(attr: *const ::pthread_attr_t, +                                 stackaddr: *mut *mut ::c_void, +                                 stacksize: *mut ::size_t) -> ::c_int; +    pub fn pthread_condattr_getclock(attr: *const pthread_condattr_t, +                                     clock_id: *mut clockid_t) -> ::c_int; +    pub fn pthread_condattr_getpshared(attr: *const pthread_condattr_t, +                                       pshared: *mut ::c_int) -> ::c_int; +    pub fn pthread_condattr_setclock(attr: *mut pthread_condattr_t, +                                     clock_id: ::clockid_t) -> ::c_int; +    pub fn pthread_condattr_setpshared(attr: *mut pthread_condattr_t, +                                       pshared: ::c_int) -> ::c_int; +    pub fn pthread_mutex_timedlock(lock: *mut pthread_mutex_t, +                                   abstime: *const ::timespec) -> ::c_int; +    pub fn pthread_mutexattr_getpshared(attr: *const pthread_mutexattr_t, +                                        pshared: *mut ::c_int) -> ::c_int; +    pub fn pthread_mutexattr_setpshared(attr: *mut pthread_mutexattr_t, +                                        pshared: ::c_int) -> ::c_int; +    pub fn pthread_rwlockattr_getpshared(attr: *const pthread_rwlockattr_t, +                                         val: *mut ::c_int) -> ::c_int; +    pub fn pthread_rwlockattr_setpshared(attr: *mut pthread_rwlockattr_t, +                                         val: ::c_int) -> ::c_int; +    pub fn pthread_set_name_np(tid: ::pthread_t, name: *const ::c_char); +    pub fn ptrace(request: ::c_int, +                  pid: ::pid_t, +                  addr: *mut ::c_char, +                  data: ::c_int) -> ::c_int; +    pub fn pututxline(ut: *const utmpx) -> *mut utmpx; +    pub fn pwritev(fd: ::c_int, +                   iov: *const ::iovec, +                   iovcnt: ::c_int, +                   offset: ::off_t) -> ::ssize_t; +    pub fn querylocale(mask: ::c_int, loc: ::locale_t) -> *const ::c_char; +    pub fn rtprio(function: ::c_int, pid: ::pid_t, rtp: *mut rtprio) -> ::c_int; +    pub fn sched_getscheduler(pid: ::pid_t) -> ::c_int;      pub fn sched_setscheduler(pid: ::pid_t,                                policy: ::c_int,                                param: *const ::sched_param) -> ::c_int; -    pub fn sched_getscheduler(pid: ::pid_t) -> ::c_int; -    pub fn memrchr(cx: *const ::c_void, -                   c: ::c_int, -                   n: ::size_t) -> *mut ::c_void; +    pub fn sem_getvalue(sem: *mut sem_t, +                        sval: *mut ::c_int) -> ::c_int; +    pub fn sem_timedwait(sem: *mut sem_t, +                         abstime: *const ::timespec) -> ::c_int;      pub fn sendfile(fd: ::c_int,                      s: ::c_int,                      offset: ::off_t, @@ -1090,11 +1194,44 @@ extern {                      hdtr: *mut ::sf_hdtr,                      sbytes: *mut ::off_t,                      flags: ::c_int) -> ::c_int; +    pub fn setdomainname(name: *const ::c_char, len: ::c_int) -> ::c_int; +    pub fn sethostname(name: *const ::c_char, len: ::c_int) -> ::c_int; +    pub fn setpriority(which: ::c_int, who: ::c_int, prio: ::c_int) -> ::c_int; +    pub fn setresgid(rgid: ::gid_t, egid: ::gid_t, sgid: ::gid_t) -> ::c_int; +    pub fn setresuid(ruid: ::uid_t, euid: ::uid_t, suid: ::uid_t) -> ::c_int; +    pub fn settimeofday(tv: *const ::timeval, tz: *const ::timezone) -> ::c_int; +    pub fn setutxent(); +    pub fn shm_open(name: *const ::c_char, oflag: ::c_int, mode: ::mode_t) +                    -> ::c_int;      pub fn sigtimedwait(set: *const sigset_t,                          info: *mut siginfo_t,                          timeout: *const ::timespec) -> ::c_int;      pub fn sigwaitinfo(set: *const sigset_t,                         info: *mut siginfo_t) -> ::c_int; +    pub fn sysctl(name: *const ::c_int, +                  namelen: ::c_uint, +                  oldp: *mut ::c_void, +                  oldlenp: *mut ::size_t, +                  newp: *const ::c_void, +                  newlen: ::size_t) +                  -> ::c_int; +    pub fn sysctlbyname(name: *const ::c_char, +                        oldp: *mut ::c_void, +                        oldlenp: *mut ::size_t, +                        newp: *const ::c_void, +                        newlen: ::size_t) +                        -> ::c_int; +    pub fn sysctlnametomib(name: *const ::c_char, +                           mibp: *mut ::c_int, +                           sizep: *mut ::size_t) +                           -> ::c_int; +    pub fn uselocale(loc: ::locale_t) -> ::locale_t; +    pub fn utimensat(dirfd: ::c_int, path: *const ::c_char, +                     times: *const ::timespec, flag: ::c_int) -> ::c_int; +} + +#[link(name = "util")] +extern {      pub fn openpty(amaster: *mut ::c_int,                     aslave: *mut ::c_int,                     name: *mut ::c_char, @@ -1104,59 +1241,6 @@ extern {                     name: *mut ::c_char,                     termp: *mut termios,                     winp: *mut ::winsize) -> ::pid_t; -    pub fn nl_langinfo_l(item: ::nl_item, locale: ::locale_t) -> *mut ::c_char; -    pub fn duplocale(base: ::locale_t) -> ::locale_t; -    pub fn newlocale(mask: ::c_int, -                     locale: *const ::c_char, -                     base: ::locale_t) -> ::locale_t; -    pub fn uselocale(loc: ::locale_t) -> ::locale_t; -    pub fn querylocale(mask: ::c_int, loc: ::locale_t) -> *const ::c_char; -    pub fn accept4(s: ::c_int, addr: *mut ::sockaddr, -                   addrlen: *mut ::socklen_t, flags: ::c_int) -> ::c_int; -    pub fn pthread_set_name_np(tid: ::pthread_t, name: *const ::c_char); -    pub fn pthread_attr_get_np(tid: ::pthread_t, -                               attr: *mut ::pthread_attr_t) -> ::c_int; -    pub fn pthread_attr_getguardsize(attr: *const ::pthread_attr_t, -                                     guardsize: *mut ::size_t) -> ::c_int; -    pub fn pthread_attr_getstack(attr: *const ::pthread_attr_t, -                                 stackaddr: *mut *mut ::c_void, -                                 stacksize: *mut ::size_t) -> ::c_int; -    pub fn pthread_condattr_setpshared(attr: *mut pthread_condattr_t, -                                       pshared: ::c_int) -> ::c_int; -    pub fn pthread_condattr_getpshared(attr: *const pthread_condattr_t, -                                       pshared: *mut ::c_int) -> ::c_int; -    pub fn pthread_mutexattr_setpshared(attr: *mut pthread_mutexattr_t, -                                        pshared: ::c_int) -> ::c_int; -    pub fn pthread_mutexattr_getpshared(attr: *const pthread_mutexattr_t, -                                        pshared: *mut ::c_int) -> ::c_int; -    pub fn pthread_rwlockattr_getpshared(attr: *const pthread_rwlockattr_t, -                                         val: *mut ::c_int) -> ::c_int; -    pub fn pthread_rwlockattr_setpshared(attr: *mut pthread_rwlockattr_t, -                                         val: ::c_int) -> ::c_int; -    pub fn getpriority(which: ::c_int, who: ::c_int) -> ::c_int; -    pub fn setpriority(which: ::c_int, who: ::c_int, prio: ::c_int) -> ::c_int; - -    pub fn fdopendir(fd: ::c_int) -> *mut ::DIR; - -    pub fn mknodat(dirfd: ::c_int, pathname: *const ::c_char, -                  mode: ::mode_t, dev: dev_t) -> ::c_int; -    pub fn mkfifoat(dirfd: ::c_int, pathname: *const ::c_char, -                    mode: ::mode_t) -> ::c_int; -    pub fn pthread_condattr_getclock(attr: *const pthread_condattr_t, -                                     clock_id: *mut clockid_t) -> ::c_int; -    pub fn pthread_condattr_setclock(attr: *mut pthread_condattr_t, -                                     clock_id: ::clockid_t) -> ::c_int; -    pub fn sethostname(name: *const ::c_char, len: ::c_int) -> ::c_int; -    pub fn sem_timedwait(sem: *mut sem_t, -                         abstime: *const ::timespec) -> ::c_int; -    pub fn pthread_mutex_timedlock(lock: *mut pthread_mutex_t, -                                   abstime: *const ::timespec) -> ::c_int; -    pub fn pipe2(fds: *mut ::c_int, flags: ::c_int) -> ::c_int; -    pub fn ppoll(fds: *mut ::pollfd, -                 nfds: ::nfds_t, -                 timeout: *const ::timespec, -                 sigmask: *const sigset_t) -> ::c_int; -    pub fn settimeofday(tv: *const ::timeval, tz: *const ::timezone) -> ::c_int;  }  cfg_if! { | 
