bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

strsignal on cygwin


From: Eric Blake
Subject: strsignal on cygwin
Date: Wed, 18 Jun 2008 17:14:58 +0000 (UTC)
User-agent: Loom/3.14 (http://gmane.org/)

Cygwin 1.5.25 and earlier provides strsignal that returns const char *; at the 
time cygwin added strsignal, it was not standardized.  Now, POSIX 200x is 
adding strsignal, but chose to follow glibc's convention of returning char* 
rather than cygwin's const char *.  I've posted a patch to cygwin 1.7.0 to 
correct the prototype to match glibc.  In the meantime, I'm committing this 
patch, justified on the basis that you should always be treating the result of 
strsignal as const char* anyways, since POSIX 200x states:

"The string pointed to shall not be modified by the application, but may be 
overwritten by a subsequent call to strsignal( ) or setlocale( )."

Why POSIX didn't make the return type const char* is beyond me.

Meanwhile, I'm looking at the POSIX definition of psiginfo, and wondering how 
on earth it is intended to be used!  psiginfo is intentionally omitted from the 
list of async-signal-safe functions, but you only ever get a populated 
siginfo_t* in the context of a signal handler, and siginfo_t is not compatible 
with sig_atomic_t; so I don't see how ANY portable application could expect to 
call psiginfo and get well-defined results (you can't safely call it in a 
signal handler, and you can't safely preserve the siginfo_t from a handler to 
later safely call it after returning from the handler).


>From a31528831b376cab4b5cb2c0e64bbc5b83d0053d Mon Sep 17 00:00:00 2001
From: Eric Blake <address@hidden>
Date: Wed, 18 Jun 2008 10:50:06 -0600
Subject: [PATCH] Work around cygwin 1.5.25 strsignal bug.

* tests/test-strsignal.c: Allow for const char *.
* doc/glibc-functions/strsignal.texi (strsignal): Document the bug.

Signed-off-by: Eric Blake <address@hidden>
---
 ChangeLog                          |    6 ++++++
 doc/glibc-functions/strsignal.texi |   16 ++++++++++++----
 tests/test-strsignal.c             |    6 +++++-
 3 files changed, 23 insertions(+), 5 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 696c961..ce4f71d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2008-06-18  Eric Blake  <address@hidden>
+
+       Work around cygwin 1.5.25 strsignal bug.
+       * tests/test-strsignal.c: Allow for const char *.
+       * doc/glibc-functions/strsignal.texi (strsignal): Document the bug.
+
 2008-06-17  Bruno Haible  <address@hidden>
 
        New macro gl_DISABLE_THREADS.
diff --git a/doc/glibc-functions/strsignal.texi b/doc/glibc-
functions/strsignal.texi
index 80ad6da..65c0b1b 100644
--- a/doc/glibc-functions/strsignal.texi
+++ b/doc/glibc-functions/strsignal.texi
@@ -2,15 +2,23 @@
 @subsection @code{strsignal}
 @findex strsignal
 
-Gnulib module: ---
+Gnulib module: strsignal
 
 Portability problems fixed by Gnulib:
 @itemize
address@hidden
+This function is missing on some platforms:
+AIX 4.3.2, HP-UX 11, IRIX 6.5, OSF/1 5.1, mingw.
+
address@hidden
+This function does not return a string for out-of-range numbers on
+some platforms:
+Solaris, AIX 5.1.
 @end itemize
 
 Portability problems not fixed by Gnulib:
 @itemize
address@hidden
-This function is missing on some platforms:
-AIX 4.3.2, HP-UX 11, IRIX 6.5, OSF/1 5.1, mingw.
+This function returns @code{const char *} instead of @code{char *} on
+some platforms:
+cygwin 1.5.25.
 @end itemize
diff --git a/tests/test-strsignal.c b/tests/test-strsignal.c
index 8cc955b..8868346 100644
--- a/tests/test-strsignal.c
+++ b/tests/test-strsignal.c
@@ -46,7 +46,11 @@
 int
 main (int argc, char **argv)
 {
-  char *str;
+  /* Work around bug in cygwin 1.5.25 <string.h> by declaring str as
+     const char *, even though strsignal is supposed to return char *.
+     At any rate, this doesn't hurt, since POSIX 200x states that "The
+     string pointed to shall not be modified by the application."  */
+  const char *str;
 
   /* We try a couple of signals, since not all signals are supported
      everywhere.  Notwithstanding the #ifdef for neatness, SIGINT should in
-- 
1.5.5.1







reply via email to

[Prev in Thread] Current Thread [Next in Thread]