diff options
| author | mycroft <mycroft@NetBSD.org> | 1993-11-17 21:14:09 +0000 |
|---|---|---|
| committer | mycroft <mycroft@NetBSD.org> | 1993-11-17 21:14:09 +0000 |
| commit | 667fb45afc721bbeb032a6fe7888722d99b34e09 (patch) | |
| tree | ec0b543e8a8a83ddbb2bc9e0b71e106f8be016b5 /gnu/lib/libg++ | |
| parent | baa5b7b22f63a9e19d4a5f1dbe125223402b42f5 (diff) | |
Clean up deleted files.
Diffstat (limited to 'gnu/lib/libg++')
| -rw-r--r-- | gnu/lib/libg++/libiberty/config.h | 1 | ||||
| -rw-r--r-- | gnu/lib/libg++/libiberty/insque.c | 77 | ||||
| -rw-r--r-- | gnu/lib/libg++/libiberty/strerror.c | 820 | ||||
| -rw-r--r-- | gnu/lib/libg++/libiberty/strsignal.c | 627 |
4 files changed, 0 insertions, 1525 deletions
diff --git a/gnu/lib/libg++/libiberty/config.h b/gnu/lib/libg++/libiberty/config.h deleted file mode 100644 index b37ee84a78a..00000000000 --- a/gnu/lib/libg++/libiberty/config.h +++ /dev/null @@ -1 +0,0 @@ -/* !Automatically generated from ./functions.def - DO NOT EDIT! */ diff --git a/gnu/lib/libg++/libiberty/insque.c b/gnu/lib/libg++/libiberty/insque.c deleted file mode 100644 index dbef95c7e27..00000000000 --- a/gnu/lib/libg++/libiberty/insque.c +++ /dev/null @@ -1,77 +0,0 @@ -/* insque(3C) routines - Copyright (C) 1991 Free Software Foundation, Inc. - -This file is part of the libiberty library. -Libiberty is free software; you can redistribute it and/or -modify it under the terms of the GNU Library General Public -License as published by the Free Software Foundation; either -version 2 of the License, or (at your option) any later version. - -Libiberty is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -Library General Public License for more details. - -You should have received a copy of the GNU Library General Public -License along with libiberty; see the file COPYING.LIB. If -not, write to the Free Software Foundation, Inc., 675 Mass Ave, -Cambridge, MA 02139, USA. */ - -#ifndef lint -static char rcsid[] = "$Id: insque.c,v 1.2 1993/08/02 17:23:52 mycroft Exp $"; -#endif /* not lint */ - -/* - -NAME - - insque, remque -- insert, remove an element from a queue - -SYNOPSIS - - struct qelem { - struct qelem *q_forw; - struct qelem *q_back; - char q_data[]; - }; - - void insque (struct qelem *elem, struct qelem *pred) - - void remque (struct qelem *elem) - -DESCRIPTION - - Routines to manipulate queues built from doubly linked lists. - The insque routine inserts ELEM in the queue immediately after - PRED. The remque routine removes ELEM from its containing queue. - -BUGS - -*/ - - -struct qelem { - struct qelem *q_forw; - struct qelem *q_back; -}; - - -void -insque (elem, pred) - struct qelem *elem; - struct qelem *pred; -{ - elem -> q_forw = pred -> q_forw; - pred -> q_forw -> q_back = elem; - elem -> q_back = pred; - pred -> q_forw = elem; -} - - -void -remque (elem) - struct qelem *elem; -{ - elem -> q_forw -> q_back = elem -> q_back; - elem -> q_back -> q_forw = elem -> q_forw; -} diff --git a/gnu/lib/libg++/libiberty/strerror.c b/gnu/lib/libg++/libiberty/strerror.c deleted file mode 100644 index 829bb552175..00000000000 --- a/gnu/lib/libg++/libiberty/strerror.c +++ /dev/null @@ -1,820 +0,0 @@ -/* Extended support for using errno values. - Copyright (C) 1992 Free Software Foundation, Inc. - Written by Fred Fish. fnf@cygnus.com - -This file is part of the libiberty library. -Libiberty is free software; you can redistribute it and/or -modify it under the terms of the GNU Library General Public -License as published by the Free Software Foundation; either -version 2 of the License, or (at your option) any later version. - -Libiberty is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -Library General Public License for more details. - -You should have received a copy of the GNU Library General Public -License along with libiberty; see the file COPYING.LIB. If -not, write to the Free Software Foundation, Inc., 675 Mass Ave, -Cambridge, MA 02139, USA. */ - -#ifndef lint -static char rcsid[] = "$Id: strerror.c,v 1.2 1993/08/02 17:23:53 mycroft Exp $"; -#endif /* not lint */ - -#include "config.h" - -#include <stdio.h> -#ifndef NEED_sys_errlist -/* Note that errno.h might declare sys_errlist in a way that the - * compiler might consider incompatible with our later declaration, - * perhaps by using const attributes. So we hide the declaration - * in errno.h (if any) using a macro. */ -#define sys_errlist sys_errlist__ -#endif -#include <errno.h> -#ifndef NEED_sys_errlist -#undef sys_errlist -#endif - -/* Routines imported from standard C runtime libraries. */ - -#ifdef __STDC__ -#include <stddef.h> -extern void *malloc (size_t size); /* 4.10.3.3 */ -extern void *memset (void *s, int c, size_t n); /* 4.11.6.1 */ -#else /* !__STDC__ */ -#ifndef const -#define const -#endif -extern char *malloc (); /* Standard memory allocater */ -extern char *memset (); -#endif /* __STDC__ */ - -#ifndef NULL -# ifdef __STDC__ -# define NULL (void *) 0 -# else -# define NULL 0 -# endif -#endif - -#ifndef MAX -# define MAX(a,b) ((a) > (b) ? (a) : (b)) -#endif - -/* Translation table for errno values. See intro(2) in most UNIX systems - Programmers Reference Manuals. - - Note that this table is generally only accessed when it is used at runtime - to initialize errno name and message tables that are indexed by errno - value. - - Not all of these errnos will exist on all systems. This table is the only - thing that should have to be updated as new error numbers are introduced. - It's sort of ugly, but at least its portable. */ - -struct error_info -{ - int value; /* The numeric value from <errno.h> */ - char *name; /* The equivalent symbolic value */ - char *msg; /* Short message about this value */ -}; - -static const struct error_info error_table[] = -{ -#if defined (EPERM) - EPERM, "EPERM", "Not owner", -#endif -#if defined (ENOENT) - ENOENT, "ENOENT", "No such file or directory", -#endif -#if defined (ESRCH) - ESRCH, "ESRCH", "No such process", -#endif -#if defined (EINTR) - EINTR, "EINTR", "Interrupted system call", -#endif -#if defined (EIO) - EIO, "EIO", "I/O error", -#endif -#if defined (ENXIO) - ENXIO, "ENXIO", "No such device or address", -#endif -#if defined (E2BIG) - E2BIG, "E2BIG", "Arg list too long", -#endif -#if defined (ENOEXEC) - ENOEXEC, "ENOEXEC", "Exec format error", -#endif -#if defined (EBADF) - EBADF, "EBADF", "Bad file number", -#endif -#if defined (ECHILD) - ECHILD, "ECHILD", "No child processes", -#endif -#if defined (EWOULDBLOCK) /* Put before EAGAIN, sometimes aliased */ - EWOULDBLOCK, "EWOULDBLOCK", "Operation would block", -#endif -#if defined (EAGAIN) - EAGAIN, "EAGAIN", "No more processes", -#endif -#if defined (ENOMEM) - ENOMEM, "ENOMEM", "Not enough space", -#endif -#if defined (EACCES) - EACCES, "EACCES", "Permission denied", -#endif -#if defined (EFAULT) - EFAULT, "EFAULT", "Bad address", -#endif -#if defined (ENOTBLK) - ENOTBLK, "ENOTBLK", "Block device required", -#endif -#if defined (EBUSY) - EBUSY, "EBUSY", "Device busy", -#endif -#if defined (EEXIST) - EEXIST, "EEXIST", "File exists", -#endif -#if defined (EXDEV) - EXDEV, "EXDEV", "Cross-device link", -#endif -#if defined (ENODEV) - ENODEV, "ENODEV", "No such device", -#endif -#if defined (ENOTDIR) - ENOTDIR, "ENOTDIR", "Not a directory", -#endif -#if defined (EISDIR) - EISDIR, "EISDIR", "Is a directory", -#endif -#if defined (EINVAL) - EINVAL, "EINVAL", "Invalid argument", -#endif -#if defined (ENFILE) - ENFILE, "ENFILE", "File table overflow", -#endif -#if defined (EMFILE) - EMFILE, "EMFILE", "Too many open files", -#endif -#if defined (ENOTTY) - ENOTTY, "ENOTTY", "Not a typewriter", -#endif -#if defined (ETXTBSY) - ETXTBSY, "ETXTBSY", "Text file busy", -#endif -#if defined (EFBIG) - EFBIG, "EFBIG", "File too large", -#endif -#if defined (ENOSPC) - ENOSPC, "ENOSPC", "No space left on device", -#endif -#if defined (ESPIPE) - ESPIPE, "ESPIPE", "Illegal seek", -#endif -#if defined (EROFS) - EROFS, "EROFS", "Read-only file system", -#endif -#if defined (EMLINK) - EMLINK, "EMLINK", "Too many links", -#endif -#if defined (EPIPE) - EPIPE, "EPIPE", "Broken pipe", -#endif -#if defined (EDOM) - EDOM, "EDOM", "Math argument out of domain of func", -#endif -#if defined (ERANGE) - ERANGE, "ERANGE", "Math result not representable", -#endif -#if defined (ENOMSG) - ENOMSG, "ENOMSG", "No message of desired type", -#endif -#if defined (EIDRM) - EIDRM, "EIDRM", "Identifier removed", -#endif -#if defined (ECHRNG) - ECHRNG, "ECHRNG", "Channel number out of range", -#endif -#if defined (EL2NSYNC) - EL2NSYNC, "EL2NSYNC", "Level 2 not synchronized", -#endif -#if defined (EL3HLT) - EL3HLT, "EL3HLT", "Level 3 halted", -#endif -#if defined (EL3RST) - EL3RST, "EL3RST", "Level 3 reset", -#endif -#if defined (ELNRNG) - ELNRNG, "ELNRNG", "Link number out of range", -#endif -#if defined (EUNATCH) - EUNATCH, "EUNATCH", "Protocol driver not attached", -#endif -#if defined (ENOCSI) - ENOCSI, "ENOCSI", "No CSI structure available", -#endif -#if defined (EL2HLT) - EL2HLT, "EL2HLT", "Level 2 halted", -#endif -#if defined (EDEADLK) - EDEADLK, "EDEADLK", "Deadlock condition", -#endif -#if defined (ENOLCK) - ENOLCK, "ENOLCK", "No record locks available", -#endif -#if defined (EBADE) - EBADE, "EBADE", "Invalid exchange", -#endif -#if defined (EBADR) - EBADR, "EBADR", "Invalid request descriptor", -#endif -#if defined (EXFULL) - EXFULL, "EXFULL", "Exchange full", -#endif -#if defined (ENOANO) - ENOANO, "ENOANO", "No anode", -#endif -#if defined (EBADRQC) - EBADRQC, "EBADRQC", "Invalid request code", -#endif -#if defined (EBADSLT) - EBADSLT, "EBADSLT", "Invalid slot", -#endif -#if defined (EDEADLOCK) - EDEADLOCK, "EDEADLOCK", "File locking deadlock error", -#endif -#if defined (EBFONT) - EBFONT, "EBFONT", "Bad font file format", -#endif -#if defined (ENOSTR) - ENOSTR, "ENOSTR", "Device not a stream", -#endif -#if defined (ENODATA) - ENODATA, "ENODATA", "No data available", -#endif -#if defined (ETIME) - ETIME, "ETIME", "Timer expired", -#endif -#if defined (ENOSR) - ENOSR, "ENOSR", "Out of streams resources", -#endif -#if defined (ENONET) - ENONET, "ENONET", "Machine is not on the network", -#endif -#if defined (ENOPKG) - ENOPKG, "ENOPKG", "Package not installed", -#endif -#if defined (EREMOTE) - EREMOTE, "EREMOTE", "Object is remote", -#endif -#if defined (ENOLINK) - ENOLINK, "ENOLINK", "Link has been severed", -#endif -#if defined (EADV) - EADV, "EADV", "Advertise error", -#endif -#if defined (ESRMNT) - ESRMNT, "ESRMNT", "Srmount error", -#endif -#if defined (ECOMM) - ECOMM, "ECOMM", "Communication error on send", -#endif -#if defined (EPROTO) - EPROTO, "EPROTO", "Protocol error", -#endif -#if defined (EMULTIHOP) - EMULTIHOP, "EMULTIHOP", "Multihop attempted", -#endif -#if defined (EDOTDOT) - EDOTDOT, "EDOTDOT", "RFS specific error", -#endif -#if defined (EBADMSG) - EBADMSG, "EBADMSG", "Not a data message", -#endif -#if defined (ENAMETOOLONG) - ENAMETOOLONG, "ENAMETOOLONG", "File name too long", -#endif -#if defined (EOVERFLOW) - EOVERFLOW, "EOVERFLOW", "Value too large for defined data type", -#endif -#if defined (ENOTUNIQ) - ENOTUNIQ, "ENOTUNIQ", "Name not unique on network", -#endif -#if defined (EBADFD) - EBADFD, "EBADFD", "File descriptor in bad state", -#endif -#if defined (EREMCHG) - EREMCHG, "EREMCHG", "Remote address changed", -#endif -#if defined (ELIBACC) - ELIBACC, "ELIBACC", "Can not access a needed shared library", -#endif -#if defined (ELIBBAD) - ELIBBAD, "ELIBBAD", "Accessing a corrupted shared library", -#endif -#if defined (ELIBSCN) - ELIBSCN, "ELIBSCN", ".lib section in a.out corrupted", -#endif -#if defined (ELIBMAX) - ELIBMAX, "ELIBMAX", "Attempting to link in too many shared libraries", -#endif -#if defined (ELIBEXEC) - ELIBEXEC, "ELIBEXEC", "Cannot exec a shared library directly", -#endif -#if defined (EILSEQ) - EILSEQ, "EILSEQ", "Illegal byte sequence", -#endif -#if defined (ENOSYS) - ENOSYS, "ENOSYS", "Operation not applicable", -#endif -#if defined (ELOOP) - ELOOP, "ELOOP", "Too many symbolic links encountered", -#endif -#if defined (ERESTART) - ERESTART, "ERESTART", "Interrupted system call should be restarted", -#endif -#if defined (ESTRPIPE) - ESTRPIPE, "ESTRPIPE", "Streams pipe error", -#endif -#if defined (ENOTEMPTY) - ENOTEMPTY, "ENOTEMPTY", "Directory not empty", -#endif -#if defined (EUSERS) - EUSERS, "EUSERS", "Too many users", -#endif -#if defined (ENOTSOCK) - ENOTSOCK, "ENOTSOCK", "Socket operation on non-socket", -#endif -#if defined (EDESTADDRREQ) - EDESTADDRREQ, "EDESTADDRREQ", "Destination address required", -#endif -#if defined (EMSGSIZE) - EMSGSIZE, "EMSGSIZE", "Message too long", -#endif -#if defined (EPROTOTYPE) - EPROTOTYPE, "EPROTOTYPE", "Protocol wrong type for socket", -#endif -#if defined (ENOPROTOOPT) - ENOPROTOOPT, "ENOPROTOOPT", "Protocol not available", -#endif -#if defined (EPROTONOSUPPORT) - EPROTONOSUPPORT, "EPROTONOSUPPORT", "Protocol not supported", -#endif -#if defined (ESOCKTNOSUPPORT) - ESOCKTNOSUPPORT, "ESOCKTNOSUPPORT", "Socket type not supported", -#endif -#if defined (EOPNOTSUPP) - EOPNOTSUPP, "EOPNOTSUPP", "Operation not supported on transport endpoint", -#endif -#if defined (EPFNOSUPPORT) - EPFNOSUPPORT, "EPFNOSUPPORT", "Protocol family not supported", -#endif -#if defined (EAFNOSUPPORT) - EAFNOSUPPORT, "EAFNOSUPPORT", "Address family not supported by protocol", -#endif -#if defined (EADDRINUSE) - EADDRINUSE, "EADDRINUSE", "Address already in use", -#endif -#if defined (EADDRNOTAVAIL) - EADDRNOTAVAIL, "EADDRNOTAVAIL","Cannot assign requested address", -#endif -#if defined (ENETDOWN) - ENETDOWN, "ENETDOWN", "Network is down", -#endif -#if defined (ENETUNREACH) - ENETUNREACH, "ENETUNREACH", "Network is unreachable", -#endif -#if defined (ENETRESET) - ENETRESET, "ENETRESET", "Network dropped connection because of reset", -#endif -#if defined (ECONNABORTED) - ECONNABORTED, "ECONNABORTED", "Software caused connection abort", -#endif -#if defined (ECONNRESET) - ECONNRESET, "ECONNRESET", "Connection reset by peer", -#endif -#if defined (ENOBUFS) - ENOBUFS, "ENOBUFS", "No buffer space available", -#endif -#if defined (EISCONN) - EISCONN, "EISCONN", "Transport endpoint is already connected", -#endif -#if defined (ENOTCONN) - ENOTCONN, "ENOTCONN", "Transport endpoint is not connected", -#endif -#if defined (ESHUTDOWN) - ESHUTDOWN, "ESHUTDOWN", "Cannot send after transport endpoint shutdown", -#endif -#if defined (ETOOMANYREFS) - ETOOMANYREFS, "ETOOMANYREFS", "Too many references: cannot splice", -#endif -#if defined (ETIMEDOUT) - ETIMEDOUT, "ETIMEDOUT", "Connection timed out", -#endif -#if defined (ECONNREFUSED) - ECONNREFUSED, "ECONNREFUSED", "Connection refused", -#endif -#if defined (EHOSTDOWN) - EHOSTDOWN, "EHOSTDOWN", "Host is down", -#endif -#if defined (EHOSTUNREACH) - EHOSTUNREACH, "EHOSTUNREACH", "No route to host", -#endif -#if defined (EALREADY) - EALREADY, "EALREADY", "Operation already in progress", -#endif -#if defined (EINPROGRESS) - EINPROGRESS, "EINPROGRESS", "Operation now in progress", -#endif -#if defined (ESTALE) - ESTALE, "ESTALE", "Stale NFS file handle", -#endif -#if defined (EUCLEAN) - EUCLEAN, "EUCLEAN", "Structure needs cleaning", -#endif -#if defined (ENOTNAM) - ENOTNAM, "ENOTNAM", "Not a XENIX named type file", -#endif -#if defined (ENAVAIL) - ENAVAIL, "ENAVAIL", "No XENIX semaphores available", -#endif -#if defined (EISNAM) - EISNAM, "EISNAM", "Is a named type file", -#endif -#if defined (EREMOTEIO) - EREMOTEIO, "EREMOTEIO", "Remote I/O error", -#endif - 0, NULL, NULL -}; - -/* Translation table allocated and initialized at runtime. Indexed by the - errno value to find the equivalent symbolic value. */ - -static char **error_names; -static int num_error_names = 0; - -/* Translation table allocated and initialized at runtime, if it does not - already exist in the host environment. Indexed by the errno value to find - the descriptive string. - - We don't export it for use in other modules because even though it has the - same name, it differs from other implementations in that it is dynamically - initialized rather than statically initialized. */ - -#ifdef NEED_sys_errlist - -static int sys_nerr; -static char **sys_errlist; - -#else - -extern int sys_nerr; -extern char *sys_errlist[]; - -#endif - - -/* - -NAME - - init_error_tables -- initialize the name and message tables - -SYNOPSIS - - static void init_error_tables (); - -DESCRIPTION - - Using the error_table, which is initialized at compile time, generate - the error_names and the sys_errlist (if needed) tables, which are - indexed at runtime by a specific errno value. - -BUGS - - The initialization of the tables may fail under low memory conditions, - in which case we don't do anything particularly useful, but we don't - bomb either. Who knows, it might succeed at a later point if we free - some memory in the meantime. In any case, the other routines know - how to deal with lack of a table after trying to initialize it. This - may or may not be considered to be a bug, that we don't specifically - warn about this particular failure mode. - -*/ - -static void -init_error_tables () -{ - const struct error_info *eip; - int nbytes; - - /* If we haven't already scanned the error_table once to find the maximum - errno value, then go find it now. */ - - if (num_error_names == 0) - { - for (eip = error_table; eip -> name != NULL; eip++) - { - if (eip -> value >= num_error_names) - { - num_error_names = eip -> value + 1; - } - } - } - - /* Now attempt to allocate the error_names table, zero it out, and then - initialize it from the statically initialized error_table. */ - - if (error_names == NULL) - { - nbytes = num_error_names * sizeof (char *); - if ((error_names = (char **) malloc (nbytes)) != NULL) - { - memset (error_names, 0, nbytes); - for (eip = error_table; eip -> name != NULL; eip++) - { - error_names[eip -> value] = eip -> name; - } - } - } - -#ifdef NEED_sys_errlist - - /* Now attempt to allocate the sys_errlist table, zero it out, and then - initialize it from the statically initialized error_table. */ - - if (sys_errlist == NULL) - { - nbytes = num_error_names * sizeof (char *); - if ((sys_errlist = (char **) malloc (nbytes)) != NULL) - { - memset (sys_errlist, 0, nbytes); - sys_nerr = num_error_names; - for (eip = error_table; eip -> name != NULL; eip++) - { - sys_errlist[eip -> value] = eip -> msg; - } - } - } - -#endif - -} - -/* - -NAME - - errno_max -- return the max errno value - -SYNOPSIS - - int errno_max (); - -DESCRIPTION - - Returns the maximum errno value for which a corresponding symbolic - name or message is available. Note that in the case where - we use the sys_errlist supplied by the system, it is possible for - there to be more symbolic names than messages, or vice versa. - In fact, the manual page for perror(3C) explicitly warns that one - should check the size of the table (sys_nerr) before indexing it, - since new error codes may be added to the system before they are - added to the table. Thus sys_nerr might be smaller than value - implied by the largest errno value defined in <errno.h>. - - We return the maximum value that can be used to obtain a meaningful - symbolic name or message. - -*/ - -int -errno_max () -{ - int maxsize; - - if (error_names == NULL) - { - init_error_tables (); - } - maxsize = MAX (sys_nerr, num_error_names); - return (maxsize - 1); -} - -#ifdef NEED_strerror - -/* - -NAME - - strerror -- map an error number to an error message string - -SYNOPSIS - - char *strerror (int errnoval) - -DESCRIPTION - - Maps an errno number to an error message string, the contents of - which are implementation defined. On systems which have the external - variables sys_nerr and sys_errlist, these strings will be the same - as the ones used by perror(). - - If the supplied error number is within the valid range of indices - for the sys_errlist, but no message is available for the particular - error number, then returns the string "Error NUM", where NUM is the - error number. - - If the supplied error number is not a valid index into sys_errlist, - returns NULL. - - The returned string is only guaranteed to be valid only until the - next call to strerror. - -*/ - -char * -strerror (errnoval) - int errnoval; -{ - char *msg; - static char buf[32]; - -#ifdef NEED_sys_errlist - - if (error_names == NULL) - { - init_error_tables (); - } - -#endif - - if ((errnoval < 0) || (errnoval >= sys_nerr)) - { - /* Out of range, just return NULL */ - msg = NULL; - } - else if ((sys_errlist == NULL) || (sys_errlist[errnoval] == NULL)) - { - /* In range, but no sys_errlist or no entry at this index. */ - sprintf (buf, "Error %d", errnoval); - msg = buf; - } - else - { - /* In range, and a valid message. Just return the message. */ - msg = sys_errlist[errnoval]; - } - - return (msg); -} - -#endif /* NEED_strerror */ - - -/* - -NAME - - strerrno -- map an error number to a symbolic name string - -SYNOPSIS - - char *strerrno (int errnoval) - -DESCRIPTION - - Given an error number returned from a system call (typically - returned in errno), returns a pointer to a string containing the - symbolic name of that error number, as found in <errno.h>. - - If the supplied error number is within the valid range of indices - for symbolic names, but no name is available for the particular - error number, then returns the string "Error NUM", where NUM is - the error number. - - If the supplied error number is not within the range of valid - indices, then returns NULL. - -BUGS - - The contents of the location pointed to are only guaranteed to be - valid until the next call to strerrno. - -*/ - -char * -strerrno (errnoval) - int errnoval; -{ - char *name; - static char buf[32]; - - if (error_names == NULL) - { - init_error_tables (); - } - - if ((errnoval < 0) || (errnoval >= num_error_names)) - { - /* Out of range, just return NULL */ - name = NULL; - } - else if ((error_names == NULL) || (error_names[errnoval] == NULL)) - { - /* In range, but no error_names or no entry at this index. */ - sprintf (buf, "Error %d", errnoval); - name = buf; - } - else - { - /* In range, and a valid name. Just return the name. */ - name = error_names[errnoval]; - } - - return (name); -} - -/* - -NAME - - strtoerrno -- map a symbolic errno name to a numeric value - -SYNOPSIS - - int strtoerrno (char *name) - -DESCRIPTION - - Given the symbolic name of a error number, map it to an errno value. - If no translation is found, returns 0. - -*/ - -int -strtoerrno (name) - char *name; -{ - int errnoval = 0; - - if (name != NULL) - { - if (error_names == NULL) - { - init_error_tables (); - } - for (errnoval = 0; errnoval < num_error_names; errnoval++) - { - if ((error_names[errnoval] != NULL) && - (strcmp (name, error_names[errnoval]) == 0)) - { - break; - } - } - if (errnoval == num_error_names) - { - errnoval = 0; - } - } - return (errnoval); -} - - -/* A simple little main that does nothing but print all the errno translations - if MAIN is defined and this file is compiled and linked. */ - -#ifdef MAIN - -main () -{ - int errn; - int errnmax; - char *name; - char *msg; - char *strerrno (); - char *strerror (); - - errnmax = errno_max (); - printf ("%d entries in names table.\n", num_error_names); - printf ("%d entries in messages table.\n", sys_nerr); - printf ("%d is max useful index.\n", errnmax); - - /* Keep printing values until we get to the end of *both* tables, not - *either* table. Note that knowing the maximum useful index does *not* - relieve us of the responsibility of testing the return pointer for - NULL. */ - - for (errn = 0; errn <= errnmax; errn++) - { - name = strerrno (errn); - name = (name == NULL) ? "<NULL>" : name; - msg = strerror (errn); - msg = (msg == NULL) ? "<NULL>" : msg; - printf ("%-4d%-18s%s\n", errn, name, msg); - } -} - -#endif diff --git a/gnu/lib/libg++/libiberty/strsignal.c b/gnu/lib/libg++/libiberty/strsignal.c deleted file mode 100644 index ca057837ed4..00000000000 --- a/gnu/lib/libg++/libiberty/strsignal.c +++ /dev/null @@ -1,627 +0,0 @@ -/* Extended support for using signal values. - Copyright (C) 1992 Free Software Foundation, Inc. - Written by Fred Fish. fnf@cygnus.com - -This file is part of the libiberty library. -Libiberty is free software; you can redistribute it and/or -modify it under the terms of the GNU Library General Public -License as published by the Free Software Foundation; either -version 2 of the License, or (at your option) any later version. - -Libiberty is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -Library General Public License for more details. - -You should have received a copy of the GNU Library General Public -License along with libiberty; see the file COPYING.LIB. If -not, write to the Free Software Foundation, Inc., 675 Mass Ave, -Cambridge, MA 02139, USA. */ - -#ifndef lint -static char rcsid[] = "$Id: strsignal.c,v 1.2 1993/08/02 17:23:54 mycroft Exp $"; -#endif /* not lint */ - -#include "config.h" - -#include <stdio.h> -#include <signal.h> - -/* Routines imported from standard C runtime libraries. */ - -#ifdef __STDC__ -#include <stddef.h> -extern void *malloc (size_t size); /* 4.10.3.3 */ -extern void *memset (void *s, int c, size_t n); /* 4.11.6.1 */ -#else /* !__STDC__ */ -#ifndef const -#define const -#endif -extern char *malloc (); /* Standard memory allocater */ -extern char *memset (); -#endif /* __STDC__ */ - -#ifndef NULL -# ifdef __STDC__ -# define NULL (void *) 0 -# else -# define NULL 0 -# endif -#endif - -#ifndef MAX -# define MAX(a,b) ((a) > (b) ? (a) : (b)) -#endif - -/* Translation table for signal values. - - Note that this table is generally only accessed when it is used at runtime - to initialize signal name and message tables that are indexed by signal - value. - - Not all of these signals will exist on all systems. This table is the only - thing that should have to be updated as new signal numbers are introduced. - It's sort of ugly, but at least its portable. */ - -struct signal_info -{ - int value; /* The numeric value from <signal.h> */ - char *name; /* The equivalent symbolic value */ - char *msg; /* Short message about this value */ -}; - -static const struct signal_info signal_table[] = -{ -#if defined (SIGHUP) - SIGHUP, "SIGHUP", "Hangup", -#endif -#if defined (SIGINT) - SIGINT, "SIGINT", "Interrupt", -#endif -#if defined (SIGQUIT) - SIGQUIT, "SIGQUIT", "Quit", -#endif -#if defined (SIGILL) - SIGILL, "SIGILL", "Illegal instruction", -#endif -#if defined (SIGTRAP) - SIGTRAP, "SIGTRAP", "Trace/breakpoint trap", -#endif -/* Put SIGIOT before SIGABRT, so that if SIGIOT==SIGABRT then SIGABRT - overrides SIGIOT. SIGABRT is in ANSI and POSIX.1, and SIGIOT isn't. */ -#if defined (SIGIOT) - SIGIOT, "SIGIOT", "IOT trap", -#endif -#if defined (SIGABRT) - SIGABRT, "SIGABRT", "Aborted", -#endif -#if defined (SIGEMT) - SIGEMT, "SIGEMT", "Emulation trap", -#endif -#if defined (SIGFPE) - SIGFPE, "SIGFPE", "Arithmetic exception", -#endif -#if defined (SIGKILL) - SIGKILL, "SIGKILL", "Killed", -#endif -#if defined (SIGBUS) - SIGBUS, "SIGBUS", "Bus error", -#endif -#if defined (SIGSEGV) - SIGSEGV, "SIGSEGV", "Segmentation fault", -#endif -#if defined (SIGSYS) - SIGSYS, "SIGSYS", "Bad system call", -#endif -#if defined (SIGPIPE) - SIGPIPE, "SIGPIPE", "Broken pipe", -#endif -#if defined (SIGALRM) - SIGALRM, "SIGALRM", "Alarm clock", -#endif -#if defined (SIGTERM) - SIGTERM, "SIGTERM", "Terminated", -#endif -#if defined (SIGUSR1) - SIGUSR1, "SIGUSR1", "User defined signal 1", -#endif -#if defined (SIGUSR2) - SIGUSR2, "SIGUSR2", "User defined signal 2", -#endif -/* Put SIGCLD before SIGCHLD, so that if SIGCLD==SIGCHLD then SIGCHLD - overrides SIGCLD. SIGCHLD is in POXIX.1 */ -#if defined (SIGCLD) - SIGCLD, "SIGCLD", "Child status changed", -#endif -#if defined (SIGCHLD) - SIGCHLD, "SIGCHLD", "Child status changed", -#endif -#if defined (SIGPWR) - SIGPWR, "SIGPWR", "Power fail/restart", -#endif -#if defined (SIGWINCH) - SIGWINCH, "SIGWINCH", "Window size changed", -#endif -#if defined (SIGURG) - SIGURG, "SIGURG", "Urgent I/O condition", -#endif -#if defined (SIGIO) - /* "I/O pending has also been suggested, but is misleading since the - signal only happens when the process has asked for it, not everytime - I/O is pending. */ - SIGIO, "SIGIO", "I/O possible", -#endif -#if defined (SIGPOLL) - SIGPOLL, "SIGPOLL", "Pollable event occurred", -#endif -#if defined (SIGSTOP) - SIGSTOP, "SIGSTOP", "Stopped (signal)", -#endif -#if defined (SIGTSTP) - SIGTSTP, "SIGTSTP", "Stopped (user)", -#endif -#if defined (SIGCONT) - SIGCONT, "SIGCONT", "Continued", -#endif -#if defined (SIGTTIN) - SIGTTIN, "SIGTTIN", "Stopped (tty input)", -#endif -#if defined (SIGTTOU) - SIGTTOU, "SIGTTOU", "Stopped (tty output)", -#endif -#if defined (SIGVTALRM) - SIGVTALRM, "SIGVTALRM", "Virtual timer expired", -#endif -#if defined (SIGPROF) - SIGPROF, "SIGPROF", "Profiling timer expired", -#endif -#if defined (SIGXCPU) - SIGXCPU, "SIGXCPU", "CPU time limit exceeded", -#endif -#if defined (SIGXFSZ) - SIGXFSZ, "SIGXFSZ", "File size limit exceeded", -#endif -#if defined (SIGWIND) - SIGWIND, "SIGWIND", "SIGWIND", -#endif -#if defined (SIGPHONE) - SIGPHONE, "SIGPHONE", "SIGPHONE", -#endif -#if defined (SIGLOST) - SIGLOST, "SIGLOST", "Resource lost", -#endif -#if defined (SIGWAITING) - SIGWAITING, "SIGWAITING", "Process's LWPs are blocked", -#endif -#if defined (SIGLWP) - SIGLWP, "SIGLWP", "Signal LWP", -#endif -#if defined (SIGDANGER) - SIGDANGER, "SIGDANGER", "Swap space dangerously low", -#endif -#if defined (SIGGRANT) - SIGGRANT, "SIGGRANT", "Monitor mode granted", -#endif -#if defined (SIGRETRACT) - SIGRETRACT, "SIGRETRACT", "Need to relinguish monitor mode", -#endif -#if defined (SIGMSG) - SIGMSG, "SIGMSG", "Monitor mode data available", -#endif -#if defined (SIGSOUND) - SIGSOUND, "SIGSOUND", "Sound completed", -#endif -#if defined (SIGSAK) - SIGSAK, "SIGSAK", "Secure attention", -#endif - 0, NULL, NULL -}; - -/* Translation table allocated and initialized at runtime. Indexed by the - signal value to find the equivalent symbolic value. */ - -static char **signal_names; -static int num_signal_names = 0; - -/* Translation table allocated and initialized at runtime, if it does not - already exist in the host environment. Indexed by the signal value to find - the descriptive string. - - We don't export it for use in other modules because even though it has the - same name, it differs from other implementations in that it is dynamically - initialized rather than statically initialized. */ - -#ifdef NEED_sys_siglist - -static int sys_nsig; -static char **sys_siglist; - -#else - -static int sys_nsig = NSIG; -extern const char * const sys_siglist[]; - -#endif - - -/* - -NAME - - init_signal_tables -- initialize the name and message tables - -SYNOPSIS - - static void init_signal_tables (); - -DESCRIPTION - - Using the signal_table, which is initialized at compile time, generate - the signal_names and the sys_siglist (if needed) tables, which are - indexed at runtime by a specific signal value. - -BUGS - - The initialization of the tables may fail under low memory conditions, - in which case we don't do anything particularly useful, but we don't - bomb either. Who knows, it might succeed at a later point if we free - some memory in the meantime. In any case, the other routines know - how to deal with lack of a table after trying to initialize it. This - may or may not be considered to be a bug, that we don't specifically - warn about this particular failure mode. - -*/ - -static void -init_signal_tables () -{ - const struct signal_info *eip; - int nbytes; - - /* If we haven't already scanned the signal_table once to find the maximum - signal value, then go find it now. */ - - if (num_signal_names == 0) - { - for (eip = signal_table; eip -> name != NULL; eip++) - { - if (eip -> value >= num_signal_names) - { - num_signal_names = eip -> value + 1; - } - } - } - - /* Now attempt to allocate the signal_names table, zero it out, and then - initialize it from the statically initialized signal_table. */ - - if (signal_names == NULL) - { - nbytes = num_signal_names * sizeof (char *); - if ((signal_names = (char **) malloc (nbytes)) != NULL) - { - memset (signal_names, 0, nbytes); - for (eip = signal_table; eip -> name != NULL; eip++) - { - signal_names[eip -> value] = eip -> name; - } - } - } - -#ifdef NEED_sys_siglist - - /* Now attempt to allocate the sys_siglist table, zero it out, and then - initialize it from the statically initialized signal_table. */ - - if (sys_siglist == NULL) - { - nbytes = num_signal_names * sizeof (char *); - if ((sys_siglist = (char **) malloc (nbytes)) != NULL) - { - memset (sys_siglist, 0, nbytes); - sys_nsig = num_signal_names; - for (eip = signal_table; eip -> name != NULL; eip++) - { - sys_siglist[eip -> value] = eip -> msg; - } - } - } - -#endif - -} - - -/* - -NAME - - signo_max -- return the max signo value - -SYNOPSIS - - int signo_max (); - -DESCRIPTION - - Returns the maximum signo value for which a corresponding symbolic - name or message is available. Note that in the case where - we use the sys_siglist supplied by the system, it is possible for - there to be more symbolic names than messages, or vice versa. - In fact, the manual page for psignal(3b) explicitly warns that one - should check the size of the table (NSIG) before indexing it, - since new signal codes may be added to the system before they are - added to the table. Thus NSIG might be smaller than value - implied by the largest signo value defined in <signal.h>. - - We return the maximum value that can be used to obtain a meaningful - symbolic name or message. - -*/ - -int -signo_max () -{ - int maxsize; - - if (signal_names == NULL) - { - init_signal_tables (); - } - maxsize = MAX (sys_nsig, num_signal_names); - return (maxsize - 1); -} - - -/* - -NAME - - strsignal -- map a signal number to a signal message string - -SYNOPSIS - - char *strsignal (int signo) - -DESCRIPTION - - Maps an signal number to an signal message string, the contents of - which are implementation defined. On systems which have the external - variable sys_siglist, these strings will be the same as the ones used - by psignal(). - - If the supplied signal number is within the valid range of indices - for the sys_siglist, but no message is available for the particular - signal number, then returns the string "Signal NUM", where NUM is the - signal number. - - If the supplied signal number is not a valid index into sys_siglist, - returns NULL. - - The returned string is only guaranteed to be valid only until the - next call to strsignal. - -*/ - -char * -strsignal (signo) - int signo; -{ - char *msg; - static char buf[32]; - -#ifdef NEED_sys_siglist - - if (signal_names == NULL) - { - init_signal_tables (); - } - -#endif - - if ((signo < 0) || (signo >= sys_nsig)) - { - /* Out of range, just return NULL */ - msg = NULL; - } - else if ((sys_siglist == NULL) || (sys_siglist[signo] == NULL)) - { - /* In range, but no sys_siglist or no entry at this index. */ - sprintf (buf, "Signal %d", signo); - msg = buf; - } - else - { - /* In range, and a valid message. Just return the message. */ - msg = (char*)sys_siglist[signo]; - } - - return (msg); -} - - -/* - -NAME - - strsigno -- map an signal number to a symbolic name string - -SYNOPSIS - - char *strsigno (int signo) - -DESCRIPTION - - Given an signal number, returns a pointer to a string containing - the symbolic name of that signal number, as found in <signal.h>. - - If the supplied signal number is within the valid range of indices - for symbolic names, but no name is available for the particular - signal number, then returns the string "Signal NUM", where NUM is - the signal number. - - If the supplied signal number is not within the range of valid - indices, then returns NULL. - -BUGS - - The contents of the location pointed to are only guaranteed to be - valid until the next call to strsigno. - -*/ - -char * -strsigno (signo) - int signo; -{ - char *name; - static char buf[32]; - - if (signal_names == NULL) - { - init_signal_tables (); - } - - if ((signo < 0) || (signo >= num_signal_names)) - { - /* Out of range, just return NULL */ - name = NULL; - } - else if ((signal_names == NULL) || (signal_names[signo] == NULL)) - { - /* In range, but no signal_names or no entry at this index. */ - sprintf (buf, "Signal %d", signo); - name = buf; - } - else - { - /* In range, and a valid name. Just return the name. */ - name = signal_names[signo]; - } - - return (name); -} - - -/* - -NAME - - strtosigno -- map a symbolic signal name to a numeric value - -SYNOPSIS - - int strtosigno (char *name) - -DESCRIPTION - - Given the symbolic name of a signal, map it to a signal number. - If no translation is found, returns 0. - -*/ - -int -strtosigno (name) - char *name; -{ - int signo = 0; - - if (name != NULL) - { - if (signal_names == NULL) - { - init_signal_tables (); - } - for (signo = 0; signo < num_signal_names; signo++) - { - if ((signal_names[signo] != NULL) && - (strcmp (name, signal_names[signo]) == 0)) - { - break; - } - } - if (signo == num_signal_names) - { - signo = 0; - } - } - return (signo); -} - - -/* - -NAME - - psignal -- print message about signal to stderr - -SYNOPSIS - - void psignal (unsigned signo, char *message); - -DESCRIPTION - - Print to the standard error the message, followed by a colon, - followed by the description of the signal specified by signo, - followed by a newline. -*/ - -#ifdef NEED_psignal - -void -psignal (signo, message) - unsigned signo; - char *message; -{ - if (signal_names == NULL) - { - init_signal_tables (); - } - if ((signo <= 0) || (signo >= sys_nsig)) - { - fprintf (stderr, "%s: unknown signal\n", message); - } - else - { - fprintf (stderr, "%s: %s\n", message, sys_siglist[signo]); - } -} - -#endif /* NEED_psignal */ - - -/* A simple little main that does nothing but print all the signal translations - if MAIN is defined and this file is compiled and linked. */ - -#ifdef MAIN - -main () -{ - int signo; - int maxsigno; - char *name; - char *msg; - char *strsigno (); - char *strsignal (); - - maxsigno = signo_max (); - printf ("%d entries in names table.\n", num_signal_names); - printf ("%d entries in messages table.\n", sys_nsig); - printf ("%d is max useful index.\n", maxsigno); - - /* Keep printing values until we get to the end of *both* tables, not - *either* table. Note that knowing the maximum useful index does *not* - relieve us of the responsibility of testing the return pointer for - NULL. */ - - for (signo = 0; signo <= maxsigno; signo++) - { - name = strsigno (signo); - name = (name == NULL) ? "<NULL>" : name; - msg = strsignal (signo); - msg = (msg == NULL) ? "<NULL>" : msg; - printf ("%-4d%-18s%s\n", signo, name, msg); - } -} - -#endif |
