public inbox for newlib@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] Export XSI sigpause
@ 2017-06-14 15:45 Yaakov Selkowitz
  2017-06-14 19:15 ` Corinna Vinschen
  0 siblings, 1 reply; 2+ messages in thread
From: Yaakov Selkowitz @ 2017-06-14 15:45 UTC (permalink / raw)
  To: cygwin-patches; +Cc: newlib

There are two common sigpause variants, both of which take an int argument.
If you request _XOPEN_SOURCE or _GNU_SOURCE, you get the System V version,
which removes the given signal from the process's signal mask; otherwise
you get the BSD version, which sets the process's signal mask to the given
value.

Signed-off-by: Yaakov Selkowitz <yselkowi@redhat.com>
---
 newlib/libc/include/sys/signal.h       | 14 +++++++++++++-
 winsup/cygwin/common.din               |  1 +
 winsup/cygwin/include/cygwin/version.h |  3 ++-
 winsup/cygwin/signal.cc                | 12 ++++++++++++
 winsup/doc/posix.xml                   | 10 ++++++++--
 5 files changed, 36 insertions(+), 4 deletions(-)

diff --git a/newlib/libc/include/sys/signal.h b/newlib/libc/include/sys/signal.h
index a56f18a1b..da064cd5f 100644
--- a/newlib/libc/include/sys/signal.h
+++ b/newlib/libc/include/sys/signal.h
@@ -200,7 +200,19 @@ int _EXFUN(sigwait, (const sigset_t *set, int *sig));
 #endif /* !__CYGWIN__ && !__rtems__ */
 #endif /* __POSIX_VISIBLE */
 
-#if __BSD_VISIBLE
+/* There are two common sigpause variants, both of which take an int argument.
+   If you request _XOPEN_SOURCE or _GNU_SOURCE, you get the System V version,
+   which removes the given signal from the process's signal mask; otherwise
+   you get the BSD version, which sets the process's signal mask to the given
+   value. */
+#if __XSI_VISIBLE && !defined(__INSIDE_CYGWIN__)
+# ifdef __GNUC__
+int _EXFUN(sigpause, (int)) __asm__ (__ASMNAME ("__xpg_sigpause"));
+# else
+int _EXFUN(__xpg_sigpause, (int));
+#  define sigpause __xpg_sigpause
+# endif
+#elif __BSD_VISIBLE
 int _EXFUN(sigpause, (int));
 #endif
 
diff --git a/winsup/cygwin/common.din b/winsup/cygwin/common.din
index 6620700c2..75fe05c1f 100644
--- a/winsup/cygwin/common.din
+++ b/winsup/cygwin/common.din
@@ -102,6 +102,7 @@ __wrap__ZdlPv NOSIGFE               # void operator delete(void *p) throw()
 __wrap__ZdlPvRKSt9nothrow_t NOSIGFE # void operator delete(void *p, const std::nothrow_t &nt) throw()
 __xdrrec_getrec SIGFE
 __xdrrec_setnonblock SIGFE
+__xpg_sigpause SIGFE
 __xpg_strerror_r SIGFE
 _exit SIGFE
 _feinitialise NOSIGFE
diff --git a/winsup/cygwin/include/cygwin/version.h b/winsup/cygwin/include/cygwin/version.h
index 7baca6158..c0254a8e0 100644
--- a/winsup/cygwin/include/cygwin/version.h
+++ b/winsup/cygwin/include/cygwin/version.h
@@ -475,12 +475,13 @@ details. */
   308: Export dladdr.
   309: Export getloadavg.
   310: Export reallocarray.
+  311: Export __xpg_sigpause.
 
   Note that we forgot to bump the api for ualarm, strtoll, strtoull,
   sigaltstack, sethostname. */
 
 #define CYGWIN_VERSION_API_MAJOR 0
-#define CYGWIN_VERSION_API_MINOR 310
+#define CYGWIN_VERSION_API_MINOR 311
 
 /* There is also a compatibity version number associated with the shared memory
    regions.  It is incremented when incompatible changes are made to the shared
diff --git a/winsup/cygwin/signal.cc b/winsup/cygwin/signal.cc
index f371a231b..fbd2b241e 100644
--- a/winsup/cygwin/signal.cc
+++ b/winsup/cygwin/signal.cc
@@ -524,6 +524,18 @@ sigpause (int signal_mask)
 }
 
 extern "C" int
+__xpg_sigpause (int sig)
+{
+  int res;
+  sigset_t signal_mask;
+  sigprocmask (0, NULL, &signal_mask);
+  sigdelset (&signal_mask, sig);
+  res = handle_sigsuspend (signal_mask);
+  syscall_printf ("%R = __xpg_sigpause(%y)", res, sig);
+  return res;
+}
+
+extern "C" int
 pause (void)
 {
   int res = handle_sigsuspend (_my_tls.sigmask);
diff --git a/winsup/doc/posix.xml b/winsup/doc/posix.xml
index 5c9f65637..ced7e383d 100644
--- a/winsup/doc/posix.xml
+++ b/winsup/doc/posix.xml
@@ -877,7 +877,7 @@ also IEEE Std 1003.1-2008 (POSIX.1-2008).</para>
     signal
     signbit			(see chapter "Implementation Notes")
     signgam
-    sigpause
+    sigpause			(see chapter "Implementation Notes")
     sigpending
     sigprocmask
     sigqueue
@@ -925,7 +925,7 @@ also IEEE Std 1003.1-2008 (POSIX.1-2008).</para>
     strdup
     strerror
     strerror_l
-    strerror_r
+    strerror_r			(see chapter "Implementation Notes")
     strfmon
     strfmon_l
     strftime
@@ -1668,6 +1668,12 @@ depending on whether _BSD_SOURCE or _GNU_SOURCE is defined when compiling.</para
 <para><function>basename</function> is available in both POSIX and GNU flavors,
 depending on whether libgen.h is included or not.</para>
 
+<para><function>sigpause</function> is available in both BSD and SysV/XSI
+flavors, depending on whether _XOPEN_SOURCE is defined when compiling.</para>
+
+<para><function>strerror_r</function> is available in both POSIX and GNU
+flavors, depending on whether _GNU_SOURCE is defined when compiling.</para>
+
 <para><function>dladdr</function> always sets the Dl_info members dli_sname and
 dli_saddr to NULL, indicating no symbol matching addr could be found.</para>
 
-- 
2.12.3

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] Export XSI sigpause
  2017-06-14 15:45 [PATCH] Export XSI sigpause Yaakov Selkowitz
@ 2017-06-14 19:15 ` Corinna Vinschen
  0 siblings, 0 replies; 2+ messages in thread
