*** empty log message ***
[coreutils.git] / lib / sig2str.h
blob4fbd21ce254d482156d39564d3ab78d5e836469c
1 /* sig2str.h -- convert between signal names and numbers
3 Copyright (C) 2002 Free Software Foundation, Inc.
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2, or (at your option)
8 any later version.
10 This program 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
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software Foundation,
17 Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
19 /* Written by Paul Eggert. */
21 /* Include <signal.h> before including this file. */
23 /* Don't override system declarations of SIG2STR_MAX, sig2str, str2sig. */
24 #ifndef SIG2STR_MAX
26 /* Upper bound on the string length of an integer converted to string.
27 302 / 1000 is ceil (log10 (2.0)). Subtract 1 for the sign bit;
28 add 1 for integer division truncation; add 1 more for a minus sign. */
29 # define INT_STRLEN_BOUND(t) ((sizeof (t) * CHAR_BIT - 1) * 302 / 1000 + 2)
31 /* Size of a buffer needed to hold a signal name like "HUP". */
32 # define SIG2STR_MAX (sizeof "SIGRTMAX" + INT_STRLEN_BOUND (int) - 1)
34 int sig2str (int, char *);
35 int str2sig (char const *, int *);
37 #endif
39 /* An upper bound on signal numbers allowed by the system. */
41 #if defined _sys_nsig
42 # define SIGNUM_BOUND (_sys_nsig - 1)
43 #elif defined NSIG
44 # define SIGNUM_BOUND (NSIG - 1)
45 #else
46 # define SIGNUM_BOUND 64
47 #endif