Skip to main content

libc/unix/
mod.rs

1//! Definitions found commonly among almost all Unix derivatives
2//!
3//! More functions and definitions can be found in the more specific modules
4//! according to the platform in question.
5
6use crate::prelude::*;
7
8pub type intmax_t = i64;
9pub type uintmax_t = u64;
10
11pub type size_t = usize;
12pub type ptrdiff_t = isize;
13pub type intptr_t = isize;
14pub type uintptr_t = usize;
15pub type ssize_t = isize;
16
17#[cfg(not(target_os = "nuttx"))]
18pub type pid_t = i32;
19pub type in_addr_t = u32;
20pub type in_port_t = u16;
21pub type sighandler_t = size_t;
22pub type cc_t = c_uchar;
23
24cfg_if! {
25    if #[cfg(any(
26        target_os = "espidf",
27        target_os = "horizon",
28        target_os = "vita"
29    ))] {
30        pub type uid_t = c_ushort;
31        pub type gid_t = c_ushort;
32    } else if #[cfg(any(target_os = "nto", target_os = "qnx"))] {
33        pub type uid_t = i32;
34        pub type gid_t = i32;
35    } else {
36        pub type uid_t = u32;
37        pub type gid_t = u32;
38    }
39}
40
41/// This is an extern type ("opaque" or "incomplete" type in C).
///
/// <div class="warning">
/// This type's current representation allows inspecting some properties, such as via
/// <code>size_of</code>, and it is technically possible to construct the type within
/// <code>MaybeUninit</code>, However, this <strong>MUST NOT</strong> be relied upon
/// because a future version of <code>libc</code> may switch to a proper
/// <a href="https://rust-lang.github.io/rfcs/1861-extern-types.html">extern type</a>
/// representation when available.
/// </div>
#[repr(C)]
pub struct DIR {
    _data: (),
    _marker: ::core::marker::PhantomData<(*mut u8,
    ::core::marker::PhantomPinned)>,
}
#[automatically_derived]
#[doc(hidden)]
unsafe impl ::core::clone::TrivialClone for DIR { }
#[automatically_derived]
impl ::core::clone::Clone for DIR {
    #[inline]
    fn clone(&self) -> Self {
        let _: ::core::clone::AssertParamIsClone<()>;
        let _:
                ::core::clone::AssertParamIsClone<::core::marker::PhantomData<(*mut u8,
                ::core::marker::PhantomPinned)>>;
        *self
    }
}
#[automatically_derived]
impl ::core::marker::Copy for DIR { }
#[automatically_derived]
impl ::core::fmt::Debug for DIR {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::debug_struct_field2_finish(f, "DIR", "_data",
            &self._data, "_marker", &&self._marker)
    }
}extern_ty! {
42    pub type DIR;
43}
44
45// Deprecated impls: see #5296
46unsafe impl Send for DIR {}
47unsafe impl Sync for DIR {}
48
49#[cfg(not(target_os = "nuttx"))]
50pub type locale_t = *mut c_void;
51
52#[repr(C)]
#[allow(deprecated)]
pub struct group {
    pub gr_name: *mut c_char,
    pub gr_passwd: *mut c_char,
    pub gr_gid: crate::gid_t,
    pub gr_mem: *mut *mut c_char,
}
#[automatically_derived]
#[doc(hidden)]
#[allow(deprecated)]
unsafe impl ::core::clone::TrivialClone for group { }
#[automatically_derived]
#[allow(deprecated)]
impl ::core::clone::Clone for group {
    #[inline]
    fn clone(&self) -> Self {
        let _: ::core::clone::AssertParamIsClone<*mut c_char>;
        let _: ::core::clone::AssertParamIsClone<*mut c_char>;
        let _: ::core::clone::AssertParamIsClone<crate::gid_t>;
        let _: ::core::clone::AssertParamIsClone<*mut *mut c_char>;
        *self
    }
}
#[automatically_derived]
#[allow(deprecated)]
impl ::core::marker::Copy for group { }
#[automatically_derived]
#[allow(deprecated)]
impl ::core::fmt::Debug for group {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::debug_struct_field4_finish(f, "group",
            "gr_name", &self.gr_name, "gr_passwd", &self.gr_passwd, "gr_gid",
            &self.gr_gid, "gr_mem", &&self.gr_mem)
    }
}
#[allow(deprecated)]
impl ::core::default::Default for group {
    #[allow(unused_doc_comments)]
    fn default() -> Self {
        Self {
            gr_name: ptr::null_mut(),
            gr_passwd: ptr::null_mut(),
            gr_gid: ::core::default::Default::default(),
            gr_mem: ptr::null_mut(),
        }
    }
}
#[repr(C)]
#[allow(deprecated)]
pub struct utimbuf {
    pub actime: time_t,
    pub modtime: time_t,
}
#[automatically_derived]
#[doc(hidden)]
#[allow(deprecated)]
unsafe impl ::core::clone::TrivialClone for utimbuf { }
#[automatically_derived]
#[allow(deprecated)]
impl ::core::clone::Clone for utimbuf {
    #[inline]
    fn clone(&self) -> Self {
        let _: ::core::clone::AssertParamIsClone<time_t>;
        *self
    }
}
#[automatically_derived]
#[allow(deprecated)]
impl ::core::marker::Copy for utimbuf { }
#[automatically_derived]
#[allow(deprecated)]
impl ::core::fmt::Debug for utimbuf {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::debug_struct_field2_finish(f, "utimbuf",
            "actime", &self.actime, "modtime", &&self.modtime)
    }
}
#[allow(deprecated)]
impl ::core::default::Default for utimbuf {
    #[allow(unused_doc_comments)]
    fn default() -> Self {
        Self {
            actime: ::core::default::Default::default(),
            modtime: ::core::default::Default::default(),
        }
    }
}
#[repr(C)]
#[allow(deprecated)]
pub struct timeval {
    pub tv_sec: time_t,
    pub tv_usec: crate::suseconds_t,
}
#[automatically_derived]
#[doc(hidden)]
#[allow(deprecated)]
unsafe impl ::core::clone::TrivialClone for timeval { }
#[automatically_derived]
#[allow(deprecated)]
impl ::core::clone::Clone for timeval {
    #[inline]
    fn clone(&self) -> Self {
        let _: ::core::clone::AssertParamIsClone<time_t>;
        let _: ::core::clone::AssertParamIsClone<crate::suseconds_t>;
        *self
    }
}
#[automatically_derived]
#[allow(deprecated)]
impl ::core::marker::Copy for timeval { }
#[automatically_derived]
#[allow(deprecated)]
impl ::core::fmt::Debug for timeval {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::debug_struct_field2_finish(f, "timeval",
            "tv_sec", &self.tv_sec, "tv_usec", &&self.tv_usec)
    }
}
#[allow(deprecated)]
impl ::core::default::Default for timeval {
    #[allow(unused_doc_comments)]
    fn default() -> Self {
        Self {
            tv_sec: ::core::default::Default::default(),
            tv_usec: ::core::default::Default::default(),
        }
    }
}
#[repr(C)]
#[allow(deprecated)]
pub struct rlimit {
    pub rlim_cur: rlim_t,
    pub rlim_max: rlim_t,
}
#[automatically_derived]
#[doc(hidden)]
#[allow(deprecated)]
unsafe impl ::core::clone::TrivialClone for rlimit { }
#[automatically_derived]
#[allow(deprecated)]
impl ::core::clone::Clone for rlimit {
    #[inline]
    fn clone(&self) -> Self {
        let _: ::core::clone::AssertParamIsClone<rlim_t>;
        *self
    }
}
#[automatically_derived]
#[allow(deprecated)]
impl ::core::marker::Copy for rlimit { }
#[automatically_derived]
#[allow(deprecated)]
impl ::core::fmt::Debug for rlimit {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::debug_struct_field2_finish(f, "rlimit",
            "rlim_cur", &self.rlim_cur, "rlim_max", &&self.rlim_max)
    }
}
#[allow(deprecated)]
impl ::core::default::Default for rlimit {
    #[allow(unused_doc_comments)]
    fn default() -> Self {
        Self {
            rlim_cur: ::core::default::Default::default(),
            rlim_max: ::core::default::Default::default(),
        }
    }
}
#[repr(C)]
#[allow(deprecated)]
pub struct rusage {
    pub ru_utime: timeval,
    pub ru_stime: timeval,
    pub ru_maxrss: c_long,
    pub ru_ixrss: c_long,
    pub ru_idrss: c_long,
    pub ru_isrss: c_long,
    pub ru_minflt: c_long,
    pub ru_majflt: c_long,
    pub ru_nswap: c_long,
    pub ru_inblock: c_long,
    pub ru_oublock: c_long,
    pub ru_msgsnd: c_long,
    pub ru_msgrcv: c_long,
    pub ru_nsignals: c_long,
    pub ru_nvcsw: c_long,
    pub ru_nivcsw: c_long,
}
#[automatically_derived]
#[doc(hidden)]
#[allow(deprecated)]
unsafe impl ::core::clone::TrivialClone for rusage { }
#[automatically_derived]
#[allow(deprecated)]
impl ::core::clone::Clone for rusage {
    #[inline]
    fn clone(&self) -> Self {
        let _: ::core::clone::AssertParamIsClone<timeval>;
        let _: ::core::clone::AssertParamIsClone<c_long>;
        *self
    }
}
#[automatically_derived]
#[allow(deprecated)]
impl ::core::marker::Copy for rusage { }
#[automatically_derived]
#[allow(deprecated)]
impl ::core::fmt::Debug for rusage {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        let names: &'static _ =
            &["ru_utime", "ru_stime", "ru_maxrss", "ru_ixrss", "ru_idrss",
                        "ru_isrss", "ru_minflt", "ru_majflt", "ru_nswap",
                        "ru_inblock", "ru_oublock", "ru_msgsnd", "ru_msgrcv",
                        "ru_nsignals", "ru_nvcsw", "ru_nivcsw"];
        let values: &[&dyn ::core::fmt::Debug] =
            &[&self.ru_utime, &self.ru_stime, &self.ru_maxrss, &self.ru_ixrss,
                        &self.ru_idrss, &self.ru_isrss, &self.ru_minflt,
                        &self.ru_majflt, &self.ru_nswap, &self.ru_inblock,
                        &self.ru_oublock, &self.ru_msgsnd, &self.ru_msgrcv,
                        &self.ru_nsignals, &self.ru_nvcsw, &&self.ru_nivcsw];
        ::core::fmt::Formatter::debug_struct_fields_finish(f, "rusage", names,
            values)
    }
}
#[allow(deprecated)]
impl ::core::default::Default for rusage {
    #[allow(unused_doc_comments)]
    fn default() -> Self {
        Self {
            ru_utime: ::core::default::Default::default(),
            ru_stime: ::core::default::Default::default(),
            ru_maxrss: ::core::default::Default::default(),
            ru_ixrss: ::core::default::Default::default(),
            ru_idrss: ::core::default::Default::default(),
            ru_isrss: ::core::default::Default::default(),
            ru_minflt: ::core::default::Default::default(),
            ru_majflt: ::core::default::Default::default(),
            ru_nswap: ::core::default::Default::default(),
            ru_inblock: ::core::default::Default::default(),
            ru_oublock: ::core::default::Default::default(),
            ru_msgsnd: ::core::default::Default::default(),
            ru_msgrcv: ::core::default::Default::default(),
            ru_nsignals: ::core::default::Default::default(),
            ru_nvcsw: ::core::default::Default::default(),
            ru_nivcsw: ::core::default::Default::default(),
        }
    }
}
#[repr(C)]
#[allow(deprecated)]
pub struct ipv6_mreq {
    pub ipv6mr_multiaddr: in6_addr,
    pub ipv6mr_interface: c_uint,
}
#[automatically_derived]
#[doc(hidden)]
#[allow(deprecated)]
unsafe impl ::core::clone::TrivialClone for ipv6_mreq { }
#[automatically_derived]
#[allow(deprecated)]
impl ::core::clone::Clone for ipv6_mreq {
    #[inline]
    fn clone(&self) -> Self {
        let _: ::core::clone::AssertParamIsClone<in6_addr>;
        let _: ::core::clone::AssertParamIsClone<c_uint>;
        *self
    }
}
#[automatically_derived]
#[allow(deprecated)]
impl ::core::marker::Copy for ipv6_mreq { }
#[automatically_derived]
#[allow(deprecated)]
impl ::core::fmt::Debug for ipv6_mreq {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::debug_struct_field2_finish(f, "ipv6_mreq",
            "ipv6mr_multiaddr", &self.ipv6mr_multiaddr, "ipv6mr_interface",
            &&self.ipv6mr_interface)
    }
}
#[allow(deprecated)]
impl ::core::default::Default for ipv6_mreq {
    #[allow(unused_doc_comments)]
    fn default() -> Self {
        Self {
            ipv6mr_multiaddr: ::core::default::Default::default(),
            ipv6mr_interface: ::core::default::Default::default(),
        }
    }
}
#[repr(C)]
#[allow(deprecated)]
pub struct hostent {
    pub h_name: *mut c_char,
    pub h_aliases: *mut *mut c_char,
    pub h_addrtype: c_int,
    pub h_length: c_int,
    pub h_addr_list: *mut *mut c_char,
}
#[automatically_derived]
#[doc(hidden)]
#[allow(deprecated)]
unsafe impl ::core::clone::TrivialClone for hostent { }
#[automatically_derived]
#[allow(deprecated)]
impl ::core::clone::Clone for hostent {
    #[inline]
    fn clone(&self) -> Self {
        let _: ::core::clone::AssertParamIsClone<*mut c_char>;
        let _: ::core::clone::AssertParamIsClone<*mut *mut c_char>;
        let _: ::core::clone::AssertParamIsClone<c_int>;
        let _: ::core::clone::AssertParamIsClone<*mut *mut c_char>;
        *self
    }
}
#[automatically_derived]
#[allow(deprecated)]
impl ::core::marker::Copy for hostent { }
#[automatically_derived]
#[allow(deprecated)]
impl ::core::fmt::Debug for hostent {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::debug_struct_field5_finish(f, "hostent",
            "h_name", &self.h_name, "h_aliases", &self.h_aliases,
            "h_addrtype", &self.h_addrtype, "h_length", &self.h_length,
            "h_addr_list", &&self.h_addr_list)
    }
}
#[allow(deprecated)]
impl ::core::default::Default for hostent {
    #[allow(unused_doc_comments)]
    fn default() -> Self {
        Self {
            h_name: ptr::null_mut(),
            h_aliases: ptr::null_mut(),
            h_addrtype: ::core::default::Default::default(),
            h_length: ::core::default::Default::default(),
            h_addr_list: ptr::null_mut(),
        }
    }
}
#[repr(C)]
#[allow(deprecated)]
pub struct iovec {
    pub iov_base: *mut c_void,
    pub iov_len: size_t,
}
#[automatically_derived]
#[doc(hidden)]
#[allow(deprecated)]
unsafe impl ::core::clone::TrivialClone for iovec { }
#[automatically_derived]
#[allow(deprecated)]
impl ::core::clone::Clone for iovec {
    #[inline]
    fn clone(&self) -> Self {
        let _: ::core::clone::AssertParamIsClone<*mut c_void>;
        let _: ::core::clone::AssertParamIsClone<size_t>;
        *self
    }
}
#[automatically_derived]
#[allow(deprecated)]
impl ::core::marker::Copy for iovec { }
#[automatically_derived]
#[allow(deprecated)]
impl ::core::fmt::Debug for iovec {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::debug_struct_field2_finish(f, "iovec",
            "iov_base", &self.iov_base, "iov_len", &&self.iov_len)
    }
}
#[allow(deprecated)]
impl ::core::default::Default for iovec {
    #[allow(unused_doc_comments)]
    fn default() -> Self {
        Self {
            iov_base: ptr::null_mut(),
            iov_len: ::core::default::Default::default(),
        }
    }
}
#[repr(C)]
#[allow(deprecated)]
pub struct pollfd {
    pub fd: c_int,
    pub events: c_short,
    pub revents: c_short,
}
#[automatically_derived]
#[doc(hidden)]
#[allow(deprecated)]
unsafe impl ::core::clone::TrivialClone for pollfd { }
#[automatically_derived]
#[allow(deprecated)]
impl ::core::clone::Clone for pollfd {
    #[inline]
    fn clone(&self) -> Self {
        let _: ::core::clone::AssertParamIsClone<c_int>;
        let _: ::core::clone::AssertParamIsClone<c_short>;
        *self
    }
}
#[automatically_derived]
#[allow(deprecated)]
impl ::core::marker::Copy for pollfd { }
#[automatically_derived]
#[allow(deprecated)]
impl ::core::fmt::Debug for pollfd {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::debug_struct_field3_finish(f, "pollfd", "fd",
            &self.fd, "events", &self.events, "revents", &&self.revents)
    }
}
#[allow(deprecated)]
impl ::core::default::Default for pollfd {
    #[allow(unused_doc_comments)]
    fn default() -> Self {
        Self {
            fd: ::core::default::Default::default(),
            events: ::core::default::Default::default(),
            revents: ::core::default::Default::default(),
        }
    }
}
#[repr(C)]
#[allow(deprecated)]
pub struct winsize {
    pub ws_row: c_ushort,
    pub ws_col: c_ushort,
    pub ws_xpixel: c_ushort,
    pub ws_ypixel: c_ushort,
}
#[automatically_derived]
#[doc(hidden)]
#[allow(deprecated)]
unsafe impl ::core::clone::TrivialClone for winsize { }
#[automatically_derived]
#[allow(deprecated)]
impl ::core::clone::Clone for winsize {
    #[inline]
    fn clone(&self) -> Self {
        let _: ::core::clone::AssertParamIsClone<c_ushort>;
        *self
    }
}
#[automatically_derived]
#[allow(deprecated)]
impl ::core::marker::Copy for winsize { }
#[automatically_derived]
#[allow(deprecated)]
impl ::core::fmt::Debug for winsize {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::debug_struct_field4_finish(f, "winsize",
            "ws_row", &self.ws_row, "ws_col", &self.ws_col, "ws_xpixel",
            &self.ws_xpixel, "ws_ypixel", &&self.ws_ypixel)
    }
}
#[allow(deprecated)]
impl ::core::default::Default for winsize {
    #[allow(unused_doc_comments)]
    fn default() -> Self {
        Self {
            ws_row: ::core::default::Default::default(),
            ws_col: ::core::default::Default::default(),
            ws_xpixel: ::core::default::Default::default(),
            ws_ypixel: ::core::default::Default::default(),
        }
    }
}
#[repr(C)]
#[allow(deprecated)]
pub struct linger {
    pub l_onoff: c_int,
    pub l_linger: c_int,
}
#[automatically_derived]
#[doc(hidden)]
#[allow(deprecated)]
unsafe impl ::core::clone::TrivialClone for linger { }
#[automatically_derived]
#[allow(deprecated)]
impl ::core::clone::Clone for linger {
    #[inline]
    fn clone(&self) -> Self {
        let _: ::core::clone::AssertParamIsClone<c_int>;
        *self
    }
}
#[automatically_derived]
#[allow(deprecated)]
impl ::core::marker::Copy for linger { }
#[automatically_derived]
#[allow(deprecated)]
impl ::core::fmt::Debug for linger {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::debug_struct_field2_finish(f, "linger",
            "l_onoff", &self.l_onoff, "l_linger", &&self.l_linger)
    }
}
#[allow(deprecated)]
impl ::core::default::Default for linger {
    #[allow(unused_doc_comments)]
    fn default() -> Self {
        Self {
            l_onoff: ::core::default::Default::default(),
            l_linger: ::core::default::Default::default(),
        }
    }
}
#[repr(C)]
#[allow(deprecated)]
pub struct sigval {
    pub sival_ptr: *mut c_void,
}
#[automatically_derived]
#[doc(hidden)]
#[allow(deprecated)]
unsafe impl ::core::clone::TrivialClone for sigval { }
#[automatically_derived]
#[allow(deprecated)]
impl ::core::clone::Clone for sigval {
    #[inline]
    fn clone(&self) -> Self {
        let _: ::core::clone::AssertParamIsClone<*mut c_void>;
        *self
    }
}
#[automatically_derived]
#[allow(deprecated)]
impl ::core::marker::Copy for sigval { }
#[automatically_derived]
#[allow(deprecated)]
impl ::core::fmt::Debug for sigval {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::debug_struct_field1_finish(f, "sigval",
            "sival_ptr", &&self.sival_ptr)
    }
}
#[allow(deprecated)]
impl ::core::default::Default for sigval {
    #[allow(unused_doc_comments)]
    fn default() -> Self { Self { sival_ptr: ptr::null_mut() } }
}
#[repr(C)]
#[allow(deprecated)]
pub struct itimerval {
    pub it_interval: crate::timeval,
    pub it_value: crate::timeval,
}
#[automatically_derived]
#[doc(hidden)]
#[allow(deprecated)]
unsafe impl ::core::clone::TrivialClone for itimerval { }
#[automatically_derived]
#[allow(deprecated)]
impl ::core::clone::Clone for itimerval {
    #[inline]
    fn clone(&self) -> Self {
        let _: ::core::clone::AssertParamIsClone<crate::timeval>;
        let _: ::core::clone::AssertParamIsClone<crate::timeval>;
        *self
    }
}
#[automatically_derived]
#[allow(deprecated)]
impl ::core::marker::Copy for itimerval { }
#[automatically_derived]
#[allow(deprecated)]
impl ::core::fmt::Debug for itimerval {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::debug_struct_field2_finish(f, "itimerval",
            "it_interval", &self.it_interval, "it_value", &&self.it_value)
    }
}
#[allow(deprecated)]
impl ::core::default::Default for itimerval {
    #[allow(unused_doc_comments)]
    fn default() -> Self {
        Self {
            it_interval: ::core::default::Default::default(),
            it_value: ::core::default::Default::default(),
        }
    }
}
#[repr(C)]
#[allow(deprecated)]
pub struct tms {
    pub tms_utime: crate::clock_t,
    pub tms_stime: crate::clock_t,
    pub tms_cutime: crate::clock_t,
    pub tms_cstime: crate::clock_t,
}
#[automatically_derived]
#[doc(hidden)]
#[allow(deprecated)]
unsafe impl ::core::clone::TrivialClone for tms { }
#[automatically_derived]
#[allow(deprecated)]
impl ::core::clone::Clone for tms {
    #[inline]
    fn clone(&self) -> Self {
        let _: ::core::clone::AssertParamIsClone<crate::clock_t>;
        let _: ::core::clone::AssertParamIsClone<crate::clock_t>;
        let _: ::core::clone::AssertParamIsClone<crate::clock_t>;
        let _: ::core::clone::AssertParamIsClone<crate::clock_t>;
        *self
    }
}
#[automatically_derived]
#[allow(deprecated)]
impl ::core::marker::Copy for tms { }
#[automatically_derived]
#[allow(deprecated)]
impl ::core::fmt::Debug for tms {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::debug_struct_field4_finish(f, "tms",
            "tms_utime", &self.tms_utime, "tms_stime", &self.tms_stime,
            "tms_cutime", &self.tms_cutime, "tms_cstime", &&self.tms_cstime)
    }
}
#[allow(deprecated)]
impl ::core::default::Default for tms {
    #[allow(unused_doc_comments)]
    fn default() -> Self {
        Self {
            tms_utime: ::core::default::Default::default(),
            tms_stime: ::core::default::Default::default(),
            tms_cutime: ::core::default::Default::default(),
            tms_cstime: ::core::default::Default::default(),
        }
    }
}
#[repr(C)]
#[allow(deprecated)]
pub struct servent {
    pub s_name: *mut c_char,
    pub s_aliases: *mut *mut c_char,
    pub s_port: c_int,
    pub s_proto: *mut c_char,
}
#[automatically_derived]
#[doc(hidden)]
#[allow(deprecated)]
unsafe impl ::core::clone::TrivialClone for servent { }
#[automatically_derived]
#[allow(deprecated)]
impl ::core::clone::Clone for servent {
    #[inline]
    fn clone(&self) -> Self {
        let _: ::core::clone::AssertParamIsClone<*mut c_char>;
        let _: ::core::clone::AssertParamIsClone<*mut *mut c_char>;
        let _: ::core::clone::AssertParamIsClone<c_int>;
        let _: ::core::clone::AssertParamIsClone<*mut c_char>;
        *self
    }
}
#[automatically_derived]
#[allow(deprecated)]
impl ::core::marker::Copy for servent { }
#[automatically_derived]
#[allow(deprecated)]
impl ::core::fmt::Debug for servent {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::debug_struct_field4_finish(f, "servent",
            "s_name", &self.s_name, "s_aliases", &self.s_aliases, "s_port",
            &self.s_port, "s_proto", &&self.s_proto)
    }
}
#[allow(deprecated)]
impl ::core::default::Default for servent {
    #[allow(unused_doc_comments)]
    fn default() -> Self {
        Self {
            s_name: ptr::null_mut(),
            s_aliases: ptr::null_mut(),
            s_port: ::core::default::Default::default(),
            s_proto: ptr::null_mut(),
        }
    }
}
#[repr(C)]
#[allow(deprecated)]
pub struct protoent {
    pub p_name: *mut c_char,
    pub p_aliases: *mut *mut c_char,
    pub p_proto: c_int,
}
#[automatically_derived]
#[doc(hidden)]
#[allow(deprecated)]
unsafe impl ::core::clone::TrivialClone for protoent { }
#[automatically_derived]
#[allow(deprecated)]
impl ::core::clone::Clone for protoent {
    #[inline]
    fn clone(&self) -> Self {
        let _: ::core::clone::AssertParamIsClone<*mut c_char>;
        let _: ::core::clone::AssertParamIsClone<*mut *mut c_char>;
        let _: ::core::clone::AssertParamIsClone<c_int>;
        *self
    }
}
#[automatically_derived]
#[allow(deprecated)]
impl ::core::marker::Copy for protoent { }
#[automatically_derived]
#[allow(deprecated)]
impl ::core::fmt::Debug for protoent {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::debug_struct_field3_finish(f, "protoent",
            "p_name", &self.p_name, "p_aliases", &self.p_aliases, "p_proto",
            &&self.p_proto)
    }
}
#[allow(deprecated)]
impl ::core::default::Default for protoent {
    #[allow(unused_doc_comments)]
    fn default() -> Self {
        Self {
            p_name: ptr::null_mut(),
            p_aliases: ptr::null_mut(),
            p_proto: ::core::default::Default::default(),
        }
    }
}
#[repr(C)]
#[allow(deprecated)]
#[repr(align(4))]
pub struct in6_addr {
    pub s6_addr: [u8; 16],
}
#[automatically_derived]
#[doc(hidden)]
#[allow(deprecated)]
unsafe impl ::core::clone::TrivialClone for in6_addr { }
#[automatically_derived]
#[allow(deprecated)]
impl ::core::clone::Clone for in6_addr {
    #[inline]
    fn clone(&self) -> Self {
        let _: ::core::clone::AssertParamIsClone<[u8; 16]>;
        *self
    }
}
#[automatically_derived]
#[allow(deprecated)]
impl ::core::marker::Copy for in6_addr { }
#[automatically_derived]
#[allow(deprecated)]
impl ::core::fmt::Debug for in6_addr {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::debug_struct_field1_finish(f, "in6_addr",
            "s6_addr", &&self.s6_addr)
    }
}
#[allow(deprecated)]
impl ::core::default::Default for in6_addr {
    #[allow(unused_doc_comments)]
    fn default() -> Self {
        Self { s6_addr: ::core::default::Default::default() }
    }
}s2! {
53    #[exhaustive] // FIXME(exhaustive): review for 1.0
54    pub struct group {
55        #[custom_default(ptr::null_mut())]
56        pub gr_name: *mut c_char,
57        #[custom_default(ptr::null_mut())]
58        pub gr_passwd: *mut c_char,
59        pub gr_gid: crate::gid_t,
60        #[custom_default(ptr::null_mut())]
61        pub gr_mem: *mut *mut c_char,
62    }
63
64    #[exhaustive] // FIXME(exhaustive): review for 1.0
65    pub struct utimbuf {
66        pub actime: time_t,
67        pub modtime: time_t,
68    }
69
70    #[exhaustive] // This one is not likely to ever change
71    pub struct timeval {
72        pub tv_sec: time_t,
73        #[cfg(not(gnu_time_bits64))]
74        pub tv_usec: crate::suseconds_t,
75        // For 64 bit time on 32 bit linux glibc, suseconds_t is still
76        // a 32 bit type.  Use __suseconds64_t instead
77        #[cfg(gnu_time_bits64)]
78        pub tv_usec: __suseconds64_t,
79    }
80
81    // linux x32 compatibility
82    // See https://sourceware.org/bugzilla/show_bug.cgi?id=16437
83    #[exhaustive] // FIXME(exhaustive): review for 1.0
84    #[cfg(not(target_env = "gnu"))]
85    pub struct timespec {
86        pub tv_sec: time_t,
87        #[cfg(all(musl32_time64, target_endian = "big"))]
88        __pad0: Padding<u32>,
89        #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))]
90        pub tv_nsec: i64,
91        #[cfg(not(all(target_arch = "x86_64", target_pointer_width = "32")))]
92        pub tv_nsec: c_long,
93        #[cfg(all(musl32_time64, target_endian = "little"))]
94        __pad0: Padding<u32>,
95    }
96
97    #[exhaustive] // FIXME(exhaustive): review for 1.0
98    pub struct rlimit {
99        pub rlim_cur: rlim_t,
100        pub rlim_max: rlim_t,
101    }
102
103    #[exhaustive] // FIXME(exhaustive): review for 1.0
104    pub struct rusage {
105        pub ru_utime: timeval,
106        pub ru_stime: timeval,
107        pub ru_maxrss: c_long,
108        #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))]
109        __pad1: Padding<u32>,
110        pub ru_ixrss: c_long,
111        #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))]
112        __pad2: Padding<u32>,
113        pub ru_idrss: c_long,
114        #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))]
115        __pad3: Padding<u32>,
116        pub ru_isrss: c_long,
117        #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))]
118        __pad4: Padding<u32>,
119        pub ru_minflt: c_long,
120        #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))]
121        __pad5: Padding<u32>,
122        pub ru_majflt: c_long,
123        #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))]
124        __pad6: Padding<u32>,
125        pub ru_nswap: c_long,
126        #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))]
127        __pad7: Padding<u32>,
128        pub ru_inblock: c_long,
129        #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))]
130        __pad8: Padding<u32>,
131        pub ru_oublock: c_long,
132        #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))]
133        __pad9: Padding<u32>,
134        pub ru_msgsnd: c_long,
135        #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))]
136        __pad10: Padding<u32>,
137        pub ru_msgrcv: c_long,
138        #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))]
139        __pad11: Padding<u32>,
140        pub ru_nsignals: c_long,
141        #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))]
142        __pad12: Padding<u32>,
143        pub ru_nvcsw: c_long,
144        #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))]
145        __pad13: Padding<u32>,
146        pub ru_nivcsw: c_long,
147        #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))]
148        __pad14: Padding<u32>,
149
150        #[cfg(any(target_env = "musl", target_env = "ohos", target_os = "emscripten"))]
151        __reserved: Padding<[c_long; 16]>,
152    }
153
154    #[exhaustive] // FIXME(exhaustive): review for 1.0
155    #[cfg(not(target_os = "nuttx"))]
156    pub struct ipv6_mreq {
157        pub ipv6mr_multiaddr: in6_addr,
158        #[cfg(target_os = "android")]
159        pub ipv6mr_interface: c_int,
160        #[cfg(not(target_os = "android"))]
161        pub ipv6mr_interface: c_uint,
162    }
163
164    #[exhaustive] // FIXME(exhaustive): review for 1.0
165    #[cfg(all(not(target_os = "cygwin"), not(target_os = "horizon")))]
166    pub struct hostent {
167        #[custom_default(ptr::null_mut())]
168        pub h_name: *mut c_char,
169        #[custom_default(ptr::null_mut())]
170        pub h_aliases: *mut *mut c_char,
171        pub h_addrtype: c_int,
172        pub h_length: c_int,
173        #[custom_default(ptr::null_mut())]
174        pub h_addr_list: *mut *mut c_char,
175    }
176
177    #[exhaustive] // Shouldn't ever change
178    pub struct iovec {
179        #[custom_default(ptr::null_mut())]
180        pub iov_base: *mut c_void,
181        pub iov_len: size_t,
182    }
183
184    #[exhaustive] // FIXME(exhaustive): review for 1.0
185    #[cfg(not(target_os = "horizon"))]
186    pub struct pollfd {
187        pub fd: c_int,
188        pub events: c_short,
189        pub revents: c_short,
190    }
191
192    #[exhaustive] // FIXME(exhaustive): review for 1.0
193    pub struct winsize {
194        pub ws_row: c_ushort,
195        pub ws_col: c_ushort,
196        pub ws_xpixel: c_ushort,
197        pub ws_ypixel: c_ushort,
198    }
199
200    #[exhaustive] // FIXME(exhaustive): review for 1.0
201    #[cfg(not(target_os = "cygwin"))]
202    pub struct linger {
203        pub l_onoff: c_int,
204        pub l_linger: c_int,
205    }
206
207    #[exhaustive] // FIXME(exhaustive): review for 1.0
208    pub struct sigval {
209        // Actually a union of an int and a void*
210        #[custom_default(ptr::null_mut())]
211        pub sival_ptr: *mut c_void,
212    }
213
214    // <sys/time.h>
215    #[exhaustive] // FIXME(exhaustive): review for 1.0
216    pub struct itimerval {
217        pub it_interval: crate::timeval,
218        pub it_value: crate::timeval,
219    }
220
221    // <sys/times.h>
222    #[exhaustive] // FIXME(exhaustive): review for 1.0
223    pub struct tms {
224        pub tms_utime: crate::clock_t,
225        pub tms_stime: crate::clock_t,
226        pub tms_cutime: crate::clock_t,
227        pub tms_cstime: crate::clock_t,
228    }
229
230    #[exhaustive] // FIXME(exhaustive): review for 1.0
231    pub struct servent {
232        #[custom_default(ptr::null_mut())]
233        pub s_name: *mut c_char,
234        #[custom_default(ptr::null_mut())]
235        pub s_aliases: *mut *mut c_char,
236        #[cfg(target_os = "cygwin")]
237        pub s_port: c_short,
238        #[cfg(not(target_os = "cygwin"))]
239        pub s_port: c_int,
240        #[custom_default(ptr::null_mut())]
241        pub s_proto: *mut c_char,
242    }
243
244    #[exhaustive] // FIXME(exhaustive): review for 1.0
245    pub struct protoent {
246        #[custom_default(ptr::null_mut())]
247        pub p_name: *mut c_char,
248        #[custom_default(ptr::null_mut())]
249        pub p_aliases: *mut *mut c_char,
250        #[cfg(not(target_os = "cygwin"))]
251        pub p_proto: c_int,
252        #[cfg(target_os = "cygwin")]
253        pub p_proto: c_short,
254    }
255
256    #[exhaustive] // FIXME(exhaustive): review for 1.0
257    #[repr(align(4))]
258    pub struct in6_addr {
259        pub s6_addr: [u8; 16],
260    }
261}
262
263#[deprecated(since = "0.2.190", note = "Use `c_int::MIN` instead.")]
264pub const INT_MIN: c_int = c_int::MIN;
265#[deprecated(since = "0.2.190", note = "Use `c_int::MAX` instead.")]
266pub const INT_MAX: c_int = c_int::MAX;
267
268pub const SIG_DFL: sighandler_t = 0 as sighandler_t;
269pub const SIG_IGN: sighandler_t = 1 as sighandler_t;
270pub const SIG_ERR: sighandler_t = !0 as sighandler_t;
271
272cfg_if! {
273    if #[cfg(all(
274        not(any(target_os = "nto", target_os = "qnx")),
275        not(target_os = "aix"),
276        not(target_os = "espidf")
277    ))] {
278        pub const DT_UNKNOWN: u8 = 0;
279        pub const DT_FIFO: u8 = 1;
280        pub const DT_CHR: u8 = 2;
281        pub const DT_DIR: u8 = 4;
282        pub const DT_BLK: u8 = 6;
283        pub const DT_REG: u8 = 8;
284        pub const DT_LNK: u8 = 10;
285        pub const DT_SOCK: u8 = 12;
286    }
287}
288cfg_if! {
289    if #[cfg(not(target_os = "redox"))] {
290        pub const FD_CLOEXEC: c_int = 0x1;
291    }
292}
293
294cfg_if! {
295    if #[cfg(not(any(
296        target_os = "nto",
297        target_os = "qnx",
298        target_os = "l4re"
299    )))] {
300        pub const USRQUOTA: c_int = 0;
301        pub const GRPQUOTA: c_int = 1;
302    }
303}
304pub const SIGIOT: c_int = 6;
305
306pub const S_ISUID: mode_t = 0o4000;
307pub const S_ISGID: mode_t = 0o2000;
308pub const S_ISVTX: mode_t = 0o1000;
309
310cfg_if! {
311    if #[cfg(not(any(
312        target_os = "haiku",
313        target_os = "illumos",
314        target_os = "solaris",
315        target_os = "cygwin"
316    )))] {
317        pub const IF_NAMESIZE: size_t = 16;
318        pub const IFNAMSIZ: size_t = IF_NAMESIZE;
319    }
320}
321
322pub const LOG_EMERG: c_int = 0;
323pub const LOG_ALERT: c_int = 1;
324pub const LOG_CRIT: c_int = 2;
325pub const LOG_ERR: c_int = 3;
326pub const LOG_WARNING: c_int = 4;
327pub const LOG_NOTICE: c_int = 5;
328pub const LOG_INFO: c_int = 6;
329pub const LOG_DEBUG: c_int = 7;
330
331pub const LOG_KERN: c_int = 0;
332pub const LOG_USER: c_int = 1 << 3;
333pub const LOG_MAIL: c_int = 2 << 3;
334pub const LOG_DAEMON: c_int = 3 << 3;
335pub const LOG_AUTH: c_int = 4 << 3;
336pub const LOG_SYSLOG: c_int = 5 << 3;
337pub const LOG_LPR: c_int = 6 << 3;
338pub const LOG_NEWS: c_int = 7 << 3;
339pub const LOG_UUCP: c_int = 8 << 3;
340pub const LOG_LOCAL0: c_int = 16 << 3;
341pub const LOG_LOCAL1: c_int = 17 << 3;
342pub const LOG_LOCAL2: c_int = 18 << 3;
343pub const LOG_LOCAL3: c_int = 19 << 3;
344pub const LOG_LOCAL4: c_int = 20 << 3;
345pub const LOG_LOCAL5: c_int = 21 << 3;
346pub const LOG_LOCAL6: c_int = 22 << 3;
347pub const LOG_LOCAL7: c_int = 23 << 3;
348
349cfg_if! {
350    if #[cfg(not(target_os = "haiku"))] {
351        pub const LOG_PID: c_int = 0x01;
352        pub const LOG_CONS: c_int = 0x02;
353        pub const LOG_ODELAY: c_int = 0x04;
354        pub const LOG_NDELAY: c_int = 0x08;
355        pub const LOG_NOWAIT: c_int = 0x10;
356    }
357}
358pub const LOG_PRIMASK: c_int = 7;
359pub const LOG_FACMASK: c_int = 0x3f8;
360
361cfg_if! {
362    if #[cfg(not(any(target_os = "nto", target_os = "qnx")))] {
363        pub const PRIO_MIN: c_int = -20;
364        pub const PRIO_MAX: c_int = 20;
365    }
366}
367pub const IPPROTO_ICMP: c_int = 1;
368pub const IPPROTO_ICMPV6: c_int = 58;
369pub const IPPROTO_TCP: c_int = 6;
370pub const IPPROTO_UDP: c_int = 17;
371pub const IPPROTO_IP: c_int = 0;
372pub const IPPROTO_IPV6: c_int = 41;
373
374pub const INADDR_LOOPBACK: in_addr_t = 2130706433;
375pub const INADDR_ANY: in_addr_t = 0;
376pub const INADDR_BROADCAST: in_addr_t = 4294967295;
377pub const INADDR_NONE: in_addr_t = 4294967295;
378
379pub const IN6ADDR_LOOPBACK_INIT: in6_addr = in6_addr {
380    s6_addr: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1],
381};
382
383pub const IN6ADDR_ANY_INIT: in6_addr = in6_addr {
384    s6_addr: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
385};
386
387cfg_if! {
388    // Not present on iOS/tvOS/watchOS/visionOS
389    if #[cfg(not(any(
390        target_os = "ios",
391        target_os = "tvos",
392        target_os = "watchos",
393        target_os = "visionos",
394    )))] {
395        pub const ARPOP_REQUEST: u16 = 1;
396        pub const ARPOP_REPLY: u16 = 2;
397
398        pub const ATF_COM: c_int = 0x02;
399        pub const ATF_PERM: c_int = 0x04;
400        pub const ATF_PUBL: c_int = 0x08;
401        pub const ATF_USETRAILERS: c_int = 0x10;
402    }
403}
404
405cfg_if! {
406    if #[cfg(any(target_os = "nto", target_os = "qnx", target_os = "aix"))] {
407        pub const FNM_PERIOD: c_int = 1 << 1;
408    } else {
409        pub const FNM_PERIOD: c_int = 1 << 2;
410    }
411}
412pub const FNM_NOMATCH: c_int = 1;
413
414cfg_if! {
415    if #[cfg(any(
416        target_os = "illumos",
417        target_os = "solaris",
418        target_os = "netbsd"
419    ))] {
420        pub const FNM_CASEFOLD: c_int = 1 << 3;
421    } else if #[cfg(not(target_os = "aix"))] {
422        pub const FNM_CASEFOLD: c_int = 1 << 4;
423    }
424}
425
426cfg_if! {
427    if #[cfg(any(
428        target_vendor = "apple",
429        target_os = "freebsd",
430        target_os = "dragonfly",
431        target_os = "android",
432        target_os = "openbsd",
433        target_os = "cygwin",
434        target_os = "netbsd",
435    ))] {
436        pub const FNM_PATHNAME: c_int = 1 << 1;
437    } else {
438        pub const FNM_PATHNAME: c_int = 1 << 0;
439    }
440}
441
442cfg_if! {
443    if #[cfg(any(
444        target_vendor = "apple",
445        target_os = "freebsd",
446        target_os = "dragonfly",
447        target_os = "android",
448        target_os = "openbsd",
449        target_os = "netbsd",
450        target_os = "cygwin",
451    ))] {
452        pub const FNM_NOESCAPE: c_int = 1 << 0;
453    } else if #[cfg(any(target_os = "nto", target_os = "qnx"))] {
454        pub const FNM_NOESCAPE: c_int = 1 << 2;
455    } else if #[cfg(target_os = "aix")] {
456        pub const FNM_NOESCAPE: c_int = 1 << 3;
457    } else {
458        pub const FNM_NOESCAPE: c_int = 1 << 1;
459    }
460}
461
462#[inline]
pub const extern "C" fn ntohs(netshort: u16) -> u16 { u16::from_be(netshort) }f! {
463    // It seems htonl, etc are macros on macOS. So we have to reimplement them. So let's
464    // reimplement them for all UNIX platforms
465    pub const safe fn htonl(hostlong: u32) -> u32 {
466        u32::to_be(hostlong)
467    }
468    pub const safe fn htons(hostshort: u16) -> u16 {
469        u16::to_be(hostshort)
470    }
471    pub const safe fn ntohl(netlong: u32) -> u32 {
472        u32::from_be(netlong)
473    }
474    pub const safe fn ntohs(netshort: u16) -> u16 {
475        u16::from_be(netshort)
476    }
477}
478
479extern "C" {
480    pub static in6addr_loopback: in6_addr;
481    pub static in6addr_any: in6_addr;
482}
483
484// FIXME(1.0): We want to remove these directives and instead expect that no-std users add their
485// own link configuration when required, rather than unconditionally linking everything that may
486// possibly be needed.
487cfg_if! {
488    if #[cfg(any(
489        target_os = "l4re",
490        target_os = "espidf",
491        target_os = "nuttx"
492    ))] {
493        // required libraries are linked externally for these platforms:
494        // * L4Re
495        // * ESP-IDF
496        // * NuttX
497    } else if #[cfg(feature = "std")] {
498        // cargo build, don't pull in anything extra as the std dep
499        // already pulls in all libs.
500    } else if #[cfg(all(
501        any(
502            all(
503                target_os = "linux",
504                any(target_env = "gnu", target_env = "uclibc")
505            ),
506            target_os = "cygwin"
507        ),
508        feature = "rustc-dep-of-std"
509    ))] {
510        #[link(
511            name = "util",
512            kind = "static",
513            modifiers = "-bundle",
514            cfg(target_feature = "crt-static")
515        )]
516        #[link(
517            name = "rt",
518            kind = "static",
519            modifiers = "-bundle",
520            cfg(target_feature = "crt-static")
521        )]
522        #[link(
523            name = "pthread",
524            kind = "static",
525            modifiers = "-bundle",
526            cfg(target_feature = "crt-static")
527        )]
528        #[link(
529            name = "m",
530            kind = "static",
531            modifiers = "-bundle",
532            cfg(target_feature = "crt-static")
533        )]
534        #[link(
535            name = "dl",
536            kind = "static",
537            modifiers = "-bundle",
538            cfg(target_feature = "crt-static")
539        )]
540        #[link(
541            name = "c",
542            kind = "static",
543            modifiers = "-bundle",
544            cfg(target_feature = "crt-static")
545        )]
546        #[link(
547            name = "gcc_eh",
548            kind = "static",
549            modifiers = "-bundle",
550            cfg(target_feature = "crt-static")
551        )]
552        #[link(
553            name = "gcc",
554            kind = "static",
555            modifiers = "-bundle",
556            cfg(target_feature = "crt-static")
557        )]
558        #[link(
559            name = "c",
560            kind = "static",
561            modifiers = "-bundle",
562            cfg(target_feature = "crt-static")
563        )]
564        #[link(name = "util", cfg(not(target_feature = "crt-static")))]
565        #[link(name = "rt", cfg(not(target_feature = "crt-static")))]
566        #[link(name = "pthread", cfg(not(target_feature = "crt-static")))]
567        #[link(name = "m", cfg(not(target_feature = "crt-static")))]
568        #[link(name = "dl", cfg(not(target_feature = "crt-static")))]
569        #[link(name = "c", cfg(not(target_feature = "crt-static")))]
570        extern "C" {}
571    } else if #[cfg(libc_pauthtest)] {
572        #[link(name = "c")]
573        #[link(name = "m")]
574        #[link(name = "rt")]
575        #[link(name = "pthread")]
576        #[link(name = "dl")]
577        extern "C" {}
578    } else if #[cfg(any(
579        all(target_env = "musl", not(libc_pauthtest)),
580        target_env = "ohos"
581    ))] {
582        #[cfg_attr(
583            feature = "rustc-dep-of-std",
584            link(
585                name = "c",
586                kind = "static",
587                modifiers = "-bundle",
588                cfg(target_feature = "crt-static")
589            )
590        )]
591        #[cfg_attr(
592            feature = "rustc-dep-of-std",
593            link(name = "c", cfg(not(target_feature = "crt-static")))
594        )]
595        extern "C" {}
596    } else if #[cfg(target_os = "emscripten")] {
597        // Don't pass -lc to Emscripten, it breaks. See:
598        // https://github.com/emscripten-core/emscripten/issues/22758
599    } else if #[cfg(all(target_os = "android", feature = "rustc-dep-of-std"))] {
600        #[link(
601            name = "c",
602            kind = "static",
603            modifiers = "-bundle",
604            cfg(target_feature = "crt-static")
605        )]
606        #[link(
607            name = "m",
608            kind = "static",
609            modifiers = "-bundle",
610            cfg(target_feature = "crt-static")
611        )]
612        #[link(name = "m", cfg(not(target_feature = "crt-static")))]
613        #[link(name = "c", cfg(not(target_feature = "crt-static")))]
614        extern "C" {}
615    } else if #[cfg(any(
616        target_vendor = "apple",
617        target_os = "android",
618        target_os = "openbsd",
619        target_os = "nto",
620        target_os = "qnx",
621    ))] {
622        #[link(name = "c")]
623        #[link(name = "m")]
624        extern "C" {}
625    } else if #[cfg(target_os = "haiku")] {
626        #[link(name = "root")]
627        #[link(name = "network")]
628        extern "C" {}
629    } else if #[cfg(target_env = "newlib")] {
630        #[link(name = "c")]
631        #[link(name = "m")]
632        extern "C" {}
633    } else if #[cfg(target_env = "illumos")] {
634        #[link(name = "c")]
635        #[link(name = "m")]
636        extern "C" {}
637    } else if #[cfg(target_os = "redox")] {
638        #[cfg_attr(
639            feature = "rustc-dep-of-std",
640            link(
641                name = "c",
642                kind = "static",
643                modifiers = "-bundle",
644                cfg(target_feature = "crt-static")
645            )
646        )]
647        #[cfg_attr(
648            feature = "rustc-dep-of-std",
649            link(name = "c", cfg(not(target_feature = "crt-static")))
650        )]
651        extern "C" {}
652    } else if #[cfg(target_os = "aix")] {
653        #[link(name = "c")]
654        #[link(name = "m")]
655        #[link(name = "bsd")]
656        #[link(name = "pthread")]
657        extern "C" {}
658    } else {
659        #[link(name = "c")]
660        #[link(name = "m")]
661        #[link(name = "rt")]
662        #[link(name = "pthread")]
663        extern "C" {}
664    }
665}
666
667cfg_if! {
668    if #[cfg(not(any(
669        target_os = "hurd",
670        all(target_os = "linux", target_env = "gnu")
671    )))] {
672        extern_ty! {
673            pub type fpos_t; // FIXME(unix): fill this out with a struct
674        }
675    }
676}
677
678/// This is an extern type ("opaque" or "incomplete" type in C).
///
/// <div class="warning">
/// This type's current representation allows inspecting some properties, such as via
/// <code>size_of</code>, and it is technically possible to construct the type within
/// <code>MaybeUninit</code>, However, this <strong>MUST NOT</strong> be relied upon
/// because a future version of <code>libc</code> may switch to a proper
/// <a href="https://rust-lang.github.io/rfcs/1861-extern-types.html">extern type</a>
/// representation when available.
/// </div>
#[repr(C)]
pub struct FILE {
    _data: (),
    _marker: ::core::marker::PhantomData<(*mut u8,
    ::core::marker::PhantomPinned)>,
}
#[automatically_derived]
#[doc(hidden)]
unsafe impl ::core::clone::TrivialClone for FILE { }
#[automatically_derived]
impl ::core::clone::Clone for FILE {
    #[inline]
    fn clone(&self) -> Self {
        let _: ::core::clone::AssertParamIsClone<()>;
        let _:
                ::core::clone::AssertParamIsClone<::core::marker::PhantomData<(*mut u8,
                ::core::marker::PhantomPinned)>>;
        *self
    }
}
#[automatically_derived]
impl ::core::marker::Copy for FILE { }
#[automatically_derived]
impl ::core::fmt::Debug for FILE {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::debug_struct_field2_finish(f, "FILE", "_data",
            &self._data, "_marker", &&self._marker)
    }
}extern_ty! {
679    pub type FILE;
680}
681
682extern "C" {
683    pub fn isalnum(c: c_int) -> c_int;
684    pub fn isalpha(c: c_int) -> c_int;
685    pub fn iscntrl(c: c_int) -> c_int;
686    pub fn isdigit(c: c_int) -> c_int;
687    pub fn isgraph(c: c_int) -> c_int;
688    pub fn islower(c: c_int) -> c_int;
689    pub fn isprint(c: c_int) -> c_int;
690    pub fn ispunct(c: c_int) -> c_int;
691    pub fn isspace(c: c_int) -> c_int;
692    pub fn isupper(c: c_int) -> c_int;
693    pub fn isxdigit(c: c_int) -> c_int;
694    pub fn isblank(c: c_int) -> c_int;
695    pub fn tolower(c: c_int) -> c_int;
696    pub fn toupper(c: c_int) -> c_int;
697    pub fn qsort(
698        base: *mut c_void,
699        num: size_t,
700        size: size_t,
701        compar: Option<unsafe extern "C" fn(*const c_void, *const c_void) -> c_int>,
702    );
703    pub fn bsearch(
704        key: *const c_void,
705        base: *const c_void,
706        num: size_t,
707        size: size_t,
708        compar: Option<unsafe extern "C" fn(*const c_void, *const c_void) -> c_int>,
709    ) -> *mut c_void;
710    #[cfg_attr(
711        all(target_os = "macos", target_arch = "x86"),
712        link_name = "fopen$UNIX2003"
713    )]
714    #[cfg_attr(gnu_file_offset_bits64, link_name = "fopen64")]
715    pub fn fopen(filename: *const c_char, mode: *const c_char) -> *mut FILE;
716    #[cfg_attr(
717        all(target_os = "macos", target_arch = "x86"),
718        link_name = "freopen$UNIX2003"
719    )]
720    #[cfg_attr(gnu_file_offset_bits64, link_name = "freopen64")]
721    pub fn freopen(filename: *const c_char, mode: *const c_char, file: *mut FILE) -> *mut FILE;
722
723    pub fn fflush(file: *mut FILE) -> c_int;
724    pub fn fclose(file: *mut FILE) -> c_int;
725    pub fn remove(filename: *const c_char) -> c_int;
726    pub fn rename(oldname: *const c_char, newname: *const c_char) -> c_int;
727    #[cfg_attr(gnu_file_offset_bits64, link_name = "tmpfile64")]
728    pub fn tmpfile() -> *mut FILE;
729    pub fn setvbuf(stream: *mut FILE, buffer: *mut c_char, mode: c_int, size: size_t) -> c_int;
730    pub fn setbuf(stream: *mut FILE, buf: *mut c_char);
731    pub fn getchar() -> c_int;
732    pub fn putchar(c: c_int) -> c_int;
733    pub fn fgetc(stream: *mut FILE) -> c_int;
734    pub fn fgets(buf: *mut c_char, n: c_int, stream: *mut FILE) -> *mut c_char;
735    pub fn fputc(c: c_int, stream: *mut FILE) -> c_int;
736    #[cfg_attr(
737        all(target_os = "macos", target_arch = "x86"),
738        link_name = "fputs$UNIX2003"
739    )]
740    pub fn fputs(s: *const c_char, stream: *mut FILE) -> c_int;
741    pub fn puts(s: *const c_char) -> c_int;
742    pub fn ungetc(c: c_int, stream: *mut FILE) -> c_int;
743    pub fn fread(ptr: *mut c_void, size: size_t, nobj: size_t, stream: *mut FILE) -> size_t;
744    #[cfg_attr(
745        all(target_os = "macos", target_arch = "x86"),
746        link_name = "fwrite$UNIX2003"
747    )]
748    pub fn fwrite(ptr: *const c_void, size: size_t, nobj: size_t, stream: *mut FILE) -> size_t;
749    pub fn fseek(stream: *mut FILE, offset: c_long, whence: c_int) -> c_int;
750    pub fn ftell(stream: *mut FILE) -> c_long;
751    pub fn rewind(stream: *mut FILE);
752    #[cfg_attr(target_os = "netbsd", link_name = "__fgetpos50")]
753    #[cfg_attr(gnu_file_offset_bits64, link_name = "fgetpos64")]
754    pub fn fgetpos(stream: *mut FILE, ptr: *mut fpos_t) -> c_int;
755    #[cfg_attr(target_os = "netbsd", link_name = "__fsetpos50")]
756    #[cfg_attr(gnu_file_offset_bits64, link_name = "fsetpos64")]
757    pub fn fsetpos(stream: *mut FILE, ptr: *const fpos_t) -> c_int;
758    pub fn feof(stream: *mut FILE) -> c_int;
759    pub fn ferror(stream: *mut FILE) -> c_int;
760    pub fn clearerr(stream: *mut FILE);
761    pub fn perror(s: *const c_char);
762    pub fn atof(s: *const c_char) -> c_double;
763    pub fn atoi(s: *const c_char) -> c_int;
764    pub fn atol(s: *const c_char) -> c_long;
765    pub fn atoll(s: *const c_char) -> c_longlong;
766    #[cfg_attr(
767        all(target_os = "macos", target_arch = "x86"),
768        link_name = "strtod$UNIX2003"
769    )]
770    pub fn strtod(s: *const c_char, endp: *mut *mut c_char) -> c_double;
771    pub fn strtof(s: *const c_char, endp: *mut *mut c_char) -> c_float;
772    pub fn strtol(s: *const c_char, endp: *mut *mut c_char, base: c_int) -> c_long;
773    pub fn strtoll(s: *const c_char, endp: *mut *mut c_char, base: c_int) -> c_longlong;
774    pub fn strtoul(s: *const c_char, endp: *mut *mut c_char, base: c_int) -> c_ulong;
775    pub fn strtoull(s: *const c_char, endp: *mut *mut c_char, base: c_int) -> c_ulonglong;
776    #[cfg_attr(target_os = "aix", link_name = "vec_calloc")]
777    pub fn calloc(nobj: size_t, size: size_t) -> *mut c_void;
778    #[cfg_attr(target_os = "aix", link_name = "vec_malloc")]
779    pub fn malloc(size: size_t) -> *mut c_void;
780    pub fn realloc(p: *mut c_void, size: size_t) -> *mut c_void;
781    pub fn free(p: *mut c_void);
782    pub fn abort() -> !;
783    pub fn exit(status: c_int) -> !;
784    pub fn _exit(status: c_int) -> !;
785    #[cfg_attr(
786        all(target_os = "macos", target_arch = "x86"),
787        link_name = "system$UNIX2003"
788    )]
789    // Not available on iOS/tvOS/watchOS/visionOS
790    #[cfg(not(any(
791        target_os = "ios",
792        target_os = "tvos",
793        target_os = "watchos",
794        target_os = "visionos"
795    )))]
796    pub fn system(s: *const c_char) -> c_int;
797    pub fn getenv(s: *const c_char) -> *mut c_char;
798
799    pub fn strcpy(dst: *mut c_char, src: *const c_char) -> *mut c_char;
800    pub fn strncpy(dst: *mut c_char, src: *const c_char, n: size_t) -> *mut c_char;
801    pub fn stpcpy(dst: *mut c_char, src: *const c_char) -> *mut c_char;
802    pub fn strcat(s: *mut c_char, ct: *const c_char) -> *mut c_char;
803    pub fn strncat(s: *mut c_char, ct: *const c_char, n: size_t) -> *mut c_char;
804    pub fn strcmp(cs: *const c_char, ct: *const c_char) -> c_int;
805    pub fn strncmp(cs: *const c_char, ct: *const c_char, n: size_t) -> c_int;
806    pub fn strcoll(cs: *const c_char, ct: *const c_char) -> c_int;
807    pub fn strchr(cs: *const c_char, c: c_int) -> *mut c_char;
808    pub fn strrchr(cs: *const c_char, c: c_int) -> *mut c_char;
809    pub fn strspn(cs: *const c_char, ct: *const c_char) -> size_t;
810    pub fn strcspn(cs: *const c_char, ct: *const c_char) -> size_t;
811    pub fn strdup(cs: *const c_char) -> *mut c_char;
812    pub fn strndup(cs: *const c_char, n: size_t) -> *mut c_char;
813    pub fn strpbrk(cs: *const c_char, ct: *const c_char) -> *mut c_char;
814    pub fn strstr(cs: *const c_char, ct: *const c_char) -> *mut c_char;
815    pub fn strcasecmp(s1: *const c_char, s2: *const c_char) -> c_int;
816    pub fn strncasecmp(s1: *const c_char, s2: *const c_char, n: size_t) -> c_int;
817    pub fn strlen(cs: *const c_char) -> size_t;
818    pub fn strnlen(cs: *const c_char, maxlen: size_t) -> size_t;
819    #[cfg_attr(
820        all(target_os = "macos", target_arch = "x86"),
821        link_name = "strerror$UNIX2003"
822    )]
823    pub fn strerror(n: c_int) -> *mut c_char;
824    pub fn strtok(s: *mut c_char, t: *const c_char) -> *mut c_char;
825    pub fn strtok_r(s: *mut c_char, t: *const c_char, p: *mut *mut c_char) -> *mut c_char;
826    pub fn strxfrm(s: *mut c_char, ct: *const c_char, n: size_t) -> size_t;
827    pub fn strsignal(sig: c_int) -> *mut c_char;
828    pub fn wcslen(buf: *const wchar_t) -> size_t;
829    pub fn wcstombs(dest: *mut c_char, src: *const wchar_t, n: size_t) -> size_t;
830
831    pub fn memchr(cx: *const c_void, c: c_int, n: size_t) -> *mut c_void;
832    pub fn wmemchr(cx: *const wchar_t, c: wchar_t, n: size_t) -> *mut wchar_t;
833    pub fn memcmp(cx: *const c_void, ct: *const c_void, n: size_t) -> c_int;
834    pub fn memcpy(dest: *mut c_void, src: *const c_void, n: size_t) -> *mut c_void;
835    pub fn memmove(dest: *mut c_void, src: *const c_void, n: size_t) -> *mut c_void;
836    pub fn memset(dest: *mut c_void, c: c_int, n: size_t) -> *mut c_void;
837    pub fn memccpy(dest: *mut c_void, src: *const c_void, c: c_int, n: size_t) -> *mut c_void;
838}
839
840extern "C" {
841    #[cfg_attr(target_os = "netbsd", link_name = "__getpwnam50")]
842    pub fn getpwnam(name: *const c_char) -> *mut passwd;
843    #[cfg_attr(target_os = "netbsd", link_name = "__getpwuid50")]
844    pub fn getpwuid(uid: crate::uid_t) -> *mut passwd;
845
846    pub fn fprintf(stream: *mut crate::FILE, format: *const c_char, ...) -> c_int;
847    pub fn printf(format: *const c_char, ...) -> c_int;
848    pub fn snprintf(s: *mut c_char, n: size_t, format: *const c_char, ...) -> c_int;
849    pub fn sprintf(s: *mut c_char, format: *const c_char, ...) -> c_int;
850    #[cfg_attr(
851        all(target_os = "linux", not(target_env = "uclibc")),
852        link_name = "__isoc99_fscanf"
853    )]
854    pub fn fscanf(stream: *mut crate::FILE, format: *const c_char, ...) -> c_int;
855    #[cfg_attr(
856        all(target_os = "linux", not(target_env = "uclibc")),
857        link_name = "__isoc99_scanf"
858    )]
859    pub fn scanf(format: *const c_char, ...) -> c_int;
860    #[cfg_attr(
861        all(target_os = "linux", not(target_env = "uclibc")),
862        link_name = "__isoc99_sscanf"
863    )]
864    pub fn sscanf(s: *const c_char, format: *const c_char, ...) -> c_int;
865    pub fn getchar_unlocked() -> c_int;
866    pub fn putchar_unlocked(c: c_int) -> c_int;
867
868    #[cfg(not(all(target_arch = "powerpc", target_vendor = "nintendo")))]
869    #[cfg_attr(target_os = "netbsd", link_name = "__socket30")]
870    #[cfg_attr(target_os = "illumos", link_name = "__xnet_socket")]
871    #[cfg_attr(target_os = "solaris", link_name = "__xnet7_socket")]
872    #[cfg_attr(target_os = "espidf", link_name = "lwip_socket")]
873    pub fn socket(domain: c_int, ty: c_int, protocol: c_int) -> c_int;
874    #[cfg(not(all(target_arch = "powerpc", target_vendor = "nintendo")))]
875    #[cfg_attr(
876        all(target_os = "macos", target_arch = "x86"),
877        link_name = "connect$UNIX2003"
878    )]
879    #[cfg_attr(
880        any(target_os = "illumos", target_os = "solaris"),
881        link_name = "__xnet_connect"
882    )]
883    #[cfg_attr(target_os = "espidf", link_name = "lwip_connect")]
884    pub fn connect(socket: c_int, address: *const sockaddr, len: socklen_t) -> c_int;
885    #[cfg_attr(
886        all(target_os = "macos", target_arch = "x86"),
887        link_name = "listen$UNIX2003"
888    )]
889    #[cfg_attr(target_os = "espidf", link_name = "lwip_listen")]
890    pub fn listen(socket: c_int, backlog: c_int) -> c_int;
891    #[cfg(not(all(target_arch = "powerpc", target_vendor = "nintendo")))]
892    #[cfg_attr(
893        all(target_os = "macos", target_arch = "x86"),
894        link_name = "accept$UNIX2003"
895    )]
896    #[cfg_attr(target_os = "espidf", link_name = "lwip_accept")]
897    #[cfg_attr(target_os = "aix", link_name = "naccept")]
898    pub fn accept(socket: c_int, address: *mut sockaddr, address_len: *mut socklen_t) -> c_int;
899    #[cfg(not(all(target_arch = "powerpc", target_vendor = "nintendo")))]
900    #[cfg_attr(
901        all(target_os = "macos", target_arch = "x86"),
902        link_name = "getpeername$UNIX2003"
903    )]
904    #[cfg_attr(target_os = "espidf", link_name = "lwip_getpeername")]
905    #[cfg_attr(target_os = "aix", link_name = "ngetpeername")]
906    pub fn getpeername(socket: c_int, address: *mut sockaddr, address_len: *mut socklen_t)
907        -> c_int;
908    #[cfg(not(all(target_arch = "powerpc", target_vendor = "nintendo")))]
909    #[cfg_attr(
910        all(target_os = "macos", target_arch = "x86"),
911        link_name = "getsockname$UNIX2003"
912    )]
913    #[cfg_attr(target_os = "espidf", link_name = "lwip_getsockname")]
914    #[cfg_attr(target_os = "aix", link_name = "ngetsockname")]
915    pub fn getsockname(socket: c_int, address: *mut sockaddr, address_len: *mut socklen_t)
916        -> c_int;
917    #[cfg_attr(target_os = "espidf", link_name = "lwip_setsockopt")]
918    #[cfg_attr(gnu_time_bits64, link_name = "__setsockopt64")]
919    pub fn setsockopt(
920        socket: c_int,
921        level: c_int,
922        name: c_int,
923        value: *const c_void,
924        option_len: socklen_t,
925    ) -> c_int;
926    #[cfg_attr(
927        all(target_os = "macos", target_arch = "x86"),
928        link_name = "socketpair$UNIX2003"
929    )]
930    #[cfg_attr(
931        any(target_os = "illumos", target_os = "solaris"),
932        link_name = "__xnet_socketpair"
933    )]
934    pub fn socketpair(
935        domain: c_int,
936        type_: c_int,
937        protocol: c_int,
938        socket_vector: *mut c_int,
939    ) -> c_int;
940    #[cfg(not(all(target_arch = "powerpc", target_vendor = "nintendo")))]
941    #[cfg_attr(
942        all(target_os = "macos", target_arch = "x86"),
943        link_name = "sendto$UNIX2003"
944    )]
945    #[cfg_attr(
946        any(target_os = "illumos", target_os = "solaris"),
947        link_name = "__xnet_sendto"
948    )]
949    #[cfg_attr(target_os = "espidf", link_name = "lwip_sendto")]
950    pub fn sendto(
951        socket: c_int,
952        buf: *const c_void,
953        len: size_t,
954        flags: c_int,
955        addr: *const sockaddr,
956        addrlen: socklen_t,
957    ) -> ssize_t;
958    #[cfg_attr(target_os = "espidf", link_name = "lwip_shutdown")]
959    pub fn shutdown(socket: c_int, how: c_int) -> c_int;
960
961    #[cfg_attr(
962        all(target_os = "macos", target_arch = "x86"),
963        link_name = "chmod$UNIX2003"
964    )]
965    pub fn chmod(path: *const c_char, mode: mode_t) -> c_int;
966    #[cfg_attr(
967        all(target_os = "macos", target_arch = "x86"),
968        link_name = "fchmod$UNIX2003"
969    )]
970    pub fn fchmod(fd: c_int, mode: mode_t) -> c_int;
971
972    #[cfg_attr(
973        all(target_os = "macos", any(target_arch = "x86", target_arch = "x86_64")),
974        link_name = "fstat$INODE64"
975    )]
976    #[cfg_attr(target_os = "netbsd", link_name = "__fstat50")]
977    #[cfg_attr(
978        all(target_os = "freebsd", any(freebsd11, freebsd10)),
979        link_name = "fstat@FBSD_1.0"
980    )]
981    #[cfg_attr(gnu_time_bits64, link_name = "__fstat64_time64")]
982    #[cfg_attr(
983        all(not(gnu_time_bits64), gnu_file_offset_bits64),
984        link_name = "fstat64"
985    )]
986    #[cfg_attr(musl_redir_time64, link_name = "__fstat_time64")]
987    pub fn fstat(fildes: c_int, buf: *mut stat) -> c_int;
988
989    pub fn mkdir(path: *const c_char, mode: mode_t) -> c_int;
990
991    #[cfg_attr(
992        all(target_os = "macos", any(target_arch = "x86", target_arch = "x86_64")),
993        link_name = "stat$INODE64"
994    )]
995    #[cfg_attr(target_os = "netbsd", link_name = "__stat50")]
996    #[cfg_attr(
997        all(target_os = "freebsd", any(freebsd11, freebsd10)),
998        link_name = "stat@FBSD_1.0"
999    )]
1000    #[cfg_attr(gnu_time_bits64, link_name = "__stat64_time64")]
1001    #[cfg_attr(
1002        all(not(gnu_time_bits64), gnu_file_offset_bits64),
1003        link_name = "stat64"
1004    )]
1005    #[cfg_attr(musl_redir_time64, link_name = "__stat_time64")]
1006    pub fn stat(path: *const c_char, buf: *mut stat) -> c_int;
1007
1008    pub fn pclose(stream: *mut crate::FILE) -> c_int;
1009    #[cfg_attr(
1010        all(target_os = "macos", target_arch = "x86"),
1011        link_name = "fdopen$UNIX2003"
1012    )]
1013    pub fn fdopen(fd: c_int, mode: *const c_char) -> *mut crate::FILE;
1014    pub fn fileno(stream: *mut crate::FILE) -> c_int;
1015
1016    #[cfg_attr(
1017        all(target_os = "macos", target_arch = "x86"),
1018        link_name = "open$UNIX2003"
1019    )]
1020    #[cfg_attr(gnu_file_offset_bits64, link_name = "open64")]
1021    pub fn open(path: *const c_char, oflag: c_int, ...) -> c_int;
1022    #[cfg_attr(
1023        all(target_os = "macos", target_arch = "x86"),
1024        link_name = "creat$UNIX2003"
1025    )]
1026    #[cfg_attr(gnu_file_offset_bits64, link_name = "creat64")]
1027    pub fn creat(path: *const c_char, mode: mode_t) -> c_int;
1028    #[cfg_attr(
1029        all(target_os = "macos", target_arch = "x86"),
1030        link_name = "fcntl$UNIX2003"
1031    )]
1032    #[cfg_attr(gnu_time_bits64, link_name = "__fcntl_time64")]
1033    #[cfg_attr(
1034        all(not(gnu_time_bits64), gnu_file_offset_bits64),
1035        link_name = "__fcntl_time64"
1036    )]
1037    pub fn fcntl(fd: c_int, cmd: c_int, ...) -> c_int;
1038
1039    #[cfg_attr(
1040        all(target_os = "macos", target_arch = "x86_64"),
1041        link_name = "opendir$INODE64"
1042    )]
1043    #[cfg_attr(
1044        all(target_os = "macos", target_arch = "x86"),
1045        link_name = "opendir$INODE64$UNIX2003"
1046    )]
1047    #[cfg_attr(target_os = "netbsd", link_name = "__opendir30")]
1048    pub fn opendir(dirname: *const c_char) -> *mut crate::DIR;
1049    #[cfg_attr(
1050        all(target_os = "macos", target_arch = "x86_64"),
1051        link_name = "fdopendir$INODE64"
1052    )]
1053    #[cfg_attr(
1054        all(target_os = "macos", target_arch = "x86"),
1055        link_name = "fdopendir$INODE64$UNIX2003"
1056    )]
1057    pub fn fdopendir(fd: c_int) -> *mut crate::DIR;
1058
1059    #[cfg_attr(
1060        all(target_os = "macos", any(target_arch = "x86", target_arch = "x86_64")),
1061        link_name = "readdir$INODE64"
1062    )]
1063    #[cfg_attr(target_os = "netbsd", link_name = "__readdir30")]
1064    #[cfg_attr(
1065        all(target_os = "freebsd", any(freebsd11, freebsd10)),
1066        link_name = "readdir@FBSD_1.0"
1067    )]
1068    #[cfg_attr(gnu_file_offset_bits64, link_name = "readdir64")]
1069    pub fn readdir(dirp: *mut crate::DIR) -> *mut crate::dirent;
1070    #[cfg_attr(
1071        all(target_os = "macos", target_arch = "x86"),
1072        link_name = "closedir$UNIX2003"
1073    )]
1074    pub fn closedir(dirp: *mut crate::DIR) -> c_int;
1075    #[cfg_attr(
1076        all(target_os = "macos", target_arch = "x86_64"),
1077        link_name = "rewinddir$INODE64"
1078    )]
1079    #[cfg_attr(
1080        all(target_os = "macos", target_arch = "x86"),
1081        link_name = "rewinddir$INODE64$UNIX2003"
1082    )]
1083    pub fn rewinddir(dirp: *mut crate::DIR);
1084
1085    pub fn fchmodat(dirfd: c_int, pathname: *const c_char, mode: mode_t, flags: c_int) -> c_int;
1086    pub fn fchown(fd: c_int, owner: crate::uid_t, group: crate::gid_t) -> c_int;
1087    #[cfg(not(target_os = "l4re"))]
1088    pub fn fchownat(
1089        dirfd: c_int,
1090        pathname: *const c_char,
1091        owner: crate::uid_t,
1092        group: crate::gid_t,
1093        flags: c_int,
1094    ) -> c_int;
1095    #[cfg_attr(gnu_file_offset_bits64, link_name = "openat64")]
1096    pub fn openat(dirfd: c_int, pathname: *const c_char, flags: c_int, ...) -> c_int;
1097    #[cfg_attr(
1098        all(target_os = "macos", any(target_arch = "x86", target_arch = "x86_64")),
1099        link_name = "fstatat$INODE64"
1100    )]
1101    #[cfg_attr(
1102        all(target_os = "freebsd", any(freebsd11, freebsd10)),
1103        link_name = "fstatat@FBSD_1.1"
1104    )]
1105    #[cfg_attr(gnu_time_bits64, link_name = "__fstatat64_time64")]
1106    #[cfg_attr(
1107        all(not(gnu_time_bits64), gnu_file_offset_bits64),
1108        link_name = "fstatat64"
1109    )]
1110    #[cfg(not(target_os = "l4re"))]
1111    #[cfg_attr(musl_redir_time64, link_name = "__fstatat_time64")]
1112    pub fn fstatat(dirfd: c_int, pathname: *const c_char, buf: *mut stat, flags: c_int) -> c_int;
1113    #[cfg(not(target_os = "l4re"))]
1114    pub fn linkat(
1115        olddirfd: c_int,
1116        oldpath: *const c_char,
1117        newdirfd: c_int,
1118        newpath: *const c_char,
1119        flags: c_int,
1120    ) -> c_int;
1121    #[cfg(not(target_os = "l4re"))]
1122    pub fn mkdirat(dirfd: c_int, pathname: *const c_char, mode: mode_t) -> c_int;
1123    #[cfg(not(target_os = "l4re"))]
1124    pub fn renameat(
1125        olddirfd: c_int,
1126        oldpath: *const c_char,
1127        newdirfd: c_int,
1128        newpath: *const c_char,
1129    ) -> c_int;
1130    #[cfg(not(target_os = "l4re"))]
1131    pub fn symlinkat(target: *const c_char, newdirfd: c_int, linkpath: *const c_char) -> c_int;
1132    #[cfg(not(target_os = "l4re"))]
1133    pub fn unlinkat(dirfd: c_int, pathname: *const c_char, flags: c_int) -> c_int;
1134
1135    pub fn access(path: *const c_char, amode: c_int) -> c_int;
1136    pub fn alarm(seconds: c_uint) -> c_uint;
1137    pub fn chdir(dir: *const c_char) -> c_int;
1138    pub fn fchdir(dirfd: c_int) -> c_int;
1139    pub fn chown(path: *const c_char, uid: uid_t, gid: gid_t) -> c_int;
1140    #[cfg_attr(
1141        all(target_os = "macos", target_arch = "x86"),
1142        link_name = "lchown$UNIX2003"
1143    )]
1144    pub fn lchown(path: *const c_char, uid: uid_t, gid: gid_t) -> c_int;
1145    #[cfg_attr(
1146        all(target_os = "macos", target_arch = "x86"),
1147        link_name = "close$NOCANCEL$UNIX2003"
1148    )]
1149    #[cfg_attr(
1150        all(target_os = "macos", target_arch = "x86_64"),
1151        link_name = "close$NOCANCEL"
1152    )]
1153    pub fn close(fd: c_int) -> c_int;
1154    pub fn dup(fd: c_int) -> c_int;
1155    pub fn dup2(src: c_int, dst: c_int) -> c_int;
1156
1157    // exec* marked as prohibited on tvOS and watchOS.
1158    #[cfg(not(any(target_os = "tvos", target_os = "watchos")))]
1159    pub fn execl(path: *const c_char, arg0: *const c_char, ...) -> c_int;
1160    #[cfg(not(any(target_os = "tvos", target_os = "watchos")))]
1161    pub fn execle(path: *const c_char, arg0: *const c_char, ...) -> c_int;
1162    #[cfg(not(any(target_os = "tvos", target_os = "watchos")))]
1163    pub fn execlp(file: *const c_char, arg0: *const c_char, ...) -> c_int;
1164
1165    // DIFF(main): changed to `*const *mut` in e77f551de9
1166    #[cfg(not(any(target_os = "tvos", target_os = "watchos")))]
1167    pub fn execv(prog: *const c_char, argv: *const *const c_char) -> c_int;
1168    #[cfg(not(any(target_os = "tvos", target_os = "watchos")))]
1169    pub fn execve(
1170        prog: *const c_char,
1171        argv: *const *const c_char,
1172        envp: *const *const c_char,
1173    ) -> c_int;
1174    #[cfg(not(any(target_os = "tvos", target_os = "watchos")))]
1175    pub fn execvp(c: *const c_char, argv: *const *const c_char) -> c_int;
1176
1177    #[cfg(not(any(target_os = "tvos", target_os = "watchos")))]
1178    pub fn fork() -> pid_t;
1179    pub fn fpathconf(filedes: c_int, name: c_int) -> c_long;
1180    pub fn getcwd(buf: *mut c_char, size: size_t) -> *mut c_char;
1181    pub fn getegid() -> gid_t;
1182    pub fn geteuid() -> uid_t;
1183    pub fn getgid() -> gid_t;
1184    pub fn getgroups(ngroups_max: c_int, groups: *mut gid_t) -> c_int;
1185    #[cfg_attr(target_os = "illumos", link_name = "getloginx")]
1186    pub fn getlogin() -> *mut c_char;
1187    #[cfg_attr(
1188        all(target_os = "macos", target_arch = "x86"),
1189        link_name = "getopt$UNIX2003"
1190    )]
1191    pub fn getopt(argc: c_int, argv: *const *mut c_char, optstr: *const c_char) -> c_int;
1192    pub fn getpgid(pid: pid_t) -> pid_t;
1193    pub fn getpgrp() -> pid_t;
1194    pub fn getpid() -> pid_t;
1195    pub fn getppid() -> pid_t;
1196    pub fn getuid() -> uid_t;
1197    pub fn isatty(fd: c_int) -> c_int;
1198    #[cfg_attr(target_os = "solaris", link_name = "__link_xpg4")]
1199    pub fn link(src: *const c_char, dst: *const c_char) -> c_int;
1200    #[cfg_attr(gnu_file_offset_bits64, link_name = "lseek64")]
1201    pub fn lseek(fd: c_int, offset: off_t, whence: c_int) -> off_t;
1202    pub fn pathconf(path: *const c_char, name: c_int) -> c_long;
1203    #[cfg_attr(
1204        all(target_os = "macos", target_arch = "x86"),
1205        link_name = "pause$UNIX2003"
1206    )]
1207    pub fn pause() -> c_int;
1208    pub fn pipe(fds: *mut c_int) -> c_int;
1209    pub fn posix_memalign(memptr: *mut *mut c_void, align: size_t, size: size_t) -> c_int;
1210    pub fn aligned_alloc(alignment: size_t, size: size_t) -> *mut c_void;
1211    #[cfg_attr(
1212        all(target_os = "macos", target_arch = "x86"),
1213        link_name = "read$UNIX2003"
1214    )]
1215    pub fn read(fd: c_int, buf: *mut c_void, count: size_t) -> ssize_t;
1216    pub fn rmdir(path: *const c_char) -> c_int;
1217    pub fn seteuid(uid: uid_t) -> c_int;
1218    pub fn setegid(gid: gid_t) -> c_int;
1219    pub fn setgid(gid: gid_t) -> c_int;
1220    pub fn setpgid(pid: pid_t, pgid: pid_t) -> c_int;
1221    pub fn setsid() -> pid_t;
1222    pub fn setuid(uid: uid_t) -> c_int;
1223    pub fn setreuid(ruid: uid_t, euid: uid_t) -> c_int;
1224    pub fn setregid(rgid: gid_t, egid: gid_t) -> c_int;
1225    #[cfg_attr(
1226        all(target_os = "macos", target_arch = "x86"),
1227        link_name = "sleep$UNIX2003"
1228    )]
1229    pub fn sleep(secs: c_uint) -> c_uint;
1230    #[cfg_attr(
1231        all(target_os = "macos", target_arch = "x86"),
1232        link_name = "nanosleep$UNIX2003"
1233    )]
1234    #[cfg_attr(target_os = "netbsd", link_name = "__nanosleep50")]
1235    #[cfg_attr(gnu_time_bits64, link_name = "__nanosleep64")]
1236    #[cfg_attr(musl_redir_time64, link_name = "__nanosleep_time64")]
1237    pub fn nanosleep(rqtp: *const timespec, rmtp: *mut timespec) -> c_int;
1238    pub fn tcgetpgrp(fd: c_int) -> pid_t;
1239    pub fn tcsetpgrp(fd: c_int, pgrp: crate::pid_t) -> c_int;
1240    pub fn ttyname(fd: c_int) -> *mut c_char;
1241    #[cfg_attr(
1242        all(target_os = "macos", target_arch = "x86"),
1243        link_name = "ttyname_r$UNIX2003"
1244    )]
1245    #[cfg_attr(
1246        any(target_os = "illumos", target_os = "solaris"),
1247        link_name = "__posix_ttyname_r"
1248    )]
1249    pub fn ttyname_r(fd: c_int, buf: *mut c_char, buflen: size_t) -> c_int;
1250    pub fn unlink(c: *const c_char) -> c_int;
1251    #[cfg_attr(
1252        all(target_os = "macos", target_arch = "x86"),
1253        link_name = "wait$UNIX2003"
1254    )]
1255    pub fn wait(status: *mut c_int) -> pid_t;
1256    #[cfg_attr(
1257        all(target_os = "macos", target_arch = "x86"),
1258        link_name = "waitpid$UNIX2003"
1259    )]
1260    pub fn waitpid(pid: pid_t, status: *mut c_int, options: c_int) -> pid_t;
1261    #[cfg_attr(
1262        all(target_os = "macos", target_arch = "x86"),
1263        link_name = "write$UNIX2003"
1264    )]
1265    pub fn write(fd: c_int, buf: *const c_void, count: size_t) -> ssize_t;
1266    #[cfg_attr(
1267        all(target_os = "macos", target_arch = "x86"),
1268        link_name = "pread$UNIX2003"
1269    )]
1270    #[cfg_attr(gnu_file_offset_bits64, link_name = "pread64")]
1271    pub fn pread(fd: c_int, buf: *mut c_void, count: size_t, offset: off_t) -> ssize_t;
1272    #[cfg_attr(
1273        all(target_os = "macos", target_arch = "x86"),
1274        link_name = "pwrite$UNIX2003"
1275    )]
1276    #[cfg_attr(gnu_file_offset_bits64, link_name = "pwrite64")]
1277    pub fn pwrite(fd: c_int, buf: *const c_void, count: size_t, offset: off_t) -> ssize_t;
1278    pub fn umask(mask: mode_t) -> mode_t;
1279
1280    #[cfg_attr(target_os = "netbsd", link_name = "__utime50")]
1281    #[cfg_attr(any(gnu_time_bits64, musl_redir_time64), link_name = "__utime64")]
1282    pub fn utime(file: *const c_char, buf: *const utimbuf) -> c_int;
1283
1284    #[cfg_attr(
1285        all(target_os = "macos", target_arch = "x86"),
1286        link_name = "kill$UNIX2003"
1287    )]
1288    pub fn kill(pid: pid_t, sig: c_int) -> c_int;
1289    #[cfg_attr(
1290        all(target_os = "macos", target_arch = "x86"),
1291        link_name = "killpg$UNIX2003"
1292    )]
1293    pub fn killpg(pgrp: pid_t, sig: c_int) -> c_int;
1294
1295    pub fn mlock(addr: *const c_void, len: size_t) -> c_int;
1296    pub fn munlock(addr: *const c_void, len: size_t) -> c_int;
1297    pub fn mlockall(flags: c_int) -> c_int;
1298    pub fn munlockall() -> c_int;
1299
1300    #[cfg_attr(
1301        all(target_os = "macos", target_arch = "x86"),
1302        link_name = "mmap$UNIX2003"
1303    )]
1304    #[cfg_attr(gnu_file_offset_bits64, link_name = "mmap64")]
1305    pub fn mmap(
1306        addr: *mut c_void,
1307        len: size_t,
1308        prot: c_int,
1309        flags: c_int,
1310        fd: c_int,
1311        offset: off_t,
1312    ) -> *mut c_void;
1313    #[cfg_attr(
1314        all(target_os = "macos", target_arch = "x86"),
1315        link_name = "munmap$UNIX2003"
1316    )]
1317    pub fn munmap(addr: *mut c_void, len: size_t) -> c_int;
1318
1319    pub fn if_nametoindex(ifname: *const c_char) -> c_uint;
1320    pub fn if_indextoname(ifindex: c_uint, ifname: *mut c_char) -> *mut c_char;
1321
1322    #[cfg_attr(
1323        all(target_os = "macos", any(target_arch = "x86", target_arch = "x86_64")),
1324        link_name = "lstat$INODE64"
1325    )]
1326    #[cfg_attr(target_os = "netbsd", link_name = "__lstat50")]
1327    #[cfg_attr(
1328        all(target_os = "freebsd", any(freebsd11, freebsd10)),
1329        link_name = "lstat@FBSD_1.0"
1330    )]
1331    #[cfg_attr(gnu_time_bits64, link_name = "__lstat64_time64")]
1332    #[cfg_attr(
1333        all(not(gnu_time_bits64), gnu_file_offset_bits64),
1334        link_name = "lstat64"
1335    )]
1336    #[cfg_attr(musl_redir_time64, link_name = "__lstat_time64")]
1337    pub fn lstat(path: *const c_char, buf: *mut stat) -> c_int;
1338
1339    #[cfg_attr(
1340        all(target_os = "macos", target_arch = "x86"),
1341        link_name = "fsync$UNIX2003"
1342    )]
1343    pub fn fsync(fd: c_int) -> c_int;
1344
1345    #[cfg_attr(
1346        all(target_os = "macos", target_arch = "x86"),
1347        link_name = "setenv$UNIX2003"
1348    )]
1349    pub fn setenv(name: *const c_char, val: *const c_char, overwrite: c_int) -> c_int;
1350    #[cfg_attr(
1351        all(target_os = "macos", target_arch = "x86"),
1352        link_name = "unsetenv$UNIX2003"
1353    )]
1354    #[cfg_attr(target_os = "netbsd", link_name = "__unsetenv13")]
1355    pub fn unsetenv(name: *const c_char) -> c_int;
1356
1357    pub fn symlink(path1: *const c_char, path2: *const c_char) -> c_int;
1358
1359    #[cfg_attr(gnu_file_offset_bits64, link_name = "truncate64")]
1360    pub fn truncate(path: *const c_char, length: off_t) -> c_int;
1361    #[cfg_attr(gnu_file_offset_bits64, link_name = "ftruncate64")]
1362    pub fn ftruncate(fd: c_int, length: off_t) -> c_int;
1363
1364    pub fn signal(signum: c_int, handler: sighandler_t) -> sighandler_t;
1365
1366    #[cfg_attr(target_os = "netbsd", link_name = "__getrusage50")]
1367    #[cfg_attr(gnu_time_bits64, link_name = "__getrusage64")]
1368    #[cfg_attr(musl_redir_time64, link_name = "__getrusage_time64")]
1369    pub fn getrusage(resource: c_int, usage: *mut rusage) -> c_int;
1370
1371    #[cfg_attr(target_vendor = "apple", link_name = "realpath$DARWIN_EXTSN")]
1372    pub fn realpath(pathname: *const c_char, resolved: *mut c_char) -> *mut c_char;
1373
1374    #[cfg_attr(target_os = "netbsd", link_name = "__times13")]
1375    pub fn times(buf: *mut crate::tms) -> crate::clock_t;
1376
1377    pub fn pthread_self() -> crate::pthread_t;
1378    pub fn pthread_equal(t1: crate::pthread_t, t2: crate::pthread_t) -> c_int;
1379    #[cfg_attr(
1380        all(target_os = "macos", target_arch = "x86"),
1381        link_name = "pthread_join$UNIX2003"
1382    )]
1383    pub fn pthread_join(native: crate::pthread_t, value: *mut *mut c_void) -> c_int;
1384    pub fn pthread_exit(value: *mut c_void) -> !;
1385    pub fn pthread_attr_init(attr: *mut crate::pthread_attr_t) -> c_int;
1386    pub fn pthread_attr_destroy(attr: *mut crate::pthread_attr_t) -> c_int;
1387    pub fn pthread_attr_getstacksize(
1388        attr: *const crate::pthread_attr_t,
1389        stacksize: *mut size_t,
1390    ) -> c_int;
1391    pub fn pthread_attr_setstacksize(attr: *mut crate::pthread_attr_t, stack_size: size_t)
1392        -> c_int;
1393    pub fn pthread_attr_setdetachstate(attr: *mut crate::pthread_attr_t, state: c_int) -> c_int;
1394    pub fn pthread_detach(thread: crate::pthread_t) -> c_int;
1395    #[cfg_attr(target_os = "netbsd", link_name = "__libc_thr_yield")]
1396    pub fn sched_yield() -> c_int;
1397    pub fn pthread_key_create(
1398        key: *mut crate::pthread_key_t,
1399        dtor: Option<unsafe extern "C" fn(*mut c_void)>,
1400    ) -> c_int;
1401    pub fn pthread_key_delete(key: crate::pthread_key_t) -> c_int;
1402    pub fn pthread_getspecific(key: crate::pthread_key_t) -> *mut c_void;
1403    pub fn pthread_setspecific(key: crate::pthread_key_t, value: *const c_void) -> c_int;
1404    pub fn pthread_mutex_init(
1405        lock: *mut crate::pthread_mutex_t,
1406        attr: *const crate::pthread_mutexattr_t,
1407    ) -> c_int;
1408    pub fn pthread_mutex_destroy(lock: *mut crate::pthread_mutex_t) -> c_int;
1409    pub fn pthread_mutex_lock(lock: *mut crate::pthread_mutex_t) -> c_int;
1410    pub fn pthread_mutex_trylock(lock: *mut crate::pthread_mutex_t) -> c_int;
1411    pub fn pthread_mutex_unlock(lock: *mut crate::pthread_mutex_t) -> c_int;
1412
1413    pub fn pthread_mutexattr_init(attr: *mut crate::pthread_mutexattr_t) -> c_int;
1414    #[cfg_attr(
1415        all(target_os = "macos", target_arch = "x86"),
1416        link_name = "pthread_mutexattr_destroy$UNIX2003"
1417    )]
1418    pub fn pthread_mutexattr_destroy(attr: *mut crate::pthread_mutexattr_t) -> c_int;
1419    pub fn pthread_mutexattr_settype(attr: *mut crate::pthread_mutexattr_t, _type: c_int) -> c_int;
1420
1421    #[cfg_attr(
1422        all(target_os = "macos", target_arch = "x86"),
1423        link_name = "pthread_cond_init$UNIX2003"
1424    )]
1425    pub fn pthread_cond_init(
1426        cond: *mut crate::pthread_cond_t,
1427        attr: *const crate::pthread_condattr_t,
1428    ) -> c_int;
1429    #[cfg_attr(
1430        all(target_os = "macos", target_arch = "x86"),
1431        link_name = "pthread_cond_wait$UNIX2003"
1432    )]
1433    pub fn pthread_cond_wait(
1434        cond: *mut crate::pthread_cond_t,
1435        lock: *mut crate::pthread_mutex_t,
1436    ) -> c_int;
1437    #[cfg_attr(
1438        all(target_os = "macos", target_arch = "x86"),
1439        link_name = "pthread_cond_timedwait$UNIX2003"
1440    )]
1441    #[cfg_attr(gnu_time_bits64, link_name = "__pthread_cond_timedwait64")]
1442    #[cfg_attr(musl_redir_time64, link_name = "__pthread_cond_timedwait_time64")]
1443    pub fn pthread_cond_timedwait(
1444        cond: *mut crate::pthread_cond_t,
1445        lock: *mut crate::pthread_mutex_t,
1446        abstime: *const crate::timespec,
1447    ) -> c_int;
1448    pub fn pthread_cond_signal(cond: *mut crate::pthread_cond_t) -> c_int;
1449    pub fn pthread_cond_broadcast(cond: *mut crate::pthread_cond_t) -> c_int;
1450    pub fn pthread_cond_destroy(cond: *mut crate::pthread_cond_t) -> c_int;
1451    pub fn pthread_condattr_init(attr: *mut crate::pthread_condattr_t) -> c_int;
1452    pub fn pthread_condattr_destroy(attr: *mut crate::pthread_condattr_t) -> c_int;
1453    #[cfg_attr(
1454        all(target_os = "macos", target_arch = "x86"),
1455        link_name = "pthread_rwlock_init$UNIX2003"
1456    )]
1457    pub fn pthread_rwlock_init(
1458        lock: *mut crate::pthread_rwlock_t,
1459        attr: *const crate::pthread_rwlockattr_t,
1460    ) -> c_int;
1461    #[cfg_attr(
1462        all(target_os = "macos", target_arch = "x86"),
1463        link_name = "pthread_rwlock_destroy$UNIX2003"
1464    )]
1465    pub fn pthread_rwlock_destroy(lock: *mut crate::pthread_rwlock_t) -> c_int;
1466    #[cfg_attr(
1467        all(target_os = "macos", target_arch = "x86"),
1468        link_name = "pthread_rwlock_rdlock$UNIX2003"
1469    )]
1470    pub fn pthread_rwlock_rdlock(lock: *mut crate::pthread_rwlock_t) -> c_int;
1471    #[cfg_attr(
1472        all(target_os = "macos", target_arch = "x86"),
1473        link_name = "pthread_rwlock_tryrdlock$UNIX2003"
1474    )]
1475    pub fn pthread_rwlock_tryrdlock(lock: *mut crate::pthread_rwlock_t) -> c_int;
1476    #[cfg_attr(
1477        all(target_os = "macos", target_arch = "x86"),
1478        link_name = "pthread_rwlock_wrlock$UNIX2003"
1479    )]
1480    pub fn pthread_rwlock_wrlock(lock: *mut crate::pthread_rwlock_t) -> c_int;
1481    #[cfg_attr(
1482        all(target_os = "macos", target_arch = "x86"),
1483        link_name = "pthread_rwlock_trywrlock$UNIX2003"
1484    )]
1485    pub fn pthread_rwlock_trywrlock(lock: *mut crate::pthread_rwlock_t) -> c_int;
1486    #[cfg_attr(
1487        all(target_os = "macos", target_arch = "x86"),
1488        link_name = "pthread_rwlock_unlock$UNIX2003"
1489    )]
1490    pub fn pthread_rwlock_unlock(lock: *mut crate::pthread_rwlock_t) -> c_int;
1491    pub fn pthread_rwlockattr_init(attr: *mut crate::pthread_rwlockattr_t) -> c_int;
1492    pub fn pthread_rwlockattr_destroy(attr: *mut crate::pthread_rwlockattr_t) -> c_int;
1493
1494    #[cfg_attr(
1495        any(target_os = "illumos", target_os = "solaris"),
1496        link_name = "__xnet_getsockopt"
1497    )]
1498    #[cfg_attr(target_os = "espidf", link_name = "lwip_getsockopt")]
1499    #[cfg_attr(gnu_time_bits64, link_name = "__getsockopt64")]
1500    pub fn getsockopt(
1501        sockfd: c_int,
1502        level: c_int,
1503        optname: c_int,
1504        optval: *mut c_void,
1505        optlen: *mut crate::socklen_t,
1506    ) -> c_int;
1507    pub fn raise(signum: c_int) -> c_int;
1508
1509    #[cfg_attr(target_os = "netbsd", link_name = "__utimes50")]
1510    #[cfg_attr(gnu_time_bits64, link_name = "__utimes64")]
1511    #[cfg_attr(musl_redir_time64, link_name = "__utimes_time64")]
1512    pub fn utimes(filename: *const c_char, times: *const crate::timeval) -> c_int;
1513    pub fn dlopen(filename: *const c_char, flag: c_int) -> *mut c_void;
1514    pub fn dlerror() -> *mut c_char;
1515    #[cfg_attr(musl_redir_time64, link_name = "__dlsym_time64")]
1516    pub fn dlsym(handle: *mut c_void, symbol: *const c_char) -> *mut c_void;
1517    pub fn dlclose(handle: *mut c_void) -> c_int;
1518
1519    #[cfg(not(all(target_arch = "powerpc", target_vendor = "nintendo")))]
1520    #[cfg_attr(
1521        any(target_os = "illumos", target_os = "solaris"),
1522        link_name = "__xnet_getaddrinfo"
1523    )]
1524    #[cfg_attr(target_os = "espidf", link_name = "lwip_getaddrinfo")]
1525    pub fn getaddrinfo(
1526        node: *const c_char,
1527        service: *const c_char,
1528        hints: *const addrinfo,
1529        res: *mut *mut addrinfo,
1530    ) -> c_int;
1531    #[cfg(not(all(target_arch = "powerpc", target_vendor = "nintendo")))]
1532    #[cfg_attr(target_os = "espidf", link_name = "lwip_freeaddrinfo")]
1533    pub fn freeaddrinfo(res: *mut addrinfo);
1534    pub fn hstrerror(errcode: c_int) -> *const c_char;
1535    pub fn gai_strerror(errcode: c_int) -> *const c_char;
1536    #[cfg_attr(
1537        any(
1538            all(
1539                target_os = "linux",
1540                not(any(target_env = "musl", target_env = "ohos"))
1541            ),
1542            target_os = "freebsd",
1543            target_os = "cygwin",
1544            target_os = "dragonfly",
1545            target_os = "haiku"
1546        ),
1547        link_name = "__res_init"
1548    )]
1549    #[cfg_attr(target_vendor = "apple", link_name = "res_9_init")]
1550    #[cfg_attr(target_os = "aix", link_name = "_res_init")]
1551    #[cfg(not(target_os = "l4re"))]
1552    pub fn res_init() -> c_int;
1553
1554    #[cfg_attr(target_os = "netbsd", link_name = "__gmtime_r50")]
1555    #[cfg_attr(gnu_time_bits64, link_name = "__gmtime64_r")]
1556    #[cfg_attr(not(musl32_time64), allow(deprecated))]
1557    #[cfg_attr(musl_redir_time64, link_name = "__gmtime64_r")]
1558    pub fn gmtime_r(time_p: *const time_t, result: *mut tm) -> *mut tm;
1559    #[cfg_attr(target_os = "netbsd", link_name = "__localtime_r50")]
1560    #[cfg_attr(gnu_time_bits64, link_name = "__localtime64_r")]
1561    #[cfg_attr(not(musl32_time64), allow(deprecated))]
1562    #[cfg_attr(musl_redir_time64, link_name = "__localtime64_r")]
1563    pub fn localtime_r(time_p: *const time_t, result: *mut tm) -> *mut tm;
1564    #[cfg_attr(
1565        all(target_os = "macos", target_arch = "x86"),
1566        link_name = "mktime$UNIX2003"
1567    )]
1568    #[cfg_attr(target_os = "netbsd", link_name = "__mktime50")]
1569    #[cfg_attr(any(gnu_time_bits64, musl_redir_time64), link_name = "__mktime64")]
1570    #[cfg_attr(not(musl32_time64), allow(deprecated))]
1571    pub fn mktime(tm: *mut tm) -> time_t;
1572    #[cfg_attr(target_os = "netbsd", link_name = "__time50")]
1573    #[cfg_attr(any(gnu_time_bits64, musl_redir_time64), link_name = "__time64")]
1574    #[cfg_attr(not(musl32_time64), allow(deprecated))]
1575    pub fn time(time: *mut time_t) -> time_t;
1576    #[cfg_attr(target_os = "netbsd", link_name = "__gmtime50")]
1577    #[cfg_attr(any(gnu_time_bits64, musl_redir_time64), link_name = "__gmtime64")]
1578    #[cfg_attr(not(musl32_time64), allow(deprecated))]
1579    pub fn gmtime(time_p: *const time_t) -> *mut tm;
1580    #[cfg_attr(target_os = "netbsd", link_name = "__locatime50")]
1581    #[cfg_attr(any(gnu_time_bits64, musl_redir_time64), link_name = "__localtime64")]
1582    #[cfg_attr(not(musl32_time64), allow(deprecated))]
1583    pub fn localtime(time_p: *const time_t) -> *mut tm;
1584    #[cfg_attr(target_os = "netbsd", link_name = "__difftime50")]
1585    #[cfg_attr(any(gnu_time_bits64, musl_redir_time64), link_name = "__difftime64")]
1586    #[cfg_attr(not(musl32_time64), allow(deprecated))]
1587    pub fn difftime(time1: time_t, time0: time_t) -> c_double;
1588    #[cfg(not(target_os = "aix"))]
1589    #[cfg_attr(target_os = "netbsd", link_name = "__timegm50")]
1590    #[cfg_attr(gnu_time_bits64, link_name = "__timegm64")]
1591    #[cfg_attr(not(musl32_time64), allow(deprecated))]
1592    #[cfg_attr(musl_redir_time64, link_name = "__timegm_time64")]
1593    pub fn timegm(tm: *mut crate::tm) -> time_t;
1594
1595    #[cfg_attr(target_os = "netbsd", link_name = "__mknod50")]
1596    #[cfg_attr(
1597        all(target_os = "freebsd", any(freebsd11, freebsd10)),
1598        link_name = "mknod@FBSD_1.0"
1599    )]
1600    pub fn mknod(pathname: *const c_char, mode: mode_t, dev: crate::dev_t) -> c_int;
1601    #[cfg(not(target_os = "espidf"))]
1602    pub fn gethostname(name: *mut c_char, len: size_t) -> c_int;
1603    pub fn endservent();
1604    pub fn getservbyname(name: *const c_char, proto: *const c_char) -> *mut servent;
1605    pub fn getservbyport(port: c_int, proto: *const c_char) -> *mut servent;
1606    pub fn getservent() -> *mut servent;
1607    pub fn setservent(stayopen: c_int);
1608    pub fn getprotobyname(name: *const c_char) -> *mut protoent;
1609    pub fn getprotobynumber(proto: c_int) -> *mut protoent;
1610    pub fn chroot(name: *const c_char) -> c_int;
1611    #[cfg(target_os = "cygwin")]
1612    pub fn usleep(secs: useconds_t) -> c_int;
1613    #[cfg_attr(
1614        all(target_os = "macos", target_arch = "x86"),
1615        link_name = "usleep$UNIX2003"
1616    )]
1617    #[cfg(not(target_os = "cygwin"))]
1618    pub fn usleep(secs: c_uint) -> c_int;
1619    #[cfg_attr(
1620        all(target_os = "macos", target_arch = "x86"),
1621        link_name = "send$UNIX2003"
1622    )]
1623    #[cfg_attr(target_os = "espidf", link_name = "lwip_send")]
1624    pub fn send(socket: c_int, buf: *const c_void, len: size_t, flags: c_int) -> ssize_t;
1625    #[cfg_attr(
1626        all(target_os = "macos", target_arch = "x86"),
1627        link_name = "recv$UNIX2003"
1628    )]
1629    #[cfg_attr(target_os = "espidf", link_name = "lwip_recv")]
1630    pub fn recv(socket: c_int, buf: *mut c_void, len: size_t, flags: c_int) -> ssize_t;
1631    #[cfg_attr(
1632        all(target_os = "macos", target_arch = "x86"),
1633        link_name = "putenv$UNIX2003"
1634    )]
1635    #[cfg_attr(target_os = "netbsd", link_name = "__putenv50")]
1636    pub fn putenv(string: *mut c_char) -> c_int;
1637    #[cfg_attr(
1638        all(target_os = "macos", target_arch = "x86"),
1639        link_name = "poll$UNIX2003"
1640    )]
1641    pub fn poll(fds: *mut pollfd, nfds: nfds_t, timeout: c_int) -> c_int;
1642    #[cfg_attr(
1643        all(target_os = "macos", target_arch = "x86_64"),
1644        link_name = "select$1050"
1645    )]
1646    #[cfg_attr(
1647        all(target_os = "macos", target_arch = "x86"),
1648        link_name = "select$UNIX2003"
1649    )]
1650    #[cfg_attr(target_os = "netbsd", link_name = "__select50")]
1651    #[cfg_attr(target_os = "aix", link_name = "__fd_select")]
1652    #[cfg_attr(gnu_time_bits64, link_name = "__select64")]
1653    #[cfg_attr(musl_redir_time64, link_name = "__select_time64")]
1654    pub fn select(
1655        nfds: c_int,
1656        readfds: *mut fd_set,
1657        writefds: *mut fd_set,
1658        errorfds: *mut fd_set,
1659        timeout: *mut timeval,
1660    ) -> c_int;
1661    #[cfg_attr(target_os = "netbsd", link_name = "__setlocale50")]
1662    pub fn setlocale(category: c_int, locale: *const c_char) -> *mut c_char;
1663    pub fn localeconv() -> *mut lconv;
1664
1665    #[cfg_attr(
1666        all(target_os = "macos", target_arch = "x86"),
1667        link_name = "sem_wait$UNIX2003"
1668    )]
1669    pub fn sem_wait(sem: *mut sem_t) -> c_int;
1670    pub fn sem_trywait(sem: *mut sem_t) -> c_int;
1671    pub fn sem_post(sem: *mut sem_t) -> c_int;
1672    #[cfg(not(all(target_os = "linux", target_env = "gnu")))] // defined in new/glibc
1673    #[cfg_attr(gnu_file_offset_bits64, link_name = "statvfs64")]
1674    pub fn statvfs(path: *const c_char, buf: *mut crate::statvfs) -> c_int;
1675    #[cfg(not(all(target_os = "linux", target_env = "gnu")))] // defined in new/glibc
1676    #[cfg_attr(gnu_file_offset_bits64, link_name = "fstatvfs64")]
1677    pub fn fstatvfs(fd: c_int, buf: *mut crate::statvfs) -> c_int;
1678
1679    #[cfg_attr(target_os = "netbsd", link_name = "__sigemptyset14")]
1680    pub fn sigemptyset(set: *mut sigset_t) -> c_int;
1681    #[cfg_attr(target_os = "netbsd", link_name = "__sigaddset14")]
1682    pub fn sigaddset(set: *mut sigset_t, signum: c_int) -> c_int;
1683    #[cfg_attr(target_os = "netbsd", link_name = "__sigfillset14")]
1684    pub fn sigfillset(set: *mut sigset_t) -> c_int;
1685    #[cfg_attr(target_os = "netbsd", link_name = "__sigdelset14")]
1686    pub fn sigdelset(set: *mut sigset_t, signum: c_int) -> c_int;
1687    #[cfg_attr(target_os = "netbsd", link_name = "__sigismember14")]
1688    pub fn sigismember(set: *const sigset_t, signum: c_int) -> c_int;
1689
1690    #[cfg_attr(target_os = "netbsd", link_name = "__sigprocmask14")]
1691    pub fn sigprocmask(how: c_int, set: *const sigset_t, oldset: *mut sigset_t) -> c_int;
1692    #[cfg_attr(target_os = "netbsd", link_name = "__sigpending14")]
1693    pub fn sigpending(set: *mut sigset_t) -> c_int;
1694
1695    #[cfg_attr(target_os = "solaris", link_name = "__sysconf_xpg7")]
1696    pub fn sysconf(name: c_int) -> c_long;
1697
1698    pub fn mkfifo(path: *const c_char, mode: mode_t) -> c_int;
1699
1700    #[cfg_attr(gnu_file_offset_bits64, link_name = "fseeko64")]
1701    pub fn fseeko(stream: *mut crate::FILE, offset: off_t, whence: c_int) -> c_int;
1702    #[cfg_attr(gnu_file_offset_bits64, link_name = "ftello64")]
1703    pub fn ftello(stream: *mut crate::FILE) -> off_t;
1704    #[cfg_attr(
1705        all(target_os = "macos", target_arch = "x86"),
1706        link_name = "tcdrain$UNIX2003"
1707    )]
1708    pub fn tcdrain(fd: c_int) -> c_int;
1709    #[cfg_attr(
1710        all(target_os = "linux", target_env = "gnu", target_arch = "arm"),
1711        link_name = "cfgetispeed@GLIBC_2.4"
1712    )]
1713    #[cfg_attr(
1714        all(target_os = "linux", target_env = "gnu", target_arch = "csky"),
1715        link_name = "cfgetispeed@GLIBC_2.29"
1716    )]
1717    #[cfg_attr(
1718        all(target_os = "linux", target_env = "gnu", target_arch = "m68k"),
1719        link_name = "cfgetispeed@GLIBC_2.0"
1720    )]
1721    #[cfg_attr(
1722        all(
1723            target_os = "linux",
1724            target_env = "gnu",
1725            any(target_arch = "mips", target_arch = "mips32r6")
1726        ),
1727        link_name = "cfgetispeed@GLIBC_2.0"
1728    )]
1729    #[cfg_attr(
1730        all(target_os = "linux", target_env = "gnu", target_arch = "powerpc"),
1731        link_name = "cfgetispeed@GLIBC_2.0"
1732    )]
1733    #[cfg_attr(
1734        all(target_os = "linux", target_env = "gnu", target_arch = "riscv32"),
1735        link_name = "cfgetispeed@GLIBC_2.33"
1736    )]
1737    #[cfg_attr(
1738        all(target_os = "linux", target_env = "gnu", target_arch = "sparc"),
1739        link_name = "cfgetispeed@GLIBC_2.0"
1740    )]
1741    #[cfg_attr(
1742        all(target_os = "linux", target_env = "gnu", target_arch = "x86"),
1743        link_name = "cfgetispeed@GLIBC_2.0"
1744    )]
1745    #[cfg_attr(
1746        all(target_os = "linux", target_env = "gnu", target_arch = "aarch64"),
1747        link_name = "cfgetispeed@GLIBC_2.17"
1748    )]
1749    #[cfg_attr(
1750        all(target_os = "linux", target_env = "gnu", target_arch = "loongarch64"),
1751        link_name = "cfgetispeed@GLIBC_2.36"
1752    )]
1753    #[cfg_attr(
1754        all(
1755            target_os = "linux",
1756            target_env = "gnu",
1757            any(target_arch = "mips64", target_arch = "mips64r6")
1758        ),
1759        link_name = "cfgetispeed@GLIBC_2.0"
1760    )]
1761    #[cfg_attr(
1762        all(
1763            target_os = "linux",
1764            target_env = "gnu",
1765            target_arch = "powerpc64",
1766            target_endian = "big",
1767            not(libc_elfv2)
1768        ),
1769        link_name = "cfgetispeed@GLIBC_2.3"
1770    )]
1771    #[cfg_attr(
1772        all(
1773            target_os = "linux",
1774            target_env = "gnu",
1775            target_arch = "powerpc64",
1776            any(target_endian = "little", libc_elfv2)
1777        ),
1778        link_name = "cfgetispeed@GLIBC_2.17"
1779    )]
1780    #[cfg_attr(
1781        all(target_os = "linux", target_env = "gnu", target_arch = "riscv64"),
1782        link_name = "cfgetispeed@GLIBC_2.27"
1783    )]
1784    #[cfg_attr(
1785        all(target_os = "linux", target_env = "gnu", target_arch = "s390x"),
1786        link_name = "cfgetispeed@GLIBC_2.2"
1787    )]
1788    #[cfg_attr(
1789        all(target_os = "linux", target_env = "gnu", target_arch = "sparc64"),
1790        link_name = "cfgetispeed@GLIBC_2.2"
1791    )]
1792    #[cfg_attr(
1793        all(
1794            target_os = "linux",
1795            target_env = "gnu",
1796            target_arch = "x86_64",
1797            target_pointer_width = "64"
1798        ),
1799        link_name = "cfgetispeed@GLIBC_2.2.5"
1800    )]
1801    #[cfg_attr(
1802        all(
1803            target_os = "linux",
1804            target_env = "gnu",
1805            target_arch = "x86_64",
1806            target_pointer_width = "32"
1807        ),
1808        link_name = "cfgetispeed@GLIBC_2.16"
1809    )]
1810    pub fn cfgetispeed(termios: *const crate::termios) -> crate::speed_t;
1811    #[cfg_attr(
1812        all(target_os = "linux", target_env = "gnu", target_arch = "arm"),
1813        link_name = "cfgetospeed@GLIBC_2.4"
1814    )]
1815    #[cfg_attr(
1816        all(target_os = "linux", target_env = "gnu", target_arch = "csky"),
1817        link_name = "cfgetospeed@GLIBC_2.29"
1818    )]
1819    #[cfg_attr(
1820        all(target_os = "linux", target_env = "gnu", target_arch = "m68k"),
1821        link_name = "cfgetospeed@GLIBC_2.0"
1822    )]
1823    #[cfg_attr(
1824        all(
1825            target_os = "linux",
1826            target_env = "gnu",
1827            any(target_arch = "mips", target_arch = "mips32r6")
1828        ),
1829        link_name = "cfgetospeed@GLIBC_2.0"
1830    )]
1831    #[cfg_attr(
1832        all(target_os = "linux", target_env = "gnu", target_arch = "powerpc"),
1833        link_name = "cfgetospeed@GLIBC_2.0"
1834    )]
1835    #[cfg_attr(
1836        all(target_os = "linux", target_env = "gnu", target_arch = "riscv32"),
1837        link_name = "cfgetospeed@GLIBC_2.33"
1838    )]
1839    #[cfg_attr(
1840        all(target_os = "linux", target_env = "gnu", target_arch = "sparc"),
1841        link_name = "cfgetospeed@GLIBC_2.0"
1842    )]
1843    #[cfg_attr(
1844        all(target_os = "linux", target_env = "gnu", target_arch = "x86"),
1845        link_name = "cfgetospeed@GLIBC_2.0"
1846    )]
1847    #[cfg_attr(
1848        all(target_os = "linux", target_env = "gnu", target_arch = "aarch64"),
1849        link_name = "cfgetospeed@GLIBC_2.17"
1850    )]
1851    #[cfg_attr(
1852        all(target_os = "linux", target_env = "gnu", target_arch = "loongarch64"),
1853        link_name = "cfgetospeed@GLIBC_2.36"
1854    )]
1855    #[cfg_attr(
1856        all(
1857            target_os = "linux",
1858            target_env = "gnu",
1859            any(target_arch = "mips64", target_arch = "mips64r6")
1860        ),
1861        link_name = "cfgetospeed@GLIBC_2.0"
1862    )]
1863    #[cfg_attr(
1864        all(
1865            target_os = "linux",
1866            target_env = "gnu",
1867            target_arch = "powerpc64",
1868            target_endian = "big",
1869            not(libc_elfv2)
1870        ),
1871        link_name = "cfgetospeed@GLIBC_2.3"
1872    )]
1873    #[cfg_attr(
1874        all(
1875            target_os = "linux",
1876            target_env = "gnu",
1877            target_arch = "powerpc64",
1878            any(target_endian = "little", libc_elfv2)
1879        ),
1880        link_name = "cfgetospeed@GLIBC_2.17"
1881    )]
1882    #[cfg_attr(
1883        all(target_os = "linux", target_env = "gnu", target_arch = "riscv64"),
1884        link_name = "cfgetospeed@GLIBC_2.27"
1885    )]
1886    #[cfg_attr(
1887        all(target_os = "linux", target_env = "gnu", target_arch = "s390x"),
1888        link_name = "cfgetospeed@GLIBC_2.2"
1889    )]
1890    #[cfg_attr(
1891        all(target_os = "linux", target_env = "gnu", target_arch = "sparc64"),
1892        link_name = "cfgetospeed@GLIBC_2.2"
1893    )]
1894    #[cfg_attr(
1895        all(
1896            target_os = "linux",
1897            target_env = "gnu",
1898            target_arch = "x86_64",
1899            target_pointer_width = "64"
1900        ),
1901        link_name = "cfgetospeed@GLIBC_2.2.5"
1902    )]
1903    #[cfg_attr(
1904        all(
1905            target_os = "linux",
1906            target_env = "gnu",
1907            target_arch = "x86_64",
1908            target_pointer_width = "32"
1909        ),
1910        link_name = "cfgetospeed@GLIBC_2.16"
1911    )]
1912    pub fn cfgetospeed(termios: *const crate::termios) -> crate::speed_t;
1913    #[cfg_attr(
1914        all(target_os = "linux", target_env = "gnu", target_arch = "arm"),
1915        link_name = "cfsetispeed@GLIBC_2.4"
1916    )]
1917    #[cfg_attr(
1918        all(target_os = "linux", target_env = "gnu", target_arch = "csky"),
1919        link_name = "cfsetispeed@GLIBC_2.29"
1920    )]
1921    #[cfg_attr(
1922        all(target_os = "linux", target_env = "gnu", target_arch = "m68k"),
1923        link_name = "cfsetispeed@GLIBC_2.0"
1924    )]
1925    #[cfg_attr(
1926        all(
1927            target_os = "linux",
1928            target_env = "gnu",
1929            any(target_arch = "mips", target_arch = "mips32r6")
1930        ),
1931        link_name = "cfsetispeed@GLIBC_2.0"
1932    )]
1933    #[cfg_attr(
1934        all(target_os = "linux", target_env = "gnu", target_arch = "powerpc"),
1935        link_name = "cfsetispeed@GLIBC_2.0"
1936    )]
1937    #[cfg_attr(
1938        all(target_os = "linux", target_env = "gnu", target_arch = "riscv32"),
1939        link_name = "cfsetispeed@GLIBC_2.33"
1940    )]
1941    #[cfg_attr(
1942        all(target_os = "linux", target_env = "gnu", target_arch = "sparc"),
1943        link_name = "cfsetispeed@GLIBC_2.0"
1944    )]
1945    #[cfg_attr(
1946        all(target_os = "linux", target_env = "gnu", target_arch = "x86"),
1947        link_name = "cfsetispeed@GLIBC_2.0"
1948    )]
1949    #[cfg_attr(
1950        all(target_os = "linux", target_env = "gnu", target_arch = "aarch64"),
1951        link_name = "cfsetispeed@GLIBC_2.17"
1952    )]
1953    #[cfg_attr(
1954        all(target_os = "linux", target_env = "gnu", target_arch = "loongarch64"),
1955        link_name = "cfsetispeed@GLIBC_2.36"
1956    )]
1957    #[cfg_attr(
1958        all(
1959            target_os = "linux",
1960            target_env = "gnu",
1961            any(target_arch = "mips64", target_arch = "mips64r6")
1962        ),
1963        link_name = "cfsetispeed@GLIBC_2.0"
1964    )]
1965    #[cfg_attr(
1966        all(
1967            target_os = "linux",
1968            target_env = "gnu",
1969            target_arch = "powerpc64",
1970            target_endian = "big",
1971            not(libc_elfv2)
1972        ),
1973        link_name = "cfsetispeed@GLIBC_2.3"
1974    )]
1975    #[cfg_attr(
1976        all(
1977            target_os = "linux",
1978            target_env = "gnu",
1979            target_arch = "powerpc64",
1980            any(target_endian = "little", libc_elfv2)
1981        ),
1982        link_name = "cfsetispeed@GLIBC_2.17"
1983    )]
1984    #[cfg_attr(
1985        all(target_os = "linux", target_env = "gnu", target_arch = "riscv64"),
1986        link_name = "cfsetispeed@GLIBC_2.27"
1987    )]
1988    #[cfg_attr(
1989        all(target_os = "linux", target_env = "gnu", target_arch = "s390x"),
1990        link_name = "cfsetispeed@GLIBC_2.2"
1991    )]
1992    #[cfg_attr(
1993        all(target_os = "linux", target_env = "gnu", target_arch = "sparc64"),
1994        link_name = "cfsetispeed@GLIBC_2.2"
1995    )]
1996    #[cfg_attr(
1997        all(
1998            target_os = "linux",
1999            target_env = "gnu",
2000            target_arch = "x86_64",
2001            target_pointer_width = "64"
2002        ),
2003        link_name = "cfsetispeed@GLIBC_2.2.5"
2004    )]
2005    #[cfg_attr(
2006        all(
2007            target_os = "linux",
2008            target_env = "gnu",
2009            target_arch = "x86_64",
2010            target_pointer_width = "32"
2011        ),
2012        link_name = "cfsetispeed@GLIBC_2.16"
2013    )]
2014    pub fn cfsetispeed(termios: *mut crate::termios, speed: crate::speed_t) -> c_int;
2015    #[cfg_attr(
2016        all(target_os = "linux", target_env = "gnu", target_arch = "arm"),
2017        link_name = "cfsetospeed@GLIBC_2.4"
2018    )]
2019    #[cfg_attr(
2020        all(target_os = "linux", target_env = "gnu", target_arch = "csky"),
2021        link_name = "cfsetospeed@GLIBC_2.29"
2022    )]
2023    #[cfg_attr(
2024        all(target_os = "linux", target_env = "gnu", target_arch = "m68k"),
2025        link_name = "cfsetospeed@GLIBC_2.0"
2026    )]
2027    #[cfg_attr(
2028        all(
2029            target_os = "linux",
2030            target_env = "gnu",
2031            any(target_arch = "mips", target_arch = "mips32r6")
2032        ),
2033        link_name = "cfsetospeed@GLIBC_2.0"
2034    )]
2035    #[cfg_attr(
2036        all(target_os = "linux", target_env = "gnu", target_arch = "powerpc"),
2037        link_name = "cfsetospeed@GLIBC_2.0"
2038    )]
2039    #[cfg_attr(
2040        all(target_os = "linux", target_env = "gnu", target_arch = "riscv32"),
2041        link_name = "cfsetospeed@GLIBC_2.33"
2042    )]
2043    #[cfg_attr(
2044        all(target_os = "linux", target_env = "gnu", target_arch = "sparc"),
2045        link_name = "cfsetospeed@GLIBC_2.0"
2046    )]
2047    #[cfg_attr(
2048        all(target_os = "linux", target_env = "gnu", target_arch = "x86"),
2049        link_name = "cfsetospeed@GLIBC_2.0"
2050    )]
2051    #[cfg_attr(
2052        all(target_os = "linux", target_env = "gnu", target_arch = "aarch64"),
2053        link_name = "cfsetospeed@GLIBC_2.17"
2054    )]
2055    #[cfg_attr(
2056        all(target_os = "linux", target_env = "gnu", target_arch = "loongarch64"),
2057        link_name = "cfsetospeed@GLIBC_2.36"
2058    )]
2059    #[cfg_attr(
2060        all(
2061            target_os = "linux",
2062            target_env = "gnu",
2063            any(target_arch = "mips64", target_arch = "mips64r6")
2064        ),
2065        link_name = "cfsetospeed@GLIBC_2.0"
2066    )]
2067    #[cfg_attr(
2068        all(
2069            target_os = "linux",
2070            target_env = "gnu",
2071            target_arch = "powerpc64",
2072            target_endian = "big",
2073            not(libc_elfv2)
2074        ),
2075        link_name = "cfsetospeed@GLIBC_2.3"
2076    )]
2077    #[cfg_attr(
2078        all(
2079            target_os = "linux",
2080            target_env = "gnu",
2081            target_arch = "powerpc64",
2082            any(target_endian = "little", libc_elfv2)
2083        ),
2084        link_name = "cfsetospeed@GLIBC_2.17"
2085    )]
2086    #[cfg_attr(
2087        all(target_os = "linux", target_env = "gnu", target_arch = "riscv64"),
2088        link_name = "cfsetospeed@GLIBC_2.27"
2089    )]
2090    #[cfg_attr(
2091        all(target_os = "linux", target_env = "gnu", target_arch = "s390x"),
2092        link_name = "cfsetospeed@GLIBC_2.2"
2093    )]
2094    #[cfg_attr(
2095        all(target_os = "linux", target_env = "gnu", target_arch = "sparc64"),
2096        link_name = "cfsetospeed@GLIBC_2.2"
2097    )]
2098    #[cfg_attr(
2099        all(
2100            target_os = "linux",
2101            target_env = "gnu",
2102            target_arch = "x86_64",
2103            target_pointer_width = "64"
2104        ),
2105        link_name = "cfsetospeed@GLIBC_2.2.5"
2106    )]
2107    #[cfg_attr(
2108        all(
2109            target_os = "linux",
2110            target_env = "gnu",
2111            target_arch = "x86_64",
2112            target_pointer_width = "32"
2113        ),
2114        link_name = "cfsetospeed@GLIBC_2.16"
2115    )]
2116    pub fn cfsetospeed(termios: *mut crate::termios, speed: crate::speed_t) -> c_int;
2117    #[cfg_attr(
2118        all(
2119            target_os = "linux",
2120            target_env = "gnu",
2121            any(
2122                target_arch = "mips",
2123                target_arch = "mips32r6",
2124                target_arch = "mips64",
2125                target_arch = "mips64r6",
2126                target_arch = "sparc"
2127            ),
2128        ),
2129        link_name = "tcgetattr@GLIBC_2.0"
2130    )]
2131    #[cfg_attr(
2132        all(target_os = "linux", target_env = "gnu", target_arch = "sparc64"),
2133        link_name = "tcgetattr@GLIBC_2.2"
2134    )]
2135    pub fn tcgetattr(fd: c_int, termios: *mut crate::termios) -> c_int;
2136    #[cfg_attr(
2137        all(
2138            target_os = "linux",
2139            target_env = "gnu",
2140            any(
2141                target_arch = "mips",
2142                target_arch = "mips32r6",
2143                target_arch = "mips64",
2144                target_arch = "mips64r6",
2145                target_arch = "sparc"
2146            ),
2147        ),
2148        link_name = "tcsetattr@GLIBC_2.0"
2149    )]
2150    #[cfg_attr(
2151        all(target_os = "linux", target_env = "gnu", target_arch = "sparc64"),
2152        link_name = "tcsetattr@GLIBC_2.2"
2153    )]
2154    pub fn tcsetattr(fd: c_int, optional_actions: c_int, termios: *const crate::termios) -> c_int;
2155    pub fn tcflow(fd: c_int, action: c_int) -> c_int;
2156    pub fn tcflush(fd: c_int, action: c_int) -> c_int;
2157    pub fn tcgetsid(fd: c_int) -> crate::pid_t;
2158    pub fn tcsendbreak(fd: c_int, duration: c_int) -> c_int;
2159    #[cfg_attr(gnu_file_offset_bits64, link_name = "mkstemp64")]
2160    pub fn mkstemp(template: *mut c_char) -> c_int;
2161    pub fn mkdtemp(template: *mut c_char) -> *mut c_char;
2162
2163    #[deprecated(
2164        since = "0.2.190",
2165        note = "function is obsolete; prefer tmpfile, mkstemp, or similar"
2166    )]
2167    pub fn tmpnam(ptr: *mut c_char) -> *mut c_char;
2168
2169    pub fn openlog(ident: *const c_char, logopt: c_int, facility: c_int);
2170    pub fn closelog();
2171    pub fn setlogmask(maskpri: c_int) -> c_int;
2172    #[cfg_attr(target_os = "macos", link_name = "syslog$DARWIN_EXTSN")]
2173    pub fn syslog(priority: c_int, message: *const c_char, ...);
2174    #[cfg_attr(
2175        all(target_os = "macos", target_arch = "x86"),
2176        link_name = "nice$UNIX2003"
2177    )]
2178    pub fn nice(incr: c_int) -> c_int;
2179
2180    #[cfg(not(target_os = "l4re"))]
2181    pub fn grantpt(fd: c_int) -> c_int;
2182    #[cfg(not(target_os = "l4re"))]
2183    pub fn posix_openpt(flags: c_int) -> c_int;
2184    #[cfg(not(target_os = "l4re"))]
2185    pub fn ptsname(fd: c_int) -> *mut c_char;
2186    #[cfg(not(target_os = "l4re"))]
2187    pub fn unlockpt(fd: c_int) -> c_int;
2188
2189    #[cfg(not(target_os = "aix"))]
2190    pub fn strcasestr(cs: *const c_char, ct: *const c_char) -> *mut c_char;
2191    pub fn getline(lineptr: *mut *mut c_char, n: *mut size_t, stream: *mut FILE) -> ssize_t;
2192
2193    #[cfg_attr(gnu_file_offset_bits64, link_name = "lockf64")]
2194    pub fn lockf(fd: c_int, cmd: c_int, len: off_t) -> c_int;
2195
2196}
2197
2198cfg_if! {
2199    if #[cfg(not(any(
2200        target_os = "emscripten",
2201        target_os = "android",
2202        target_os = "haiku",
2203        target_os = "nto",
2204        target_os = "qnx",
2205        target_os = "solaris",
2206        target_os = "cygwin",
2207        target_os = "aix",
2208        target_os = "l4re",
2209    )))] {
2210        extern "C" {
2211            #[cfg_attr(target_os = "netbsd", link_name = "__adjtime50")]
2212            #[cfg_attr(any(gnu_time_bits64, musl_redir_time64), link_name = "__adjtime64")]
2213            pub fn adjtime(delta: *const timeval, olddelta: *mut timeval) -> c_int;
2214        }
2215    } else if #[cfg(target_os = "solaris")] {
2216        extern "C" {
2217            pub fn adjtime(delta: *mut timeval, olddelta: *mut timeval) -> c_int;
2218        }
2219    }
2220}
2221
2222cfg_if! {
2223    if #[cfg(not(any(
2224        target_os = "emscripten",
2225        target_os = "android",
2226        target_os = "nto"
2227    )))] {
2228        extern "C" {
2229            pub fn stpncpy(dst: *mut c_char, src: *const c_char, n: size_t) -> *mut c_char;
2230        }
2231    }
2232}
2233
2234cfg_if! {
2235    if #[cfg(not(any(
2236        target_os = "dragonfly",
2237        target_os = "emscripten",
2238        target_os = "hurd",
2239        target_vendor = "apple",
2240        target_os = "openbsd",
2241        target_os = "l4re",
2242    )))] {
2243        extern "C" {
2244            pub fn sigqueue(pid: pid_t, sig: c_int, value: crate::sigval) -> c_int;
2245        }
2246    }
2247}
2248
2249cfg_if! {
2250    if #[cfg(not(target_os = "android"))] {
2251        extern "C" {
2252            #[cfg_attr(
2253                all(target_os = "macos", target_arch = "x86"),
2254                link_name = "confstr$UNIX2003"
2255            )]
2256            #[cfg_attr(target_os = "solaris", link_name = "__confstr_xpg7")]
2257            pub fn confstr(name: c_int, buf: *mut c_char, len: size_t) -> size_t;
2258        }
2259    }
2260}
2261
2262cfg_if! {
2263    if #[cfg(not(target_os = "aix"))] {
2264        extern "C" {
2265            pub fn dladdr(addr: *const c_void, info: *mut Dl_info) -> c_int;
2266        }
2267    }
2268}
2269
2270cfg_if! {
2271    if #[cfg(not(target_os = "solaris"))] {
2272        extern "C" {
2273            pub fn flock(fd: c_int, operation: c_int) -> c_int;
2274        }
2275    }
2276}
2277
2278cfg_if! {
2279    if #[cfg(not(any(target_env = "uclibc", target_os = "nto")))] {
2280        extern "C" {
2281            pub fn open_wmemstream(ptr: *mut *mut wchar_t, sizeloc: *mut size_t) -> *mut FILE;
2282        }
2283    }
2284}
2285
2286cfg_if! {
2287    if #[cfg(not(target_os = "redox"))] {
2288        extern "C" {
2289            pub fn getsid(pid: pid_t) -> pid_t;
2290            #[cfg_attr(
2291                all(target_os = "macos", any(target_arch = "x86", target_arch = "x86_64")),
2292                link_name = "readdir_r$INODE64"
2293            )]
2294            #[cfg_attr(target_os = "netbsd", link_name = "__readdir_r30")]
2295            #[cfg_attr(
2296                all(target_os = "freebsd", any(freebsd11, freebsd10)),
2297                link_name = "readdir_r@FBSD_1.0"
2298            )]
2299            #[cfg_attr(
2300                all(target_os = "freebsd", not(any(freebsd11, freebsd10))),
2301                link_name = "readdir_r@FBSD_1.5"
2302            )]
2303            /// The 64-bit libc on Solaris and illumos only has readdir_r. If a
2304            /// 32-bit Solaris or illumos target is ever created, it should use
2305            /// __posix_readdir_r. See libc(3LIB) on Solaris or illumos:
2306            ///
2307            /// * <https://illumos.org/man/3lib/libc>
2308            /// * <https://docs.oracle.com/cd/E36784_01/html/E36873/libc-3lib.html>
2309            /// * <https://www.unix.com/man-page/opensolaris/3LIB/libc/>
2310            #[cfg_attr(gnu_file_offset_bits64, link_name = "readdir64_r")]
2311            pub fn readdir_r(
2312                dirp: *mut crate::DIR,
2313                entry: *mut crate::dirent,
2314                result: *mut *mut crate::dirent,
2315            ) -> c_int;
2316        }
2317    }
2318}
2319
2320cfg_if! {
2321    if #[cfg(any(target_os = "nto", target_os = "qnx"))] {
2322        extern "C" {
2323            pub fn readlinkat(
2324                dirfd: c_int,
2325                pathname: *const c_char,
2326                buf: *mut c_char,
2327                bufsiz: size_t,
2328            ) -> c_int;
2329            pub fn readlink(path: *const c_char, buf: *mut c_char, bufsz: size_t) -> c_int;
2330            pub fn pselect(
2331                nfds: c_int,
2332                readfds: *mut fd_set,
2333                writefds: *mut fd_set,
2334                errorfds: *mut fd_set,
2335                timeout: *mut timespec,
2336                sigmask: *const sigset_t,
2337            ) -> c_int;
2338            pub fn sigaction(signum: c_int, act: *const sigaction, oldact: *mut sigaction)
2339                -> c_int;
2340        }
2341    } else {
2342        extern "C" {
2343            #[cfg(not(target_os = "l4re"))]
2344            pub fn readlinkat(
2345                dirfd: c_int,
2346                pathname: *const c_char,
2347                buf: *mut c_char,
2348                bufsiz: size_t,
2349            ) -> ssize_t;
2350            #[cfg(not(target_os = "l4re"))]
2351            pub fn fmemopen(buf: *mut c_void, size: size_t, mode: *const c_char) -> *mut FILE;
2352            #[cfg(not(target_os = "l4re"))]
2353            pub fn open_memstream(ptr: *mut *mut c_char, sizeloc: *mut size_t) -> *mut FILE;
2354            pub fn atexit(cb: extern "C" fn()) -> c_int;
2355            #[cfg(not(all(target_os = "linux", target_env = "gnu")))] // defined in new/glibc
2356            #[cfg_attr(target_os = "netbsd", link_name = "__sigaction14")]
2357            pub fn sigaction(signum: c_int, act: *const sigaction, oldact: *mut sigaction)
2358                -> c_int;
2359            pub fn readlink(path: *const c_char, buf: *mut c_char, bufsz: size_t) -> ssize_t;
2360            #[cfg_attr(
2361                all(target_os = "macos", target_arch = "x86_64"),
2362                link_name = "pselect$1050"
2363            )]
2364            #[cfg_attr(
2365                all(target_os = "macos", target_arch = "x86"),
2366                link_name = "pselect$UNIX2003"
2367            )]
2368            #[cfg_attr(target_os = "netbsd", link_name = "__pselect50")]
2369            #[cfg_attr(gnu_time_bits64, link_name = "__pselect64")]
2370            #[cfg_attr(musl_redir_time64, link_name = "__pselect_time64")]
2371            pub fn pselect(
2372                nfds: c_int,
2373                readfds: *mut fd_set,
2374                writefds: *mut fd_set,
2375                errorfds: *mut fd_set,
2376                timeout: *const timespec,
2377                sigmask: *const sigset_t,
2378            ) -> c_int;
2379        }
2380    }
2381}
2382
2383cfg_if! {
2384    if #[cfg(any(target_os = "aix", target_os = "nto"))] {
2385        extern "C" {
2386            pub fn cfmakeraw(termios: *mut crate::termios) -> c_int;
2387        }
2388    } else if #[cfg(not(any(target_os = "solaris", target_os = "illumos",)))] {
2389        extern "C" {
2390            pub fn cfmakeraw(termios: *mut crate::termios);
2391        }
2392    }
2393}
2394
2395cfg_if! {
2396    if #[cfg(any(target_os = "aix", target_os = "qnx",))] {
2397        extern "C" {
2398            pub fn cfsetspeed(termios: *mut crate::termios, speed: crate::speed_t) -> c_int;
2399        }
2400    } else if #[cfg(not(any(
2401        target_os = "solaris",
2402        target_os = "illumos",
2403        target_os = "nto"
2404    )))] {
2405        extern "C" {
2406            #[cfg(not(target_os = "l4re"))]
2407            #[cfg_attr(
2408                all(target_os = "linux", target_env = "gnu", target_arch = "arm"),
2409                link_name = "cfsetspeed@GLIBC_2.4"
2410            )]
2411            #[cfg_attr(
2412                all(target_os = "linux", target_env = "gnu", target_arch = "csky"),
2413                link_name = "cfsetspeed@GLIBC_2.29"
2414            )]
2415            #[cfg_attr(
2416                all(target_os = "linux", target_env = "gnu", target_arch = "m68k"),
2417                link_name = "cfsetspeed@GLIBC_2.0"
2418            )]
2419            #[cfg_attr(
2420                all(
2421                    target_os = "linux",
2422                    target_env = "gnu",
2423                    any(target_arch = "mips", target_arch = "mips32r6")
2424                ),
2425                link_name = "cfsetspeed@GLIBC_2.0"
2426            )]
2427            #[cfg_attr(
2428                all(target_os = "linux", target_env = "gnu", target_arch = "powerpc"),
2429                link_name = "cfsetspeed@GLIBC_2.0"
2430            )]
2431            #[cfg_attr(
2432                all(target_os = "linux", target_env = "gnu", target_arch = "riscv32"),
2433                link_name = "cfsetspeed@GLIBC_2.33"
2434            )]
2435            #[cfg_attr(
2436                all(target_os = "linux", target_env = "gnu", target_arch = "sparc"),
2437                link_name = "cfsetspeed@GLIBC_2.0"
2438            )]
2439            #[cfg_attr(
2440                all(target_os = "linux", target_env = "gnu", target_arch = "x86"),
2441                link_name = "cfsetspeed@GLIBC_2.0"
2442            )]
2443            #[cfg_attr(
2444                all(target_os = "linux", target_env = "gnu", target_arch = "aarch64"),
2445                link_name = "cfsetspeed@GLIBC_2.17"
2446            )]
2447            #[cfg_attr(
2448                all(target_os = "linux", target_env = "gnu", target_arch = "loongarch64"),
2449                link_name = "cfsetspeed@GLIBC_2.36"
2450            )]
2451            #[cfg_attr(
2452                all(
2453                    target_os = "linux",
2454                    target_env = "gnu",
2455                    any(target_arch = "mips64", target_arch = "mips64r6")
2456                ),
2457                link_name = "cfsetspeed@GLIBC_2.0"
2458            )]
2459            #[cfg_attr(
2460                all(
2461                    target_os = "linux",
2462                    target_env = "gnu",
2463                    target_arch = "powerpc64",
2464                    target_endian = "big",
2465                    not(libc_elfv2)
2466                ),
2467                link_name = "cfsetspeed@GLIBC_2.3"
2468            )]
2469            #[cfg_attr(
2470                all(
2471                    target_os = "linux",
2472                    target_env = "gnu",
2473                    target_arch = "powerpc64",
2474                    any(target_endian = "little", libc_elfv2)
2475                ),
2476                link_name = "cfsetspeed@GLIBC_2.17"
2477            )]
2478            #[cfg_attr(
2479                all(target_os = "linux", target_env = "gnu", target_arch = "riscv64"),
2480                link_name = "cfsetspeed@GLIBC_2.27"
2481            )]
2482            #[cfg_attr(
2483                all(target_os = "linux", target_env = "gnu", target_arch = "s390x"),
2484                link_name = "cfsetspeed@GLIBC_2.2"
2485            )]
2486            #[cfg_attr(
2487                all(target_os = "linux", target_env = "gnu", target_arch = "sparc64"),
2488                link_name = "cfsetspeed@GLIBC_2.2"
2489            )]
2490            #[cfg_attr(
2491                all(
2492                    target_os = "linux",
2493                    target_env = "gnu",
2494                    target_arch = "x86_64",
2495                    target_pointer_width = "64"
2496                ),
2497                link_name = "cfsetspeed@GLIBC_2.2.5"
2498            )]
2499            #[cfg_attr(
2500                all(
2501                    target_os = "linux",
2502                    target_env = "gnu",
2503                    target_arch = "x86_64",
2504                    target_pointer_width = "32"
2505                ),
2506                link_name = "cfsetspeed@GLIBC_2.16"
2507            )]
2508            pub fn cfsetspeed(termios: *mut crate::termios, speed: crate::speed_t) -> c_int;
2509        }
2510    }
2511}
2512
2513extern "C" {
2514    pub fn fnmatch(pattern: *const c_char, name: *const c_char, flags: c_int) -> c_int;
2515}
2516
2517cfg_if! {
2518    if #[cfg(target_env = "newlib")] {
2519        mod newlib;
2520        pub use self::newlib::*;
2521    } else if #[cfg(any(
2522        target_os = "linux",
2523        target_os = "l4re",
2524        target_os = "android",
2525        target_os = "emscripten"
2526    ))] {
2527        mod linux_like;
2528        pub use self::linux_like::*;
2529    } else if #[cfg(any(
2530        target_vendor = "apple",
2531        target_os = "freebsd",
2532        target_os = "dragonfly",
2533        target_os = "openbsd",
2534        target_os = "netbsd"
2535    ))] {
2536        mod bsd;
2537        pub use self::bsd::*;
2538    } else if #[cfg(any(target_os = "solaris", target_os = "illumos"))] {
2539        mod solarish;
2540        pub use self::solarish::*;
2541    } else if #[cfg(target_os = "haiku")] {
2542        mod haiku;
2543        pub use self::haiku::*;
2544    } else if #[cfg(target_os = "redox")] {
2545        mod redox;
2546        pub use self::redox::*;
2547    } else if #[cfg(target_os = "cygwin")] {
2548        mod cygwin;
2549        pub use self::cygwin::*;
2550    } else if #[cfg(any(target_os = "nto", target_os = "qnx"))] {
2551        mod nto;
2552        pub use self::nto::*;
2553    } else if #[cfg(target_os = "aix")] {
2554        mod aix;
2555        pub use self::aix::*;
2556    } else if #[cfg(target_os = "hurd")] {
2557        mod hurd;
2558        pub use self::hurd::*;
2559    } else if #[cfg(target_os = "nuttx")] {
2560        mod nuttx;
2561        pub use self::nuttx::*;
2562    } else {
2563        // Unknown target_os
2564    }
2565}