signal.c revision 34f9b3eef6fdadbda0a846aa4d68691ac40eace5
/***********************************************************************
* *
* This software is part of the ast package *
* Copyright (c) 1985-2009 AT&T Intellectual Property *
* and is licensed under the *
* Common Public License, Version 1.0 *
* by AT&T Intellectual Property *
* *
* A copy of the License is available at *
* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
* *
* Information and Software Systems Research *
* AT&T Research *
* Florham Park NJ *
* *
* Glenn Fowler <gsf@research.att.com> *
* David Korn <dgk@research.att.com> *
* Phong Vo <kpv@research.att.com> *
* *
***********************************************************************/
#pragma prototyped
/*
* Glenn Fowler
* AT&T Research
*
* generate signal features
*/
#define strsignal ______strsignal
#include <signal.h>
struct _m_
{
char* text;
char* name;
int value;
};
#define elementsof(x) (sizeof(x)/sizeof(x[0]))
{
#ifdef SIGABRT
#define HAD_SIGABRT 1
#endif
#ifdef SIGAIO
#define HAD_SIGAIO 1
#endif
#ifdef SIGALRM
#define HAD_SIGALRM 1
#endif
#ifdef SIGAPOLLO
#define HAD_SIGAPOLLO 1
#endif
#ifdef SIGBUS
#define HAD_SIGBUS 1
#endif
#ifdef SIGCHLD
#define HAD_SIGCHLD 1
#endif
#ifdef SIGCLD
#define HAD_SIGCLD 1
#endif
#ifdef SIGCONT
#define HAD_SIGCONT 1
#endif
#ifdef SIGDANGER
#define HAD_SIGDANGER 1
#endif
#ifdef SIGDEBUG
#define HAD_SIGDEBUG 1
#endif
#ifdef SIGDIL
#define HAD_SIGDIL 1
#endif
#ifdef SIGEMT
#define HAD_SIGEMT 1
#endif
#ifdef SIGERR
#define HAD_SIGERR 1
#endif
#ifdef SIGEXIT
#define HAD_SIGEXIT 1
#endif
#ifdef SIGFPE
#define HAD_SIGFPE 1
#endif
#ifdef SIGFREEZE
#define HAD_SIGFREEZE 1
#endif
#ifdef SIGHUP
#define HAD_SIGHUP 1
#endif
#ifdef SIGILL
#define HAD_SIGILL 1
#endif
#ifdef SIGINT
#define HAD_SIGINT 1
#endif
#ifdef SIGIO
#define HAD_SIGIO 1
#endif
#ifdef SIGIOT
#define HAD_SIGIOT 1
#endif
#ifdef SIGKILL
#define HAD_SIGKILL 1
#endif
#ifdef SIGLAB
#define HAD_SIGLAB 1
#endif
#ifdef SIGLOST
#define HAD_SIGLOST 1
#endif
#ifdef SIGLWP
#define HAD_SIGLWP 1
#endif
#ifdef SIGMIGRATE
#define HAD_SIGMIGRATE 1
#endif
#ifdef SIGPHONE
#define HAD_SIGPHONE 1
#endif
#ifdef SIGPIPE
#define HAD_SIGPIPE 1
#endif
#ifdef SIGPOLL
#define HAD_SIGPOLL 1
#endif
#ifdef SIGPROF
#define HAD_SIGPROF 1
#endif
#ifdef SIGPWR
#define HAD_SIGPWR 1
#endif
#ifdef SIGQUIT
#define HAD_SIGQUIT 1
#endif
#ifdef SIGSEGV
#define HAD_SIGSEGV 1
#endif
#ifdef SIGSOUND
#define HAD_SIGSOUND 1
#endif
#ifdef SIGSSTOP
#define HAD_SIGSSTOP 1
#endif
#ifdef gould
#define HAD_gould 1
"Stack overflow", "STKOV", 28,
#endif
#ifdef SIGSTOP
#define HAD_SIGSTOP 1
#endif
#ifdef SIGSYS
#define HAD_SIGSYS 1
#endif
#ifdef SIGTERM
#define HAD_SIGTERM 1
#endif
#ifdef SIGTHAW
#define HAD_SIGTHAW 1
#endif
#ifdef SIGTINT
#define HAD_SIGTINT 1
#endif
#ifdef SIGTRAP
#define HAD_SIGTRAP 1
#endif
#ifdef SIGTSTP
#define HAD_SIGTSTP 1
#endif
#ifdef SIGTTIN
#define HAD_SIGTTIN 1
#endif
#ifdef SIGTTOU
#define HAD_SIGTTOU 1
#endif
#ifdef SIGURG
#define HAD_SIGURG 1
#endif
#ifdef SIGUSR1
#define HAD_SIGUSR1 1
#endif
#ifdef SIGUSR2
#define HAD_SIGUSR2 1
#endif
#ifdef SIGVTALRM
#define HAD_SIGVTALRM 1
#endif
#ifdef SIGWAITING
#define HAD_SIGWAITING 1
#endif
#ifdef SIGWINCH
#define HAD_SIGWINCH 1
#endif
#ifdef SIGWIND
#define HAD_SIGWIND 1
#endif
#ifdef SIGWINDOW
#define HAD_SIGWINDOW 1
#endif
#ifdef SIGXCPU
#define HAD_SIGXCPU 1
#endif
#ifdef SIGXFSZ
#define HAD_SIGXFSZ 1
#endif
0
};
static int mapindex[1024];
#if _lib_strsignal
extern char* strsignal(int);
#endif
int
main()
{
register int i;
register int j;
register int k;
int m;
int n;
#if _lib_strsignal
char* s;
#endif
k = 0;
{
if (j > k)
k = j;
mapindex[j] = i;
}
#ifdef SIGRTMIN
i = SIGRTMIN;
#ifdef SIGRTMAX
j = SIGRTMAX;
#else
j = i;
#endif
if (j >= elementsof(mapindex))
{
if (j > k)
k = j;
n = 1;
while (++i < j)
}
#endif
printf("#pragma prototyped\n");
printf("#define SIG_MAX %d\n", k);
printf("\n");
printf("static const char* const sig_name[] =\n");
printf("{\n");
for (i = 0; i <= k; i++)
if (!(j = mapindex[i]))
printf(" \"%d\",\n", i);
else if (j & RANGE_RT)
{
if (j & RANGE_MIN)
printf(" \"RTMIN\",\n");
else if (j & RANGE_MAX)
printf(" \"RTMAX\",\n");
else
{
m = j & RANGE_SIG;
if (m > n / 2)
printf(" \"RTMAX-%d\",\n", n - m);
else
printf(" \"RTMIN+%d\",\n", m);
}
}
else
printf(" 0\n");
printf("};\n");
printf("\n");
printf("static const char* const sig_text[] =\n");
printf("{\n");
for (i = 0; i <= k; i++)
if (!(j = mapindex[i]))
printf(" \"Signal %d\",\n", i);
else if (j & RANGE_RT)
printf(" \"Realtime priority %d%s\",\n", j & RANGE_SIG, (j & RANGE_MIN) ? " (lo)" : (j & RANGE_MAX) ? " (hi)" : "");
#if _lib_strsignal
else if (s = strsignal(i))
printf(" \"%s\",\n", s);
#endif
else
printf(" \"Signal %d\",\n", i);
printf(" 0\n");
printf("};\n");
return 0;
}