2017-04-07 Vladimir Makarov <vmakarov@redhat.com>
[official-gcc.git] / libgo / mksigtab.sh
blobfd31022824c00a4f9549b1809c4ac3aa776c7753
1 #!/bin/sh
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.
7 # Create sigtab.go from gen-sysinfo.go.
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.
14 # This script simply writes to standard output.
16 set -e
18 echo '// Generated by mksigtab.sh. Do not edit.'
19 echo
20 echo 'package runtime'
21 echo
22 echo 'var sigtable = [...]sigTabT{'
24 # Handle signals valid on all Unix systems.
26 echo ' 0: {0, "SIGNONE: no trap"},'
27 echo ' _SIGHUP: {_SigNotify + _SigKill, "SIGHUP: terminal line hangup"},'
28 echo ' _SIGINT: {_SigNotify + _SigKill, "SIGINT: interrupt"},'
29 echo ' _SIGQUIT: {_SigNotify + _SigThrow, "SIGQUIT: quit"},'
30 echo ' _SIGILL: {_SigThrow + _SigUnblock, "SIGILL: illegal instruction"},'
31 echo ' _SIGTRAP: {_SigThrow + _SigUnblock, "SIGTRAP: trace trap"},'
32 echo ' _SIGABRT: {_SigNotify + _SigThrow, "SIGABRT: abort"},'
33 echo ' _SIGBUS: {_SigPanic + _SigUnblock, "SIGBUS: bus error"},'
34 echo ' _SIGFPE: {_SigPanic + _SigUnblock, "SIGFPE: floating-point exception"},'
35 echo ' _SIGKILL: {0, "SIGKILL: kill"},'
36 echo ' _SIGUSR1: {_SigNotify, "SIGUSR1: user-defined signal 1"},'
37 echo ' _SIGSEGV: {_SigPanic + _SigUnblock, "SIGSEGV: segmentation violation"},'
38 echo ' _SIGUSR2: {_SigNotify, "SIGUSR2: user-defined signal 2"},'
39 echo ' _SIGPIPE: {_SigNotify, "SIGPIPE: write to broken pipe"},'
40 echo ' _SIGALRM: {_SigNotify, "SIGALRM: alarm clock"},'
41 echo ' _SIGTERM: {_SigNotify + _SigKill, "SIGTERM: termination"},'
42 echo ' _SIGCHLD: {_SigNotify + _SigUnblock, "SIGCHLD: child status has changed"},'
43 echo ' _SIGCONT: {_SigNotify + _SigDefault, "SIGCONT: continue"},'
44 echo ' _SIGSTOP: {0, "SIGSTOP: stop"},'
45 echo ' _SIGTSTP: {_SigNotify + _SigDefault, "SIGTSTP: keyboard stop"},'
46 echo ' _SIGTTIN: {_SigNotify + _SigDefault, "SIGTTIN: background read from tty"},'
47 echo ' _SIGTTOU: {_SigNotify + _SigDefault, "SIGTTOU: background write to tty"},'
48 echo ' _SIGURG: {_SigNotify, "SIGURG: urgent condition on socket"},'
49 echo ' _SIGXCPU: {_SigNotify, "SIGXCPU: cpu limit exceeded"},'
50 echo ' _SIGXFSZ: {_SigNotify, "SIGXFSZ: file size limit exceeded"},'
51 echo ' _SIGVTALRM: {_SigNotify, "SIGVTALRM: virtual alarm clock"},'
52 echo ' _SIGPROF: {_SigNotify + _SigUnblock, "SIGPROF: profiling alarm clock"},'
53 echo ' _SIGWINCH: {_SigNotify, "SIGWINCH: window size change"},'
54 echo ' _SIGSYS: {_SigThrow, "SIGSYS: bad system call"},'
56 # Handle signals that are not supported on all systems.
58 checksig() {
59 if grep "const $1 = " gen-sysinfo.go >/dev/null 2>&1 \
60 && ! grep "const $1 = _SIG" gen-sysinfo.go > /dev/null 2>&1; then
61 echo " $1: $2,"
65 checksig _SIGSTKFLT ' {_SigThrow + _SigUnblock, "SIGSTKFLT: stack fault"}'
66 checksig _SIGIO ' {_SigNotify, "SIGIO: i/o now possible"}'
67 checksig _SIGPWR ' {_SigNotify, "SIGPWR: power failure restart"}'
68 checksig _SIGEMT ' {_SigThrow, "SIGEMT: emulate instruction executed"}'
69 checksig _SIGINFO ' {_SigNotify, "SIGINFO: status request from keyboard"}'
70 checksig _SIGTHR ' {_SigNotify, "SIGTHR: reserved"}'
71 checksig _SIGPOLL ' {_SigNotify, "SIGPOLL: pollable event occurred"}'
72 checksig _SIGWAITING '{_SigNotify, "SIGWAITING: reserved signal no longer used by"}'
73 checksig _SIGLWP ' {_SigNotify, "SIGLWP: reserved signal no longer used by"}'
74 checksig _SIGFREEZE ' {_SigNotify, "SIGFREEZE: special signal used by CPR"}'
75 checksig _SIGTHAW ' {_SigNotify, "SIGTHAW: special signal used by CPR"}'
76 checksig _SIGCANCEL ' {_SigSetStack + _SigUnblock, "SIGCANCEL: reserved signal for thread cancellation"}'
77 checksig _SIGXRES ' {_SigNotify, "SIGXRES: resource control exceeded"}'
78 checksig _SIGJVM1 ' {_SigNotify, "SIGJVM1: reserved signal for Java Virtual Machine"}'
79 checksig _SIGJVM2 ' {_SigNotify, "SIGJVM2: reserved signal for Java Virtual Machine"}'
81 # Special handling of signals 32 and 33 on GNU/Linux systems,
82 # because they are special to glibc.
83 if test "${GOOS}" = "linux"; then
84 echo ' 32: {_SigSetStack + _SigUnblock, "signal 32"}, /* SIGCANCEL; see issue 6997 */'
85 echo ' 33: {_SigSetStack + _SigUnblock, "signal 33"}, /* SIGSETXID; see issues 3871, 9400, 12498 */'
88 nsig=`grep 'const _*NSIG = [0-9]*$' gen-sysinfo.go | sed -e 's/.* = \([0-9]*\)/\1/'`
89 i=1
90 while test "$i" -lt "$nsig"; do
91 if ! grep "const _SIG.* = $i" gen-sysinfo.go >/dev/null 2>&1; then
92 if test "${GOOS}" != "linux" || test "$i" -ne 32 -a "$i" -ne 33; then
93 echo " $i: {_SigNotify, \"signal $i\"},"
96 i=`expr "$i" + 1`
97 done
99 echo '}'