]> git.ipfire.org Git - thirdparty/gcc.git/blame - libgo/mksigtab.sh
runtime: fix assembly syntax
[thirdparty/gcc.git] / libgo / mksigtab.sh
CommitLineData
87211034 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
03118c21 24SIGLIST=""
25
87211034 26# Handle signals valid on all Unix systems.
27
03118c21 28addsig() {
29 echo " $1: $2,"
30 # Get the signal number and add it to SIGLIST
6d68866a 31 signum=`grep "const $1 = " gen-sysinfo.go | sed -e 's/.* = //'`
bab15769 32 if echo "$signum" | grep '^_SIG[A-Z0-9_]*$' >/dev/null 2>&1; then
6d68866a 33 # Recurse once to obtain signal number
34 # This is needed for some MIPS signals defined as aliases of other signals
35 signum=`grep "const $signum = " gen-sysinfo.go | sed -e 's/.* = //'`
36 fi
03118c21 37 SIGLIST=$SIGLIST"_${signum}_"
38}
39
87211034 40echo ' 0: {0, "SIGNONE: no trap"},'
03118c21 41addsig _SIGHUP '{_SigNotify + _SigKill, "SIGHUP: terminal line hangup"}'
42addsig _SIGINT '{_SigNotify + _SigKill, "SIGINT: interrupt"}'
43addsig _SIGQUIT '{_SigNotify + _SigThrow, "SIGQUIT: quit"}'
44addsig _SIGILL '{_SigThrow + _SigUnblock, "SIGILL: illegal instruction"}'
45addsig _SIGTRAP '{_SigThrow + _SigUnblock, "SIGTRAP: trace trap"}'
46addsig _SIGABRT '{_SigNotify + _SigThrow, "SIGABRT: abort"}'
47addsig _SIGBUS '{_SigPanic + _SigUnblock, "SIGBUS: bus error"}'
48addsig _SIGFPE '{_SigPanic + _SigUnblock, "SIGFPE: floating-point exception"}'
49addsig _SIGKILL '{0, "SIGKILL: kill"}'
50addsig _SIGUSR1 '{_SigNotify, "SIGUSR1: user-defined signal 1"}'
51addsig _SIGSEGV '{_SigPanic + _SigUnblock, "SIGSEGV: segmentation violation"}'
52addsig _SIGUSR2 '{_SigNotify, "SIGUSR2: user-defined signal 2"}'
53addsig _SIGPIPE '{_SigNotify, "SIGPIPE: write to broken pipe"}'
54addsig _SIGALRM '{_SigNotify, "SIGALRM: alarm clock"}'
55addsig _SIGTERM '{_SigNotify + _SigKill, "SIGTERM: termination"}'
56addsig _SIGCHLD '{_SigNotify + _SigUnblock, "SIGCHLD: child status has changed"}'
57addsig _SIGCONT '{_SigNotify + _SigDefault, "SIGCONT: continue"}'
58addsig _SIGSTOP '{0, "SIGSTOP: stop"}'
59addsig _SIGTSTP '{_SigNotify + _SigDefault, "SIGTSTP: keyboard stop"}'
60addsig _SIGTTIN '{_SigNotify + _SigDefault, "SIGTTIN: background read from tty"}'
61addsig _SIGTTOU '{_SigNotify + _SigDefault, "SIGTTOU: background write to tty"}'
62addsig _SIGURG '{_SigNotify, "SIGURG: urgent condition on socket"}'
63addsig _SIGXCPU '{_SigNotify, "SIGXCPU: cpu limit exceeded"}'
64addsig _SIGXFSZ '{_SigNotify, "SIGXFSZ: file size limit exceeded"}'
65addsig _SIGVTALRM '{_SigNotify, "SIGVTALRM: virtual alarm clock"}'
66addsig _SIGPROF '{_SigNotify + _SigUnblock, "SIGPROF: profiling alarm clock"}'
67addsig _SIGWINCH '{_SigNotify, "SIGWINCH: window size change"}'
68addsig _SIGSYS '{_SigThrow, "SIGSYS: bad system call"}'
87211034 69
70# Handle signals that are not supported on all systems.
71
72checksig() {
9ee6024b 73 if grep "const $1 = " gen-sysinfo.go >/dev/null 2>&1 \
74 && ! grep "const $1 = _SIG" gen-sysinfo.go > /dev/null 2>&1; then
03118c21 75 addsig $1 "$2"
87211034 76 fi
77}
78
03118c21 79checksig _SIGSTKFLT '{_SigThrow + _SigUnblock, "SIGSTKFLT: stack fault"}'
80checksig _SIGIO '{_SigNotify, "SIGIO: i/o now possible"}'
81checksig _SIGPWR '{_SigNotify, "SIGPWR: power failure restart"}'
82checksig _SIGEMT '{_SigThrow, "SIGEMT: emulate instruction executed"}'
83checksig _SIGINFO '{_SigNotify, "SIGINFO: status request from keyboard"}'
84checksig _SIGTHR '{_SigNotify, "SIGTHR: reserved"}'
85checksig _SIGPOLL '{_SigNotify, "SIGPOLL: pollable event occurred"}'
87211034 86checksig _SIGWAITING '{_SigNotify, "SIGWAITING: reserved signal no longer used by"}'
03118c21 87checksig _SIGLWP '{_SigNotify, "SIGLWP: reserved signal no longer used by"}'
88checksig _SIGFREEZE '{_SigNotify, "SIGFREEZE: special signal used by CPR"}'
89checksig _SIGTHAW '{_SigNotify, "SIGTHAW: special signal used by CPR"}'
90checksig _SIGCANCEL '{_SigSetStack + _SigUnblock, "SIGCANCEL: reserved signal for thread cancellation"}'
91checksig _SIGXRES '{_SigNotify, "SIGXRES: resource control exceeded"}'
92checksig _SIGJVM1 '{_SigNotify, "SIGJVM1: reserved signal for Java Virtual Machine"}'
93checksig _SIGJVM2 '{_SigNotify, "SIGJVM2: reserved signal for Java Virtual Machine"}'
c6ad139d 94checksig _SIGLOST ' {_SigNotify, "SIGLOST: resource lost (Sun); server died (GNU)"}'
87211034 95
96# Special handling of signals 32 and 33 on GNU/Linux systems,
97# because they are special to glibc.
98if test "${GOOS}" = "linux"; then
03118c21 99 SIGLIST=$SIGLIST"_32__33_"
87211034 100 echo ' 32: {_SigSetStack + _SigUnblock, "signal 32"}, /* SIGCANCEL; see issue 6997 */'
101 echo ' 33: {_SigSetStack + _SigUnblock, "signal 33"}, /* SIGSETXID; see issues 3871, 9400, 12498 */'
102fi
103
03118c21 104if test "${GOOS}" = "aix"; then
105 # _NSIG = _NSIG32/_NSIG64 and _NSIG* = _SIGMAX* + 1
106 bits=`grep 'const _NSIG = _NSIG[0-9]*$' gen-sysinfo.go | sed -e 's/.* = _NSIG\([0-9]*\)/\1/'`
107 nsig=`grep "const _SIGMAX$bits = [0-9]*$" gen-sysinfo.go | sed -e 's/.* = \([0-9]*\)/\1/'`
108 nsig=`expr $nsig + 1`
109else
110 nsig=`grep 'const _*NSIG = [0-9]*$' gen-sysinfo.go | sed -e 's/.* = \([0-9]*\)/\1/'`
a7cc3f54 111 if test -z "$nsig"; then
112 if grep 'const _*NSIG = [ (]*_*SIGRTMAX + 1[ )]*' gen-sysinfo.go >/dev/null 2>&1; then
113 rtmax=`grep 'const _*SIGRTMAX = [0-9]*$' gen-sysinfo.go | sed -e 's/.* = \([0-9]*\)/\1/'`
114 if test -n "$rtmax"; then
115 nsig=`expr $rtmax + 1`
c6ad139d 116 elif grep 'const _*SIGRTMAX = [ (]*_*SIGRTMIN[ )]*' gen-sysinfo.go >/dev/null 2>&1; then
117 rtmin=`grep 'const _*SIGRTMIN = [0-9]*$' gen-sysinfo.go | sed -e 's/.* = \([0-9]*\)/\1/'`
118 if test -n "$rtmin"; then
119 nsig=`expr $rtmin + 1`
120 fi
a7cc3f54 121 fi
122 fi
123 fi
124fi
125
126if test -z "$nsig"; then
127 echo 1>&2 "could not determine number of signals"
128 exit 1
03118c21 129fi
130
87211034 131i=1
03118c21 132# Fill in the remaining signal numbers in sigtable
87211034 133while test "$i" -lt "$nsig"; do
03118c21 134 if ! echo $SIGLIST | grep "_${i}_" >/dev/null 2>&1; then
135 echo " $i: {_SigNotify, \"signal $i\"},"
87211034 136 fi
137 i=`expr "$i" + 1`
138done
87211034 139echo '}'