From 7fa46987b5403d56e90a2a242511902f4b5f3f63 Mon Sep 17 00:00:00 2001 From: Zac Berkowitz Date: Thu, 2 Mar 2017 18:01:58 +0000 Subject: [PATCH 1/4] Fixed constants for MIPS --- src/errno.rs | 558 ++++++++++++++++++++------------------- src/sys/socket/consts.rs | 50 ++-- 2 files changed, 306 insertions(+), 302 deletions(-) diff --git a/src/errno.rs b/src/errno.rs index 4218bf9cd3..d8aaf7f3f8 100644 --- a/src/errno.rs +++ b/src/errno.rs @@ -374,10 +374,10 @@ fn desc(errno: Errno) -> &'static str { #[cfg(any(target_os = "linux", target_os = "android"))] ENOTRECOVERABLE => "State not recoverable", - #[cfg(target_os = "linux")] + #[cfg(all(target_os = "linux", not(target_arch="mips")))] ERFKILL => "Operation not possible due to RF-kill", - #[cfg(target_os = "linux")] + #[cfg(all(target_os = "linux", not(target_arch="mips")))] EHWPOISON => "Memory page has hardware error", #[cfg(any(target_os = "freebsd", target_os = "dragonfly"))] @@ -522,143 +522,145 @@ fn desc(errno: Errno) -> &'static str { #[cfg(any(target_os = "linux", target_os = "android"))] mod consts { + use libc; + #[derive(Debug, Clone, PartialEq, Copy)] pub enum Errno { UnknownErrno = 0, - EPERM = 1, - ENOENT = 2, - ESRCH = 3, - EINTR = 4, - EIO = 5, - ENXIO = 6, - E2BIG = 7, - ENOEXEC = 8, - EBADF = 9, - ECHILD = 10, - EAGAIN = 11, - ENOMEM = 12, - EACCES = 13, - EFAULT = 14, - ENOTBLK = 15, - EBUSY = 16, - EEXIST = 17, - EXDEV = 18, - ENODEV = 19, - ENOTDIR = 20, - EISDIR = 21, - EINVAL = 22, - ENFILE = 23, - EMFILE = 24, - ENOTTY = 25, - ETXTBSY = 26, - EFBIG = 27, - ENOSPC = 28, - ESPIPE = 29, - EROFS = 30, - EMLINK = 31, - EPIPE = 32, - EDOM = 33, - ERANGE = 34, - EDEADLK = 35, - ENAMETOOLONG = 36, - ENOLCK = 37, - ENOSYS = 38, - ENOTEMPTY = 39, - ELOOP = 40, - ENOMSG = 42, - EIDRM = 43, - ECHRNG = 44, - EL2NSYNC = 45, - EL3HLT = 46, - EL3RST = 47, - ELNRNG = 48, - EUNATCH = 49, - ENOCSI = 50, - EL2HLT = 51, - EBADE = 52, - EBADR = 53, - EXFULL = 54, - ENOANO = 55, - EBADRQC = 56, - EBADSLT = 57, - EBFONT = 59, - ENOSTR = 60, - ENODATA = 61, - ETIME = 62, - ENOSR = 63, - ENONET = 64, - ENOPKG = 65, - EREMOTE = 66, - ENOLINK = 67, - EADV = 68, - ESRMNT = 69, - ECOMM = 70, - EPROTO = 71, - EMULTIHOP = 72, - EDOTDOT = 73, - EBADMSG = 74, - EOVERFLOW = 75, - ENOTUNIQ = 76, - EBADFD = 77, - EREMCHG = 78, - ELIBACC = 79, - ELIBBAD = 80, - ELIBSCN = 81, - ELIBMAX = 82, - ELIBEXEC = 83, - EILSEQ = 84, - ERESTART = 85, - ESTRPIPE = 86, - EUSERS = 87, - ENOTSOCK = 88, - EDESTADDRREQ = 89, - EMSGSIZE = 90, - EPROTOTYPE = 91, - ENOPROTOOPT = 92, - EPROTONOSUPPORT = 93, - ESOCKTNOSUPPORT = 94, - EOPNOTSUPP = 95, - EPFNOSUPPORT = 96, - EAFNOSUPPORT = 97, - EADDRINUSE = 98, - EADDRNOTAVAIL = 99, - ENETDOWN = 100, - ENETUNREACH = 101, - ENETRESET = 102, - ECONNABORTED = 103, - ECONNRESET = 104, - ENOBUFS = 105, - EISCONN = 106, - ENOTCONN = 107, - ESHUTDOWN = 108, - ETOOMANYREFS = 109, - ETIMEDOUT = 110, - ECONNREFUSED = 111, - EHOSTDOWN = 112, - EHOSTUNREACH = 113, - EALREADY = 114, - EINPROGRESS = 115, - ESTALE = 116, - EUCLEAN = 117, - ENOTNAM = 118, - ENAVAIL = 119, - EISNAM = 120, - EREMOTEIO = 121, - EDQUOT = 122, - ENOMEDIUM = 123, - EMEDIUMTYPE = 124, - ECANCELED = 125, - ENOKEY = 126, - EKEYEXPIRED = 127, - EKEYREVOKED = 128, - EKEYREJECTED = 129, - EOWNERDEAD = 130, - ENOTRECOVERABLE = 131, - - #[cfg(not(target_os = "android"))] - ERFKILL = 132, - #[cfg(not(target_os = "android"))] - EHWPOISON = 133, + EPERM = libc::EPERM as isize, + ENOENT = libc::ENOENT as isize, + ESRCH = libc::ESRCH as isize, + EINTR = libc::EINTR as isize, + EIO = libc::EIO as isize, + ENXIO = libc::ENXIO as isize, + E2BIG = libc::E2BIG as isize, + ENOEXEC = libc::ENOEXEC as isize, + EBADF = libc::EBADF as isize, + ECHILD = libc::ECHILD as isize, + EAGAIN = libc::EAGAIN as isize, + ENOMEM = libc::ENOMEM as isize, + EACCES = libc::EACCES as isize, + EFAULT = libc::EFAULT as isize, + ENOTBLK = libc::ENOTBLK as isize, + EBUSY = libc::EBUSY as isize, + EEXIST = libc::EEXIST as isize, + EXDEV = libc::EXDEV as isize, + ENODEV = libc::ENODEV as isize, + ENOTDIR = libc::ENOTDIR as isize, + EISDIR = libc::EISDIR as isize, + EINVAL = libc::EINVAL as isize, + ENFILE = libc::ENFILE as isize, + EMFILE = libc::EMFILE as isize, + ENOTTY = libc::ENOTTY as isize, + ETXTBSY = libc::ETXTBSY as isize, + EFBIG = libc::EFBIG as isize, + ENOSPC = libc::ENOSPC as isize, + ESPIPE = libc::ESPIPE as isize, + EROFS = libc::EROFS as isize, + EMLINK = libc::EMLINK as isize, + EPIPE = libc::EPIPE as isize, + EDOM = libc::EDOM as isize, + ERANGE = libc::ERANGE as isize, + EDEADLK = libc::EDEADLK as isize, + ENAMETOOLONG = libc::ENAMETOOLONG as isize, + ENOLCK = libc::ENOLCK as isize, + ENOSYS = libc::ENOSYS as isize, + ENOTEMPTY = libc::ENOTEMPTY as isize, + ELOOP = libc::ELOOP as isize, + ENOMSG = libc::ENOMSG as isize, + EIDRM = libc::EIDRM as isize, + ECHRNG = libc::ECHRNG as isize, + EL2NSYNC = libc::EL2NSYNC as isize, + EL3HLT = libc::EL3HLT as isize, + EL3RST = libc::EL3RST as isize, + ELNRNG = libc::ELNRNG as isize, + EUNATCH = libc::EUNATCH as isize, + ENOCSI = libc::ENOCSI as isize, + EL2HLT = libc::EL2HLT as isize, + EBADE = libc::EBADE as isize, + EBADR = libc::EBADR as isize, + EXFULL = libc::EXFULL as isize, + ENOANO = libc::ENOANO as isize, + EBADRQC = libc::EBADRQC as isize, + EBADSLT = libc::EBADSLT as isize, + EBFONT = libc::EBFONT as isize, + ENOSTR = libc::ENOSTR as isize, + ENODATA = libc::ENODATA as isize, + ETIME = libc::ETIME as isize, + ENOSR = libc::ENOSR as isize, + ENONET = libc::ENONET as isize, + ENOPKG = libc::ENOPKG as isize, + EREMOTE = libc::EREMOTE as isize, + ENOLINK = libc::ENOLINK as isize, + EADV = libc::EADV as isize, + ESRMNT = libc::ESRMNT as isize, + ECOMM = libc::ECOMM as isize, + EPROTO = libc::EPROTO as isize, + EMULTIHOP = libc::EMULTIHOP as isize, + EDOTDOT = libc::EDOTDOT as isize, + EBADMSG = libc::EBADMSG as isize, + EOVERFLOW = libc::EOVERFLOW as isize, + ENOTUNIQ = libc::ENOTUNIQ as isize, + EBADFD = libc::EBADFD as isize, + EREMCHG = libc::EREMCHG as isize, + ELIBACC = libc::ELIBACC as isize, + ELIBBAD = libc::ELIBBAD as isize, + ELIBSCN = libc::ELIBSCN as isize, + ELIBMAX = libc::ELIBMAX as isize, + ELIBEXEC = libc::ELIBEXEC as isize, + EILSEQ = libc::EILSEQ as isize, + ERESTART = libc::ERESTART as isize, + ESTRPIPE = libc::ESTRPIPE as isize, + EUSERS = libc::EUSERS as isize, + ENOTSOCK = libc::ENOTSOCK as isize, + EDESTADDRREQ = libc::EDESTADDRREQ as isize, + EMSGSIZE = libc::EMSGSIZE as isize, + EPROTOTYPE = libc::EPROTOTYPE as isize, + ENOPROTOOPT = libc::ENOPROTOOPT as isize, + EPROTONOSUPPORT = libc::EPROTONOSUPPORT as isize, + ESOCKTNOSUPPORT = libc::ESOCKTNOSUPPORT as isize, + EOPNOTSUPP = libc::EOPNOTSUPP as isize, + EPFNOSUPPORT = libc::EPFNOSUPPORT as isize, + EAFNOSUPPORT = libc::EAFNOSUPPORT as isize, + EADDRINUSE = libc::EADDRINUSE as isize, + EADDRNOTAVAIL = libc::EADDRNOTAVAIL as isize, + ENETDOWN = libc::ENETDOWN as isize, + ENETUNREACH = libc::ENETUNREACH as isize, + ENETRESET = libc::ENETRESET as isize, + ECONNABORTED = libc::ECONNABORTED as isize, + ECONNRESET = libc::ECONNRESET as isize, + ENOBUFS = libc::ENOBUFS as isize, + EISCONN = libc::EISCONN as isize, + ENOTCONN = libc::ENOTCONN as isize, + ESHUTDOWN = libc::ESHUTDOWN as isize, + ETOOMANYREFS = libc::ETOOMANYREFS as isize, + ETIMEDOUT = libc::ETIMEDOUT as isize, + ECONNREFUSED = libc::ECONNREFUSED as isize, + EHOSTDOWN = libc::EHOSTDOWN as isize, + EHOSTUNREACH = libc::EHOSTUNREACH as isize, + EALREADY = libc::EALREADY as isize, + EINPROGRESS = libc::EINPROGRESS as isize, + ESTALE = libc::ESTALE as isize, + EUCLEAN = libc::EUCLEAN as isize, + ENOTNAM = libc::ENOTNAM as isize, + ENAVAIL = libc::ENAVAIL as isize, + EISNAM = libc::EISNAM as isize, + EREMOTEIO = libc::EREMOTEIO as isize, + EDQUOT = libc::EDQUOT as isize, + ENOMEDIUM = libc::ENOMEDIUM as isize, + EMEDIUMTYPE = libc::EMEDIUMTYPE as isize, + ECANCELED = libc::ECANCELED as isize, + ENOKEY = libc::ENOKEY as isize, + EKEYEXPIRED = libc::EKEYEXPIRED as isize, + EKEYREVOKED = libc::EKEYREVOKED as isize, + EKEYREJECTED = libc::EKEYREJECTED as isize, + EOWNERDEAD = libc::EOWNERDEAD as isize, + ENOTRECOVERABLE = libc::ENOTRECOVERABLE as isize, + + #[cfg(not(any(target_os = "android", target_arch="mips")))] + ERFKILL = libc::ERFKILL as isize, + #[cfg(not(any(target_os = "android", target_arch="mips")))] + EHWPOISON = libc::EHWPOISON as isize, } pub const EWOULDBLOCK: Errno = Errno::EAGAIN; @@ -669,140 +671,140 @@ mod consts { match e { 0 => UnknownErrno, - 1 => EPERM, - 2 => ENOENT, - 3 => ESRCH, - 4 => EINTR, - 5 => EIO, - 6 => ENXIO, - 7 => E2BIG, - 8 => ENOEXEC, - 9 => EBADF, - 10 => ECHILD, - 11 => EAGAIN, - 12 => ENOMEM, - 13 => EACCES, - 14 => EFAULT, - 15 => ENOTBLK, - 16 => EBUSY, - 17 => EEXIST, - 18 => EXDEV, - 19 => ENODEV, - 20 => ENOTDIR, - 21 => EISDIR, - 22 => EINVAL, - 23 => ENFILE, - 24 => EMFILE, - 25 => ENOTTY, - 26 => ETXTBSY, - 27 => EFBIG, - 28 => ENOSPC, - 29 => ESPIPE, - 30 => EROFS, - 31 => EMLINK, - 32 => EPIPE, - 33 => EDOM, - 34 => ERANGE, - 35 => EDEADLK, - 36 => ENAMETOOLONG, - 37 => ENOLCK, - 38 => ENOSYS, - 39 => ENOTEMPTY, - 40 => ELOOP, - 42 => ENOMSG, - 43 => EIDRM, - 44 => ECHRNG, - 45 => EL2NSYNC, - 46 => EL3HLT, - 47 => EL3RST, - 48 => ELNRNG, - 49 => EUNATCH, - 50 => ENOCSI, - 51 => EL2HLT, - 52 => EBADE, - 53 => EBADR, - 54 => EXFULL, - 55 => ENOANO, - 56 => EBADRQC, - 57 => EBADSLT, - 59 => EBFONT, - 60 => ENOSTR, - 61 => ENODATA, - 62 => ETIME, - 63 => ENOSR, - 64 => ENONET, - 65 => ENOPKG, - 66 => EREMOTE, - 67 => ENOLINK, - 68 => EADV, - 69 => ESRMNT, - 70 => ECOMM, - 71 => EPROTO, - 72 => EMULTIHOP, - 73 => EDOTDOT, - 74 => EBADMSG, - 75 => EOVERFLOW, - 76 => ENOTUNIQ, - 77 => EBADFD, - 78 => EREMCHG, - 79 => ELIBACC, - 80 => ELIBBAD, - 81 => ELIBSCN, - 82 => ELIBMAX, - 83 => ELIBEXEC, - 84 => EILSEQ, - 85 => ERESTART, - 86 => ESTRPIPE, - 87 => EUSERS, - 88 => ENOTSOCK, - 89 => EDESTADDRREQ, - 90 => EMSGSIZE, - 91 => EPROTOTYPE, - 92 => ENOPROTOOPT, - 93 => EPROTONOSUPPORT, - 94 => ESOCKTNOSUPPORT, - 95 => EOPNOTSUPP, - 96 => EPFNOSUPPORT, - 97 => EAFNOSUPPORT, - 98 => EADDRINUSE, - 99 => EADDRNOTAVAIL, - 100 => ENETDOWN, - 101 => ENETUNREACH, - 102 => ENETRESET, - 103 => ECONNABORTED, - 104 => ECONNRESET, - 105 => ENOBUFS, - 106 => EISCONN, - 107 => ENOTCONN, - 108 => ESHUTDOWN, - 109 => ETOOMANYREFS, - 110 => ETIMEDOUT, - 111 => ECONNREFUSED, - 112 => EHOSTDOWN, - 113 => EHOSTUNREACH, - 114 => EALREADY, - 115 => EINPROGRESS, - 116 => ESTALE, - 117 => EUCLEAN, - 118 => ENOTNAM, - 119 => ENAVAIL, - 120 => EISNAM, - 121 => EREMOTEIO, - 122 => EDQUOT, - 123 => ENOMEDIUM, - 124 => EMEDIUMTYPE, - 125 => ECANCELED, - 126 => ENOKEY, - 127 => EKEYEXPIRED, - 128 => EKEYREVOKED, - 129 => EKEYREJECTED, - 130 => EOWNERDEAD, - 131 => ENOTRECOVERABLE, - - #[cfg(not(target_os = "android"))] - 132 => ERFKILL, - #[cfg(not(target_os = "android"))] - 133 => EHWPOISON, + 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::ECHRNG => ECHRNG, + libc::EL2NSYNC => EL2NSYNC, + libc::EL3HLT => EL3HLT, + libc::EL3RST => EL3RST, + libc::ELNRNG => ELNRNG, + libc::EUNATCH => EUNATCH, + libc::ENOCSI => ENOCSI, + libc::EL2HLT => EL2HLT, + libc::EBADE => EBADE, + libc::EBADR => EBADR, + libc::EXFULL => EXFULL, + libc::ENOANO => ENOANO, + libc::EBADRQC => EBADRQC, + libc::EBADSLT => EBADSLT, + libc::EBFONT => EBFONT, + libc::ENOSTR => ENOSTR, + libc::ENODATA => ENODATA, + libc::ETIME => ETIME, + libc::ENOSR => ENOSR, + libc::ENONET => ENONET, + libc::ENOPKG => ENOPKG, + libc::EREMOTE => EREMOTE, + libc::ENOLINK => ENOLINK, + libc::EADV => EADV, + libc::ESRMNT => ESRMNT, + libc::ECOMM => ECOMM, + libc::EPROTO => EPROTO, + libc::EMULTIHOP => EMULTIHOP, + libc::EDOTDOT => EDOTDOT, + libc::EBADMSG => EBADMSG, + libc::EOVERFLOW => EOVERFLOW, + libc::ENOTUNIQ => ENOTUNIQ, + libc::EBADFD => EBADFD, + libc::EREMCHG => EREMCHG, + libc::ELIBACC => ELIBACC, + libc::ELIBBAD => ELIBBAD, + libc::ELIBSCN => ELIBSCN, + libc::ELIBMAX => ELIBMAX, + libc::ELIBEXEC => ELIBEXEC, + libc::EILSEQ => EILSEQ, + libc::ERESTART => ERESTART, + libc::ESTRPIPE => ESTRPIPE, + libc::EUSERS => EUSERS, + libc::ENOTSOCK => ENOTSOCK, + libc::EDESTADDRREQ => EDESTADDRREQ, + libc::EMSGSIZE => EMSGSIZE, + libc::EPROTOTYPE => EPROTOTYPE, + libc::ENOPROTOOPT => ENOPROTOOPT, + libc::EPROTONOSUPPORT => EPROTONOSUPPORT, + libc::ESOCKTNOSUPPORT => ESOCKTNOSUPPORT, + libc::EOPNOTSUPP => EOPNOTSUPP, + 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::EALREADY => EALREADY, + libc::EINPROGRESS => EINPROGRESS, + libc::ESTALE => ESTALE, + libc::EUCLEAN => EUCLEAN, + libc::ENOTNAM => ENOTNAM, + libc::ENAVAIL => ENAVAIL, + libc::EISNAM => EISNAM, + libc::EREMOTEIO => EREMOTEIO, + libc::EDQUOT => EDQUOT, + libc::ENOMEDIUM => ENOMEDIUM, + libc::EMEDIUMTYPE => EMEDIUMTYPE, + libc::ECANCELED => ECANCELED, + libc::ENOKEY => ENOKEY, + libc::EKEYEXPIRED => EKEYEXPIRED, + libc::EKEYREVOKED => EKEYREVOKED, + libc::EKEYREJECTED => EKEYREJECTED, + libc::EOWNERDEAD => EOWNERDEAD, + libc::ENOTRECOVERABLE => ENOTRECOVERABLE, + + #[cfg(not(any(target_os = "android", target_arch="mips")))] + libc::ERFKILL => ERFKILL, + #[cfg(not(any(target_os = "android", target_arch="mips")))] + libc::EHWPOISON => EHWPOISON, _ => UnknownErrno, } } @@ -2057,13 +2059,15 @@ mod test { ENOTRECOVERABLE); } - #[test] - #[cfg(target_os = "linux")] - pub fn test_linux_not_android_errnos() { - check_errno!( - ERFKILL /*, - EHWPOISON */); - } + // This test fails because MIPS does not have + // ERFKILL or EHWPOISON. + // #[test] + // #[cfg(target_os = "linux")] + // pub fn test_linux_not_android_errnos() { + // check_errno!( + // ERFKILL /*, + // EHWPOISON */); + // } #[test] #[cfg(target_os = "freebsd")] diff --git a/src/sys/socket/consts.rs b/src/sys/socket/consts.rs index 9a1861fa3e..8e5440e147 100644 --- a/src/sys/socket/consts.rs +++ b/src/sys/socket/consts.rs @@ -11,14 +11,14 @@ mod os { pub const AF_NETLINK: c_int = 16; pub const AF_PACKET: c_int = 17; - pub const SOCK_STREAM: c_int = 1; - pub const SOCK_DGRAM: c_int = 2; - pub const SOCK_SEQPACKET: c_int = 5; - pub const SOCK_RAW: c_int = 3; + pub const SOCK_STREAM: c_int = libc::SOCK_STREAM; + pub const SOCK_DGRAM: c_int = libc::SOCK_DGRAM; + pub const SOCK_SEQPACKET: c_int = libc::SOCK_SEQPACKET; + pub const SOCK_RAW: c_int = libc::SOCK_RAW; pub const SOCK_RDM: c_int = 4; pub const SOL_IP: c_int = 0; - pub const SOL_SOCKET: c_int = 1; + pub const SOL_SOCKET: c_int = libc::SOL_SOCKET; pub const SOL_TCP: c_int = 6; pub const SOL_UDP: c_int = 17; pub const SOL_IPV6: c_int = 41; @@ -28,36 +28,36 @@ mod os { pub const IPPROTO_TCP: c_int = SOL_TCP; pub const IPPROTO_UDP: c_int = SOL_UDP; - pub const SO_ACCEPTCONN: c_int = 30; + pub const SO_ACCEPTCONN: c_int = libc::SO_ACCEPTCONN; pub const SO_BINDTODEVICE: c_int = 25; - pub const SO_BROADCAST: c_int = 6; + pub const SO_BROADCAST: c_int = libc::SO_BROADCAST; pub const SO_BSDCOMPAT: c_int = 14; pub const SO_DEBUG: c_int = 1; pub const SO_DOMAIN: c_int = 39; - pub const SO_ERROR: c_int = 4; - pub const SO_DONTROUTE: c_int = 5; - pub const SO_KEEPALIVE: c_int = 9; - pub const SO_LINGER: c_int = 13; + pub const SO_ERROR: c_int = libc::SO_ERROR; + pub const SO_DONTROUTE: c_int = libc::SO_DONTROUTE; + pub const SO_KEEPALIVE: c_int = libc::SO_KEEPALIVE; + pub const SO_LINGER: c_int = libc::SO_LINGER; pub const SO_MARK: c_int = 36; - pub const SO_OOBINLINE: c_int = 10; - pub const SO_PASSCRED: c_int = 16; + pub const SO_OOBINLINE: c_int = libc::SO_OOBINLINE; + pub const SO_PASSCRED: c_int = libc::SO_PASSCRED; pub const SO_PEEK_OFF: c_int = 42; - pub const SO_PEERCRED: c_int = 17; + pub const SO_PEERCRED: c_int = libc::SO_PEERCRED; pub const SO_PRIORITY: c_int = 12; pub const SO_PROTOCOL: c_int = 38; - pub const SO_RCVBUF: c_int = 8; + pub const SO_RCVBUF: c_int = libc::SO_RCVBUF; pub const SO_RCVBUFFORCE: c_int = 33; - pub const SO_RCVLOWAT: c_int = 18; - pub const SO_SNDLOWAT: c_int = 19; - pub const SO_RCVTIMEO: c_int = 20; - pub const SO_SNDTIMEO: c_int = 21; - pub const SO_REUSEADDR: c_int = 2; - pub const SO_REUSEPORT: c_int = 15; + pub const SO_RCVLOWAT: c_int = libc::SO_RCVLOWAT; + pub const SO_SNDLOWAT: c_int = libc::SO_SNDLOWAT; + pub const SO_RCVTIMEO: c_int = libc::SO_RCVTIMEO; + pub const SO_SNDTIMEO: c_int = libc::SO_SNDTIMEO; + pub const SO_REUSEADDR: c_int = libc::SO_REUSEADDR; + pub const SO_REUSEPORT: c_int = libc::SO_REUSEPORT; pub const SO_RXQ_OVFL: c_int = 40; - pub const SO_SNDBUF: c_int = 7; - pub const SO_SNDBUFFORCE: c_int = 32; + pub const SO_SNDBUF: c_int = libc::SO_SNDBUF; + pub const SO_SNDBUFFORCE: c_int = libc::SO_SNDBUFFORCE; pub const SO_TIMESTAMP: c_int = 29; - pub const SO_TYPE: c_int = 3; + pub const SO_TYPE: c_int = libc::SO_TYPE; pub const SO_BUSY_POLL: c_int = 46; #[cfg(target_os = "linux")] pub const SO_ORIGINAL_DST: c_int = 80; @@ -152,7 +152,7 @@ mod os { #[cfg(any(target_os = "macos", target_os = "ios"))] pub const SYSPROTO_CONTROL: c_int = 2; - pub const SO_ACCEPTCONN: c_int = 0x0002; + pub const SO_ACCEPTCONN: c_int = libc::SO_ACCEPTCONN; pub const SO_BROADCAST: c_int = 0x0020; pub const SO_DEBUG: c_int = 0x0001; #[cfg(not(target_os = "netbsd"))] From f5ed62863d5dcaf942c12652dda45406b8a68615 Mon Sep 17 00:00:00 2001 From: Zac Berkowitz Date: Thu, 2 Mar 2017 18:45:51 +0000 Subject: [PATCH 2/4] Removed some socket constants from arch=arm --- src/sys/socket/consts.rs | 3 +++ src/sys/socket/sockopt.rs | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/sys/socket/consts.rs b/src/sys/socket/consts.rs index 8e5440e147..ba3981c27b 100644 --- a/src/sys/socket/consts.rs +++ b/src/sys/socket/consts.rs @@ -40,8 +40,10 @@ mod os { pub const SO_LINGER: c_int = libc::SO_LINGER; pub const SO_MARK: c_int = 36; pub const SO_OOBINLINE: c_int = libc::SO_OOBINLINE; + #[cfg(not(target_arch="arm"))] pub const SO_PASSCRED: c_int = libc::SO_PASSCRED; pub const SO_PEEK_OFF: c_int = 42; + #[cfg(not(target_arch="arm"))] pub const SO_PEERCRED: c_int = libc::SO_PEERCRED; pub const SO_PRIORITY: c_int = 12; pub const SO_PROTOCOL: c_int = 38; @@ -55,6 +57,7 @@ mod os { pub const SO_REUSEPORT: c_int = libc::SO_REUSEPORT; pub const SO_RXQ_OVFL: c_int = 40; pub const SO_SNDBUF: c_int = libc::SO_SNDBUF; + #[cfg(not(target_arch="arm"))] pub const SO_SNDBUFFORCE: c_int = libc::SO_SNDBUFFORCE; pub const SO_TIMESTAMP: c_int = 29; pub const SO_TYPE: c_int = libc::SO_TYPE; diff --git a/src/sys/socket/sockopt.rs b/src/sys/socket/sockopt.rs index bf17347cf3..5d33341f76 100644 --- a/src/sys/socket/sockopt.rs +++ b/src/sys/socket/sockopt.rs @@ -152,7 +152,7 @@ sockopt_impl!(Both, Broadcast, consts::SOL_SOCKET, consts::SO_BROADCAST, bool); sockopt_impl!(Both, OobInline, consts::SOL_SOCKET, consts::SO_OOBINLINE, bool); sockopt_impl!(GetOnly, SocketError, consts::SOL_SOCKET, consts::SO_ERROR, i32); sockopt_impl!(Both, KeepAlive, consts::SOL_SOCKET, consts::SO_KEEPALIVE, bool); -#[cfg(target_os = "linux")] +#[cfg(all(target_os = "linux", not(target_arch="arm")))] sockopt_impl!(GetOnly, PeerCredentials, consts::SOL_SOCKET, consts::SO_PEERCRED, super::ucred); #[cfg(any(target_os = "macos", target_os = "ios"))] @@ -167,7 +167,7 @@ sockopt_impl!(Both, RcvBuf, consts::SOL_SOCKET, consts::SO_RCVBUF, usize); sockopt_impl!(Both, SndBuf, consts::SOL_SOCKET, consts::SO_SNDBUF, usize); #[cfg(target_os = "linux")] sockopt_impl!(SetOnly, RcvBufForce, consts::SOL_SOCKET, consts::SO_RCVBUFFORCE, usize); -#[cfg(target_os = "linux")] +#[cfg(all(target_os = "linux", not(target_arch="arm")))] sockopt_impl!(SetOnly, SndBufForce, consts::SOL_SOCKET, consts::SO_SNDBUFFORCE, usize); sockopt_impl!(GetOnly, SockType, consts::SOL_SOCKET, consts::SO_TYPE, super::SockType); #[cfg(any(target_os = "freebsd", From 452f9ae9d1d5aa9aca5d153a2d92ada2bfb50a01 Mon Sep 17 00:00:00 2001 From: Zac Berkowitz Date: Thu, 2 Mar 2017 19:53:35 +0000 Subject: [PATCH 3/4] Fixed failing ioctl tests. --- test/sys/test_ioctl.rs | 32 +++++++++++++++++++++++++------- 1 file changed, 25 insertions(+), 7 deletions(-) diff --git a/test/sys/test_ioctl.rs b/test/sys/test_ioctl.rs index 1d9fbcc834..b68622d148 100644 --- a/test/sys/test_ioctl.rs +++ b/test/sys/test_ioctl.rs @@ -10,21 +10,34 @@ ioctl!(read buf readbuf_test with 0, 0; u32); ioctl!(write buf writebuf_test with 0, 0; u32); ioctl!(readwrite buf readwritebuf_test with 0, 0; u32); -// See C code for source of values for op calculations: +// See C code for source of values for op calculations (does NOT work for mips/powerpc): // https://gist.github.com/posborne/83ea6880770a1aef332e +// +// TODO: Need a way to compute these constants at test time. Using precomputed +// values is fragile and needs to be maintained. #[cfg(any(target_os = "linux", target_os = "android"))] mod linux { #[test] fn test_op_none() { - assert_eq!(io!(b'q', 10), 0x0000710A); - assert_eq!(io!(b'a', 255), 0x000061FF); + if cfg!(any(target_arch = "mips", target_arch="powerpc")){ + assert_eq!(io!(b'q', 10), 0x2000710A); + assert_eq!(io!(b'a', 255), 0x200061FF); + } else { + assert_eq!(io!(b'q', 10), 0x0000710A); + assert_eq!(io!(b'a', 255), 0x000061FF); + } } #[test] fn test_op_write() { - assert_eq!(iow!(b'z', 10, 1), 0x40017A0A); - assert_eq!(iow!(b'z', 10, 512), 0x42007A0A); + if cfg!(any(target_arch = "mips", target_arch="powerpc")){ + assert_eq!(iow!(b'z', 10, 1), 0x80017A0A); + assert_eq!(iow!(b'z', 10, 512), 0x82007A0A); + } else { + assert_eq!(iow!(b'z', 10, 1), 0x40017A0A); + assert_eq!(iow!(b'z', 10, 512), 0x42007A0A); + } } #[cfg(target_pointer_width = "64")] @@ -35,8 +48,13 @@ mod linux { #[test] fn test_op_read() { - assert_eq!(ior!(b'z', 10, 1), 0x80017A0A); - assert_eq!(ior!(b'z', 10, 512), 0x82007A0A); + if cfg!(any(target_arch = "mips", target_arch="powerpc")){ + assert_eq!(ior!(b'z', 10, 1), 0x40017A0A); + assert_eq!(ior!(b'z', 10, 512), 0x42007A0A); + } else { + assert_eq!(ior!(b'z', 10, 1), 0x80017A0A); + assert_eq!(ior!(b'z', 10, 512), 0x82007A0A); + } } #[cfg(target_pointer_width = "64")] From 1d6a27d08cf0afba8e31c31bb4ada9e704c86ee9 Mon Sep 17 00:00:00 2001 From: Zac Berkowitz Date: Sun, 5 Mar 2017 19:26:57 +0000 Subject: [PATCH 4/4] Re-enabled errorno test for not_android. --- src/errno.rs | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/src/errno.rs b/src/errno.rs index d8aaf7f3f8..a27abaa730 100644 --- a/src/errno.rs +++ b/src/errno.rs @@ -2059,15 +2059,13 @@ mod test { ENOTRECOVERABLE); } - // This test fails because MIPS does not have - // ERFKILL or EHWPOISON. - // #[test] - // #[cfg(target_os = "linux")] - // pub fn test_linux_not_android_errnos() { - // check_errno!( - // ERFKILL /*, - // EHWPOISON */); - // } + #[test] + #[cfg(all(target_os = "linux", not(target_arch = "mips")))] + pub fn test_linux_not_android_errnos() { + check_errno!( + ERFKILL /*, + EHWPOISON */); + } #[test] #[cfg(target_os = "freebsd")]