This is the mail archive of the cygwin-cvs@cygwin.com mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[newlib-cygwin] Cygwin: rearrange sigwait functions, convert sigwait_common to inline


https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=7af691a7848f808d629a8c18fe3b7a6aed9b9870

commit 7af691a7848f808d629a8c18fe3b7a6aed9b9870
Author: Corinna Vinschen <corinna@vinschen.de>
Date:   Mon Dec 18 19:44:30 2017 +0100

    Cygwin: rearrange sigwait functions, convert sigwait_common to inline
    
    Signed-off-by: Corinna Vinschen <corinna@vinschen.de>

Diff:
---
 winsup/cygwin/signal.cc | 88 ++++++++++++++++++++++++-------------------------
 1 file changed, 43 insertions(+), 45 deletions(-)

diff --git a/winsup/cygwin/signal.cc b/winsup/cygwin/signal.cc
index 16210b5..f7c56c5 100644
--- a/winsup/cygwin/signal.cc
+++ b/winsup/cygwin/signal.cc
@@ -575,51 +575,7 @@ siginterrupt (int sig, int flag)
   return res;
 }
 
-static int sigwait_common (const sigset_t *, siginfo_t *, PLARGE_INTEGER);
-
-extern "C" int
-sigtimedwait (const sigset_t *set, siginfo_t *info, const timespec *timeout)
-{
-  LARGE_INTEGER waittime;
-
-  if (timeout)
-    {
-      if (timeout->tv_sec < 0
-	    || timeout->tv_nsec < 0 || timeout->tv_nsec > (NSPERSEC * 100LL))
-	{
-	  set_errno (EINVAL);
-	  return -1;
-	}
-      /* convert timespec to 100ns units */
-      waittime.QuadPart = (LONGLONG) timeout->tv_sec * NSPERSEC
-                          + ((LONGLONG) timeout->tv_nsec + 99LL) / 100LL;
-    }
-
-  return sigwait_common (set, info, timeout ? &waittime : cw_infinite);
-}
-
-extern "C" int
-sigwait (const sigset_t *set, int *sig_ptr)
-{
-  int sig;
-
-  do
-    {
-      sig = sigwait_common (set, NULL, cw_infinite);
-    }
-  while (sig == -1 && get_errno () == EINTR);
-  if (sig > 0)
-    *sig_ptr = sig;
-  return sig > 0 ? 0 : get_errno ();
-}
-
-extern "C" int
-sigwaitinfo (const sigset_t *set, siginfo_t *info)
-{
-  return sigwait_common (set, info, cw_infinite);
-}
-
-static int
+static inline int
 sigwait_common (const sigset_t *set, siginfo_t *info, PLARGE_INTEGER waittime)
 {
   int res = -1;
@@ -664,6 +620,48 @@ sigwait_common (const sigset_t *set, siginfo_t *info, PLARGE_INTEGER waittime)
   return res;
 }
 
+extern "C" int
+sigtimedwait (const sigset_t *set, siginfo_t *info, const timespec *timeout)
+{
+  LARGE_INTEGER waittime;
+
+  if (timeout)
+    {
+      if (timeout->tv_sec < 0
+	    || timeout->tv_nsec < 0 || timeout->tv_nsec > (NSPERSEC * 100LL))
+	{
+	  set_errno (EINVAL);
+	  return -1;
+	}
+      /* convert timespec to 100ns units */
+      waittime.QuadPart = (LONGLONG) timeout->tv_sec * NSPERSEC
+                          + ((LONGLONG) timeout->tv_nsec + 99LL) / 100LL;
+    }
+
+  return sigwait_common (set, info, timeout ? &waittime : cw_infinite);
+}
+
+extern "C" int
+sigwait (const sigset_t *set, int *sig_ptr)
+{
+  int sig;
+
+  do
+    {
+      sig = sigwait_common (set, NULL, cw_infinite);
+    }
+  while (sig == -1 && get_errno () == EINTR);
+  if (sig > 0)
+    *sig_ptr = sig;
+  return sig > 0 ? 0 : get_errno ();
+}
+
+extern "C" int
+sigwaitinfo (const sigset_t *set, siginfo_t *info)
+{
+  return sigwait_common (set, info, cw_infinite);
+}
+
 /* FIXME: SUSv3 says that this function should block until the signal has
    actually been delivered.  Currently, this will only happen when sending
    signals to the current process.  It will not happen when sending signals


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]