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