From cd8447550de252e2f3181bd73ef35f80ca744d08 Mon Sep 17 00:00:00 2001 From: Bryant Mairs Date: Thu, 23 Feb 2017 10:21:42 -0800 Subject: [PATCH 1/7] Add ppoll() for all unix platforms. I'm unsure of whether there is support in OS X for this, and I can't find anything online (I'm betting there isn't), but I'm going to let this run through CI to confirm --- src/unix/mod.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/unix/mod.rs b/src/unix/mod.rs index 47edaf1ae13ab..ca5a48bdf501a 100644 --- a/src/unix/mod.rs +++ b/src/unix/mod.rs @@ -721,6 +721,9 @@ extern { #[cfg_attr(all(target_os = "macos", target_arch = "x86"), link_name = "poll$UNIX2003")] pub fn poll(fds: *mut pollfd, nfds: nfds_t, timeout: ::c_int) -> ::c_int; + #[cfg_attr(all(target_os = "macos", target_arch = "x86"), + link_name = "ppoll$UNIX2003")] + pub fn ppoll(fds: *mut pollfd, nfds: nfds_t, timeout: ::c_int, sigmask: *const sigset_t) -> ::c_int; #[cfg_attr(all(target_os = "macos", target_arch = "x86_64"), link_name = "select$1050")] #[cfg_attr(all(target_os = "macos", target_arch = "x86"), From f79eed589a97966eccb5b2145ae5c75472a5d52e Mon Sep 17 00:00:00 2001 From: Bryant Mairs Date: Thu, 23 Feb 2017 14:46:56 -0800 Subject: [PATCH 2/7] Fix style errors --- src/unix/mod.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/unix/mod.rs b/src/unix/mod.rs index ca5a48bdf501a..0eaa36c27ec2f 100644 --- a/src/unix/mod.rs +++ b/src/unix/mod.rs @@ -723,7 +723,10 @@ extern { pub fn poll(fds: *mut pollfd, nfds: nfds_t, timeout: ::c_int) -> ::c_int; #[cfg_attr(all(target_os = "macos", target_arch = "x86"), link_name = "ppoll$UNIX2003")] - pub fn ppoll(fds: *mut pollfd, nfds: nfds_t, timeout: ::c_int, sigmask: *const sigset_t) -> ::c_int; + pub fn ppoll(fds: *mut pollfd, + nfds: nfds_t, + timeout: ::c_int, + sigmask: *const sigset_t) -> ::c_int; #[cfg_attr(all(target_os = "macos", target_arch = "x86_64"), link_name = "select$1050")] #[cfg_attr(all(target_os = "macos", target_arch = "x86"), From d86901e25992414032a0c33cb1791ba482b4afe3 Mon Sep 17 00:00:00 2001 From: Bryant Mairs Date: Thu, 23 Feb 2017 15:03:41 -0800 Subject: [PATCH 3/7] Fix timeout argument type --- src/unix/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/unix/mod.rs b/src/unix/mod.rs index 0eaa36c27ec2f..4214dac2a36af 100644 --- a/src/unix/mod.rs +++ b/src/unix/mod.rs @@ -725,7 +725,7 @@ extern { link_name = "ppoll$UNIX2003")] pub fn ppoll(fds: *mut pollfd, nfds: nfds_t, - timeout: ::c_int, + timeout: *const timespec, sigmask: *const sigset_t) -> ::c_int; #[cfg_attr(all(target_os = "macos", target_arch = "x86_64"), link_name = "select$1050")] From 029cd2d957a2e59035b4a6d035d90d4f6e2110c6 Mon Sep 17 00:00:00 2001 From: Bryant Mairs Date: Fri, 24 Feb 2017 08:07:19 -0800 Subject: [PATCH 4/7] Only expose ppoll on non-BSD targets --- src/unix/mod.rs | 6 ------ src/unix/notbsd/mod.rs | 5 +++++ 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/src/unix/mod.rs b/src/unix/mod.rs index 4214dac2a36af..47edaf1ae13ab 100644 --- a/src/unix/mod.rs +++ b/src/unix/mod.rs @@ -721,12 +721,6 @@ extern { #[cfg_attr(all(target_os = "macos", target_arch = "x86"), link_name = "poll$UNIX2003")] pub fn poll(fds: *mut pollfd, nfds: nfds_t, timeout: ::c_int) -> ::c_int; - #[cfg_attr(all(target_os = "macos", target_arch = "x86"), - link_name = "ppoll$UNIX2003")] - pub fn ppoll(fds: *mut pollfd, - nfds: nfds_t, - timeout: *const timespec, - sigmask: *const sigset_t) -> ::c_int; #[cfg_attr(all(target_os = "macos", target_arch = "x86_64"), link_name = "select$1050")] #[cfg_attr(all(target_os = "macos", target_arch = "x86"), diff --git a/src/unix/notbsd/mod.rs b/src/unix/notbsd/mod.rs index 10aa0b5bcb21e..9386c42fe7a9f 100644 --- a/src/unix/notbsd/mod.rs +++ b/src/unix/notbsd/mod.rs @@ -1,4 +1,5 @@ use dox::mem; +use ::{pollfd, timespec}; pub type sa_family_t = u16; pub type pthread_key_t = ::c_uint; @@ -841,6 +842,10 @@ extern { linkpath: *const ::c_char) -> ::c_int; pub fn unlinkat(dirfd: ::c_int, pathname: *const ::c_char, flags: ::c_int) -> ::c_int; + pub fn ppoll(fds: *mut pollfd, + nfds: nfds_t, + timeout: *const timespec, + sigmask: *const sigset_t) -> ::c_int; pub fn pthread_condattr_getclock(attr: *const pthread_condattr_t, clock_id: *mut clockid_t) -> ::c_int; pub fn pthread_condattr_setclock(attr: *mut pthread_condattr_t, From 6d5aa56e714d6c929021f4d00d970f516a30fedc Mon Sep 17 00:00:00 2001 From: Bryant Mairs Date: Fri, 24 Feb 2017 08:46:00 -0800 Subject: [PATCH 5/7] Unify import style --- src/unix/notbsd/mod.rs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/unix/notbsd/mod.rs b/src/unix/notbsd/mod.rs index 9386c42fe7a9f..9f8d8e56f57f3 100644 --- a/src/unix/notbsd/mod.rs +++ b/src/unix/notbsd/mod.rs @@ -1,5 +1,4 @@ use dox::mem; -use ::{pollfd, timespec}; pub type sa_family_t = u16; pub type pthread_key_t = ::c_uint; @@ -842,9 +841,9 @@ extern { linkpath: *const ::c_char) -> ::c_int; pub fn unlinkat(dirfd: ::c_int, pathname: *const ::c_char, flags: ::c_int) -> ::c_int; - pub fn ppoll(fds: *mut pollfd, + pub fn ppoll(fds: *mut ::pollfd, nfds: nfds_t, - timeout: *const timespec, + timeout: *const ::timespec, sigmask: *const sigset_t) -> ::c_int; pub fn pthread_condattr_getclock(attr: *const pthread_condattr_t, clock_id: *mut clockid_t) -> ::c_int; From 871f3b2cf638517e535d1ae8fbde207abee611d2 Mon Sep 17 00:00:00 2001 From: Bryant Mairs Date: Fri, 24 Feb 2017 08:46:15 -0800 Subject: [PATCH 6/7] Expose ppoll on some BSDs --- src/unix/bsd/freebsdlike/mod.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/unix/bsd/freebsdlike/mod.rs b/src/unix/bsd/freebsdlike/mod.rs index 5f156c1716d53..f9e5947fe4fe8 100644 --- a/src/unix/bsd/freebsdlike/mod.rs +++ b/src/unix/bsd/freebsdlike/mod.rs @@ -922,6 +922,10 @@ extern { pub fn pthread_mutex_timedlock(lock: *mut pthread_mutex_t, abstime: *const ::timespec) -> ::c_int; pub fn pipe2(fds: *mut ::c_int, flags: ::c_int) -> ::c_int; + pub fn ppoll(fds: *mut ::pollfd, + nfds: nfds_t, + timeout: *const ::timespec, + sigmask: *const sigset_t) -> ::c_int; } cfg_if! { From 88e37f278c8a64e063e7444db5814ec63007d483 Mon Sep 17 00:00:00 2001 From: Bryant Mairs Date: Fri, 24 Feb 2017 08:59:22 -0800 Subject: [PATCH 7/7] Fix path for nfds_t --- src/unix/bsd/freebsdlike/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/unix/bsd/freebsdlike/mod.rs b/src/unix/bsd/freebsdlike/mod.rs index f9e5947fe4fe8..326ad57d73ad6 100644 --- a/src/unix/bsd/freebsdlike/mod.rs +++ b/src/unix/bsd/freebsdlike/mod.rs @@ -923,7 +923,7 @@ extern { abstime: *const ::timespec) -> ::c_int; pub fn pipe2(fds: *mut ::c_int, flags: ::c_int) -> ::c_int; pub fn ppoll(fds: *mut ::pollfd, - nfds: nfds_t, + nfds: ::nfds_t, timeout: *const ::timespec, sigmask: *const sigset_t) -> ::c_int; }