diff --git a/src/unix/notbsd/linux/mips/mips32.rs b/src/unix/notbsd/linux/mips/mips32.rs
new file mode 100644
index 0000000000000000000000000000000000000000..8b9c5ca767a49d8d0d40b27540c0fd072dd8cf85
--- /dev/null
+++ b/src/unix/notbsd/linux/mips/mips32.rs
@@ -0,0 +1,281 @@
+pub type c_char = i8;
+pub type c_long = i32;
+pub type c_ulong = u32;
+pub type clock_t = i32;
+pub type time_t = i32;
+pub type suseconds_t = i32;
+pub type wchar_t = i32;
+pub type off_t = i32;
+pub type ino_t = u32;
+pub type blkcnt_t = i32;
+pub type blksize_t = i32;
+pub type nlink_t = u32;
+pub type fsblkcnt_t = ::c_ulong;
+pub type fsfilcnt_t = ::c_ulong;
+pub type rlim_t = c_ulong;
+
+s! {
+    pub struct aiocb {
+        pub aio_fildes: ::c_int,
+        pub aio_lio_opcode: ::c_int,
+        pub aio_reqprio: ::c_int,
+        pub aio_buf: *mut ::c_void,
+        pub aio_nbytes: ::size_t,
+        pub aio_sigevent: ::sigevent,
+        __next_prio: *mut aiocb,
+        __abs_prio: ::c_int,
+        __policy: ::c_int,
+        __error_code: ::c_int,
+        __return_value: ::ssize_t,
+        pub aio_offset: off_t,
+        __unused1: [::c_char; 4],
+        __glibc_reserved: [::c_char; 32]
+    }
+
+    pub struct stat {
+        pub st_dev: ::c_ulong,
+        st_pad1: [::c_long; 3],
+        pub st_ino: ::ino_t,
+        pub st_mode: ::mode_t,
+        pub st_nlink: ::nlink_t,
+        pub st_uid: ::uid_t,
+        pub st_gid: ::gid_t,
+        pub st_rdev: ::c_ulong,
+        pub st_pad2: [::c_long; 2],
+        pub st_size: ::off_t,
+        st_pad3: ::c_long,
+        pub st_atime: ::time_t,
+        pub st_atime_nsec: ::c_long,
+        pub st_mtime: ::time_t,
+        pub st_mtime_nsec: ::c_long,
+        pub st_ctime: ::time_t,
+        pub st_ctime_nsec: ::c_long,
+        pub st_blksize: ::blksize_t,
+        pub st_blocks: ::blkcnt_t,
+        st_pad5: [::c_long; 14],
+    }
+
+    pub struct stat64 {
+        pub st_dev: ::c_ulong,
+        st_pad1: [::c_long; 3],
+        pub st_ino: ::ino64_t,
+        pub st_mode: ::mode_t,
+        pub st_nlink: ::nlink_t,
+        pub st_uid: ::uid_t,
+        pub st_gid: ::gid_t,
+        pub st_rdev: ::c_ulong,
+        st_pad2: [::c_long; 2],
+        pub st_size: ::off64_t,
+        pub st_atime: ::time_t,
+        pub st_atime_nsec: ::c_long,
+        pub st_mtime: ::time_t,
+        pub st_mtime_nsec: ::c_long,
+        pub st_ctime: ::time_t,
+        pub st_ctime_nsec: ::c_long,
+        pub st_blksize: ::blksize_t,
+        st_pad3: ::c_long,
+        pub st_blocks: ::blkcnt64_t,
+        st_pad5: [::c_long; 14],
+    }
+
+    pub struct pthread_attr_t {
+        __size: [u32; 9]
+    }
+
+    pub struct sigaction {
+        pub sa_flags: ::c_int,
+        pub sa_sigaction: ::sighandler_t,
+        pub sa_mask: sigset_t,
+        _restorer: *mut ::c_void,
+        _resv: [::c_int; 1],
+    }
+
+    pub struct stack_t {
+        pub ss_sp: *mut ::c_void,
+        pub ss_size: ::size_t,
+        pub ss_flags: ::c_int,
+    }
+
+    pub struct sigset_t {
+        __val: [::c_ulong; 32],
+    }
+
+    pub struct siginfo_t {
+        pub si_signo: ::c_int,
+        pub si_code: ::c_int,
+        pub si_errno: ::c_int,
+        pub _pad: [::c_int; 29],
+    }
+
+    pub struct glob64_t {
+        pub gl_pathc: ::size_t,
+        pub gl_pathv: *mut *mut ::c_char,
+        pub gl_offs: ::size_t,
+        pub gl_flags: ::c_int,
+
+        __unused1: *mut ::c_void,
+        __unused2: *mut ::c_void,
+        __unused3: *mut ::c_void,
+        __unused4: *mut ::c_void,
+        __unused5: *mut ::c_void,
+    }
+
+    pub struct ipc_perm {
+        pub __key: ::key_t,
+        pub uid: ::uid_t,
+        pub gid: ::gid_t,
+        pub cuid: ::uid_t,
+        pub cgid: ::gid_t,
+        pub mode: ::c_uint,
+        pub __seq: ::c_ushort,
+        __pad1: ::c_ushort,
+        __unused1: ::c_ulong,
+        __unused2: ::c_ulong
+    }
+
+    pub struct shmid_ds {
+        pub shm_perm: ::ipc_perm,
+        pub shm_segsz: ::size_t,
+        pub shm_atime: ::time_t,
+        pub shm_dtime: ::time_t,
+        pub shm_ctime: ::time_t,
+        pub shm_cpid: ::pid_t,
+        pub shm_lpid: ::pid_t,
+        pub shm_nattch: ::shmatt_t,
+        __unused4: ::c_ulong,
+        __unused5: ::c_ulong
+    }
+
+    pub struct msqid_ds {
+        pub msg_perm: ::ipc_perm,
+        #[cfg(target_endian = "big")]
+        __glibc_reserved1: ::c_ulong,
+        pub msg_stime: ::time_t,
+        #[cfg(target_endian = "little")]
+        __glibc_reserved1: ::c_ulong,
+        #[cfg(target_endian = "big")]
+        __glibc_reserved2: ::c_ulong,
+        pub msg_rtime: ::time_t,
+        #[cfg(target_endian = "little")]
+        __glibc_reserved2: ::c_ulong,
+        #[cfg(target_endian = "big")]
+        __glibc_reserved3: ::c_ulong,
+        pub msg_ctime: ::time_t,
+        #[cfg(target_endian = "little")]
+        __glibc_reserved3: ::c_ulong,
+        __msg_cbytes: ::c_ulong,
+        pub msg_qnum: ::msgqnum_t,
+        pub msg_qbytes: ::msglen_t,
+        pub msg_lspid: ::pid_t,
+        pub msg_lrpid: ::pid_t,
+        __glibc_reserved4: ::c_ulong,
+        __glibc_reserved5: ::c_ulong,
+    }
+
+    pub struct statfs {
+        pub f_type: ::c_long,
+        pub f_bsize: ::c_long,
+        pub f_frsize: ::c_long,
+        pub f_blocks: ::fsblkcnt_t,
+        pub f_bfree: ::fsblkcnt_t,
+        pub f_files: ::fsblkcnt_t,
+        pub f_ffree: ::fsblkcnt_t,
+        pub f_bavail: ::fsblkcnt_t,
+        pub f_fsid: ::fsid_t,
+
+        pub f_namelen: ::c_long,
+        f_spare: [::c_long; 6],
+    }
+
+    pub struct msghdr {
+        pub msg_name: *mut ::c_void,
+        pub msg_namelen: ::socklen_t,
+        pub msg_iov: *mut ::iovec,
+        pub msg_iovlen: ::size_t,
+        pub msg_control: *mut ::c_void,
+        pub msg_controllen: ::size_t,
+        pub msg_flags: ::c_int,
+    }
+
+    pub struct termios {
+        pub c_iflag: ::tcflag_t,
+        pub c_oflag: ::tcflag_t,
+        pub c_cflag: ::tcflag_t,
+        pub c_lflag: ::tcflag_t,
+        pub c_line: ::cc_t,
+        pub c_cc: [::cc_t; ::NCCS],
+    }
+
+    pub struct flock {
+        pub l_type: ::c_short,
+        pub l_whence: ::c_short,
+        pub l_start: ::off_t,
+        pub l_len: ::off_t,
+        pub l_sysid: ::c_long,
+        pub l_pid: ::pid_t,
+        pad: [::c_long; 4],
+    }
+
+    pub struct sysinfo {
+        pub uptime: ::c_long,
+        pub loads: [::c_ulong; 3],
+        pub totalram: ::c_ulong,
+        pub freeram: ::c_ulong,
+        pub sharedram: ::c_ulong,
+        pub bufferram: ::c_ulong,
+        pub totalswap: ::c_ulong,
+        pub freeswap: ::c_ulong,
+        pub procs: ::c_ushort,
+        pub pad: ::c_ushort,
+        pub totalhigh: ::c_ulong,
+        pub freehigh: ::c_ulong,
+        pub mem_unit: ::c_uint,
+        pub _f: [::c_char; 8],
+    }
+
+    // FIXME this is actually a union
+    pub struct sem_t {
+        #[cfg(target_pointer_width = "32")]
+        __size: [::c_char; 16],
+        #[cfg(target_pointer_width = "64")]
+        __size: [::c_char; 32],
+        __align: [::c_long; 0],
+    }
+}
+
+pub const __SIZEOF_PTHREAD_CONDATTR_T: usize = 4;
+pub const __SIZEOF_PTHREAD_MUTEX_T: usize = 24;
+pub const __SIZEOF_PTHREAD_RWLOCK_T: usize = 32;
+pub const __SIZEOF_PTHREAD_MUTEXATTR_T: usize = 4;
+
+pub const RLIM_INFINITY: ::rlim_t = 0x7fffffff;
+
+pub const SYS_gettid: ::c_long = 4222;   // Valid for O32
+
+#[link(name = "util")]
+extern {
+    pub fn sysctl(name: *mut ::c_int,
+                  namelen: ::c_int,
+                  oldp: *mut ::c_void,
+                  oldlenp: *mut ::size_t,
+                  newp: *mut ::c_void,
+                  newlen: ::size_t)
+                  -> ::c_int;
+    pub fn ioctl(fd: ::c_int, request: ::c_ulong, ...) -> ::c_int;
+    pub fn backtrace(buf: *mut *mut ::c_void,
+                     sz: ::c_int) -> ::c_int;
+    pub fn glob64(pattern: *const ::c_char,
+                  flags: ::c_int,
+                  errfunc: ::dox::Option<extern fn(epath: *const ::c_char,
+                                                   errno: ::c_int)
+                                                   -> ::c_int>,
+                  pglob: *mut glob64_t) -> ::c_int;
+    pub fn globfree64(pglob: *mut glob64_t);
+    pub fn ptrace(request: ::c_uint, ...) -> ::c_long;
+    pub fn pthread_attr_getaffinity_np(attr: *const ::pthread_attr_t,
+                                       cpusetsize: ::size_t,
+                                       cpuset: *mut ::cpu_set_t) -> ::c_int;
+    pub fn pthread_attr_setaffinity_np(attr: *mut ::pthread_attr_t,
+                                       cpusetsize: ::size_t,
+                                       cpuset: *const ::cpu_set_t) -> ::c_int;
+}
diff --git a/src/unix/notbsd/linux/mips64.rs b/src/unix/notbsd/linux/mips/mips64.rs
similarity index 78%
rename from src/unix/notbsd/linux/mips64.rs
rename to src/unix/notbsd/linux/mips/mips64.rs
index 505e82c6f839dff5a7f3fbfca6e3c3f9960c065c..71dfb71d4985768cf636faeb7ecceece0ba6f038 100644
--- a/src/unix/notbsd/linux/mips64.rs
+++ b/src/unix/notbsd/linux/mips/mips64.rs
@@ -209,46 +209,9 @@ pub const __SIZEOF_PTHREAD_MUTEXATTR_T: usize = 4;
 pub const __SIZEOF_PTHREAD_MUTEX_T: usize = 40;
 pub const __SIZEOF_PTHREAD_RWLOCK_T: usize = 56;
 
