annotate libgo/mksigtab.sh @ 158:494b0b89df80 default tip

...
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Mon, 25 May 2020 18:13:55 +0900
parents 1830386684a0
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
111
kono
parents:
diff changeset
1 #!/bin/sh
kono
parents:
diff changeset
2
kono
parents:
diff changeset
3 # Copyright 2016 The Go Authors. All rights reserved.
kono
parents:
diff changeset
4 # Use of this source code is governed by a BSD-style
kono
parents:
diff changeset
5 # license that can be found in the LICENSE file.
kono
parents:
diff changeset
6
kono
parents:
diff changeset
7 # Create sigtab.go from gen-sysinfo.go.
kono
parents:
diff changeset
8
kono
parents:
diff changeset
9 # This shell scripts creates the sigtab.go file, which maps signals to
kono
parents:
diff changeset
10 # their dispositions. We generate a file so that we can build a
kono
parents:
diff changeset
11 # composite literal that only refers to signals that are defined on
kono
parents:
diff changeset
12 # this system.
kono
parents:
diff changeset
13
kono
parents:
diff changeset
14 # This script simply writes to standard output.
kono
parents:
diff changeset
15
kono
parents:
diff changeset
16 set -e
kono
parents:
diff changeset
17
kono
parents:
diff changeset
18 echo '// Generated by mksigtab.sh. Do not edit.'
kono
parents:
diff changeset
19 echo
kono
parents:
diff changeset
20 echo 'package runtime'
kono
parents:
diff changeset
21 echo
kono
parents:
diff changeset
22 echo 'var sigtable = [...]sigTabT{'
kono
parents:
diff changeset
23
kono
parents:
diff changeset
24 SIGLIST=""
kono
parents:
diff changeset
25
kono
parents:
diff changeset
26 # Handle signals valid on all Unix systems.
kono
parents:
diff changeset
27
kono
parents:
diff changeset
28 addsig() {
kono
parents:
diff changeset
29 echo " $1: $2,"
kono
parents:
diff changeset
30 # Get the signal number and add it to SIGLIST
kono
parents:
diff changeset
31 signum=`grep "const $1 = " gen-sysinfo.go | sed -e 's/.* = //'`
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
32 if echo "$signum" | grep '^_SIG[A-Z0-9_]*$' >/dev/null 2>&1; then
111
kono
parents:
diff changeset
33 # Recurse once to obtain signal number
kono
parents:
diff changeset
34 # This is needed for some MIPS signals defined as aliases of other signals
kono
parents:
diff changeset
35 signum=`grep "const $signum = " gen-sysinfo.go | sed -e 's/.* = //'`
kono
parents:
diff changeset
36 fi
kono
parents:
diff changeset
37 SIGLIST=$SIGLIST"_${signum}_"
kono
parents:
diff changeset
38 }
kono
parents:
diff changeset
39
kono
parents:
diff changeset
40 echo ' 0: {0, "SIGNONE: no trap"},'
kono
parents:
diff changeset
41 addsig _SIGHUP '{_SigNotify + _SigKill, "SIGHUP: terminal line hangup"}'
kono
parents:
diff changeset
42 addsig _SIGINT '{_SigNotify + _SigKill, "SIGINT: interrupt"}'
kono
parents:
diff changeset
43 addsig _SIGQUIT '{_SigNotify + _SigThrow, "SIGQUIT: quit"}'
kono
parents:
diff changeset
44 addsig _SIGILL '{_SigThrow + _SigUnblock, "SIGILL: illegal instruction"}'
kono
parents:
diff changeset
45 addsig _SIGTRAP '{_SigThrow + _SigUnblock, "SIGTRAP: trace trap"}'
kono
parents:
diff changeset
46 addsig _SIGABRT '{_SigNotify + _SigThrow, "SIGABRT: abort"}'
kono
parents:
diff changeset
47 addsig _SIGBUS '{_SigPanic + _SigUnblock, "SIGBUS: bus error"}'
kono
parents:
diff changeset
48 addsig _SIGFPE '{_SigPanic + _SigUnblock, "SIGFPE: floating-point exception"}'
kono
parents:
diff changeset
49 addsig _SIGKILL '{0, "SIGKILL: kill"}'
kono
parents:
diff changeset
50 addsig _SIGUSR1 '{_SigNotify, "SIGUSR1: user-defined signal 1"}'
kono
parents:
diff changeset
51 addsig _SIGSEGV '{_SigPanic + _SigUnblock, "SIGSEGV: segmentation violation"}'
kono
parents:
diff changeset
52 addsig _SIGUSR2 '{_SigNotify, "SIGUSR2: user-defined signal 2"}'
kono
parents:
diff changeset
53 addsig _SIGPIPE '{_SigNotify, "SIGPIPE: write to broken pipe"}'
kono
parents:
diff changeset
54 addsig _SIGALRM '{_SigNotify, "SIGALRM: alarm clock"}'
kono
parents:
diff changeset
55 addsig _SIGTERM '{_SigNotify + _SigKill, "SIGTERM: termination"}'
kono
parents:
diff changeset
56 addsig _SIGCHLD '{_SigNotify + _SigUnblock, "SIGCHLD: child status has changed"}'
kono
parents:
diff changeset
57 addsig _SIGCONT '{_SigNotify + _SigDefault, "SIGCONT: continue"}'
kono
parents:
diff changeset
58 addsig _SIGSTOP '{0, "SIGSTOP: stop"}'
kono
parents:
diff changeset
59 addsig _SIGTSTP '{_SigNotify + _SigDefault, "SIGTSTP: keyboard stop"}'
kono
parents:
diff changeset
60 addsig _SIGTTIN '{_SigNotify + _SigDefault, "SIGTTIN: background read from tty"}'
kono
parents:
diff changeset
61 addsig _SIGTTOU '{_SigNotify + _SigDefault, "SIGTTOU: background write to tty"}'
kono
parents:
diff changeset
62 addsig _SIGURG '{_SigNotify, "SIGURG: urgent condition on socket"}'
kono
parents:
diff changeset
63 addsig _SIGXCPU '{_SigNotify, "SIGXCPU: cpu limit exceeded"}'
kono
parents:
diff changeset
64 addsig _SIGXFSZ '{_SigNotify, "SIGXFSZ: file size limit exceeded"}'
kono
parents:
diff changeset
65 addsig _SIGVTALRM '{_SigNotify, "SIGVTALRM: virtual alarm clock"}'
kono
parents:
diff changeset
66 addsig _SIGPROF '{_SigNotify + _SigUnblock, "SIGPROF: profiling alarm clock"}'
kono
parents:
diff changeset
67 addsig _SIGWINCH '{_SigNotify, "SIGWINCH: window size change"}'
kono
parents:
diff changeset
68 addsig _SIGSYS '{_SigThrow, "SIGSYS: bad system call"}'
kono
parents:
diff changeset
69
kono
parents:
diff changeset
70 # Handle signals that are not supported on all systems.
kono
parents:
diff changeset
71
kono
parents:
diff changeset
72 checksig() {
kono
parents:
diff changeset
73 if grep "const $1 = " gen-sysinfo.go >/dev/null 2>&1 \
kono
parents:
diff changeset
74 && ! grep "const $1 = _SIG" gen-sysinfo.go > /dev/null 2>&1; then
kono
parents:
diff changeset
75 addsig $1 "$2"
kono
parents:
diff changeset
76 fi
kono
parents:
diff changeset
77 }
kono
parents:
diff changeset
78
kono
parents:
diff changeset
79 checksig _SIGSTKFLT '{_SigThrow + _SigUnblock, "SIGSTKFLT: stack fault"}'
kono
parents:
diff changeset
80 checksig _SIGIO '{_SigNotify, "SIGIO: i/o now possible"}'
kono
parents:
diff changeset
81 checksig _SIGPWR '{_SigNotify, "SIGPWR: power failure restart"}'
kono
parents:
diff changeset
82 checksig _SIGEMT '{_SigThrow, "SIGEMT: emulate instruction executed"}'
kono
parents:
diff changeset
83 checksig _SIGINFO '{_SigNotify, "SIGINFO: status request from keyboard"}'
kono
parents:
diff changeset
84 checksig _SIGTHR '{_SigNotify, "SIGTHR: reserved"}'
kono
parents:
diff changeset
85 checksig _SIGPOLL '{_SigNotify, "SIGPOLL: pollable event occurred"}'
kono
parents:
diff changeset
86 checksig _SIGWAITING '{_SigNotify, "SIGWAITING: reserved signal no longer used by"}'
kono
parents:
diff changeset
87 checksig _SIGLWP '{_SigNotify, "SIGLWP: reserved signal no longer used by"}'
kono
parents:
diff changeset
88 checksig _SIGFREEZE '{_SigNotify, "SIGFREEZE: special signal used by CPR"}'
kono
parents:
diff changeset
89 checksig _SIGTHAW '{_SigNotify, "SIGTHAW: special signal used by CPR"}'
kono
parents:
diff changeset
90 checksig _SIGCANCEL '{_SigSetStack + _SigUnblock, "SIGCANCEL: reserved signal for thread cancellation"}'
kono
parents:
diff changeset
91 checksig _SIGXRES '{_SigNotify, "SIGXRES: resource control exceeded"}'
kono
parents:
diff changeset
92 checksig _SIGJVM1 '{_SigNotify, "SIGJVM1: reserved signal for Java Virtual Machine"}'
kono
parents:
diff changeset
93 checksig _SIGJVM2 '{_SigNotify, "SIGJVM2: reserved signal for Java Virtual Machine"}'
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
94 checksig _SIGLOST ' {_SigNotify, "SIGLOST: resource lost (Sun); server died (GNU)"}'
111
kono
parents:
diff changeset
95
kono
parents:
diff changeset
96 # Special handling of signals 32 and 33 on GNU/Linux systems,
kono
parents:
diff changeset
97 # because they are special to glibc.
kono
parents:
diff changeset
98 if test "${GOOS}" = "linux"; then
kono
parents:
diff changeset
99 SIGLIST=$SIGLIST"_32__33_"
kono
parents:
diff changeset
100 echo ' 32: {_SigSetStack + _SigUnblock, "signal 32"}, /* SIGCANCEL; see issue 6997 */'
kono
parents:
diff changeset
101 echo ' 33: {_SigSetStack + _SigUnblock, "signal 33"}, /* SIGSETXID; see issues 3871, 9400, 12498 */'
kono
parents:
diff changeset
102 fi
kono
parents:
diff changeset
103
kono
parents:
diff changeset
104 if test "${GOOS}" = "aix"; then
kono
parents:
diff changeset
105 # _NSIG = _NSIG32/_NSIG64 and _NSIG* = _SIGMAX* + 1
kono
parents:
diff changeset
106 bits=`grep 'const _NSIG = _NSIG[0-9]*$' gen-sysinfo.go | sed -e 's/.* = _NSIG\([0-9]*\)/\1/'`
kono
parents:
diff changeset
107 nsig=`grep "const _SIGMAX$bits = [0-9]*$" gen-sysinfo.go | sed -e 's/.* = \([0-9]*\)/\1/'`
kono
parents:
diff changeset
108 nsig=`expr $nsig + 1`
kono
parents:
diff changeset
109 else
kono
parents:
diff changeset
110 nsig=`grep 'const _*NSIG = [0-9]*$' gen-sysinfo.go | sed -e 's/.* = \([0-9]*\)/\1/'`
kono
parents:
diff changeset
111 if test -z "$nsig"; then
kono
parents:
diff changeset
112 if grep 'const _*NSIG = [ (]*_*SIGRTMAX + 1[ )]*' gen-sysinfo.go >/dev/null 2>&1; then
kono
parents:
diff changeset
113 rtmax=`grep 'const _*SIGRTMAX = [0-9]*$' gen-sysinfo.go | sed -e 's/.* = \([0-9]*\)/\1/'`
kono
parents:
diff changeset
114 if test -n "$rtmax"; then
kono
parents:
diff changeset
115 nsig=`expr $rtmax + 1`
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
116 elif grep 'const _*SIGRTMAX = [ (]*_*SIGRTMIN[ )]*' gen-sysinfo.go >/dev/null 2>&1; then
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
117 rtmin=`grep 'const _*SIGRTMIN = [0-9]*$' gen-sysinfo.go | sed -e 's/.* = \([0-9]*\)/\1/'`
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
118 if test -n "$rtmin"; then
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
119 nsig=`expr $rtmin + 1`
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
120 fi
111
kono
parents:
diff changeset
121 fi
kono
parents:
diff changeset
122 fi
kono
parents:
diff changeset
123 fi
kono
parents:
diff changeset
124 fi
kono
parents:
diff changeset
125
kono
parents:
diff changeset
126 if test -z "$nsig"; then
kono
parents:
diff changeset
127 echo 1>&2 "could not determine number of signals"
kono
parents:
diff changeset
128 exit 1
kono
parents:
diff changeset
129 fi
kono
parents:
diff changeset
130
kono
parents:
diff changeset
131 i=1
kono
parents:
diff changeset
132 # Fill in the remaining signal numbers in sigtable
kono
parents:
diff changeset
133 while test "$i" -lt "$nsig"; do
kono
parents:
diff changeset
134 if ! echo $SIGLIST | grep "_${i}_" >/dev/null 2>&1; then
kono
parents:
diff changeset
135 echo " $i: {_SigNotify, \"signal $i\"},"
kono
parents:
diff changeset
136 fi
kono
parents:
diff changeset
137 i=`expr "$i" + 1`
kono
parents:
diff changeset
138 done
kono
parents:
diff changeset
139 echo '}'