From ed32e3fc8eb447af32aaefe5ca53676ec0e0bc15 Mon Sep 17 00:00:00 2001
From: Alex Crichton <alex@alexcrichton.com>
Date: Sun, 28 Aug 2016 11:53:09 -0700
Subject: [PATCH] Add CI for mipsel-unknown-linux-musl

Download a trunk OpenWRT toolchain and verify bindings against that. Also fixup
a few stray errors today
---
 .travis.yml                                    |  3 +++
 ci/docker/mipsel-unknown-linux-musl/Dockerfile | 14 ++++++++++++++
 ci/run.sh                                      |  4 ++++
 src/unix/notbsd/linux/musl/b32/arm.rs          | 13 +++++++++++++
 src/unix/notbsd/linux/musl/b32/asmjs.rs        | 13 +++++++++++++
 src/unix/notbsd/linux/musl/b32/mips.rs         | 15 ++++++++++++++-
 src/unix/notbsd/linux/musl/b32/x86.rs          | 13 +++++++++++++
 src/unix/notbsd/linux/musl/b64/mod.rs          | 13 +++++++++++++
 src/unix/notbsd/linux/musl/mod.rs              | 12 ------------
 9 files changed, 87 insertions(+), 13 deletions(-)
 create mode 100644 ci/docker/mipsel-unknown-linux-musl/Dockerfile

diff --git a/.travis.yml b/.travis.yml
index b746d9be..d0e95910 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -79,6 +79,9 @@ matrix:
     - os: linux
       env: TARGET=powerpc64-unknown-linux-gnu
       rust: stable
+    - os: linux
+      env: TARGET=mipsel-unknown-linux-musl
+      rust: stable
 
     # beta
     - os: linux
diff --git a/ci/docker/mipsel-unknown-linux-musl/Dockerfile b/ci/docker/mipsel-unknown-linux-musl/Dockerfile
new file mode 100644
index 00000000..bf7b45b7
--- /dev/null
+++ b/ci/docker/mipsel-unknown-linux-musl/Dockerfile
@@ -0,0 +1,14 @@
+FROM ubuntu:16.04
+
+RUN apt-get update
+RUN apt-get install -y --no-install-recommends \
+        gcc libc6-dev qemu-user ca-certificates qemu-system-mips curl \
+        bzip2
+
+RUN mkdir /toolchain
+RUN curl -L https://downloads.openwrt.org/snapshots/trunk/malta/generic/OpenWrt-Toolchain-malta-le_gcc-5.3.0_musl-1.1.15.Linux-x86_64.tar.bz2 | \
+      tar xjf - -C /toolchain --strip-components=2
+
+ENV PATH=$PATH:/rust/bin:/toolchain/bin \
+    CC_mipsel_unknown_linux_musl=mipsel-openwrt-linux-gcc \
+    CARGO_TARGET_MIPSEL_UNKNOWN_LINUX_MUSL_LINKER=mipsel-openwrt-linux-gcc
diff --git a/ci/run.sh b/ci/run.sh
index eb5d94ad..4e04dddd 100755
--- a/ci/run.sh
+++ b/ci/run.sh
@@ -117,6 +117,10 @@ case "$TARGET" in
     qemu-mips -L /usr/mips-linux-gnu $CARGO_TARGET_DIR/$TARGET/debug/libc-test
     ;;
 
+  mipsel-unknown-linux-musl)
+    qemu-mipsel -L /toolchain $CARGO_TARGET_DIR/$TARGET/debug/libc-test
+    ;;
+
   powerpc-unknown-linux-gnu)
     qemu-ppc -L /usr/powerpc-linux-gnu $CARGO_TARGET_DIR/$TARGET/debug/libc-test
     ;;
diff --git a/src/unix/notbsd/linux/musl/b32/arm.rs b/src/unix/notbsd/linux/musl/b32/arm.rs
index 5d648618..2f27e311 100644
--- a/src/unix/notbsd/linux/musl/b32/arm.rs
+++ b/src/unix/notbsd/linux/musl/b32/arm.rs
@@ -82,6 +82,14 @@ s! {
         pub f_flags: ::c_ulong,
         pub f_spare: [::c_ulong; 4],
     }
