Use x86-64 bits/byteswap.h for both i386 and x86_64
[glibc.git] / stdio-common / psignal.c
blob23026f9b18a721e999d7986caa787cd6e364ed12
1 /* Copyright (C) 1991, 1992, 1995, 1996, 1997, 2001, 2002, 2004, 2005, 2009
2 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
19 #include <stdio.h>
20 #include <signal.h>
21 #include <stdlib.h>
22 #include <libintl.h>
23 #include <wchar.h>
26 /* Defined in sys_siglist.c. */
27 extern const char *const _sys_siglist[];
28 extern const char *const _sys_siglist_internal[] attribute_hidden;
31 /* Print out on stderr a line consisting of the test in S, a colon, a space,
32 a message describing the meaning of the signal number SIG and a newline.
33 If S is NULL or "", the colon and space are omitted. */
34 void
35 psignal (int sig, const char *s)
37 const char *colon, *desc;
39 if (s == NULL || *s == '\0')
40 s = colon = "";
41 else
42 colon = ": ";
44 if (sig >= 0 && sig < NSIG && (desc = INTUSE(_sys_siglist)[sig]) != NULL)
45 (void) __fxprintf (NULL, "%s%s%s\n", s, colon, _(desc));
46 else
48 char *buf;
50 if (__asprintf (&buf, _("%s%sUnknown signal %d\n"), s, colon, sig) < 0)
51 (void) __fxprintf (NULL, "%s%s%s\n", s, colon, _("Unknown signal"));
52 else
54 (void) __fxprintf (NULL, "%s", buf);
56 free (buf);