diff --git a/src/unix/mod.rs b/src/unix/mod.rs
index 618bfa9ff6b89b363391ff50be531c18296c746b..972c2c0dae89d022591e8b4b2500e6d2777b989e 100644
--- a/src/unix/mod.rs
+++ b/src/unix/mod.rs
@@ -1091,12 +1091,8 @@ extern {
     pub fn tcdrain(fd: ::c_int) -> ::c_int;
     pub fn cfgetispeed(termios: *const ::termios) -> ::speed_t;
     pub fn cfgetospeed(termios: *const ::termios) -> ::speed_t;
-    #[cfg(not(any(target_os = "solaris", target_os = "illumos")))]
-    pub fn cfmakeraw(termios: *mut ::termios);
     pub fn cfsetispeed(termios: *mut ::termios, speed: ::speed_t) -> ::c_int;
     pub fn cfsetospeed(termios: *mut ::termios, speed: ::speed_t) -> ::c_int;
-    #[cfg(not(any(target_os = "solaris", target_os = "illumos")))]
-    pub fn cfsetspeed(termios: *mut ::termios, speed: ::speed_t) -> ::c_int;
     pub fn tcgetattr(fd: ::c_int, termios: *mut ::termios) -> ::c_int;
     pub fn tcsetattr(fd: ::c_int,
                      optional_actions: ::c_int,
@@ -1129,6 +1125,16 @@ extern {
         stream: *mut FILE) -> ssize_t;
 }
 
+cfg_if! {
+   if #[cfg(not(any(target_os = "solaris", target_os = "illumos")))] {
+        extern {
+            pub fn cfmakeraw(termios: *mut ::termios);
+            pub fn cfsetspeed(termios: *mut ::termios,
+                              speed: ::speed_t) -> ::c_int;
+        }
+   }
+}
+
 cfg_if! {
     if #[cfg(target_env = "uclibc")] {
         mod uclibc;