From: Corinna Vinschen @ 2017-06-14 19:15 UTC (permalink / raw)
  To: cygwin-patches, newlib

[-- Attachment #1: Type: text/plain, Size: 940 bytes --]

On Jun 14 10:45, Yaakov Selkowitz wrote:
> There are two common sigpause variants, both of which take an int argument.
> If you request _XOPEN_SOURCE or _GNU_SOURCE, you get the System V version,
> which removes the given signal from the process's signal mask; otherwise
> you get the BSD version, which sets the process's signal mask to the given
> value.
> 
> Signed-off-by: Yaakov Selkowitz <yselkowi@redhat.com>
> ---
>  newlib/libc/include/sys/signal.h       | 14 +++++++++++++-
>  winsup/cygwin/common.din               |  1 +
>  winsup/cygwin/include/cygwin/version.h |  3 ++-
>  winsup/cygwin/signal.cc                | 12 ++++++++++++
>  winsup/doc/posix.xml                   | 10 ++++++++--
>  5 files changed, 36 insertions(+), 4 deletions(-)

ACK, looks good.  Please add this to the cygwin release notes file, too
(in a 2nd commit).


Thanks,
Corinna

-- 
Corinna Vinschen
Cygwin Maintainer
Red Hat

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2017-06-14 19:15 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-06-14 15:45 [PATCH] Export XSI sigpause Yaakov Selkowitz
2017-06-14 19:15 ` Corinna Vinschen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).