From f04b44292e70c26b5934bd1fd186543d7321934c Mon Sep 17 00:00:00 2001
From: Bryant Mairs <bryant@mai.rs>
Date: Tue, 11 Jul 2017 23:17:15 -0700
Subject: [PATCH] Add CMSPAR to linux/mips

It needs to be skipped during testing because there's no way to include
a combination of headers that will expose it without giving a "type has
already been defined" error.
---
 libc-test/build.rs                 | 7 +++++++
 src/unix/notbsd/android/mod.rs     | 1 -
 src/unix/notbsd/linux/musl/mod.rs  | 1 -
 src/unix/notbsd/linux/other/mod.rs | 2 --
 src/unix/notbsd/linux/s390x.rs     | 1 -
 src/unix/notbsd/mod.rs             | 1 +
 6 files changed, 8 insertions(+), 5 deletions(-)

diff --git a/libc-test/build.rs b/libc-test/build.rs
index 08530eef..ce907e96 100644
--- a/libc-test/build.rs
+++ b/libc-test/build.rs
@@ -432,6 +432,13 @@ fn main() {
             // See constant definition for more details.
             "ENOATTR" if linux => true,
 
+            // On mips*-unknown-linux-gnu* CMSPAR cannot be included with the set of headers we
+            // want to use here for testing. It's originally defined in asm/termbits.h, which is
+            // also included by asm/termios.h, but not the standard termios.h. There's no way to
+            // include both asm/termbits.h and termios.h and there's no way to include both
+            // asm/termios.h and ioctl.h (+ some other headers) because of redeclared types.
+            "CMSPAR" if mips && linux && !musl => true,
+
             _ => false,
         }
     });
diff --git a/src/unix/notbsd/android/mod.rs b/src/unix/notbsd/android/mod.rs
index be527f0c..56dc60c2 100644
--- a/src/unix/notbsd/android/mod.rs
+++ b/src/unix/notbsd/android/mod.rs
@@ -792,7 +792,6 @@ pub const NLA_TYPE_MASK: ::c_int = !(NLA_F_NESTED | NLA_F_NET_BYTEORDER);
 
 pub const SIGEV_THREAD_ID: ::c_int = 4;
 
-pub const CMSPAR: ::tcflag_t = 0o10000000000;
 pub const CIBAUD: ::tcflag_t = 0o02003600000;
 pub const CBAUDEX: ::tcflag_t = 0o010000;
 
diff --git a/src/unix/notbsd/linux/musl/mod.rs b/src/unix/notbsd/linux/musl/mod.rs
index c7841721..e7076f4d 100644
--- a/src/unix/notbsd/linux/musl/mod.rs
+++ b/src/unix/notbsd/linux/musl/mod.rs
@@ -279,7 +279,6 @@ pub const ISIG: ::tcflag_t = 0x00000001;
 pub const ICANON: ::tcflag_t = 0x00000002;
 pub const PENDIN: ::tcflag_t = 0x00004000;
 pub const NOFLSH: ::tcflag_t = 0x00000080;
-pub const CMSPAR: ::tcflag_t = 0o10000000000;
 pub const CIBAUD: ::tcflag_t = 0o02003600000;
 pub const CBAUDEX: ::tcflag_t = 0o010000;
 pub const VSWTC: usize = 7;
diff --git a/src/unix/notbsd/linux/other/mod.rs b/src/unix/notbsd/linux/other/mod.rs
index 6dc59c78..08347f14 100644
--- a/src/unix/notbsd/linux/other/mod.rs
+++ b/src/unix/notbsd/linux/other/mod.rs
@@ -517,8 +517,6 @@ pub const NLA_F_NESTED: ::c_int = 1 << 15;
 pub const NLA_F_NET_BYTEORDER: ::c_int = 1 << 14;
 pub const NLA_TYPE_MASK: ::c_int = !(NLA_F_NESTED | NLA_F_NET_BYTEORDER);
 
-pub const CMSPAR: ::tcflag_t = 0o10000000000;
-
 pub const TIOCM_LE: ::c_int = 0x001;
 pub const TIOCM_DTR: ::c_int = 0x002;
 pub const TIOCM_RTS: ::c_int = 0x004;
diff --git a/src/unix/notbsd/linux/s390x.rs b/src/unix/notbsd/linux/s390x.rs
index 52c35a6f..cb73bf33 100644
--- a/src/unix/notbsd/linux/s390x.rs
+++ b/src/unix/notbsd/linux/s390x.rs
@@ -778,7 +778,6 @@ pub const LINUX_REBOOT_CMD_KEXEC: ::c_int = 0x45584543;
 pub const SYS_gettid: ::c_long = 236;
 pub const SYS_perf_event_open: ::c_long = 331;
 
-pub const CMSPAR: ::tcflag_t = 0o10000000000;
 pub const VSWTC: usize = 7;
 pub const OLCUC:  ::tcflag_t = 0o000002;
 pub const NLDLY:  ::tcflag_t = 0o000400;
diff --git a/src/unix/notbsd/mod.rs b/src/unix/notbsd/mod.rs
index d07401e5..473856e9 100644
--- a/src/unix/notbsd/mod.rs
+++ b/src/unix/notbsd/mod.rs
@@ -679,6 +679,7 @@ pub const IMAXBEL: ::tcflag_t = 0x00002000;
 pub const IUTF8: ::tcflag_t = 0x00004000;
 pub const OPOST: ::tcflag_t = 0x1;
 pub const CS5: ::tcflag_t = 0x00000000;
+pub const CMSPAR: ::tcflag_t = 0o10000000000;
 pub const CRTSCTS: ::tcflag_t = 0x80000000;
 pub const ECHO: ::tcflag_t = 0x00000008;
 pub const OCRNL:  ::tcflag_t = 0o000010;
-- 
GitLab