+
+    pub struct siginfo_t {
+        pub si_signo: ::c_int,
+        pub si_errno: ::c_int,
+        pub si_code: ::c_int,
+        pub _pad: [::c_int; 29],
+        _align: [usize; 0],
+    }
 }
 
 pub const O_DIRECT: ::c_int = 0x4000;
@@ -306,3 +314,8 @@ pub const TIOCCONS: ::c_int = 0x541D;
 
 pub const SYS_gettid: ::c_long = 224;
 pub const SYS_perf_event_open: ::c_long = 364;
+
+pub const POSIX_MADV_DONTNEED: ::c_int = 0;
+pub const RUSAGE_CHILDREN: ::c_int = 1;
+pub const POLLWRNORM: ::c_short = 0x100;
+pub const POLLWRBAND: ::c_short = 0x200;
diff --git a/src/unix/notbsd/linux/musl/b32/asmjs.rs b/src/unix/notbsd/linux/musl/b32/asmjs.rs
index 93e4ab6b..991196c2 100644
--- a/src/unix/notbsd/linux/musl/b32/asmjs.rs
+++ b/src/unix/notbsd/linux/musl/b32/asmjs.rs
@@ -82,6 +82,14 @@ s! {
         pub f_flags: ::c_ulong,
         pub f_spare: [::c_ulong; 4],
     }
+
+    pub struct siginfo_t {
+        pub si_signo: ::c_int,
+        pub si_errno: ::c_int,
+        pub si_code: ::c_int,
+        pub _pad: [::c_int; 29],
+        _align: [usize; 0],
+    }
 }
 
 pub const O_DIRECT: ::c_int = 0x4000;
@@ -305,3 +313,8 @@ pub const FIONREAD: ::c_int = 0x541B;
 pub const TIOCCONS: ::c_int = 0x541D;
 
 pub const SYS_gettid: ::c_long = 224; // Valid for arm (32-bit) and x86 (32-bit)
+
+pub const POSIX_MADV_DONTNEED: ::c_int = 0;
+pub const RUSAGE_CHILDREN: ::c_int = 1;
+pub const POLLWRNORM: ::c_short = 0x100;
+pub const POLLWRBAND: ::c_short = 0x200;
diff --git a/src/unix/notbsd/linux/musl/b32/mips.rs b/src/unix/notbsd/linux/musl/b32/mips.rs
index f52d1953..88542c45 100644
--- a/src/unix/notbsd/linux/musl/b32/mips.rs
+++ b/src/unix/notbsd/linux/musl/b32/mips.rs
@@ -81,6 +81,14 @@ s! {
         pub f_flags: ::c_ulong,
         pub f_spare: [::c_ulong; 5],
     }
+
+    pub struct siginfo_t {
+        pub si_signo: ::c_int,
+        pub si_code: ::c_int,
+        pub si_errno: ::c_int,
+        pub _pad: [::c_int; 29],
+        _align: [usize; 0],
+    }
 }
 
 pub const O_DIRECT: ::c_int = 0o100000;
@@ -299,9 +307,14 @@ pub const TIOCSWINSZ: ::c_int = 0x80087467;
 pub const TIOCMGET: ::c_int = 0x741D;
 pub const TIOCMBIS: ::c_int = 0x741B;
 pub const TIOCMBIC: ::c_int = 0x741C;
-pub const TIOCMSET: ::c_int = 0x741D;
+pub const TIOCMSET: ::c_int = 0x741A;
 pub const FIONREAD: ::c_int = 0x467F;
 pub const TIOCCONS: ::c_int = 0x80047478;
 
 pub const SYS_gettid: ::c_long = 4222;   // Valid for O32
 pub const SYS_perf_event_open: ::c_long = 4333;  // Valid for O32
+
+pub const POSIX_MADV_DONTNEED: ::c_int = 4;
+pub const RUSAGE_CHILDREN: ::c_int = !0;
+pub const POLLWRNORM: ::c_short = 0x4;
+pub const POLLWRBAND: ::c_short = 0x100;
diff --git a/src/unix/notbsd/linux/musl/b32/x86.rs b/src/unix/notbsd/linux/musl/b32/x86.rs
index 9d057de7..593c37a2 100644
--- a/src/unix/notbsd/linux/musl/b32/x86.rs
+++ b/src/unix/notbsd/linux/musl/b32/x86.rs
@@ -95,6 +95,14 @@ s! {
         pub uc_sigmask: ::sigset_t,
         __private: [u8; 112],
     }
