diff mbox

libiberty: fix psignal parameter type

Message ID x57jy5wi2qk8.fsf@frobland.mtv.corp.google.com
State New
Headers show

Commit Message

Roland McGrath Oct. 18, 2011, 4:49 p.m. UTC
When libiberty defines psignal, it doesn't use the canonical signature.
This came up as a problem in a configuration where libiberty wants to
define psignal itself, but the build environment's <signal.h> declares
it too.  

This was a --with-newlib configuration using the newlib trunk, where newlib
does define psignal (and strsignal, among other things), but libiberty's
configure thinks it knows exactly what newlib does and doesn't define
without checking.  This hard-coding seems unwise to me, exactly because of
the potential for cases like this, where newlib's set of available
functions changes over time.

I think the fragility of that hard-coding ought to be addressed somehow.
But regardless, this change alleviates the immediate problem, and is
otherwise harmless.


Thanks,
Roland


libiberty/
2011-10-18  Roland McGrath  <mcgrathr@google.com>

	* strsignal.c (psignal): Use const second in parameter type.
	* functions.texi: Updated.

Comments

Andrew Pinski Oct. 18, 2011, 4:50 p.m. UTC | #1
On Tue, Oct 18, 2011 at 9:49 AM, Roland McGrath <mcgrathr@google.com> wrote:
> When libiberty defines psignal, it doesn't use the canonical signature.
> This came up as a problem in a configuration where libiberty wants to
> define psignal itself, but the build environment's <signal.h> declares
> it too.
>
> This was a --with-newlib configuration using the newlib trunk, where newlib
> does define psignal (and strsignal, among other things), but libiberty's
> configure thinks it knows exactly what newlib does and doesn't define
> without checking.  This hard-coding seems unwise to me, exactly because of
> the potential for cases like this, where newlib's set of available
> functions changes over time.

libiberty is no longer compiled for the target so this should never
happen really.

Thanks,
Andrew Pinski
Roland McGrath Oct. 18, 2011, 4:53 p.m. UTC | #2
On Tue, Oct 18, 2011 at 9:50 AM, Andrew Pinski <pinskia@gmail.com> wrote:
> libiberty is no longer compiled for the target so this should never
> happen really.

I see.  I was indeed using an older source base, and just noticed that all
the offending configure logic was still the same.  Perhaps all the
--with-newlib logic in libiberty's configure should be removed now?

Regardless, the psignal change is an appropriate cleanup in its own right.


Thanks,
Roland
Ian Lance Taylor Oct. 18, 2011, 5:18 p.m. UTC | #3
On Tue, Oct 18, 2011 at 9:49 AM, Roland McGrath <mcgrathr@google.com> wrote:
>
> libiberty/
> 2011-10-18  Roland McGrath  <mcgrathr@google.com>
>
>        * strsignal.c (psignal): Use const second in parameter type.
>        * functions.texi: Updated.

This is OK.

Thanks.

Ian
Roland McGrath Oct. 18, 2011, 5:31 p.m. UTC | #4
On Tue, Oct 18, 2011 at 10:18 AM, Ian Lance Taylor <iant@google.com> wrote:
> On Tue, Oct 18, 2011 at 9:49 AM, Roland McGrath <mcgrathr@google.com> wrote:
>>
>> libiberty/
>> 2011-10-18  Roland McGrath  <mcgrathr@google.com>
>>
>>        * strsignal.c (psignal): Use const second in parameter type.
>>        * functions.texi: Updated.
>
> This is OK.

Thanks.  But last I checked, I'm not a GCC committer.
So somebody has to do it for me.


Thanks,
Roland
diff mbox

Patch

diff --git a/libiberty/functions.texi b/libiberty/functions.texi
index c9df186..2945c61 100644
--- a/libiberty/functions.texi
+++ b/libiberty/functions.texi
@@ -1097,7 +1097,7 @@  documented.
 @end deftypefn
 
 @c strsignal.c:541
-@deftypefn Supplemental void psignal (int @var{signo}, char *@var{message})
+@deftypefn Supplemental void psignal (int @var{signo}, const char *@var{message})
 
 Print @var{message} to the standard error, followed by a colon,
 followed by the description of the signal specified by @var{signo},
diff --git a/libiberty/strsignal.c b/libiberty/strsignal.c
index 666b1b4..3b56d16 100644
--- a/libiberty/strsignal.c
+++ b/libiberty/strsignal.c
@@ -538,7 +538,7 @@  strtosigno (const char *name)
 
 /*
 
-@deftypefn Supplemental void psignal (int @var{signo}, char *@var{message})
+@deftypefn Supplemental void psignal (int @var{signo}, const char *@var{message})
 
 Print @var{message} to the standard error, followed by a colon,
 followed by the description of the signal specified by @var{signo},
@@ -551,7 +551,7 @@  followed by a newline.
 #ifndef HAVE_PSIGNAL
 
 void
-psignal (int signo, char *message)
+psignal (int signo, const char *message)
 {
   if (signal_names == NULL)
     {