diff --git a/src/dir.rs b/src/dir.rs index e1854c35e8..d6b7ea9b7c 100644 --- a/src/dir.rs +++ b/src/dir.rs @@ -221,7 +221,8 @@ impl Entry { #[allow(clippy::unnecessary_cast)] pub fn ino(&self) -> u64 { cfg_if! { - if #[cfg(any(target_os = "android", + if #[cfg(any(target_os = "aix", + target_os = "android", target_os = "emscripten", target_os = "fuchsia", target_os = "haiku", @@ -250,6 +251,7 @@ impl Entry { /// `fstat` if this returns `None`. pub fn file_type(&self) -> Option { #[cfg(not(any( + target_os = "aix", target_os = "illumos", target_os = "solaris", target_os = "haiku" @@ -267,6 +269,7 @@ impl Entry { // illumos, Solaris, and Haiku systems do not have the d_type member at all: #[cfg(any( + target_os = "aix", target_os = "illumos", target_os = "solaris", target_os = "haiku" diff --git a/src/errno.rs b/src/errno.rs index d8ad28de85..50b35248f8 100644 --- a/src/errno.rs +++ b/src/errno.rs @@ -34,6 +34,10 @@ cfg_if! { unsafe fn errno_location() -> *mut c_int { libc::_errnop() } + } else if #[cfg(any(target_os = "aix"))] { + unsafe fn errno_location() -> *mut c_int { + libc::_Errno() + } } } @@ -223,6 +227,7 @@ fn desc(errno: Errno) -> &'static str { #[cfg(any( target_os = "linux", target_os = "android", + target_os = "aix", target_os = "illumos", target_os = "solaris", target_os = "fuchsia" @@ -232,6 +237,7 @@ fn desc(errno: Errno) -> &'static str { #[cfg(any( target_os = "linux", target_os = "android", + target_os = "aix", target_os = "illumos", target_os = "solaris", target_os = "fuchsia" @@ -241,6 +247,7 @@ fn desc(errno: Errno) -> &'static str { #[cfg(any( target_os = "linux", target_os = "android", + target_os = "aix", target_os = "illumos", target_os = "solaris", target_os = "fuchsia" @@ -250,6 +257,7 @@ fn desc(errno: Errno) -> &'static str { #[cfg(any( target_os = "linux", target_os = "android", + target_os = "aix", target_os = "illumos", target_os = "solaris", target_os = "fuchsia" @@ -259,6 +267,7 @@ fn desc(errno: Errno) -> &'static str { #[cfg(any( target_os = "linux", target_os = "android", + target_os = "aix", target_os = "illumos", target_os = "solaris", target_os = "fuchsia" @@ -268,6 +277,7 @@ fn desc(errno: Errno) -> &'static str { #[cfg(any( target_os = "linux", target_os = "android", + target_os = "aix", target_os = "illumos", target_os = "solaris", target_os = "fuchsia" @@ -277,6 +287,7 @@ fn desc(errno: Errno) -> &'static str { #[cfg(any( target_os = "linux", target_os = "android", + target_os = "aix", target_os = "illumos", target_os = "solaris", target_os = "fuchsia" @@ -286,6 +297,7 @@ fn desc(errno: Errno) -> &'static str { #[cfg(any( target_os = "linux", target_os = "android", + target_os = "aix", target_os = "illumos", target_os = "solaris", target_os = "fuchsia" @@ -421,6 +433,7 @@ fn desc(errno: Errno) -> &'static str { #[cfg(any( target_os = "linux", target_os = "android", + target_os = "aix", target_os = "illumos", target_os = "solaris", target_os = "fuchsia" @@ -457,6 +470,7 @@ fn desc(errno: Errno) -> &'static str { #[cfg(any( target_os = "linux", target_os = "android", + target_os = "aix", target_os = "illumos", target_os = "solaris", target_os = "fuchsia" @@ -466,6 +480,7 @@ fn desc(errno: Errno) -> &'static str { #[cfg(any( target_os = "linux", target_os = "android", + target_os = "aix", target_os = "illumos", target_os = "solaris", target_os = "fuchsia" @@ -482,6 +497,7 @@ fn desc(errno: Errno) -> &'static str { #[cfg(any( target_os = "linux", target_os = "android", + target_os = "aix", target_os = "fuchsia" ))] EBADMSG => "Not a data message", @@ -492,6 +508,7 @@ fn desc(errno: Errno) -> &'static str { #[cfg(any( target_os = "linux", target_os = "android", + target_os = "aix", target_os = "fuchsia", target_os = "haiku" ))] @@ -572,6 +589,7 @@ fn desc(errno: Errno) -> &'static str { #[cfg(any( target_os = "linux", target_os = "android", + target_os = "aix", target_os = "illumos", target_os = "solaris", target_os = "fuchsia", @@ -582,6 +600,7 @@ fn desc(errno: Errno) -> &'static str { #[cfg(any( target_os = "linux", target_os = "android", + target_os = "aix", target_os = "illumos", target_os = "solaris", target_os = "fuchsia" @@ -722,6 +741,7 @@ fn desc(errno: Errno) -> &'static str { #[cfg(any( target_os = "linux", target_os = "android", + target_os = "aix", target_os = "fuchsia" ))] EOWNERDEAD => "Owner died", @@ -732,6 +752,7 @@ fn desc(errno: Errno) -> &'static str { #[cfg(any( target_os = "linux", target_os = "android", + target_os = "aix", target_os = "fuchsia" ))] ENOTRECOVERABLE => "State not recoverable", @@ -868,6 +889,7 @@ fn desc(errno: Errno) -> &'static str { target_os = "ios", target_os = "openbsd", target_os = "netbsd", + target_os = "aix", target_os = "illumos", target_os = "solaris", target_os = "haiku" @@ -879,6 +901,7 @@ fn desc(errno: Errno) -> &'static str { target_os = "freebsd", target_os = "dragonfly", target_os = "ios", + target_os = "aix", target_os = "openbsd", target_os = "netbsd" ))] @@ -889,6 +912,7 @@ fn desc(errno: Errno) -> &'static str { target_os = "freebsd", target_os = "dragonfly", target_os = "ios", + target_os = "aix", target_os = "openbsd", target_os = "netbsd", target_os = "redox" @@ -903,6 +927,7 @@ fn desc(errno: Errno) -> &'static str { target_os = "openbsd", target_os = "netbsd", target_os = "redox", + target_os = "aix", target_os = "illumos", target_os = "solaris", target_os = "haiku" @@ -917,6 +942,7 @@ fn desc(errno: Errno) -> &'static str { target_os = "openbsd", target_os = "netbsd", target_os = "redox", + target_os = "aix", target_os = "illumos", target_os = "solaris", target_os = "haiku" @@ -928,6 +954,7 @@ fn desc(errno: Errno) -> &'static str { target_os = "freebsd", target_os = "dragonfly", target_os = "ios", + target_os = "aix", target_os = "openbsd", target_os = "netbsd", target_os = "redox" @@ -1009,6 +1036,7 @@ fn desc(errno: Errno) -> &'static str { target_os = "freebsd", target_os = "dragonfly", target_os = "ios", + target_os = "aix", target_os = "openbsd", target_os = "netbsd", target_os = "redox" @@ -1044,6 +1072,7 @@ fn desc(errno: Errno) -> &'static str { #[cfg(any( target_os = "macos", target_os = "ios", + target_os = "aix", target_os = "netbsd", target_os = "redox" ))] @@ -1060,6 +1089,7 @@ fn desc(errno: Errno) -> &'static str { #[cfg(any( target_os = "macos", target_os = "ios", + target_os = "aix", target_os = "netbsd", target_os = "redox" ))] @@ -1068,6 +1098,7 @@ fn desc(errno: Errno) -> &'static str { #[cfg(any( target_os = "macos", target_os = "ios", + target_os = "aix", target_os = "netbsd", target_os = "redox" ))] @@ -1076,6 +1107,7 @@ fn desc(errno: Errno) -> &'static str { #[cfg(any( target_os = "macos", target_os = "ios", + target_os = "aix", target_os = "netbsd", target_os = "redox" ))] @@ -1084,6 +1116,7 @@ fn desc(errno: Errno) -> &'static str { #[cfg(any( target_os = "macos", target_os = "ios", + target_os = "aix", target_os = "illumos", target_os = "solaris" ))] @@ -3131,3 +3164,217 @@ mod consts { } } } + +#[cfg(target_os = "aix")] +mod consts { + #[derive(Clone, Copy, Debug, Eq, PartialEq)] + #[repr(i32)] + #[non_exhaustive] + pub enum Errno { + UnknownErrno = 0, + EPERM = libc::EPERM, + ENOENT = libc::ENOENT, + ESRCH = libc::ESRCH, + EINTR = libc::EINTR, + EIO = libc::EIO, + ENXIO = libc::ENXIO, + E2BIG = libc::E2BIG, + ENOEXEC = libc::ENOEXEC, + EBADF = libc::EBADF, + ECHILD = libc::ECHILD, + EAGAIN = libc::EAGAIN, + ENOMEM = libc::ENOMEM, + EACCES = libc::EACCES, + EFAULT = libc::EFAULT, + ENOTBLK = libc::ENOTBLK, + EBUSY = libc::EBUSY, + EEXIST = libc::EEXIST, + EXDEV = libc::EXDEV, + ENODEV = libc::ENODEV, + ENOTDIR = libc::ENOTDIR, + EISDIR = libc::EISDIR, + EINVAL = libc::EINVAL, + ENFILE = libc::ENFILE, + EMFILE = libc::EMFILE, + ENOTTY = libc::ENOTTY, + ETXTBSY = libc::ETXTBSY, + EFBIG = libc::EFBIG, + ENOSPC = libc::ENOSPC, + ESPIPE = libc::ESPIPE, + EROFS = libc::EROFS, + EMLINK = libc::EMLINK, + EPIPE = libc::EPIPE, + EDOM = libc::EDOM, + ERANGE = libc::ERANGE, + EDEADLK = libc::EDEADLK, + ENAMETOOLONG = libc::ENAMETOOLONG, + ENOLCK = libc::ENOLCK, + ENOSYS = libc::ENOSYS, + ENOTEMPTY = libc::ENOTEMPTY, + ELOOP = libc::ELOOP, + ENOMSG = libc::ENOMSG, + EIDRM = libc::EIDRM, + EINPROGRESS = libc::EINPROGRESS, + EALREADY = libc::EALREADY, + ENOTSOCK = libc::ENOTSOCK, + EDESTADDRREQ = libc::EDESTADDRREQ, + EMSGSIZE = libc::EMSGSIZE, + EPROTOTYPE = libc::EPROTOTYPE, + ENOPROTOOPT = libc::ENOPROTOOPT, + EPROTONOSUPPORT = libc::EPROTONOSUPPORT, + ESOCKTNOSUPPORT = libc::ESOCKTNOSUPPORT, + EPFNOSUPPORT = libc::EPFNOSUPPORT, + EAFNOSUPPORT = libc::EAFNOSUPPORT, + EADDRINUSE = libc::EADDRINUSE, + EADDRNOTAVAIL = libc::EADDRNOTAVAIL, + ENETDOWN = libc::ENETDOWN, + ENETUNREACH = libc::ENETUNREACH, + ENETRESET = libc::ENETRESET, + ECONNABORTED = libc::ECONNABORTED, + ECONNRESET = libc::ECONNRESET, + ENOBUFS = libc::ENOBUFS, + EISCONN = libc::EISCONN, + ENOTCONN = libc::ENOTCONN, + ESHUTDOWN = libc::ESHUTDOWN, + ETOOMANYREFS = libc::ETOOMANYREFS, + ETIMEDOUT = libc::ETIMEDOUT, + ECONNREFUSED = libc::ECONNREFUSED, + EHOSTDOWN = libc::EHOSTDOWN, + EHOSTUNREACH = libc::EHOSTUNREACH, + ECHRNG = libc::ECHRNG, + EL2NSYNC = libc::EL2NSYNC, + EL3HLT = libc::EL3HLT, + EL3RST = libc::EL3RST, + ELNRNG = libc::ELNRNG, + EUNATCH = libc::EUNATCH, + ENOCSI = libc::ENOCSI, + EL2HLT = libc::EL2HLT, + ENOLINK = libc::ENOLINK, + EPROTO = libc::EPROTO, + EMULTIHOP = libc::EMULTIHOP, + EBADMSG = libc::EBADMSG, + EOVERFLOW = libc::EOVERFLOW, + EILSEQ = libc::EILSEQ, + ERESTART = libc::ERESTART, + EOWNERDEAD = libc::EOWNERDEAD, + ENOTRECOVERABLE = libc::ENOTRECOVERABLE, + ENOTSUP = libc::ENOTSUP, + EPROCLIM = libc::EPROCLIM, + EUSERS = libc::EUSERS, + EDQUOT = libc::EDQUOT, + ESTALE = libc::ESTALE, + EREMOTE = libc::EREMOTE, + ECANCELED = libc::ECANCELED, + ENODATA = libc::ENODATA, + ENOSR = libc::ENOSR, + ENOSTR = libc::ENOSTR, + ETIME = libc::ETIME, + EOPNOTSUPP = libc::EOPNOTSUPP, + } + + pub const fn from_i32(e: i32) -> Errno { + use self::Errno::*; + + match e { + libc::EPERM => EPERM, + libc::ENOENT => ENOENT, + libc::ESRCH => ESRCH, + libc::EINTR => EINTR, + libc::EIO => EIO, + libc::ENXIO => ENXIO, + libc::E2BIG => E2BIG, + libc::ENOEXEC => ENOEXEC, + libc::EBADF => EBADF, + libc::ECHILD => ECHILD, + libc::EAGAIN => EAGAIN, + libc::ENOMEM => ENOMEM, + libc::EACCES => EACCES, + libc::EFAULT => EFAULT, + libc::ENOTBLK => ENOTBLK, + libc::EBUSY => EBUSY, + libc::EEXIST => EEXIST, + libc::EXDEV => EXDEV, + libc::ENODEV => ENODEV, + libc::ENOTDIR => ENOTDIR, + libc::EISDIR => EISDIR, + libc::EINVAL => EINVAL, + libc::ENFILE => ENFILE, + libc::EMFILE => EMFILE, + libc::ENOTTY => ENOTTY, + libc::ETXTBSY => ETXTBSY, + libc::EFBIG => EFBIG, + libc::ENOSPC => ENOSPC, + libc::ESPIPE => ESPIPE, + libc::EROFS => EROFS, + libc::EMLINK => EMLINK, + libc::EPIPE => EPIPE, + libc::EDOM => EDOM, + libc::ERANGE => ERANGE, + libc::EDEADLK => EDEADLK, + libc::ENAMETOOLONG => ENAMETOOLONG, + libc::ENOLCK => ENOLCK, + libc::ENOSYS => ENOSYS, + libc::ENOTEMPTY => ENOTEMPTY, + libc::ELOOP => ELOOP, + libc::ENOMSG => ENOMSG, + libc::EIDRM => EIDRM, + libc::EINPROGRESS => EINPROGRESS, + libc::EALREADY => EALREADY, + libc::ENOTSOCK => ENOTSOCK, + libc::EDESTADDRREQ => EDESTADDRREQ, + libc::EMSGSIZE => EMSGSIZE, + libc::EPROTOTYPE => EPROTOTYPE, + libc::ENOPROTOOPT => ENOPROTOOPT, + libc::EPROTONOSUPPORT => EPROTONOSUPPORT, + libc::ESOCKTNOSUPPORT => ESOCKTNOSUPPORT, + libc::EPFNOSUPPORT => EPFNOSUPPORT, + libc::EAFNOSUPPORT => EAFNOSUPPORT, + libc::EADDRINUSE => EADDRINUSE, + libc::EADDRNOTAVAIL => EADDRNOTAVAIL, + libc::ENETDOWN => ENETDOWN, + libc::ENETUNREACH => ENETUNREACH, + libc::ENETRESET => ENETRESET, + libc::ECONNABORTED => ECONNABORTED, + libc::ECONNRESET => ECONNRESET, + libc::ENOBUFS => ENOBUFS, + libc::EISCONN => EISCONN, + libc::ENOTCONN => ENOTCONN, + libc::ESHUTDOWN => ESHUTDOWN, + libc::ETOOMANYREFS => ETOOMANYREFS, + libc::ETIMEDOUT => ETIMEDOUT, + libc::ECONNREFUSED => ECONNREFUSED, + libc::EHOSTDOWN => EHOSTDOWN, + libc::EHOSTUNREACH => EHOSTUNREACH, + libc::ECHRNG => ECHRNG, + libc::EL2NSYNC => EL2NSYNC, + libc::EL3HLT => EL3HLT, + libc::EL3RST => EL3RST, + libc::ELNRNG => ELNRNG, + libc::EUNATCH => EUNATCH, + libc::ENOCSI => ENOCSI, + libc::EL2HLT => EL2HLT, + libc::ENOLINK => ENOLINK, + libc::EPROTO => EPROTO, + libc::EMULTIHOP => EMULTIHOP, + libc::EBADMSG => EBADMSG, + libc::EOVERFLOW => EOVERFLOW, + libc::EILSEQ => EILSEQ, + libc::ERESTART => ERESTART, + libc::ENOTRECOVERABLE => ENOTRECOVERABLE, + libc::EOWNERDEAD => EOWNERDEAD, + libc::ENOTSUP => ENOTSUP, + libc::EPROCLIM => EPROCLIM, + libc::EUSERS => EUSERS, + libc::EDQUOT => EDQUOT, + libc::ESTALE => ESTALE, + libc::EREMOTE => EREMOTE, + libc::ECANCELED => ECANCELED, + libc::ENODATA => ENODATA, + libc::ENOSR => ENOSR, + libc::ENOSTR => ENOSTR, + libc::ETIME => ETIME, + libc::EOPNOTSUPP => EOPNOTSUPP, + _ => UnknownErrno, + } + } +} diff --git a/src/fcntl.rs b/src/fcntl.rs index d799ff378e..f7bb698980 100644 --- a/src/fcntl.rs +++ b/src/fcntl.rs @@ -54,7 +54,10 @@ libc_bitflags!( /// Open the file in append-only mode. O_APPEND; /// Generate a signal when input or output becomes possible. - #[cfg(not(any(target_os = "illumos", target_os = "solaris", target_os = "haiku")))] + #[cfg(not(any(target_os = "aix", + target_os = "illumos", + target_os = "solaris", + target_os = "haiku")))] #[cfg_attr(docsrs, doc(cfg(all())))] O_ASYNC; /// Closes the file descriptor once an `execve` call is made. diff --git a/src/features.rs b/src/features.rs index 2f07a8fccd..9e292cbf5d 100644 --- a/src/features.rs +++ b/src/features.rs @@ -113,6 +113,7 @@ mod os { } #[cfg(any( + target_os = "aix", target_os = "macos", target_os = "ios", target_os = "fuchsia", diff --git a/src/pty.rs b/src/pty.rs index 2866c6df48..455828b703 100644 --- a/src/pty.rs +++ b/src/pty.rs @@ -5,13 +5,17 @@ pub use libc::winsize as Winsize; use std::ffi::CStr; use std::io; +#[cfg(not(target_os = "aix"))] use std::mem; use std::os::unix::prelude::*; use crate::errno::Errno; +#[cfg(not(target_os = "aix"))] use crate::sys::termios::Termios; #[cfg(feature = "process")] -use crate::unistd::{ForkResult, Pid}; +use crate::unistd::ForkResult; +#[cfg(all(feature = "process", not(target_os = "aix")))] +use crate::unistd::Pid; use crate::{fcntl, unistd, Result}; /// Representation of a master/slave pty pair @@ -224,6 +228,7 @@ pub fn unlockpt(fd: &PtyMaster) -> Result<()> { /// the values in `winsize`. If `termios` is not `None`, the pseudoterminal's /// terminal settings of the slave will be set to the values in `termios`. #[inline] +#[cfg(not(target_os = "aix"))] pub fn openpty< 'a, 'b, @@ -315,6 +320,7 @@ feature! { /// special care must be taken to only invoke code you can control and audit. /// /// [async-signal-safe]: https://man7.org/linux/man-pages/man7/signal-safety.7.html +#[cfg(not(target_os = "aix"))] pub unsafe fn forkpty<'a, 'b, T: Into>, U: Into>>( winsize: T, termios: U, diff --git a/src/sys/mman.rs b/src/sys/mman.rs index e689e06e04..8cfd6d6d54 100644 --- a/src/sys/mman.rs +++ b/src/sys/mman.rs @@ -82,7 +82,7 @@ libc_bitflags! { /// Do not reserve swap space for this mapping. /// /// This was removed in FreeBSD 11 and is unused in DragonFlyBSD. - #[cfg(not(any(target_os = "dragonfly", target_os = "freebsd")))] + #[cfg(not(any(target_os = "dragonfly", target_os = "freebsd", target_os = "aix")))] #[cfg_attr(docsrs, doc(cfg(all())))] MAP_NORESERVE; /// Populate page tables for a mapping. @@ -282,6 +282,8 @@ libc_enum! { #[cfg_attr(docsrs, doc(cfg(all())))] MADV_DODUMP, /// Specify that the application no longer needs the pages in the given range. + #[cfg(not(target_os = "aix"))] + #[cfg_attr(docsrs, doc(cfg(all())))] MADV_FREE, /// Request that the system not flush the current range to disk unless it needs to. #[cfg(any(target_os = "dragonfly", target_os = "freebsd"))] diff --git a/src/sys/resource.rs b/src/sys/resource.rs index 8927737763..f42d32e3ca 100644 --- a/src/sys/resource.rs +++ b/src/sys/resource.rs @@ -20,6 +20,7 @@ cfg_if! { target_os = "ios", target_os = "android", target_os = "dragonfly", + target_os = "aix", all(target_os = "linux", not(target_env = "gnu")) ))]{ use libc::rlimit; @@ -51,6 +52,7 @@ libc_enum! { target_os = "ios", target_os = "android", target_os = "dragonfly", + target_os = "aix", all(target_os = "linux", not(any(target_env = "gnu", target_env = "uclibc"))) ), repr(i32))] #[non_exhaustive] @@ -115,6 +117,7 @@ libc_enum! { target_os = "netbsd", target_os = "openbsd", target_os = "linux", + target_os = "aix", ))] #[cfg_attr(docsrs, doc(cfg(all())))] /// The maximum number of simultaneous processes for this user id. @@ -131,6 +134,7 @@ libc_enum! { target_os = "netbsd", target_os = "openbsd", target_os = "linux", + target_os = "aix", ))] #[cfg_attr(docsrs, doc(cfg(all())))] /// When there is memory pressure and swap is available, prioritize diff --git a/src/sys/signal.rs b/src/sys/signal.rs index efa35ebfd2..60f835c5f8 100644 --- a/src/sys/signal.rs +++ b/src/sys/signal.rs @@ -93,7 +93,8 @@ libc_enum! { #[cfg_attr(docsrs, doc(cfg(all())))] SIGIO, #[cfg(any(target_os = "android", target_os = "emscripten", - target_os = "fuchsia", target_os = "linux"))] + target_os = "fuchsia", target_os = "linux", + target_os = "aix"))] #[cfg_attr(docsrs, doc(cfg(all())))] /// Power failure imminent. SIGPWR, @@ -107,7 +108,8 @@ libc_enum! { SIGEMT, #[cfg(not(any(target_os = "android", target_os = "emscripten", target_os = "fuchsia", target_os = "linux", - target_os = "redox", target_os = "haiku")))] + target_os = "redox", target_os = "haiku", + target_os = "aix")))] #[cfg_attr(docsrs, doc(cfg(all())))] /// Information request SIGINFO, @@ -186,6 +188,7 @@ impl FromStr for Signal { target_os = "fuchsia", target_os = "linux", target_os = "redox", + target_os = "aix", target_os = "haiku" )))] "SIGINFO" => Signal::SIGINFO, @@ -250,6 +253,7 @@ impl Signal { target_os = "android", target_os = "emscripten", target_os = "fuchsia", + target_os = "aix", target_os = "linux" ))] Signal::SIGPWR => "SIGPWR", @@ -269,6 +273,7 @@ impl Signal { target_os = "fuchsia", target_os = "linux", target_os = "redox", + target_os = "aix", target_os = "haiku" )))] Signal::SIGINFO => "SIGINFO", @@ -345,11 +350,20 @@ const SIGNALS: [Signal; 30] = [ SIGSTOP, SIGTSTP, SIGTTIN, SIGTTOU, SIGURG, SIGXCPU, SIGXFSZ, SIGVTALRM, SIGPROF, SIGWINCH, SIGIO, SIGPWR, SIGSYS, ]; +#[cfg(target_os = "aix")] +#[cfg(feature = "signal")] +const SIGNALS: [Signal; 30] = [ + SIGHUP, SIGINT, SIGQUIT, SIGILL, SIGABRT, SIGEMT, SIGFPE, SIGKILL, SIGSEGV, + SIGSYS, SIGPIPE, SIGALRM, SIGTERM, SIGUSR1, SIGUSR2, SIGPWR, SIGWINCH, + SIGURG, SIGPOLL, SIGIO, SIGSTOP, SIGTSTP, SIGCONT, SIGTTIN, SIGTTOU, + SIGVTALRM, SIGPROF, SIGXCPU, SIGXFSZ, SIGTRAP, +]; #[cfg(not(any( target_os = "linux", target_os = "android", target_os = "fuchsia", target_os = "emscripten", + target_os = "aix", target_os = "redox", target_os = "haiku" )))] @@ -669,6 +683,7 @@ impl SigAction { /// is the `SigAction` variant). `mask` specifies other signals to block during execution of /// the signal-catching function. pub fn new(handler: SigHandler, flags: SaFlags, mask: SigSet) -> SigAction { + #[cfg(not(target_os = "aix"))] unsafe fn install_sig(p: *mut libc::sigaction, handler: SigHandler) { (*p).sa_sigaction = match handler { SigHandler::SigDfl => libc::SIG_DFL, @@ -679,6 +694,16 @@ impl SigAction { }; } + #[cfg(target_os = "aix")] + unsafe fn install_sig(p: *mut libc::sigaction, handler: SigHandler) { + (*p).sa_union.__su_sigaction = match handler { + SigHandler::SigDfl => mem::transmute::(libc::SIG_DFL), + SigHandler::SigIgn => mem::transmute::(libc::SIG_IGN), + SigHandler::Handler(f) => mem::transmute::(f), + SigHandler::SigAction(f) => f, + }; + } + let mut s = mem::MaybeUninit::::uninit(); unsafe { let p = s.as_mut_ptr(); @@ -706,6 +731,7 @@ impl SigAction { } /// Returns the action's handler. + #[cfg(not(target_os = "aix"))] pub fn handler(&self) -> SigHandler { match self.sigaction.sa_sigaction { libc::SIG_DFL => SigHandler::SigDfl, @@ -738,6 +764,26 @@ impl SigAction { as extern fn(libc::c_int)), } } + + /// Returns the action's handler. + #[cfg(target_os = "aix")] + pub fn handler(&self) -> SigHandler { + unsafe { + match self.sigaction.sa_union.__su_sigaction as usize { + libc::SIG_DFL => SigHandler::SigDfl, + libc::SIG_IGN => SigHandler::SigIgn, + p if self.flags().contains(SaFlags::SA_SIGINFO) => + SigHandler::SigAction( + *(&p as *const usize + as *const extern fn(_, _, _)) + as extern fn(_, _, _)), + p => SigHandler::Handler( + *(&p as *const usize + as *const extern fn(libc::c_int)) + as extern fn(libc::c_int)), + } + } + } } /// Changes the action taken by a process on receipt of a specific signal. diff --git a/src/sys/socket/addr.rs b/src/sys/socket/addr.rs index 1d86e756f9..a7a45ff543 100644 --- a/src/sys/socket/addr.rs +++ b/src/sys/socket/addr.rs @@ -9,7 +9,8 @@ target_os = "netbsd", target_os = "openbsd", target_os = "haiku", - target_os = "fuchsia" + target_os = "fuchsia", + target_os = "aix", ))] #[cfg(feature = "net")] pub use self::datalink::LinkAddr; @@ -99,7 +100,8 @@ pub enum AddressFamily { #[cfg_attr(docsrs, doc(cfg(all())))] Ax25 = libc::AF_AX25, /// IPX - Novell protocols - #[cfg(not(target_os = "redox"))] + #[cfg(not(any(target_os = "aix", target_os = "redox")))] + #[cfg_attr(docsrs, doc(cfg(all())))] Ipx = libc::AF_IPX, /// AppleTalk #[cfg(not(target_os = "redox"))] @@ -200,6 +202,7 @@ pub enum AddressFamily { Tipc = libc::AF_TIPC, /// Bluetooth low-level socket protocol #[cfg(not(any( + target_os = "aix", target_os = "illumos", target_os = "ios", target_os = "macos", @@ -219,6 +222,7 @@ pub enum AddressFamily { RxRpc = libc::AF_RXRPC, /// New "modular ISDN" driver interface protocol #[cfg(not(any( + target_os = "aix", target_os = "illumos", target_os = "solaris", target_os = "haiku", @@ -1014,6 +1018,7 @@ impl SockaddrIn { target_os = "ios", target_os = "macos", target_os = "netbsd", + target_os = "aix", target_os = "haiku", target_os = "openbsd" ))] @@ -2153,6 +2158,7 @@ mod datalink { target_os = "illumos", target_os = "netbsd", target_os = "haiku", + target_os = "aix", target_os = "openbsd" ))] #[cfg_attr(docsrs, doc(cfg(all())))] @@ -2524,6 +2530,7 @@ mod tests { #[test] fn size() { #[cfg(any( + target_os = "aix", target_os = "dragonfly", target_os = "freebsd", target_os = "ios", diff --git a/src/sys/socket/mod.rs b/src/sys/socket/mod.rs index c304f6e3c2..3103502168 100644 --- a/src/sys/socket/mod.rs +++ b/src/sys/socket/mod.rs @@ -322,6 +322,8 @@ libc_bitflags! { /// which will affect all threads in /// the calling process and as well as other processes that hold /// file descriptors referring to the same open file description. + #[cfg(not(target_os = "aix"))] + #[cfg_attr(docsrs, doc(cfg(all())))] MSG_DONTWAIT; /// Receive flags: Control Data was discarded (buffer too small) MSG_CTRUNC; @@ -887,7 +889,7 @@ impl ControlMessageOwned { let cred: libc::cmsgcred = ptr::read_unaligned(p as *const _); ControlMessageOwned::ScmCreds(cred.into()) } - #[cfg(not(target_os = "haiku"))] + #[cfg(not(any(target_os = "aix", target_os = "haiku")))] (libc::SOL_SOCKET, libc::SCM_TIMESTAMP) => { let tv: libc::timeval = ptr::read_unaligned(p as *const _); ControlMessageOwned::ScmTimestamp(TimeVal::from(tv)) diff --git a/src/sys/socket/sockopt.rs b/src/sys/socket/sockopt.rs index 0d675ffb01..5d28185cb8 100644 --- a/src/sys/socket/sockopt.rs +++ b/src/sys/socket/sockopt.rs @@ -693,7 +693,7 @@ sockopt_impl!( libc::SO_TIMESTAMPING, super::TimestampingFlag ); -#[cfg(not(any(target_os = "haiku", target_os = "redox")))] +#[cfg(not(any(target_os = "aix", target_os = "haiku", target_os = "redox")))] sockopt_impl!( /// Enable or disable the receiving of the `SO_TIMESTAMP` control message. ReceiveTimestamp, diff --git a/src/sys/termios.rs b/src/sys/termios.rs index af29d64dfa..ecaa3eaf8f 100644 --- a/src/sys/termios.rs +++ b/src/sys/termios.rs @@ -397,6 +397,8 @@ libc_enum! { #[cfg_attr(docsrs, doc(cfg(all())))] B28800, B38400, + #[cfg(not(target_os = "aix"))] + #[cfg_attr(docsrs, doc(cfg(all())))] B57600, #[cfg(any(target_os = "dragonfly", target_os = "freebsd", @@ -405,10 +407,14 @@ libc_enum! { target_os = "openbsd"))] #[cfg_attr(docsrs, doc(cfg(all())))] B76800, + #[cfg(not(target_os = "aix"))] + #[cfg_attr(docsrs, doc(cfg(all())))] B115200, #[cfg(any(target_os = "illumos", target_os = "solaris"))] #[cfg_attr(docsrs, doc(cfg(all())))] B153600, + #[cfg(not(target_os = "aix"))] + #[cfg_attr(docsrs, doc(cfg(all())))] B230400, #[cfg(any(target_os = "illumos", target_os = "solaris"))] #[cfg_attr(docsrs, doc(cfg(all())))] @@ -542,6 +548,8 @@ libc_enum! { #[repr(usize)] #[non_exhaustive] pub enum SpecialCharacterIndices { + #[cfg(not(target_os = "aix"))] + #[cfg_attr(docsrs, doc(cfg(all())))] VDISCARD, #[cfg(any(target_os = "dragonfly", target_os = "freebsd", @@ -549,6 +557,7 @@ libc_enum! { target_os = "macos", target_os = "netbsd", target_os = "openbsd", + target_os = "aix", target_os = "solaris"))] #[cfg_attr(docsrs, doc(cfg(all())))] VDSUSP, @@ -566,7 +575,7 @@ libc_enum! { VKILL, VLNEXT, #[cfg(not(any(all(target_os = "linux", target_arch = "sparc64"), - target_os = "illumos", target_os = "solaris")))] + target_os = "illumos", target_os = "solaris", target_os = "aix")))] #[cfg_attr(docsrs, doc(cfg(all())))] VMIN, VQUIT, @@ -590,9 +599,11 @@ libc_enum! { #[cfg_attr(docsrs, doc(cfg(all())))] VSWTCH, #[cfg(not(any(all(target_os = "linux", target_arch = "sparc64"), - target_os = "illumos", target_os = "solaris")))] + target_os = "illumos", target_os = "solaris", target_os = "aix")))] #[cfg_attr(docsrs, doc(cfg(all())))] VTIME, + #[cfg(not(target_os = "aix"))] + #[cfg_attr(docsrs, doc(cfg(all())))] VWERASE, #[cfg(target_os = "dragonfly")] #[cfg_attr(docsrs, doc(cfg(all())))] @@ -603,7 +614,8 @@ libc_enum! { #[cfg(any( all(target_os = "linux", target_arch = "sparc64"), target_os = "illumos", - target_os = "solaris" + target_os = "solaris", + target_os = "aix", ))] impl SpecialCharacterIndices { pub const VMIN: SpecialCharacterIndices = SpecialCharacterIndices::VEOF; @@ -616,6 +628,7 @@ pub use libc::NCCS; target_os = "dragonfly", target_os = "freebsd", target_os = "linux", + target_os = "aix", target_os = "macos", target_os = "netbsd", target_os = "openbsd" @@ -881,7 +894,7 @@ libc_bitflags! { PARODD; HUPCL; CLOCAL; - #[cfg(not(target_os = "redox"))] + #[cfg(not(any(target_os = "redox", target_os = "aix")))] #[cfg_attr(docsrs, doc(cfg(all())))] CRTSCTS; #[cfg(any(target_os = "android", target_os = "linux"))] @@ -967,7 +980,7 @@ libc_bitflags! { #[cfg_attr(docsrs, doc(cfg(all())))] ALTWERASE; IEXTEN; - #[cfg(not(any(target_os = "redox", target_os = "haiku")))] + #[cfg(not(any(target_os = "redox", target_os = "haiku", target_os = "aix")))] #[cfg_attr(docsrs, doc(cfg(all())))] EXTPROC; TOSTOP; diff --git a/src/unistd.rs b/src/unistd.rs index afa80e9b9d..bb9f1c1f67 100644 --- a/src/unistd.rs +++ b/src/unistd.rs @@ -1025,6 +1025,7 @@ pub fn sethostname>(name: S) -> Result<()> { target_os = "illumos", target_os = "ios", target_os = "macos", + target_os = "aix", target_os = "solaris", ))] { type sethostname_len_t = c_int; } else { @@ -1646,7 +1647,8 @@ pub fn getgroups() -> Result> { )))] pub fn setgroups(groups: &[Gid]) -> Result<()> { cfg_if! { - if #[cfg(any(target_os = "dragonfly", + if #[cfg(any(target_os = "aix", + target_os = "dragonfly", target_os = "freebsd", target_os = "illumos", target_os = "ios", @@ -1693,6 +1695,7 @@ pub fn setgroups(groups: &[Gid]) -> Result<()> { /// partial list of groups when `NGROUPS_MAX` is exceeded, this implementation /// will only ever return the complete list or else an error. #[cfg(not(any( + target_os = "aix", target_os = "illumos", target_os = "ios", target_os = "macos", @@ -3457,6 +3460,7 @@ pub struct User { pub shell: PathBuf, /// Login class #[cfg(not(any( + target_os = "aix", target_os = "android", target_os = "fuchsia", target_os = "haiku", @@ -3468,6 +3472,7 @@ pub struct User { pub class: CString, /// Last password change #[cfg(not(any( + target_os = "aix", target_os = "android", target_os = "fuchsia", target_os = "haiku", @@ -3479,6 +3484,7 @@ pub struct User { pub change: libc::time_t, /// Expiration time of account #[cfg(not(any( + target_os = "aix", target_os = "android", target_os = "fuchsia", target_os = "haiku", @@ -3533,6 +3539,7 @@ impl From<&libc::passwd> for User { uid: Uid::from_raw(pw.pw_uid), gid: Gid::from_raw(pw.pw_gid), #[cfg(not(any( + target_os = "aix", target_os = "android", target_os = "fuchsia", target_os = "haiku", @@ -3543,6 +3550,7 @@ impl From<&libc::passwd> for User { class: CString::new(CStr::from_ptr(pw.pw_class).to_bytes()) .unwrap(), #[cfg(not(any( + target_os = "aix", target_os = "android", target_os = "fuchsia", target_os = "haiku", @@ -3552,6 +3560,7 @@ impl From<&libc::passwd> for User { )))] change: pw.pw_change, #[cfg(not(any( + target_os = "aix", target_os = "android", target_os = "fuchsia", target_os = "haiku", @@ -3593,6 +3602,7 @@ impl From for libc::passwd { pw_uid: u.uid.0, pw_gid: u.gid.0, #[cfg(not(any( + target_os = "aix", target_os = "android", target_os = "fuchsia", target_os = "haiku", @@ -3602,6 +3612,7 @@ impl From for libc::passwd { )))] pw_class: u.class.into_raw(), #[cfg(not(any( + target_os = "aix", target_os = "android", target_os = "fuchsia", target_os = "haiku", @@ -3611,6 +3622,7 @@ impl From for libc::passwd { )))] pw_change: u.change, #[cfg(not(any( + target_os = "aix", target_os = "android", target_os = "fuchsia", target_os = "haiku",