Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
att
GitHub Repository: att/ast
Path: blob/master/src/lib/libast/features/sig.sh
1810 views
1
########################################################################
2
# #
3
# This software is part of the ast package #
4
# Copyright (c) 1985-2011 AT&T Intellectual Property #
5
# and is licensed under the #
6
# Eclipse Public License, Version 1.0 #
7
# by AT&T Intellectual Property #
8
# #
9
# A copy of the License is available at #
10
# http://www.eclipse.org/org/documents/epl-v10.html #
11
# (with md5 checksum b35adb5213ca9657e911e9befb180842) #
12
# #
13
# Information and Software Systems Research #
14
# AT&T Research #
15
# Florham Park NJ #
16
# #
17
# Glenn Fowler <[email protected]> #
18
# David Korn <[email protected]> #
19
# Phong Vo <[email protected]> #
20
# #
21
########################################################################
22
: generate sig features
23
case $# in
24
0) ;;
25
*) eval $1
26
shift
27
;;
28
esac
29
echo "#include <signal.h>
30
int xxx;" > $tmp.c
31
$cc -c $tmp.c >/dev/null 2>$tmp.e
32
echo "#pragma prototyped
33
#define sig_info _sig_info_
34
35
#if defined(__STDPP__directive) && defined(__STDPP__hide)
36
__STDPP__directive pragma pp:hide kill killpg
37
#else
38
#define kill ______kill
39
#define killpg ______killpg
40
#endif
41
#include <signal.h>
42
#if defined(__STDPP__directive) && defined(__STDPP__hide)
43
__STDPP__directive pragma pp:nohide kill killpg
44
#else
45
#undef kill
46
#undef killpg
47
#endif
48
#ifndef sigmask
49
#define sigmask(s) (1<<((s)-1))
50
#endif"
51
echo "#include <signal.h>
52
#ifdef TYPE
53
#if defined(__STDC__) || defined(__cplusplus) || defined(c_plusplus)
54
typedef TYPE (*Sig_handler_t)(ARG);
55
#else
56
typedef TYPE (*Sig_handler_t)();
57
#endif
58
#endif
59
Sig_handler_t f()
60
{
61
Sig_handler_t handler;
62
handler = signal(1, SIG_IGN);
63
return(handler);
64
}" > $tmp.c
65
if $cc -c $tmp.c >/dev/null
66
then :
67
else e=`wc -l $tmp.e`
68
i1= j1=
69
for i in void int
70
do for j in int,... ... int
71
do $cc -c -DTYPE=$i -DARG=$j $tmp.c >/dev/null 2>$tmp.e || continue
72
case `wc -l $tmp.e` in
73
$e) i1= j1=; break 2 ;;
74
esac
75
case $i1 in
76
"") i1=$i j1=$j ;;
77
esac
78
done
79
done
80
case $i1 in
81
?*) i=$i1 j=$j1 ;;
82
esac
83
echo "typedef $i (*Sig_handler_t)($j);"
84
fi
85
echo '
86
87
#define Handler_t Sig_handler_t
88
89
#define SIG_REG_PENDING (-1)
90
#define SIG_REG_POP 0
91
#define SIG_REG_EXEC 00001
92
#define SIG_REG_PROC 00002
93
#define SIG_REG_TERM 00004
94
#define SIG_REG_ALL 00777
95
#define SIG_REG_SET 01000
96
97
typedef struct
98
{
99
char** name;
100
char** text;
101
int sigmax;
102
} Sig_info_t;
103
104
extern int kill(pid_t, int);
105
extern int killpg(pid_t, int);
106
107
#if _BLD_ast && defined(__EXPORT__)
108
#define extern extern __EXPORT__
109
#endif
110
#if !_BLD_ast && defined(__IMPORT__)
111
#define extern extern __IMPORT__
112
#endif
113
114
extern Sig_info_t sig_info;
115
116
#undef extern
117
118
#if _lib_sigflag && _npt_sigflag
119
extern int sigflag(int, int, int);
120
#endif
121
122
#if _BLD_ast && defined(__EXPORT__)
123
#define extern __EXPORT__
124
#endif
125
126
#if !_lib_sigflag
127
extern int sigflag(int, int, int);
128
#endif
129
extern int sigcritical(int);
130
extern int sigunblock(int);
131
132
#undef extern'
133
134