From 2235bf4619d3d93b20e801c082912e1239703077 Mon Sep 17 00:00:00 2001 From: Jessica Hamilton Date: Tue, 26 Sep 2017 03:57:25 +0000 Subject: [PATCH] haiku: add platform support. --- src/errno.rs | 213 +++++++++++++++++++++++++++++++++++--- src/fcntl.rs | 7 +- src/features.rs | 2 +- src/sys/ioctl/mod.rs | 3 +- src/sys/mman.rs | 5 +- src/sys/signal.rs | 45 +++++++- src/sys/socket/addr.rs | 6 +- src/sys/socket/mod.rs | 5 + src/sys/socket/sockopt.rs | 5 +- src/sys/termios.rs | 8 ++ src/unistd.rs | 76 +++++++++++--- 11 files changed, 331 insertions(+), 44 deletions(-) diff --git a/src/errno.rs b/src/errno.rs index 9102d7b17b..3bad6729c4 100644 --- a/src/errno.rs +++ b/src/errno.rs @@ -47,6 +47,12 @@ unsafe fn errno_location() -> *mut c_int { __errno() } +#[cfg(target_os = "haiku")] +unsafe fn errno_location() -> *mut c_int { + extern { fn _errnop() -> *mut c_int; } + _errnop() +} + /// Sets the platform-specific errno to no-error unsafe fn clear() -> () { *errno_location() = 0; @@ -144,6 +150,7 @@ fn desc(errno: Errno) -> &'static str { ENOMEM => "Out of memory", EACCES => "Permission denied", EFAULT => "Bad address", + #[cfg(not(target_os = "haiku"))] ENOTBLK => "Block device required", EBUSY => "Device or resource busy", EEXIST => "File exists", @@ -180,6 +187,7 @@ fn desc(errno: Errno) -> &'static str { EPROTOTYPE => "Protocol wrong type for socket", ENOPROTOOPT => "Protocol not available", EPROTONOSUPPORT => "Protocol not supported", + #[cfg(not(target_os = "haiku"))] ESOCKTNOSUPPORT => "Socket type not supported", EPFNOSUPPORT => "Protocol family not supported", EAFNOSUPPORT => "Address family not supported by protocol", @@ -194,6 +202,7 @@ fn desc(errno: Errno) -> &'static str { EISCONN => "Transport endpoint is already connected", ENOTCONN => "Transport endpoint is not connected", ESHUTDOWN => "Cannot send after transport endpoint shutdown", + #[cfg(not(target_os = "haiku"))] ETOOMANYREFS => "Too many references: cannot splice", ETIMEDOUT => "Connection timed out", ECONNREFUSED => "Connection refused", @@ -389,10 +398,10 @@ fn desc(errno: Errno) -> &'static str { #[cfg(any(target_os = "freebsd", target_os = "dragonfly"))] EDOOFUS => "Programming error", - #[cfg(any(target_os = "freebsd", target_os = "dragonfly"))] + #[cfg(any(target_os = "freebsd", target_os = "dragonfly", target_os = "haiku"))] EMULTIHOP => "Multihop attempted", - #[cfg(any(target_os = "freebsd", target_os = "dragonfly"))] + #[cfg(any(target_os = "freebsd", target_os = "dragonfly", target_os = "haiku"))] ENOLINK => "Link has been severed", #[cfg(target_os = "freebsd")] @@ -404,19 +413,19 @@ fn desc(errno: Errno) -> &'static str { #[cfg(any(target_os = "macos", target_os = "freebsd", target_os = "dragonfly", target_os = "ios", target_os = "openbsd", target_os = "netbsd"))] ENEEDAUTH => "Need authenticator", - #[cfg(any(target_os = "macos", target_os = "freebsd", target_os = "dragonfly", target_os = "ios", target_os = "openbsd", target_os = "netbsd"))] + #[cfg(any(target_os = "macos", target_os = "freebsd", target_os = "dragonfly", target_os = "ios", target_os = "openbsd", target_os = "netbsd", target_os = "haiku"))] EOVERFLOW => "Value too large to be stored in data type", - #[cfg(any(target_os = "macos", target_os = "freebsd", target_os = "dragonfly", target_os = "ios", target_os = "netbsd"))] + #[cfg(any(target_os = "macos", target_os = "freebsd", target_os = "dragonfly", target_os = "ios", target_os = "netbsd", target_os = "haiku"))] EILSEQ => "Illegal byte sequence", - #[cfg(any(target_os = "macos", target_os = "freebsd", target_os = "dragonfly", target_os = "ios", target_os = "openbsd", target_os = "netbsd"))] + #[cfg(any(target_os = "macos", target_os = "freebsd", target_os = "dragonfly", target_os = "ios", target_os = "openbsd", target_os = "netbsd", target_os = "haiku"))] ENOATTR => "Attribute not found", - #[cfg(any(target_os = "macos", target_os = "freebsd", target_os = "dragonfly", target_os = "ios", target_os = "netbsd"))] + #[cfg(any(target_os = "macos", target_os = "freebsd", target_os = "dragonfly", target_os = "ios", target_os = "netbsd", target_os = "haiku"))] EBADMSG => "Bad message", - #[cfg(any(target_os = "macos", target_os = "freebsd", target_os = "dragonfly", target_os = "ios", target_os = "netbsd"))] + #[cfg(any(target_os = "macos", target_os = "freebsd", target_os = "dragonfly", target_os = "ios", target_os = "netbsd", target_os = "haiku"))] EPROTO => "Protocol error", #[cfg(any(target_os = "macos", target_os = "freebsd", target_os = "ios"))] @@ -425,7 +434,7 @@ fn desc(errno: Errno) -> &'static str { #[cfg(any(target_os = "macos", target_os = "freebsd", target_os = "ios"))] EOWNERDEAD => "Previous owner died", - #[cfg(any(target_os = "macos", target_os = "freebsd", target_os = "dragonfly", target_os = "ios", target_os = "openbsd", target_os = "netbsd"))] + #[cfg(any(target_os = "macos", target_os = "freebsd", target_os = "dragonfly", target_os = "ios", target_os = "openbsd", target_os = "netbsd", target_os = "haiku"))] ENOTSUP => "Operation not supported", #[cfg(any(target_os = "macos", target_os = "freebsd", target_os = "dragonfly", target_os = "ios", target_os = "openbsd", target_os = "netbsd"))] @@ -434,10 +443,10 @@ fn desc(errno: Errno) -> &'static str { #[cfg(any(target_os = "macos", target_os = "freebsd", target_os = "dragonfly", target_os = "ios", target_os = "openbsd", target_os = "netbsd"))] EUSERS => "Too many users", - #[cfg(any(target_os = "macos", target_os = "freebsd", target_os = "dragonfly", target_os = "ios", target_os = "openbsd", target_os = "netbsd"))] + #[cfg(any(target_os = "macos", target_os = "freebsd", target_os = "dragonfly", target_os = "ios", target_os = "openbsd", target_os = "netbsd", target_os = "haiku"))] EDQUOT => "Disc quota exceeded", - #[cfg(any(target_os = "macos", target_os = "freebsd", target_os = "dragonfly", target_os = "ios", target_os = "openbsd", target_os = "netbsd"))] + #[cfg(any(target_os = "macos", target_os = "freebsd", target_os = "dragonfly", target_os = "ios", target_os = "openbsd", target_os = "netbsd", target_os = "haiku"))] ESTALE => "Stale NFS file handle", #[cfg(any(target_os = "macos", target_os = "freebsd", target_os = "dragonfly", target_os = "ios", target_os = "openbsd", target_os = "netbsd"))] @@ -464,7 +473,7 @@ fn desc(errno: Errno) -> &'static str { #[cfg(any(target_os = "macos", target_os = "freebsd", target_os = "dragonfly", target_os = "ios", target_os = "openbsd", target_os = "netbsd"))] EAUTH => "Authentication error", - #[cfg(any(target_os = "macos", target_os = "freebsd", target_os = "dragonfly", target_os = "ios", target_os = "openbsd", target_os = "netbsd"))] + #[cfg(any(target_os = "macos", target_os = "freebsd", target_os = "dragonfly", target_os = "ios", target_os = "openbsd", target_os = "netbsd", target_os = "haiku"))] ECANCELED => "Operation canceled", #[cfg(any(target_os = "macos", target_os = "ios"))] @@ -488,19 +497,19 @@ fn desc(errno: Errno) -> &'static str { #[cfg(any(target_os = "macos", target_os = "ios", target_os = "netbsd"))] EMULTIHOP => "Reserved", - #[cfg(any(target_os = "macos", target_os = "ios", target_os = "netbsd"))] + #[cfg(any(target_os = "macos", target_os = "ios", target_os = "netbsd", target_os = "haiku"))] ENODATA => "No message available on STREAM", #[cfg(any(target_os = "macos", target_os = "ios", target_os = "netbsd"))] ENOLINK => "Reserved", - #[cfg(any(target_os = "macos", target_os = "ios", target_os = "netbsd"))] + #[cfg(any(target_os = "macos", target_os = "ios", target_os = "netbsd", target_os = "haiku"))] ENOSR => "No STREAM resources", - #[cfg(any(target_os = "macos", target_os = "ios", target_os = "netbsd"))] + #[cfg(any(target_os = "macos", target_os = "ios", target_os = "netbsd", target_os = "haiku"))] ENOSTR => "Not a STREAM", - #[cfg(any(target_os = "macos", target_os = "ios", target_os = "netbsd"))] + #[cfg(any(target_os = "macos", target_os = "ios", target_os = "netbsd", target_os = "haiku"))] ETIME => "STREAM ioctl timeout", #[cfg(any(target_os = "macos", target_os = "ios"))] @@ -512,7 +521,7 @@ fn desc(errno: Errno) -> &'static str { #[cfg(any(target_os = "macos", target_os = "ios"))] EQFULL => "Interface output queue is full", - #[cfg(target_os = "openbsd")] + #[cfg(any(target_os = "openbsd", target_os = "haiku"))] EOPNOTSUPP => "Operation not supported", #[cfg(target_os = "openbsd")] @@ -523,6 +532,12 @@ fn desc(errno: Errno) -> &'static str { #[cfg(target_os = "dragonfly")] EASYNC => "Async", + + #[cfg(target_os = "haiku")] + EFPOS => "File position error", + + #[cfg(target_os = "haiku")] + ESIGPARM => "Signal error", } } @@ -1910,6 +1925,172 @@ mod consts { } } +#[cfg(target_os = "haiku")] +mod consts { + #[derive(Copy, Debug, Clone, PartialEq)] + pub enum Errno { + UnknownErrno = 0, + E2BIG = -2147454975, + ECHILD = -2147454974, + EDEADLK = -2147454973, + EFBIG = -2147454972, + EMLINK = -2147454971, + ENFILE = -2147454970, + ENODEV = -2147454969, + ENOLCK = -2147454968, + ENOSYS = -2147454967, + ENOTTY = -2147454966, + ENXIO = -2147454965, + ESPIPE = -2147454964, + ESRCH = -2147454963, + EFPOS = -2147457962, + ESIGPARM = -2147457961, + EDOM = -2147454960, + ERANGE = -2147454959, + EPROTOTYPE = -2147454958, + EPROTONOSUPPORT = -2147454957, + EPFNOSUPPORT = -2147454956, + EAFNOSUPPORT = -2147454955, + EADDRINUSE = -2147454954, + EADDRNOTAVAIL = -2147454953, + ENETDOWN = -2147454952, + ENETUNREACH = -2147454951, + ENETRESET = -2147454950, + ECONNABORTED = -2147454949, + ECONNRESET = -2147454948, + EISCONN = -2147454947, + ENOTCONN = -2147454946, + ESHUTDOWN = -2147454945, + ECONNREFUSED = -2147454944, + EHOSTUNREACH = -2147454943, + ENOPROTOOPT = -2147454942, + ENOBUFS = -2147454941, + EINPROGRESS = -2147454940, + EALREADY = -2147454939, + EILSEQ = -2147454938, + ENOMSG = -2147454937, + ESTALE = -2147454936, + EOVERFLOW = -2147454935, + EMSGSIZE = -2147454934, + EOPNOTSUPP = -2147454933, + ENOTSOCK = -2147454932, + EHOSTDOWN = -2147454931, + EBADMSG = -2147454930, + ECANCELED = -2147454929, + EDESTADDRREQ = -2147454928, + EDQUOT = -2147454927, + EIDRM = -2147454926, + EMULTIHOP = -2147454925, + ENODATA = -2147454924, + ENOLINK = -2147454923, + ENOSR = -2147454922, + ENOSTR = -2147454921, + ENOTSUP = -2147454920, + EPROTO = -2147454919, + ETIME = -2147454918, + ETXTBSY = -2147454917, + ENOATTR = -2147454916, + ENOMEM = -2147454976, + EACCES = -2147483646, + EINTR = -2147483638, + EIO = -2147483647, + EBUSY = -2147483634, + EFAULT = -2147478783, + ETIMEDOUT = -2147483639, + EAGAIN = -2147483637, + EBADF = -2147459072, + EEXIST = -2147459070, + EINVAL = -2147483643, + ENAMETOOLONG = -2147459068, + ENOENT = -2147459069, + EPERM = -2147483633, + ENOTDIR = -2147459067, + EISDIR = -2147459063, + ENOTEMPTY = -2147459066, + ENOSPC = -2147459065, + EROFS = -2147459064, + EMFILE = -2147459062, + EXDEV = -2147459061, + ELOOP = -2147459060, + ENOEXEC = -2147478782, + EPIPE = -2147459059, + } + + pub const ELAST: Errno = Errno::ENOTSUP; + pub const EWOULDBLOCK: Errno = Errno::EAGAIN; + + pub const EL2NSYC: Errno = Errno::UnknownErrno; + + pub fn from_i32(e: i32) -> Errno { + use self::Errno::*; + + match e { + 0 => UnknownErrno, + -2147454975 => E2BIG, + -2147454974 => ECHILD, + -2147454973 => EDEADLK, + -2147454972 => EFBIG, + -2147454971 => EMLINK, + -2147454970 => ENFILE, + -2147454969 => ENODEV, + -2147454968 => ENOLCK, + -2147454967 => ENOSYS, + -2147454966 => ENOTTY, + -2147454965 => ENXIO, + -2147454964 => ESPIPE, + -2147454963 => ESRCH, + -2147457962 => EFPOS, + -2147457961 => ESIGPARM, + -2147454960 => EDOM, + -2147454959 => ERANGE, + -2147454958 => EPROTOTYPE, + -2147454957 => EPROTONOSUPPORT, + -2147454956 => EPFNOSUPPORT, + -2147454955 => EAFNOSUPPORT, + -2147454954 => EADDRINUSE, + -2147454953 => EADDRNOTAVAIL, + -2147454952 => ENETDOWN, + -2147454951 => ENETUNREACH, + -2147454950 => ENETRESET, + -2147454949 => ECONNABORTED, + -2147454948 => ECONNRESET, + -2147454947 => EISCONN, + -2147454946 => ENOTCONN, + -2147454945 => ESHUTDOWN, + -2147454944 => ECONNREFUSED, + -2147454943 => EHOSTUNREACH, + -2147454942 => ENOPROTOOPT, + -2147454941 => ENOBUFS, + -2147454940 => EINPROGRESS, + -2147454939 => EALREADY, + -2147454938 => EILSEQ, + -2147454937 => ENOMSG, + -2147454936 => ESTALE, + -2147454935 => EOVERFLOW, + -2147454934 => EMSGSIZE, + -2147454933 => EOPNOTSUPP, + -2147454932 => ENOTSOCK, + -2147454931 => EHOSTDOWN, + -2147454930 => EBADMSG, + -2147454929 => ECANCELED, + -2147454928 => EDESTADDRREQ, + -2147454927 => EDQUOT, + -2147454926 => EIDRM, + -2147454925 => EMULTIHOP, + -2147454924 => ENODATA, + -2147454923 => ENOLINK, + -2147454922 => ENOSR, + -2147454921 => ENOSTR, + -2147454920 => ENOTSUP, + -2147454919 => EPROTO, + -2147454918 => ETIME, + -2147454917 => ETXTBSY, + -2147454916 => ENOATTR, + -2147454976 => ENOMEM, + _ => UnknownErrno, + } + } +} #[cfg(test)] mod test { diff --git a/src/fcntl.rs b/src/fcntl.rs index 003c316c06..879d1fe0ef 100644 --- a/src/fcntl.rs +++ b/src/fcntl.rs @@ -28,6 +28,7 @@ libc_bitflags!( O_ALT_IO; /// Open the file in append-only mode. O_APPEND; + #[cfg(not(target_os = "haiku"))] /// Generate a signal when input or output becomes possible. O_ASYNC; /// Closes the file descriptor once an `execve` call is made. @@ -52,7 +53,8 @@ libc_bitflags!( target_os = "linux", target_os = "macos", target_os = "netbsd", - target_os = "openbsd"))] + target_os = "openbsd", + target_os = "haiku"))] O_DSYNC; /// Error out if a file was not created. O_EXCL; @@ -84,6 +86,7 @@ libc_bitflags!( O_NOATIME; /// Don't attach the device as the process' controlling terminal. O_NOCTTY; + #[cfg(not(target_os = "haiku"))] /// Same as `O_NONBLOCK`. O_NDELAY; /// `open()` will fail if the given path is a symbolic link. @@ -107,7 +110,7 @@ libc_bitflags!( /// This should not be combined with `O_WRONLY` or `O_RDWR`. O_RDWR; /// Similar to `O_DSYNC` but applies to `read`s instead. - #[cfg(any(target_os = "linux", target_os = "netbsd", target_os = "openbsd"))] + #[cfg(any(target_os = "linux", target_os = "netbsd", target_os = "openbsd", target_os = "haiku"))] O_RSYNC; /// Skip search permission checks. #[cfg(target_os = "netbsd")] diff --git a/src/features.rs b/src/features.rs index 1448fdd013..5e4381e332 100644 --- a/src/features.rs +++ b/src/features.rs @@ -92,7 +92,7 @@ mod os { } } -#[cfg(any(target_os = "macos", target_os = "freebsd", target_os = "dragonfly", target_os = "ios", target_os = "openbsd", target_os = "netbsd"))] +#[cfg(any(target_os = "macos", target_os = "freebsd", target_os = "dragonfly", target_os = "ios", target_os = "openbsd", target_os = "netbsd", target_os = "haiku"))] mod os { pub fn socket_atomic_cloexec() -> bool { false diff --git a/src/sys/ioctl/mod.rs b/src/sys/ioctl/mod.rs index b29c8b422b..2d66311d7b 100644 --- a/src/sys/ioctl/mod.rs +++ b/src/sys/ioctl/mod.rs @@ -235,7 +235,8 @@ mod platform; target_os = "netbsd", target_os = "openbsd", target_os = "freebsd", - target_os = "dragonfly"))] + target_os = "dragonfly", + target_os = "haiku"))] #[path = "platform/bsd.rs"] #[macro_use] mod platform; diff --git a/src/sys/mman.rs b/src/sys/mman.rs index dc21899b71..0cf024491c 100644 --- a/src/sys/mman.rs +++ b/src/sys/mman.rs @@ -38,7 +38,7 @@ libc_bitflags!{ /// Synonym for `MAP_ANONYMOUS`. MAP_ANON; /// The mapping is not backed by any file. - #[cfg(any(target_os = "android", target_os = "linux", target_os = "freebsd"))] + #[cfg(any(target_os = "android", target_os = "linux", target_os = "freebsd", target_os = "haiku"))] MAP_ANONYMOUS; /// Put the mapping into the first 2GB of the process address space. #[cfg(any(all(any(target_os = "android", target_os = "linux"), @@ -61,7 +61,7 @@ libc_bitflags!{ /// Do not reserve swap space for this mapping. /// /// This was removed in FreeBSD 11. - #[cfg(not(target_os = "freebsd"))] + #[cfg(not(any(target_os = "freebsd", target_os = "haiku")))] MAP_NORESERVE; /// Populate page tables for a mapping. #[cfg(any(target_os = "android", target_os = "linux"))] @@ -150,6 +150,7 @@ libc_enum!{ #[cfg(any(target_os = "android", target_os = "linux"))] MADV_DODUMP, /// Specify that the application no longer needs the pages in the given range. + #[cfg(not(target_os = "haiku"))] 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/signal.rs b/src/sys/signal.rs index c53b5f5c36..48a9f2f09e 100644 --- a/src/sys/signal.rs +++ b/src/sys/signal.rs @@ -47,14 +47,19 @@ pub enum Signal { SIGVTALRM = libc::SIGVTALRM, SIGPROF = libc::SIGPROF, SIGWINCH = libc::SIGWINCH, + #[cfg(not(target_os = "haiku"))] SIGIO = libc::SIGIO, #[cfg(any(target_os = "linux", target_os = "android", target_os = "emscripten"))] SIGPWR = libc::SIGPWR, SIGSYS = libc::SIGSYS, - #[cfg(not(any(target_os = "linux", target_os = "android", target_os = "emscripten")))] + #[cfg(not(any(target_os = "linux", target_os = "android", target_os = "emscripten", target_os = "haiku")))] SIGEMT = libc::SIGEMT, - #[cfg(not(any(target_os = "linux", target_os = "android", target_os = "emscripten")))] + #[cfg(not(any(target_os = "linux", target_os = "android", target_os = "emscripten", target_os = "haiku")))] SIGINFO = libc::SIGINFO, + #[cfg(target_os = "haiku")] + SIGKILLTHR = libc::SIGKILLTHR, + #[cfg(target_os = "haiku")] + SIGPOLL = libc::SIGPOLL, } pub use self::Signal::*; @@ -124,7 +129,7 @@ const SIGNALS: [Signal; 30] = [ SIGIO, SIGPWR, SIGSYS]; -#[cfg(not(any(target_os = "linux", target_os = "android", target_os = "emscripten")))] +#[cfg(not(any(target_os = "linux", target_os = "android", target_os = "emscripten", target_os = "haiku")))] const SIGNALS: [Signal; 31] = [ SIGHUP, SIGINT, @@ -158,6 +163,39 @@ const SIGNALS: [Signal; 31] = [ SIGEMT, SIGINFO]; +#[cfg(target_os = "haiku")] +const SIGNALS: [Signal; 30] = [ + SIGHUP, + SIGINT, + SIGQUIT, + SIGILL, + SIGCHLD, + SIGABRT, + SIGPIPE, + SIGFPE, + SIGKILL, + SIGSTOP, + SIGSEGV, + SIGCONT, + SIGTSTP, + SIGALRM, + SIGTERM, + SIGTTIN, + SIGTTOU, + SIGUSR1, + SIGUSR2, + SIGWINCH, + SIGKILLTHR, + SIGTRAP, + SIGPOLL, + SIGPROF, + SIGSYS, + SIGURG, + SIGVTALRM, + SIGXCPU, + SIGXFSZ, + SIGBUS]; + pub const NSIG: libc::c_int = 32; pub struct SignalIterator { @@ -196,6 +234,7 @@ impl Signal { } pub const SIGIOT : Signal = SIGABRT; +#[cfg(not(target_os = "haiku"))] pub const SIGPOLL : Signal = SIGIO; pub const SIGUNUSED : Signal = SIGSYS; diff --git a/src/sys/socket/addr.rs b/src/sys/socket/addr.rs index d57207ed50..6c8d70b36a 100644 --- a/src/sys/socket/addr.rs +++ b/src/sys/socket/addr.rs @@ -51,6 +51,7 @@ pub enum AddressFamily { X25 = libc::AF_X25, #[cfg(any(target_os = "android", target_os = "linux"))] Rose = libc::AF_ROSE, + #[cfg(not(target_os = "haiku"))] Decnet = libc::AF_DECnet, #[cfg(any(target_os = "android", target_os = "linux"))] NetBeui = libc::AF_NETBEUI, @@ -66,6 +67,7 @@ pub enum AddressFamily { AtmSvc = libc::AF_ATMSVC, #[cfg(any(target_os = "android", target_os = "linux"))] Rds = libc::AF_RDS, + #[cfg(not(target_os = "haiku"))] Sna = libc::AF_SNA, #[cfg(any(target_os = "android", target_os = "linux"))] Irda = libc::AF_IRDA, @@ -89,6 +91,7 @@ pub enum AddressFamily { Iucv = libc::AF_IUCV, #[cfg(any(target_os = "android", target_os = "linux"))] RxRpc = libc::AF_RXRPC, + #[cfg(not(target_os = "haiku"))] Isdn = libc::AF_ISDN, #[cfg(any(target_os = "android", target_os = "linux"))] Phonet = libc::AF_PHONET, @@ -176,7 +179,8 @@ pub enum AddressFamily { target_os = "ios", target_os = "macos", target_os = "netbsd", - target_os = "openbsd"))] + target_os = "openbsd", + target_os = "haiku"))] Link = libc::AF_LINK, #[cfg(any(target_os = "dragonfly", target_os = "freebsd", diff --git a/src/sys/socket/mod.rs b/src/sys/socket/mod.rs index baddf34e13..f987b33ea4 100644 --- a/src/sys/socket/mod.rs +++ b/src/sys/socket/mod.rs @@ -68,6 +68,7 @@ pub enum SockType { SeqPacket = libc::SOCK_SEQPACKET, /// Provides raw network protocol access. Raw = libc::SOCK_RAW, + #[cfg(not(target_os = "haiku"))] /// Provides a reliable datagram layer that does not /// guarantee ordering. Rdm = libc::SOCK_RDM, @@ -278,6 +279,7 @@ impl<'a> Iterator for CmsgIterator<'a> { slice::from_raw_parts( &cmsg.cmsg_data as *const _ as *const _, 1))) }, + #[cfg(not(target_os = "haiku"))] (libc::SOL_SOCKET, libc::SCM_TIMESTAMP) => unsafe { Some(ControlMessage::ScmTimestamp( &*(&cmsg.cmsg_data as *const _ as *const _))) @@ -315,6 +317,7 @@ pub enum ControlMessage<'a> { // https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=222039 #[cfg_attr(not(all(target_os = "freebsd", target_arch = "x86")), doc = " ```")] #[cfg_attr(all(target_os = "freebsd", target_arch = "x86"), doc = " ```no_run")] + #[cfg(not(target_os = "haiku"))] /// use nix::sys::socket::*; /// use nix::sys::uio::IoVec; /// use nix::sys::time::*; @@ -396,6 +399,7 @@ impl<'a> ControlMessage<'a> { ControlMessage::ScmRights(fds) => { mem::size_of_val(fds) }, + #[cfg(not(target_os = "haiku"))] ControlMessage::ScmTimestamp(t) => { mem::size_of_val(t) }, @@ -429,6 +433,7 @@ impl<'a> ControlMessage<'a> { copy_bytes(fds, buf); }, + #[cfg(not(target_os = "haiku"))] ControlMessage::ScmTimestamp(t) => { let cmsg = cmsghdr { cmsg_len: self.len() as type_of_cmsg_len, diff --git a/src/sys/socket/sockopt.rs b/src/sys/socket/sockopt.rs index 98a4eeac75..040c1d45b8 100644 --- a/src/sys/socket/sockopt.rs +++ b/src/sys/socket/sockopt.rs @@ -134,9 +134,9 @@ sockopt_impl!(Both, TcpNoDelay, libc::IPPROTO_TCP, libc::TCP_NODELAY, bool); sockopt_impl!(Both, Linger, libc::SOL_SOCKET, libc::SO_LINGER, super::linger); sockopt_impl!(SetOnly, IpAddMembership, libc::IPPROTO_IP, libc::IP_ADD_MEMBERSHIP, super::ip_mreq); sockopt_impl!(SetOnly, IpDropMembership, libc::IPPROTO_IP, libc::IP_DROP_MEMBERSHIP, super::ip_mreq); -#[cfg(not(any(target_os = "dragonfly", target_os = "freebsd", target_os = "ios", target_os = "macos", target_os = "netbsd", target_os = "openbsd")))] +#[cfg(not(any(target_os = "dragonfly", target_os = "freebsd", target_os = "ios", target_os = "macos", target_os = "netbsd", target_os = "openbsd", target_os = "haiku")))] sockopt_impl!(SetOnly, Ipv6AddMembership, libc::IPPROTO_IPV6, libc::IPV6_ADD_MEMBERSHIP, super::ipv6_mreq); -#[cfg(not(any(target_os = "dragonfly", target_os = "freebsd", target_os = "ios", target_os = "macos", target_os = "netbsd", target_os = "openbsd")))] +#[cfg(not(any(target_os = "dragonfly", target_os = "freebsd", target_os = "ios", target_os = "macos", target_os = "netbsd", target_os = "openbsd", target_os = "haiku")))] sockopt_impl!(SetOnly, Ipv6DropMembership, libc::IPPROTO_IPV6, libc::IPV6_DROP_MEMBERSHIP, super::ipv6_mreq); #[cfg(any(target_os = "dragonfly", target_os = "freebsd", target_os = "ios", target_os = "macos", target_os = "netbsd", target_os = "openbsd"))] sockopt_impl!(SetOnly, Ipv6AddMembership, libc::IPPROTO_IPV6, libc::IPV6_JOIN_GROUP, super::ipv6_mreq); @@ -171,6 +171,7 @@ sockopt_impl!(GetOnly, SockType, libc::SOL_SOCKET, libc::SO_TYPE, super::SockTyp sockopt_impl!(GetOnly, AcceptConn, libc::SOL_SOCKET, libc::SO_ACCEPTCONN, bool); #[cfg(any(target_os = "linux", target_os = "android"))] sockopt_impl!(GetOnly, OriginalDst, libc::SOL_IP, libc::SO_ORIGINAL_DST, libc::sockaddr_in); +#[cfg(not(target_os = "haiku"))] sockopt_impl!(Both, ReceiveTimestamp, libc::SOL_SOCKET, libc::SO_TIMESTAMP, bool); /* diff --git a/src/sys/termios.rs b/src/sys/termios.rs index 89f18ee1ff..8898cc08a3 100644 --- a/src/sys/termios.rs +++ b/src/sys/termios.rs @@ -406,6 +406,7 @@ libc_enum! { /// Indices into the `termios.c_cc` array for special characters. #[repr(usize)] pub enum SpecialCharacterIndices { + #[cfg(not(target_os = "haiku"))] VDISCARD, #[cfg(any(target_os = "dragonfly", target_os = "freebsd", @@ -421,9 +422,12 @@ libc_enum! { VERASE2, VINTR, VKILL, + #[cfg(not(target_os = "haiku"))] VLNEXT, + #[cfg(not(target_os = "haiku"))] VMIN, VQUIT, + #[cfg(not(target_os = "haiku"))] VREPRINT, VSTART, #[cfg(any(target_os = "dragonfly", @@ -438,7 +442,9 @@ libc_enum! { VSWTC, #[cfg(target_os = "haiku")] VSWTCH, + #[cfg(not(target_os = "haiku"))] VTIME, + #[cfg(not(target_os = "haiku"))] VWERASE, #[cfg(target_os = "dragonfly")] VCHECKPT, @@ -469,6 +475,7 @@ libc_bitflags! { IXON; IXOFF; IXANY; + #[cfg(not(target_os = "haiku"))] IMAXBEL; #[cfg(any(target_os = "android", target_os = "linux", target_os = "macos"))] IUTF8; @@ -745,6 +752,7 @@ libc_bitflags! { target_os = "openbsd"))] ALTWERASE; IEXTEN; + #[cfg(not(target_os = "haiku"))] EXTPROC; TOSTOP; FLUSHO; diff --git a/src/unistd.rs b/src/unistd.rs index fad51272e0..eef908a275 100644 --- a/src/unistd.rs +++ b/src/unistd.rs @@ -1050,7 +1050,7 @@ pub fn mkstemp(template: &P) -> Result<(RawFd, PathBuf)> { #[repr(i32)] pub enum PathconfVar { #[cfg(any(target_os = "dragonfly", target_os = "freebsd", target_os = "linux", - target_os = "netbsd", target_os = "openbsd"))] + target_os = "netbsd", target_os = "openbsd", target_os = "haiku"))] /// Minimum number of bits needed to represent, as a signed integer value, /// the maximum size of a regular file allowed in the specified directory. FILESIZEBITS = libc::_PC_FILESIZEBITS, @@ -1074,33 +1074,34 @@ pub enum PathconfVar { /// a pipe. PIPE_BUF = libc::_PC_PIPE_BUF, #[cfg(any(target_os = "android", target_os = "dragonfly", target_os = "linux", - target_os = "netbsd", target_os = "openbsd"))] + target_os = "netbsd", target_os = "openbsd", target_os = "haiku"))] /// Symbolic links can be created. POSIX2_SYMLINKS = libc::_PC_2_SYMLINKS, #[cfg(any(target_os = "android", target_os = "dragonfly", target_os = "freebsd", - target_os = "linux", target_os = "openbsd"))] + target_os = "linux", target_os = "openbsd", target_os = "haiku"))] /// Minimum number of bytes of storage actually allocated for any portion of /// a file. POSIX_ALLOC_SIZE_MIN = libc::_PC_ALLOC_SIZE_MIN, #[cfg(any(target_os = "android", target_os = "dragonfly", target_os = "freebsd", - target_os = "linux", target_os = "openbsd"))] + target_os = "linux", target_os = "openbsd", target_os = "haiku"))] /// Recommended increment for file transfer sizes between the /// `POSIX_REC_MIN_XFER_SIZE` and `POSIX_REC_MAX_XFER_SIZE` values. POSIX_REC_INCR_XFER_SIZE = libc::_PC_REC_INCR_XFER_SIZE, #[cfg(any(target_os = "android", target_os = "dragonfly", target_os = "freebsd", - target_os = "linux", target_os = "openbsd"))] + target_os = "linux", target_os = "openbsd", target_os = "haiku"))] /// Maximum recommended file transfer size. POSIX_REC_MAX_XFER_SIZE = libc::_PC_REC_MAX_XFER_SIZE, #[cfg(any(target_os = "android", target_os = "dragonfly", target_os = "freebsd", - target_os = "linux", target_os = "openbsd"))] + target_os = "linux", target_os = "openbsd", target_os = "haiku"))] /// Minimum recommended file transfer size. POSIX_REC_MIN_XFER_SIZE = libc::_PC_REC_MIN_XFER_SIZE, #[cfg(any(target_os = "android", target_os = "dragonfly", target_os = "freebsd", - target_os = "linux", target_os = "openbsd"))] + target_os = "linux", target_os = "openbsd", target_os = "haiku"))] /// Recommended file transfer buffer alignment. POSIX_REC_XFER_ALIGN = libc::_PC_REC_XFER_ALIGN, #[cfg(any(target_os = "android", target_os = "dragonfly", target_os = "freebsd", - target_os = "linux", target_os = "netbsd", target_os = "openbsd"))] + target_os = "linux", target_os = "netbsd", target_os = "openbsd", + target_os = "haiku"))] /// Maximum number of bytes in a symbolic link. SYMLINK_MAX = libc::_PC_SYMLINK_MAX, /// The use of `chown` and `fchown` is restricted to a process with @@ -1114,17 +1115,18 @@ pub enum PathconfVar { /// disable terminal special character handling. _POSIX_VDISABLE = libc::_PC_VDISABLE, #[cfg(any(target_os = "android", target_os = "dragonfly", target_os = "freebsd", - target_os = "linux", target_os = "openbsd"))] + target_os = "linux", target_os = "openbsd", target_os = "haiku"))] /// Asynchronous input or output operations may be performed for the /// associated file. _POSIX_ASYNC_IO = libc::_PC_ASYNC_IO, #[cfg(any(target_os = "android", target_os = "dragonfly", target_os = "freebsd", - target_os = "linux", target_os = "openbsd"))] + target_os = "linux", target_os = "openbsd", target_os = "haiku"))] /// Prioritized input or output operations may be performed for the /// associated file. _POSIX_PRIO_IO = libc::_PC_PRIO_IO, #[cfg(any(target_os = "android", target_os = "dragonfly", target_os = "freebsd", - target_os = "linux", target_os = "netbsd", target_os = "openbsd"))] + target_os = "linux", target_os = "netbsd", target_os = "openbsd", + target_os = "haiku"))] /// Synchronized input or output operations may be performed for the /// associated file. _POSIX_SYNC_IO = libc::_PC_SYNC_IO, @@ -1223,9 +1225,11 @@ pub fn pathconf(path: &P, var: PathconfVar) -> Result. LINE_MAX = libc::_SC_LINE_MAX, + #[cfg(not(target_os="haiku"))] /// Maximum length of a login name. LOGIN_NAME_MAX = libc::_SC_LOGIN_NAME_MAX, /// Maximum number of simultaneous supplementary group IDs per process. @@ -1280,8 +1292,10 @@ pub enum SysconfVar { GETGR_R_SIZE_MAX = libc::_SC_GETGR_R_SIZE_MAX, /// Initial size of `getpwuid_r` and `getpwnam_r` data buffers GETPW_R_SIZE_MAX = libc::_SC_GETPW_R_SIZE_MAX, + #[cfg(not(target_os="haiku"))] /// The maximum number of open message queue descriptors a process may hold. MQ_OPEN_MAX = libc::_SC_MQ_OPEN_MAX, + #[cfg(not(target_os="haiku"))] /// The maximum number of message priorities supported by the implementation. MQ_PRIO_MAX = libc::_SC_MQ_PRIO_MAX, /// A value one greater than the maximum value that the system may assign to @@ -1296,6 +1310,7 @@ pub enum SysconfVar { target_os="openbsd"))] /// The implementation supports barriers. _POSIX_BARRIERS = libc::_SC_BARRIERS, + #[cfg(not(target_os="haiku"))] /// The implementation supports asynchronous input and output. _POSIX_ASYNCHRONOUS_IO = libc::_SC_ASYNCHRONOUS_IO, #[cfg(any(target_os="dragonfly", target_os="freebsd", target_os = "ios", @@ -1308,6 +1323,7 @@ pub enum SysconfVar { target_os="openbsd"))] /// The implementation supports the Process CPU-Time Clocks option. _POSIX_CPUTIME = libc::_SC_CPUTIME, + #[cfg(not(target_os="haiku"))] /// The implementation supports the File Synchronization option. _POSIX_FSYNC = libc::_SC_FSYNC, #[cfg(any(target_os="dragonfly", target_os="freebsd", target_os = "ios", @@ -1318,12 +1334,16 @@ pub enum SysconfVar { _POSIX_JOB_CONTROL = libc::_SC_JOB_CONTROL, /// The implementation supports memory mapped Files. _POSIX_MAPPED_FILES = libc::_SC_MAPPED_FILES, + #[cfg(not(target_os="haiku"))] /// The implementation supports the Process Memory Locking option. _POSIX_MEMLOCK = libc::_SC_MEMLOCK, + #[cfg(not(target_os="haiku"))] /// The implementation supports the Range Memory Locking option. _POSIX_MEMLOCK_RANGE = libc::_SC_MEMLOCK_RANGE, + #[cfg(not(target_os="haiku"))] /// The implementation supports memory protection. _POSIX_MEMORY_PROTECTION = libc::_SC_MEMORY_PROTECTION, + #[cfg(not(target_os="haiku"))] /// The implementation supports the Message Passing option. _POSIX_MESSAGE_PASSING = libc::_SC_MESSAGE_PASSING, /// The implementation supports the Monotonic Clock option. @@ -1333,6 +1353,7 @@ pub enum SysconfVar { target_os="openbsd"))] /// The implementation supports the Prioritized Input and Output option. _POSIX_PRIORITIZED_IO = libc::_SC_PRIORITIZED_IO, + #[cfg(not(target_os="haiku"))] /// The implementation supports the Process Scheduling option. _POSIX_PRIORITY_SCHEDULING = libc::_SC_PRIORITY_SCHEDULING, #[cfg(any(target_os="dragonfly", target_os="freebsd", target_os = "ios", @@ -1346,18 +1367,20 @@ pub enum SysconfVar { _POSIX_READER_WRITER_LOCKS = libc::_SC_READER_WRITER_LOCKS, #[cfg(any(target_os = "android", target_os="dragonfly", target_os="freebsd", target_os = "ios", target_os="linux", target_os = "macos", - target_os = "openbsd"))] + target_os = "openbsd", target_os="haiku"))] /// The implementation supports realtime signals. _POSIX_REALTIME_SIGNALS = libc::_SC_REALTIME_SIGNALS, #[cfg(any(target_os="dragonfly", target_os="freebsd", target_os = "ios", target_os="linux", target_os = "macos", target_os="netbsd", target_os="openbsd"))] + #[cfg(not(target_os="haiku"))] /// The implementation supports the Regular Expression Handling option. _POSIX_REGEXP = libc::_SC_REGEXP, /// Each process has a saved set-user-ID and a saved set-group-ID. _POSIX_SAVED_IDS = libc::_SC_SAVED_IDS, /// The implementation supports semaphores. _POSIX_SEMAPHORES = libc::_SC_SEMAPHORES, + #[cfg(not(target_os="haiku"))] /// The implementation supports the Shared Memory Objects option. _POSIX_SHARED_MEMORY_OBJECTS = libc::_SC_SHARED_MEMORY_OBJECTS, #[cfg(any(target_os="dragonfly", target_os="freebsd", target_os = "ios", @@ -1382,6 +1405,7 @@ pub enum SysconfVar { #[cfg(any(target_os = "ios", target_os="linux", target_os = "macos", target_os="openbsd"))] _POSIX_SS_REPL_MAX = libc::_SC_SS_REPL_MAX, + #[cfg(not(target_os="haiku"))] /// The implementation supports the Synchronized Input and Output option. _POSIX_SYNCHRONIZED_IO = libc::_SC_SYNCHRONIZED_IO, /// The implementation supports the Thread Stack Address Attribute option. @@ -1392,16 +1416,18 @@ pub enum SysconfVar { target_os="netbsd", target_os="openbsd"))] /// The implementation supports the Thread CPU-Time Clocks option. _POSIX_THREAD_CPUTIME = libc::_SC_THREAD_CPUTIME, + #[cfg(not(target_os="haiku"))] /// The implementation supports the Non-Robust Mutex Priority Inheritance /// option. _POSIX_THREAD_PRIO_INHERIT = libc::_SC_THREAD_PRIO_INHERIT, + #[cfg(not(target_os="haiku"))] /// The implementation supports the Non-Robust Mutex Priority Protection option. _POSIX_THREAD_PRIO_PROTECT = libc::_SC_THREAD_PRIO_PROTECT, /// The implementation supports the Thread Execution Scheduling option. _POSIX_THREAD_PRIORITY_SCHEDULING = libc::_SC_THREAD_PRIORITY_SCHEDULING, #[cfg(any(target_os="dragonfly", target_os="freebsd", target_os = "ios", target_os="linux", target_os = "macos", target_os="netbsd", - target_os="openbsd"))] + target_os="openbsd", target_os="haiku"))] /// The implementation supports the Thread Process-Shared Synchronization /// option. _POSIX_THREAD_PROCESS_SHARED = libc::_SC_THREAD_PROCESS_SHARED, @@ -1411,6 +1437,7 @@ pub enum SysconfVar { #[cfg(any(target_os="dragonfly", target_os="linux", target_os="openbsd"))] /// The implementation supports the Robust Mutex Priority Protection option. _POSIX_THREAD_ROBUST_PRIO_PROTECT = libc::_SC_THREAD_ROBUST_PRIO_PROTECT, + #[cfg(not(target_os="haiku"))] /// The implementation supports thread-safe functions. _POSIX_THREAD_SAFE_FUNCTIONS = libc::_SC_THREAD_SAFE_FUNCTIONS, #[cfg(any(target_os="dragonfly", target_os="freebsd", target_os = "ios", @@ -1423,6 +1450,7 @@ pub enum SysconfVar { target_os="linux", target_os = "macos", target_os="openbsd"))] /// The implementation supports timeouts. _POSIX_TIMEOUTS = libc::_SC_TIMEOUTS, + #[cfg(not(target_os="haiku"))] /// The implementation supports timers. _POSIX_TIMERS = libc::_SC_TIMERS, #[cfg(any(target_os="dragonfly", target_os="freebsd", target_os = "ios", @@ -1487,16 +1515,22 @@ pub enum SysconfVar { /// `int` type using at least 32 bits and `long`, pointer, and `off_t` types /// using at least 64 bits. _POSIX_V6_LPBIG_OFFBIG = libc::_SC_V6_LPBIG_OFFBIG, + #[cfg(not(target_os="haiku"))] /// The implementation supports the C-Language Binding option. _POSIX2_C_BIND = libc::_SC_2_C_BIND, + #[cfg(not(target_os="haiku"))] /// The implementation supports the C-Language Development Utilities option. _POSIX2_C_DEV = libc::_SC_2_C_DEV, + #[cfg(not(target_os="haiku"))] /// The implementation supports the Terminal Characteristics option. _POSIX2_CHAR_TERM = libc::_SC_2_CHAR_TERM, + #[cfg(not(target_os="haiku"))] /// The implementation supports the FORTRAN Development Utilities option. _POSIX2_FORT_DEV = libc::_SC_2_FORT_DEV, + #[cfg(not(target_os="haiku"))] /// The implementation supports the FORTRAN Runtime Utilities option. _POSIX2_FORT_RUN = libc::_SC_2_FORT_RUN, + #[cfg(not(target_os="haiku"))] /// The implementation supports the creation of locales by the localedef /// utility. _POSIX2_LOCALEDEF = libc::_SC_2_LOCALEDEF, @@ -1529,12 +1563,16 @@ pub enum SysconfVar { #[cfg(any(target_os="dragonfly", target_os="freebsd", target_os = "ios", target_os="linux", target_os = "macos", target_os="netbsd", target_os="openbsd"))] + #[cfg(not(target_os="haiku"))] /// The implementation supports the Track Batch Job Request option. _POSIX2_PBS_TRACK = libc::_SC_2_PBS_TRACK, + #[cfg(not(target_os="haiku"))] /// The implementation supports the Software Development Utilities option. _POSIX2_SW_DEV = libc::_SC_2_SW_DEV, + #[cfg(not(target_os="haiku"))] /// The implementation supports the User Portability Utilities option. _POSIX2_UPE = libc::_SC_2_UPE, + #[cfg(not(target_os="haiku"))] /// Integer value indicating version of the Shell and Utilities volume of /// POSIX.1 to which the implementation conforms. _POSIX2_VERSION = libc::_SC_2_VERSION, @@ -1543,23 +1581,27 @@ pub enum SysconfVar { /// POSIX also defines an alias named `PAGESIZE`, but Rust does not allow two /// enum constants to have the same value, so nix omits `PAGESIZE`. PAGE_SIZE = libc::_SC_PAGE_SIZE, + #[cfg(not(target_os="haiku"))] PTHREAD_DESTRUCTOR_ITERATIONS = libc::_SC_THREAD_DESTRUCTOR_ITERATIONS, + #[cfg(not(target_os="haiku"))] PTHREAD_KEYS_MAX = libc::_SC_THREAD_KEYS_MAX, PTHREAD_STACK_MIN = libc::_SC_THREAD_STACK_MIN, + #[cfg(not(target_os="haiku"))] PTHREAD_THREADS_MAX = libc::_SC_THREAD_THREADS_MAX, + #[cfg(not(target_os="haiku"))] RE_DUP_MAX = libc::_SC_RE_DUP_MAX, #[cfg(any(target_os="android", target_os="dragonfly", target_os="freebsd", target_os = "ios", target_os="linux", target_os = "macos", - target_os="openbsd"))] + target_os="openbsd", target_os="haiku"))] RTSIG_MAX = libc::_SC_RTSIG_MAX, SEM_NSEMS_MAX = libc::_SC_SEM_NSEMS_MAX, #[cfg(any(target_os="android", target_os="dragonfly", target_os="freebsd", target_os = "ios", target_os="linux", target_os = "macos", - target_os="openbsd"))] + target_os="openbsd", target_os="haiku"))] SEM_VALUE_MAX = libc::_SC_SEM_VALUE_MAX, #[cfg(any(target_os = "android", target_os="dragonfly", target_os="freebsd", target_os = "ios", target_os="linux", target_os = "macos", - target_os = "openbsd"))] + target_os = "openbsd", target_os="haiku"))] SIGQUEUE_MAX = libc::_SC_SIGQUEUE_MAX, STREAM_MAX = libc::_SC_STREAM_MAX, #[cfg(any(target_os="dragonfly", target_os="freebsd", target_os = "ios", @@ -1567,6 +1609,7 @@ pub enum SysconfVar { target_os="openbsd"))] SYMLOOP_MAX = libc::_SC_SYMLOOP_MAX, TIMER_MAX = libc::_SC_TIMER_MAX, + #[cfg(not(target_os="haiku"))] TTY_NAME_MAX = libc::_SC_TTY_NAME_MAX, TZNAME_MAX = libc::_SC_TZNAME_MAX, #[cfg(any(target_os="android", target_os="dragonfly", target_os="freebsd", @@ -1594,6 +1637,7 @@ pub enum SysconfVar { target_os="openbsd"))] /// The implementation supports the X/Open Realtime Threads Option Group. _XOPEN_REALTIME_THREADS = libc::_SC_XOPEN_REALTIME_THREADS, + #[cfg(not(target_os="haiku"))] /// The implementation supports the Issue 4, Version 2 Shared Memory Option /// Group. _XOPEN_SHM = libc::_SC_XOPEN_SHM,