+
+    pub struct siginfo_t {
+        pub si_signo: ::c_int,
+        pub si_errno: ::c_int,
+        pub si_code: ::c_int,
+        pub _pad: [::c_int; 29],
+        _align: [usize; 0],
+    }
 }
 
 pub const O_DIRECT: ::c_int = 0x4000;
@@ -320,3 +328,8 @@ pub const TIOCCONS: ::c_int = 0x541D;
 
 pub const SYS_gettid: ::c_long = 224;
 pub const SYS_perf_event_open: ::c_long = 336;
+
+pub const POSIX_MADV_DONTNEED: ::c_int = 0;
+pub const RUSAGE_CHILDREN: ::c_int = 1;
+pub const POLLWRNORM: ::c_short = 0x100;
+pub const POLLWRBAND: ::c_short = 0x200;
diff --git a/src/unix/notbsd/linux/musl/b64/mod.rs b/src/unix/notbsd/linux/musl/b64/mod.rs
index afe41fad..227bffa1 100644
--- a/src/unix/notbsd/linux/musl/b64/mod.rs
+++ b/src/unix/notbsd/linux/musl/b64/mod.rs
@@ -103,6 +103,14 @@ s! {
     pub struct sem_t {
         __val: [::c_int; 8],
     }
+
+    pub struct siginfo_t {
+        pub si_signo: ::c_int,
+        pub si_errno: ::c_int,
+        pub si_code: ::c_int,
+        pub _pad: [::c_int; 29],
+        _align: [usize; 0],
+    }
 }
 
 pub const __SIZEOF_PTHREAD_RWLOCK_T: usize = 56;
@@ -329,6 +337,11 @@ pub const TIOCMSET: ::c_int = 0x5418;
 pub const FIONREAD: ::c_int = 0x541B;
 pub const TIOCCONS: ::c_int = 0x541D;
 
+pub const POSIX_MADV_DONTNEED: ::c_int = 0;
+pub const RUSAGE_CHILDREN: ::c_int = 1;
+pub const POLLWRNORM: ::c_short = 0x100;
+pub const POLLWRBAND: ::c_short = 0x200;
+
 cfg_if! {
     if #[cfg(target_arch = "aarch64")] {
         mod aarch64;
diff --git a/src/unix/notbsd/linux/musl/mod.rs b/src/unix/notbsd/linux/musl/mod.rs
index c8c52a1b..b9fb3d42 100644
--- a/src/unix/notbsd/linux/musl/mod.rs
+++ b/src/unix/notbsd/linux/musl/mod.rs
@@ -18,14 +18,6 @@ s! {
         _restorer: *mut ::c_void,
     }
 
-    pub struct siginfo_t {
-        pub si_signo: ::c_int,
-        pub si_errno: ::c_int,
-        pub si_code: ::c_int,
-        pub _pad: [::c_int; 29],
-        _align: [usize; 0],
-    }
-
     pub struct ipc_perm {
         pub __ipc_perm_key: ::key_t,
         pub uid: ::uid_t,
@@ -78,10 +70,8 @@ s! {
 pub const BUFSIZ: ::c_uint = 1024;
 pub const TMP_MAX: ::c_uint = 10000;
 pub const FOPEN_MAX: ::c_uint = 1000;
-pub const POSIX_MADV_DONTNEED: ::c_int = 0;
 pub const O_ACCMODE: ::c_int = 0o10000003;
 pub const O_NDELAY: ::c_int = O_NONBLOCK;
-pub const RUSAGE_CHILDREN: ::c_int = 1;
 pub const NI_MAXHOST: ::socklen_t = 255;
 pub const PTHREAD_STACK_MIN: ::size_t = 2048;
 
@@ -154,9 +144,7 @@ pub const MADV_DONTDUMP: ::c_int = 16;
 pub const EPOLLWAKEUP: ::c_int = 0x20000000;
 
 pub const POLLRDNORM: ::c_short = 0x040;
-pub const POLLWRNORM: ::c_short = 0x100;
 pub const POLLRDBAND: ::c_short = 0x080;
-pub const POLLWRBAND: ::c_short = 0x200;
 
 pub const MADV_HUGEPAGE: ::c_int = 14;
 pub const MADV_NOHUGEPAGE: ::c_int = 15;
-- 
GitLab