-pub const EADDRINUSE: ::c_int = 125;
-pub const EADDRNOTAVAIL: ::c_int = 126;
-pub const ECONNABORTED: ::c_int = 130;
-pub const ECONNREFUSED: ::c_int = 146;
-pub const ECONNRESET: ::c_int = 131;
-pub const EDEADLK: ::c_int = 45;
-pub const ENOSYS: ::c_int = 89;
-pub const ENOTCONN: ::c_int = 134;
-pub const ETIMEDOUT: ::c_int = 145;
-pub const FIOCLEX: ::c_ulong = 0x6601;
-pub const FIONBIO: ::c_ulong = 0x667e;
-pub const MAP_ANON: ::c_int = 0x800;
-pub const O_ACCMODE: ::c_int = 3;
-pub const O_APPEND: ::c_int = 8;
-pub const O_CREAT: ::c_int = 256;
-pub const O_EXCL: ::c_int = 1024;
-pub const O_NONBLOCK: ::c_int = 128;
-pub const POSIX_FADV_DONTNEED: ::c_int = 4;
-pub const POSIX_FADV_NOREUSE: ::c_int = 5;
-pub const PTHREAD_STACK_MIN: ::size_t = 131072;
-pub const NFS_SUPER_MAGIC: ::c_long = 0x00006969;
-pub const RLIM_INFINITY: ::rlim_t = 0xffffffffffffffff;
-pub const SA_ONSTACK: ::c_int = 0x08000000;
-pub const SA_SIGINFO: ::c_int = 0x00000008;
-pub const SIGBUS: ::c_int = 10;
-pub const SIGSYS: ::c_int = 12;
-pub const SIGSTKSZ: ::size_t = 0x2000;
-pub const SIG_SETMASK: ::c_int = 3;
-pub const SOCK_DGRAM: ::c_int = 1;
-pub const SOCK_STREAM: ::c_int = 2;
-pub const SOL_SOCKET: ::c_int = 0xffff;
-pub const SO_BROADCAST: ::c_int = 32;
-pub const SO_ERROR: ::c_int = 4103;
-pub const SO_RCVTIMEO: ::c_int = 4102;
-pub const SO_REUSEADDR: ::c_int = 4;
-pub const SO_SNDTIMEO: ::c_int = 4101;
-pub const SO_REUSEPORT: ::c_int = 0x200;
-pub const SO_SNDBUF: ::c_int = 4097;
-pub const SO_RCVBUF: ::c_int = 4098;
-pub const SO_KEEPALIVE: ::c_int = 8;
+pub const RLIM_INFINITY: ::rlim_t = 0xffff_ffff_ffff_ffff;
+
+pub const SYS_gettid: ::c_long = 5178;   // Valid for n64
 
 #[link(name = "util")]
 extern {
diff --git a/src/unix/notbsd/linux/mips.rs b/src/unix/notbsd/linux/mips/mod.rs
similarity index 63%
rename from src/unix/notbsd/linux/mips.rs
rename to src/unix/notbsd/linux/mips/mod.rs
index ef0496b54cd3fa7eb91c85c3ab17cfdc68a16ae5..7952e3a40d70e9f36e73da40b753156e2d20db0d 100644
--- a/src/unix/notbsd/linux/mips.rs
+++ b/src/unix/notbsd/linux/mips/mod.rs
@@ -1,248 +1,3 @@
-pub type c_char = i8;
-pub type c_long = i32;
-pub type c_ulong = u32;
-pub type clock_t = i32;
-pub type time_t = i32;
-pub type suseconds_t = i32;
-pub type wchar_t = i32;
-pub type off_t = i32;
-pub type ino_t = u32;
-pub type blkcnt_t = i32;
-pub type blksize_t = i32;
-pub type nlink_t = u32;
-pub type fsblkcnt_t = ::c_ulong;
-pub type fsfilcnt_t = ::c_ulong;
-pub type rlim_t = c_ulong;
-
-s! {
-    pub struct aiocb {
-        pub aio_fildes: ::c_int,
-        pub aio_lio_opcode: ::c_int,
-        pub aio_reqprio: ::c_int,
-        pub aio_buf: *mut ::c_void,
-        pub aio_nbytes: ::size_t,
-        pub aio_sigevent: ::sigevent,
-        __next_prio: *mut aiocb,
-        __abs_prio: ::c_int,
-        __policy: ::c_int,
-        __error_code: ::c_int,
-        __return_value: ::ssize_t,
-        pub aio_offset: off_t,
-        __unused1: [::c_char; 4],
-        __glibc_reserved: [::c_char; 32]
-    }
-
-    pub struct stat {
-        pub st_dev: ::c_ulong,
-        st_pad1: [::c_long; 3],
-        pub st_ino: ::ino_t,
-        pub st_mode: ::mode_t,
-        pub st_nlink: ::nlink_t,
-        pub st_uid: ::uid_t,
-        pub st_gid: ::gid_t,
-        pub st_rdev: ::c_ulong,
-        pub st_pad2: [::c_long; 2],
-        pub st_size: ::off_t,
-        st_pad3: ::c_long,
-        pub st_atime: ::time_t,
-        pub st_atime_nsec: ::c_long,
-        pub st_mtime: ::time_t,
-        pub st_mtime_nsec: ::c_long,
-        pub st_ctime: ::time_t,
-        pub st_ctime_nsec: ::c_long,
-        pub st_blksize: ::blksize_t,
-        pub st_blocks: ::blkcnt_t,
-        st_pad5: [::c_long; 14],
-    }
-
-    pub struct stat64 {
-        pub st_dev: ::c_ulong,
-        st_pad1: [::c_long; 3],
-        pub st_ino: ::ino64_t,
-        pub st_mode: ::mode_t,
-        pub st_nlink: ::nlink_t,
-        pub st_uid: ::uid_t,
-        pub st_gid: ::gid_t,
-        pub st_rdev: ::c_ulong,
-        st_pad2: [::c_long; 2],
-        pub st_size: ::off64_t,
-        pub st_atime: ::time_t,
-        pub st_atime_nsec: ::c_long,
-        pub st_mtime: ::time_t,
-        pub st_mtime_nsec: ::c_long,
-        pub st_ctime: ::time_t,
-        pub st_ctime_nsec: ::c_long,
-        pub st_blksize: ::blksize_t,
-        st_pad3: ::c_long,
-        pub st_blocks: ::blkcnt64_t,
-        st_pad5: [::c_long; 14],
-    }
-
-    pub struct pthread_attr_t {
-        __size: [u32; 9]
-    }
-
-    pub struct sigaction {
-        pub sa_flags: ::c_int,
-        pub sa_sigaction: ::sighandler_t,
-        pub sa_mask: sigset_t,
-        _restorer: *mut ::c_void,
-        _resv: [::c_int; 1],
-    }
-
-    pub struct stack_t {
-        pub ss_sp: *mut ::c_void,
-        pub ss_size: ::size_t,
-        pub ss_flags: ::c_int,
-    }
-
-    pub struct sigset_t {
-        __val: [::c_ulong; 32],
-    }
-
-    pub struct siginfo_t {
-        pub si_signo: ::c_int,
-        pub si_code: ::c_int,
-        pub si_errno: ::c_int,
-        pub _pad: [::c_int; 29],
-    }
-
-    pub struct glob64_t {
-        pub gl_pathc: ::size_t,
-        pub gl_pathv: *mut *mut ::c_char,
-        pub gl_offs: ::size_t,
-        pub gl_flags: ::c_int,
-
-        __unused1: *mut ::c_void,
-        __unused2: *mut ::c_void,
-        __unused3: *mut ::c_void,
-        __unused4: *mut ::c_void,
-        __unused5: *mut ::c_void,
-    }
-
-    pub struct ipc_perm {
-        pub __key: ::key_t,
-        pub uid: ::uid_t,
-        pub gid: ::gid_t,
-        pub cuid: ::uid_t,
-        pub cgid: ::gid_t,
-        pub mode: ::c_uint,
-        pub __seq: ::c_ushort,
-        __pad1: ::c_ushort,
-        __unused1: ::c_ulong,
-        __unused2: ::c_ulong
-    }
-
-    pub struct shmid_ds {
-        pub shm_perm: ::ipc_perm,
-        pub shm_segsz: ::size_t,
-        pub shm_atime: ::time_t,
-        pub shm_dtime: ::time_t,
-        pub shm_ctime: ::time_t,
-        pub shm_cpid: ::pid_t,
-        pub shm_lpid: ::pid_t,
-        pub shm_nattch: ::shmatt_t,
-        __unused4: ::c_ulong,
-        __unused5: ::c_ulong
-    }
-
-    pub struct msqid_ds {
-        pub msg_perm: ::ipc_perm,
-        #[cfg(target_endian = "big")]
-        __glibc_reserved1: ::c_ulong,
-        pub msg_stime: ::time_t,
-        #[cfg(target_endian = "little")]
-        __glibc_reserved1: ::c_ulong,
-        #[cfg(target_endian = "big")]
-        __glibc_reserved2: ::c_ulong,
-        pub msg_rtime: ::time_t,
-        #[cfg(target_endian = "little")]
-        __glibc_reserved2: ::c_ulong,
-        #[cfg(target_endian = "big")]
-        __glibc_reserved3: ::c_ulong,
-        pub msg_ctime: ::time_t,
-        #[cfg(target_endian = "little")]
-        __glibc_reserved3: ::c_ulong,
-        __msg_cbytes: ::c_ulong,
-        pub msg_qnum: ::msgqnum_t,
-        pub msg_qbytes: ::msglen_t,
-        pub msg_lspid: ::pid_t,
-        pub msg_lrpid: ::pid_t,
-        __glibc_reserved4: ::c_ulong,
-        __glibc_reserved5: ::c_ulong,
-    }
-
-    pub struct statfs {
-        pub f_type: ::c_long,
-        pub f_bsize: ::c_long,
-        pub f_frsize: ::c_long,
-        pub f_blocks: ::fsblkcnt_t,
-        pub f_bfree: ::fsblkcnt_t,
-        pub f_files: ::fsblkcnt_t,
-        pub f_ffree: ::fsblkcnt_t,
-        pub f_bavail: ::fsblkcnt_t,
-        pub f_fsid: ::fsid_t,
-
-        pub f_namelen: ::c_long,
-        f_spare: [::c_long; 6],
-    }
-
-    pub struct msghdr {
-        pub msg_name: *mut ::c_void,
-        pub msg_namelen: ::socklen_t,
-        pub msg_iov: *mut ::iovec,
-        pub msg_iovlen: ::size_t,
-        pub msg_control: *mut ::c_void,
-        pub msg_controllen: ::size_t,
-        pub msg_flags: ::c_int,
-    }
-
-    pub struct termios {
-        pub c_iflag: ::tcflag_t,
-        pub c_oflag: ::tcflag_t,
-        pub c_cflag: ::tcflag_t,
-        pub c_lflag: ::tcflag_t,
-        pub c_line: ::cc_t,
-        pub c_cc: [::cc_t; ::NCCS],
-    }
-
-    pub struct flock {
-        pub l_type: ::c_short,
-        pub l_whence: ::c_short,
-        pub l_start: ::off_t,
-        pub l_len: ::off_t,
-        pub l_sysid: ::c_long,
-        pub l_pid: ::pid_t,
-        pad: [::c_long; 4],
-    }
-
-    pub struct sysinfo {
-        pub uptime: ::c_long,
-        pub loads: [::c_ulong; 3],
-        pub totalram: ::c_ulong,
-        pub freeram: ::c_ulong,
-        pub sharedram: ::c_ulong,
-        pub bufferram: ::c_ulong,
-        pub totalswap: ::c_ulong,
-        pub freeswap: ::c_ulong,
-        pub procs: ::c_ushort,
-        pub pad: ::c_ushort,
-        pub totalhigh: ::c_ulong,
-        pub freehigh: ::c_ulong,
-        pub mem_unit: ::c_uint,
-        pub _f: [::c_char; 8],
-    }
-
-    // FIXME this is actually a union
-    pub struct sem_t {
-        #[cfg(target_pointer_width = "32")]
-        __size: [::c_char; 16],
-        #[cfg(target_pointer_width = "64")]
-        __size: [::c_char; 32],
-        __align: [::c_long; 0],
-    }
-}
-
 pub const BUFSIZ: ::c_uint = 8192;
 pub const TMP_MAX: ::c_uint = 238328;
 pub const FOPEN_MAX: ::c_uint = 16;
@@ -263,7 +18,6 @@ pub const RLIMIT_RSS: ::c_int = 7;
 pub const RLIMIT_NPROC: ::c_int = 8;
 pub const RLIMIT_MEMLOCK: ::c_int = 9;
 pub const RLIMIT_NLIMITS: ::c_int = 16;
-pub const RLIM_INFINITY: ::rlim_t = 0x7fffffff;
 
 pub const O_APPEND: ::c_int = 8;
 pub const O_CREAT: ::c_int = 256;
@@ -423,11 +177,6 @@ pub const SO_RCVTIMEO: ::c_int = 4102;
 pub const SO_SNDTIMEO: ::c_int = 4101;
 pub const SO_ACCEPTCONN: ::c_int = 4105;
 
-pub const __SIZEOF_PTHREAD_CONDATTR_T: usize = 4;
-pub const __SIZEOF_PTHREAD_MUTEX_T: usize = 24;
-pub const __SIZEOF_PTHREAD_RWLOCK_T: usize = 32;
-pub const __SIZEOF_PTHREAD_MUTEXATTR_T: usize = 4;
-
 pub const FIOCLEX: ::c_ulong = 0x6601;
 pub const FIONBIO: ::c_ulong = 0x667e;
 
@@ -593,8 +342,6 @@ pub const LINUX_REBOOT_CMD_RESTART2: ::c_int = 0xA1B2C3D4;
 pub const LINUX_REBOOT_CMD_SW_SUSPEND: ::c_int = 0xD000FCE2;
 pub const LINUX_REBOOT_CMD_KEXEC: ::c_int = 0x45584543;
 
-pub const SYS_gettid: ::c_long = 4222;   // Valid for O32
-
 pub const MCL_CURRENT: ::c_int = 0x0001;
 pub const MCL_FUTURE: ::c_int = 0x0002;
 
@@ -640,30 +387,14 @@ pub const ICANON: ::tcflag_t = 0x00000002;
 pub const PENDIN: ::tcflag_t = 0x00004000;
 pub const NOFLSH: ::tcflag_t = 0x00000080;
 
-#[link(name = "util")]
-extern {
-    pub fn sysctl(name: *mut ::c_int,
-                  namelen: ::c_int,
-                  oldp: *mut ::c_void,
-                  oldlenp: *mut ::size_t,
-                  newp: *mut ::c_void,
-                  newlen: ::size_t)
-                  -> ::c_int;
-    pub fn ioctl(fd: ::c_int, request: ::c_ulong, ...) -> ::c_int;
-    pub fn backtrace(buf: *mut *mut ::c_void,
-                     sz: ::c_int) -> ::c_int;
-    pub fn glob64(pattern: *const ::c_char,
-                  flags: ::c_int,
-                  errfunc: ::dox::Option<extern fn(epath: *const ::c_char,
-                                                   errno: ::c_int)
-                                                   -> ::c_int>,
-                  pglob: *mut glob64_t) -> ::c_int;
-    pub fn globfree64(pglob: *mut glob64_t);
-    pub fn ptrace(request: ::c_uint, ...) -> ::c_long;
-    pub fn pthread_attr_getaffinity_np(attr: *const ::pthread_attr_t,
-                                       cpusetsize: ::size_t,
-                                       cpuset: *mut ::cpu_set_t) -> ::c_int;
-    pub fn pthread_attr_setaffinity_np(attr: *mut ::pthread_attr_t,
-                                       cpusetsize: ::size_t,
-                                       cpuset: *const ::cpu_set_t) -> ::c_int;
+cfg_if! {
+    if #[cfg(target_arch = "mips")] {
+        mod mips32;
+        pub use self::mips32::*;
+    } else if #[cfg(target_arch = "mips64")] {
+        mod mips64;
+        pub use self::mips64::*;
+    } else {
+        // Unknown target_arch
+    }
 }
diff --git a/src/unix/notbsd/linux/mod.rs b/src/unix/notbsd/linux/mod.rs
index 6da20d0f4702100be08019b91380c0217a03b428..08efed2ea0b5b17738d7b3620b7237fdf9eb303f 100644
--- a/src/unix/notbsd/linux/mod.rs
+++ b/src/unix/notbsd/linux/mod.rs
@@ -756,15 +756,13 @@ cfg_if! {
                  target_os = "emscripten"))] {
         mod musl;
         pub use self::musl::*;
-    } else if #[cfg(any(target_arch = "mips"))] {
+    } else if #[cfg(any(target_arch = "mips",
+                        target_arch = "mips64"))] {
         mod mips;
         pub use self::mips::*;
     } else if #[cfg(any(target_arch = "s390x"))] {
         mod s390x;
         pub use self::s390x::*;
-    } else if #[cfg(any(target_arch = "mips64"))] {
-        mod mips64;
-        pub use self::mips64::*;
     } else {
         mod other;
         pub use self::other::*;