Commit 007e8d2a by Kaveh R. Ghazi Committed by Kaveh Ghazi

Add support for strsignal, for platforms which have it but don't have…

Add support for strsignal, for platforms which have it but don't have sys_siglist (like Solaris 2.7.)

Add support for strsignal, for platforms which have it but don't have
sys_siglist (like Solaris 2.7.)
        * acconfig.h (NEED_DECLARATION_STRSIGNAL): Provide a stub.
        * collect2.c: Don't declare `sys_siglist' here.
        (my_strsignal): Prototype and define new function.  Use it in
        place of `sys_siglist' hacks.
        * mips_tfile.c:  Likewise.
        * configure.in (AC_CHECK_FUNCS): Check for strsignal.
        (GCC_NEED_DECLARATIONS): Likewise.
        * system.h (strsignal): Prototype it, if necessary.
        (sys_siglist): Declare it, if necessary.

From-SVN: r22403
parent 9655bf95
Sun Sep 13 09:11:59 1998 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>
* acconfig.h (NEED_DECLARATION_STRSIGNAL): Provide a stub.
* collect2.c: Don't declare `sys_siglist' here.
(my_strsignal): Prototype and define new function. Use it in
place of `sys_siglist' hacks.
* mips_tfile.c: Likewise.
* configure.in (AC_CHECK_FUNCS): Check for strsignal.
(GCC_NEED_DECLARATIONS): Likewise.
* system.h (strsignal): Prototype it, if necessary.
(sys_siglist): Declare it, if necessary.
Sun Sep 13 04:37:28 1998 David S. Miller <davem@pierdol.cobaltmicro.com>
* loop.c (move_movables): While removing insn sequences, preserve
......
......@@ -69,6 +69,9 @@
/* Whether strerror must be declared even if <string.h> is included. */
#undef NEED_DECLARATION_STRERROR
/* Whether strsignal must be declared even if <string.h> is included. */
#undef NEED_DECLARATION_STRSIGNAL
/* Whether getcwd must be declared even if <unistd.h> is included. */
#undef NEED_DECLARATION_GETCWD
......
......@@ -186,11 +186,6 @@ enum pass {
PASS_SECOND /* with constructors linked in */
};
#ifndef NO_SYS_SIGLIST
#ifndef SYS_SIGLIST_DECLARED
extern char *sys_siglist[];
#endif
#endif
extern char *version_string;
int vflag; /* true if -v */
......@@ -269,6 +264,7 @@ static char *libexts[3] = {"a", "so", NULL}; /* possible library extentions */
#endif
static char *my_strerror PROTO((int));
static const char *my_strsignal PROTO((int));
static void handler PROTO((int));
static int is_ctor_dtor PROTO((char *));
static char *find_a_file PROTO((struct path_prefix *, char *));
......@@ -350,6 +346,29 @@ my_strerror (e)
return buffer;
#endif
}
static const char *
my_strsignal (s)
int s;
{
#ifdef HAVE_STRSIGNAL
return strsignal (s);
#else
if (s >= 0 && s < NSIG)
{
# ifdef NO_SYS_SIGLIST
static char buffer[30];
sprintf (buffer, "Unknown signal %d", s);
return buffer;
# else
return sys_siglist[s];
# endif
}
else
return NULL;
#endif /* HAVE_STRSIGNAL */
}
/* Delete tempfiles and exit function. */
......@@ -1578,18 +1597,11 @@ collect_wait (prog)
if (WIFSIGNALED (status))
{
int sig = WTERMSIG (status);
#ifdef NO_SYS_SIGLIST
error ("%s terminated with signal %d %s",
prog,
sig,
(status & 0200) ? ", core dumped" : "");
#else
error ("%s terminated with signal %d [%s]%s",
prog,
sig,
sys_siglist[sig],
my_strsignal(sig),
(status & 0200) ? ", core dumped" : "");
#endif
collect_exit (FATAL_EXIT_CODE);
}
......
......@@ -70,6 +70,9 @@
/* Whether strerror must be declared even if <string.h> is included. */
#undef NEED_DECLARATION_STRERROR
/* Whether strsignal must be declared even if <string.h> is included. */
#undef NEED_DECLARATION_STRSIGNAL
/* Whether getcwd must be declared even if <unistd.h> is included. */
#undef NEED_DECLARATION_GETCWD
......@@ -154,6 +157,9 @@
/* Define if you have the strrchr function. */
#undef HAVE_STRRCHR
/* Define if you have the strsignal function. */
#undef HAVE_STRSIGNAL
/* Define if you have the strtoul function. */
#undef HAVE_STRTOUL
......
......@@ -304,7 +304,7 @@ AC_MSG_RESULT($gcc_cv_header_inttypes_h)
AC_CHECK_FUNCS(strtoul bsearch strerror putenv popen bcopy bzero bcmp \
index rindex strchr strrchr kill getrlimit setrlimit atoll atoq \
sysconf isascii gettimeofday)
sysconf isascii gettimeofday strsignal)
# Make sure wchar_t is available
#AC_CHECK_TYPE(wchar_t, unsigned int)
......@@ -313,7 +313,8 @@ GCC_FUNC_VFPRINTF_DOPRNT
GCC_FUNC_PRINTF_PTR
GCC_NEED_DECLARATIONS(malloc realloc calloc free bcopy bzero bcmp \
index rindex getenv atol sbrk abort atof strerror getcwd getwd)
index rindex getenv atol sbrk abort atof strerror getcwd getwd \
strsignal)
GCC_NEED_DECLARATIONS(getrlimit setrlimit, [
#include <sys/types.h>
......
......@@ -1722,6 +1722,7 @@ STATIC void free_thead __proto((thead_t *));
STATIC char *local_index __proto((const char *, int));
STATIC char *local_rindex __proto((const char *, int));
STATIC const char *my_strsignal __proto((int));
extern char *mktemp __proto((char *));
extern long strtol __proto((const char *, char **, int));
......@@ -1730,12 +1731,6 @@ extern char *optarg;
extern int optind;
extern int opterr;
extern char *version_string;
#ifndef NO_SYS_SIGLIST
#ifndef SYS_SIGLIST_DECLARED
extern char *sys_siglist[NSIG + 1];
#endif
#endif
/* List of assembler pseudo ops and beginning sequences that need
special actions. Someday, this should be a hash table, and such,
......@@ -5050,6 +5045,29 @@ main (argc, argv)
}
STATIC const char *
my_strsignal (s)
int s;
{
#ifdef HAVE_STRSIGNAL
return strsignal (s);
#else
if (s >= 0 && s < NSIG)
{
# ifdef NO_SYS_SIGLIST
static char buffer[30];
sprintf (buffer, "Unknown signal %d", s);
return buffer;
# else
return sys_siglist[s];
# endif
}
else
return NULL;
#endif /* HAVE_STRSIGNAL */
}
/* Catch a signal and exit without dumping core. */
STATIC void
......@@ -5057,11 +5075,7 @@ catch_signal (signum)
int signum;
{
(void) signal (signum, SIG_DFL); /* just in case... */
#ifdef NO_SYS_SIGLIST
fatal ("caught signal");
#else
fatal (sys_siglist[signum]);
#endif
fatal (my_strsignal(signum));
}
/* Print a fatal error message. NAME is the text.
......
......@@ -247,6 +247,20 @@ extern int sys_nerr;
extern char *sys_errlist[];
#endif /* HAVE_STRERROR */
#ifdef HAVE_STRSIGNAL
# ifdef NEED_DECLARATION_STRSIGNAL
# ifndef strsignal
extern char * strsignal ();
# endif
# endif
#else /* ! HAVE_STRSIGNAL */
# ifndef SYS_SIGLIST_DECLARED
# ifndef NO_SYS_SIGLIST
extern char * sys_siglist[];
# endif
# endif
#endif /* HAVE_STRSIGNAL */
#ifdef HAVE_GETRLIMIT
# ifdef NEED_DECLARATION_GETRLIMIT
# ifndef getrlimit
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment