2009-11-14 16:29:09 -07:00
|
|
|
#!/usr/bin/env bash
|
2009-06-01 23:14:57 -06:00
|
|
|
# Copyright 2009 The Go Authors. All rights reserved.
|
|
|
|
# Use of this source code is governed by a BSD-style
|
|
|
|
# license that can be found in the LICENSE file.
|
|
|
|
|
2009-11-01 12:13:27 -07:00
|
|
|
# Generate Go code listing errors and other #defined constant
|
|
|
|
# values (ENAMETOOLONG etc.), by asking the preprocessor
|
|
|
|
# about the definitions.
|
2009-06-01 23:14:57 -06:00
|
|
|
|
2009-12-01 17:53:43 -07:00
|
|
|
unset LANG
|
|
|
|
export LC_ALL=C
|
|
|
|
export LC_CTYPE=C
|
|
|
|
|
2010-08-23 04:25:14 -06:00
|
|
|
GCC=gcc
|
2009-10-01 07:55:01 -06:00
|
|
|
|
2009-11-01 12:13:27 -07:00
|
|
|
uname=$(uname)
|
2009-06-01 23:14:57 -06:00
|
|
|
|
2009-11-01 12:13:27 -07:00
|
|
|
includes_Darwin='
|
2011-01-18 12:02:41 -07:00
|
|
|
#define _DARWIN_C_SOURCE
|
2009-11-01 12:13:27 -07:00
|
|
|
#define KERNEL
|
|
|
|
#define _DARWIN_USE_64_BIT_INODE
|
2011-02-11 12:34:00 -07:00
|
|
|
#include <sys/types.h>
|
2009-11-01 12:13:27 -07:00
|
|
|
#include <sys/event.h>
|
2011-06-14 10:56:46 -06:00
|
|
|
#include <sys/ptrace.h>
|
2011-01-31 10:50:50 -07:00
|
|
|
#include <sys/socket.h>
|
|
|
|
#include <sys/sockio.h>
|
2011-02-11 12:34:00 -07:00
|
|
|
#include <sys/sysctl.h>
|
2011-04-06 15:52:02 -06:00
|
|
|
#include <sys/mman.h>
|
2011-02-11 12:34:00 -07:00
|
|
|
#include <sys/wait.h>
|
2011-04-21 14:58:20 -06:00
|
|
|
#include <net/bpf.h>
|
2011-01-31 10:50:50 -07:00
|
|
|
#include <net/if.h>
|
2011-05-26 18:02:03 -06:00
|
|
|
#include <net/if_types.h>
|
2011-02-11 12:34:00 -07:00
|
|
|
#include <net/route.h>
|
|
|
|
#include <netinet/in.h>
|
2011-01-31 10:50:50 -07:00
|
|
|
#include <netinet/ip.h>
|
|
|
|
#include <netinet/ip_mroute.h>
|
2011-06-22 16:07:20 -06:00
|
|
|
#include <termios.h>
|
2009-11-01 12:13:27 -07:00
|
|
|
'
|
|
|
|
|
2009-11-14 16:29:09 -07:00
|
|
|
includes_FreeBSD='
|
2011-02-11 12:34:00 -07:00
|
|
|
#include <sys/types.h>
|
2009-11-14 16:29:09 -07:00
|
|
|
#include <sys/event.h>
|
2011-02-01 06:46:21 -07:00
|
|
|
#include <sys/socket.h>
|
|
|
|
#include <sys/sockio.h>
|
2011-02-11 12:34:00 -07:00
|
|
|
#include <sys/sysctl.h>
|
2013-03-08 22:25:30 -07:00
|
|
|
#include <sys/mman.h>
|
2011-02-11 12:34:00 -07:00
|
|
|
#include <sys/wait.h>
|
2011-06-22 16:07:20 -06:00
|
|
|
#include <sys/ioctl.h>
|
2011-04-04 13:40:40 -06:00
|
|
|
#include <net/bpf.h>
|
2011-02-01 06:46:21 -07:00
|
|
|
#include <net/if.h>
|
2011-05-26 18:02:03 -06:00
|
|
|
#include <net/if_types.h>
|
2011-02-11 12:34:00 -07:00
|
|
|
#include <net/route.h>
|
2011-02-01 06:46:21 -07:00
|
|
|
#include <netinet/in.h>
|
2011-06-27 09:02:32 -06:00
|
|
|
#include <termios.h>
|
2011-02-01 06:46:21 -07:00
|
|
|
#include <netinet/ip.h>
|
|
|
|
#include <netinet/ip_mroute.h>
|
2009-11-14 16:29:09 -07:00
|
|
|
'
|
|
|
|
|
2011-12-16 03:51:25 -07:00
|
|
|
includes_Linux='
|
|
|
|
#define _LARGEFILE_SOURCE
|
|
|
|
#define _LARGEFILE64_SOURCE
|
|
|
|
#define _FILE_OFFSET_BITS 64
|
|
|
|
#define _GNU_SOURCE
|
|
|
|
|
|
|
|
#include <bits/sockaddr.h>
|
|
|
|
#include <sys/epoll.h>
|
|
|
|
#include <sys/inotify.h>
|
|
|
|
#include <sys/ioctl.h>
|
|
|
|
#include <sys/mman.h>
|
|
|
|
#include <sys/mount.h>
|
2012-01-09 05:37:46 -07:00
|
|
|
#include <sys/prctl.h>
|
2011-12-16 03:51:25 -07:00
|
|
|
#include <sys/stat.h>
|
|
|
|
#include <sys/types.h>
|
2013-05-23 01:22:05 -06:00
|
|
|
#include <sys/socket.h>
|
2011-12-16 03:51:25 -07:00
|
|
|
#include <linux/if_addr.h>
|
|
|
|
#include <linux/if_ether.h>
|
|
|
|
#include <linux/if_tun.h>
|
|
|
|
#include <linux/filter.h>
|
|
|
|
#include <linux/netlink.h>
|
|
|
|
#include <linux/reboot.h>
|
|
|
|
#include <linux/rtnetlink.h>
|
|
|
|
#include <linux/ptrace.h>
|
|
|
|
#include <linux/wait.h>
|
2013-05-23 01:22:05 -06:00
|
|
|
#include <linux/icmpv6.h>
|
2011-12-16 03:51:25 -07:00
|
|
|
#include <net/if.h>
|
|
|
|
#include <net/if_arp.h>
|
|
|
|
#include <net/route.h>
|
|
|
|
#include <netpacket/packet.h>
|
2013-02-27 16:51:51 -07:00
|
|
|
|
|
|
|
#ifndef MSG_FASTOPEN
|
|
|
|
#define MSG_FASTOPEN 0x20000000
|
|
|
|
#endif
|
2011-12-16 03:51:25 -07:00
|
|
|
'
|
|
|
|
|
2011-12-19 09:57:58 -07:00
|
|
|
includes_NetBSD='
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/param.h>
|
|
|
|
#include <sys/event.h>
|
|
|
|
#include <sys/socket.h>
|
|
|
|
#include <sys/sockio.h>
|
|
|
|
#include <sys/sysctl.h>
|
|
|
|
#include <sys/termios.h>
|
|
|
|
#include <sys/ttycom.h>
|
|
|
|
#include <sys/wait.h>
|
|
|
|
#include <net/bpf.h>
|
|
|
|
#include <net/if.h>
|
|
|
|
#include <net/if_types.h>
|
|
|
|
#include <net/route.h>
|
|
|
|
#include <netinet/in.h>
|
|
|
|
#include <netinet/in_systm.h>
|
|
|
|
#include <netinet/ip.h>
|
|
|
|
#include <netinet/ip_mroute.h>
|
|
|
|
#include <netinet/if_ether.h>
|
2012-05-14 11:40:13 -06:00
|
|
|
|
|
|
|
// Needed since <sys/param.h> refers to it...
|
2012-05-22 09:33:48 -06:00
|
|
|
#define schedppq 1
|
2011-12-19 09:57:58 -07:00
|
|
|
'
|
|
|
|
|
2011-08-22 21:24:32 -06:00
|
|
|
includes_OpenBSD='
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/param.h>
|
|
|
|
#include <sys/event.h>
|
|
|
|
#include <sys/socket.h>
|
|
|
|
#include <sys/sockio.h>
|
|
|
|
#include <sys/sysctl.h>
|
|
|
|
#include <sys/termios.h>
|
|
|
|
#include <sys/ttycom.h>
|
|
|
|
#include <sys/wait.h>
|
|
|
|
#include <net/bpf.h>
|
|
|
|
#include <net/if.h>
|
|
|
|
#include <net/if_types.h>
|
|
|
|
#include <net/route.h>
|
|
|
|
#include <netinet/in.h>
|
|
|
|
#include <netinet/in_systm.h>
|
|
|
|
#include <netinet/ip.h>
|
|
|
|
#include <netinet/ip_mroute.h>
|
|
|
|
#include <netinet/if_ether.h>
|
|
|
|
#include <net/if_bridge.h>
|
|
|
|
'
|
|
|
|
|
2009-11-01 12:13:27 -07:00
|
|
|
includes='
|
|
|
|
#include <sys/types.h>
|
2011-12-07 23:12:08 -07:00
|
|
|
#include <sys/file.h>
|
2009-11-01 12:13:27 -07:00
|
|
|
#include <fcntl.h>
|
|
|
|
#include <dirent.h>
|
|
|
|
#include <sys/socket.h>
|
|
|
|
#include <netinet/in.h>
|
2010-03-30 15:32:59 -06:00
|
|
|
#include <netinet/ip.h>
|
|
|
|
#include <netinet/ip6.h>
|
2009-11-01 12:13:27 -07:00
|
|
|
#include <netinet/tcp.h>
|
|
|
|
#include <errno.h>
|
|
|
|
#include <sys/signal.h>
|
|
|
|
#include <signal.h>
|
2011-11-18 23:17:40 -07:00
|
|
|
#include <sys/resource.h>
|
2009-11-01 12:13:27 -07:00
|
|
|
'
|
2009-06-01 23:14:57 -06:00
|
|
|
|
2011-11-10 17:08:28 -07:00
|
|
|
ccflags="$@"
|
2010-04-30 00:34:06 -06:00
|
|
|
|
2012-02-02 20:22:40 -07:00
|
|
|
# Write go tool cgo -godefs input.
|
2009-06-01 23:14:57 -06:00
|
|
|
(
|
2011-11-10 17:08:28 -07:00
|
|
|
echo package syscall
|
|
|
|
echo
|
|
|
|
echo '/*'
|
2009-11-01 12:13:27 -07:00
|
|
|
indirect="includes_$(uname)"
|
|
|
|
echo "${!indirect} $includes"
|
2011-11-10 17:08:28 -07:00
|
|
|
echo '*/'
|
|
|
|
echo 'import "C"'
|
2009-11-01 12:13:27 -07:00
|
|
|
echo
|
2011-11-10 17:08:28 -07:00
|
|
|
echo 'const ('
|
2009-11-01 12:13:27 -07:00
|
|
|
|
|
|
|
# The gcc command line prints all the #defines
|
|
|
|
# it encounters while processing the input
|
2010-04-30 00:34:06 -06:00
|
|
|
echo "${!indirect} $includes" | $GCC -x c - -E -dM $ccflags |
|
2009-11-01 12:13:27 -07:00
|
|
|
awk '
|
2011-08-22 21:24:32 -06:00
|
|
|
$1 != "#define" || $2 ~ /\(/ || $3 == "" {next}
|
2010-12-09 11:55:59 -07:00
|
|
|
|
2010-05-03 12:11:01 -06:00
|
|
|
$2 ~ /^E([ABCD]X|[BIS]P|[SD]I|S|FL)$/ {next} # 386 registers
|
2009-11-01 12:13:27 -07:00
|
|
|
$2 ~ /^(SIGEV_|SIGSTKSZ|SIGRT(MIN|MAX))/ {next}
|
2010-12-07 11:40:14 -07:00
|
|
|
$2 ~ /^(SCM_SRCRT)$/ {next}
|
|
|
|
$2 ~ /^(MAP_FAILED)$/ {next}
|
2009-11-01 12:13:27 -07:00
|
|
|
|
2010-12-09 11:55:59 -07:00
|
|
|
$2 !~ /^ETH_/ &&
|
2011-02-11 12:34:00 -07:00
|
|
|
$2 !~ /^EPROC_/ &&
|
|
|
|
$2 !~ /^EQUIV_/ &&
|
|
|
|
$2 !~ /^EXPR_/ &&
|
2009-11-01 12:13:27 -07:00
|
|
|
$2 ~ /^E[A-Z0-9_]+$/ ||
|
2012-05-03 15:33:19 -06:00
|
|
|
$2 ~ /^B[0-9_]+$/ ||
|
|
|
|
$2 ~ /^V[A-Z0-9]+$/ ||
|
|
|
|
$2 ~ /^CS[A-Z0-9]/ ||
|
|
|
|
$2 ~ /^I(SIG|CANON|CRNL|EXTEN|MAXBEL|STRIP|UTF8)$/ ||
|
|
|
|
$2 ~ /^IGN/ ||
|
|
|
|
$2 ~ /^IX(ON|ANY|OFF)$/ ||
|
|
|
|
$2 ~ /^IN(LCR|PCK)$/ ||
|
|
|
|
$2 ~ /(^FLU?SH)|(FLU?SH$)/ ||
|
|
|
|
$2 ~ /^C(LOCAL|READ)$/ ||
|
|
|
|
$2 == "BRKINT" ||
|
|
|
|
$2 == "HUPCL" ||
|
|
|
|
$2 == "PENDIN" ||
|
|
|
|
$2 == "TOSTOP" ||
|
|
|
|
$2 ~ /^PAR/ ||
|
2009-11-01 12:13:27 -07:00
|
|
|
$2 ~ /^SIG[^_]/ ||
|
2012-05-03 15:33:19 -06:00
|
|
|
$2 ~ /^O[CNPFP][A-Z]+[^_][A-Z]+$/ ||
|
2010-09-27 09:44:26 -06:00
|
|
|
$2 ~ /^IN_/ ||
|
2011-12-07 23:12:08 -07:00
|
|
|
$2 ~ /^LOCK_(SH|EX|NB|UN)$/ ||
|
2013-05-23 01:22:05 -06:00
|
|
|
$2 ~ /^(AF|SOCK|SO|SOL|IPPROTO|IP|IPV6|ICMP6|TCP|EVFILT|NOTE|EV|SHUT|PROT|MAP|PACKET|MSG|SCM|MCL|DT|MADV|PR)_/ ||
|
|
|
|
$2 == "ICMPV6_FILTER" ||
|
2009-11-01 12:13:27 -07:00
|
|
|
$2 == "SOMAXCONN" ||
|
|
|
|
$2 == "NAME_MAX" ||
|
2010-12-09 11:55:59 -07:00
|
|
|
$2 == "IFNAMSIZ" ||
|
2012-05-22 09:33:48 -06:00
|
|
|
$2 ~ /^CTL_(MAXNAME|NET|QUERY)$/ ||
|
|
|
|
$2 ~ /^SYSCTL_VERS/ ||
|
2011-03-09 06:58:47 -07:00
|
|
|
$2 ~ /^(MS|MNT)_/ ||
|
2010-12-09 11:55:59 -07:00
|
|
|
$2 ~ /^TUN(SET|GET|ATTACH|DETACH)/ ||
|
2011-06-14 10:56:46 -06:00
|
|
|
$2 ~ /^(O|F|FD|NAME|S|PTRACE|PT)_/ ||
|
2011-03-09 06:45:08 -07:00
|
|
|
$2 ~ /^LINUX_REBOOT_CMD_/ ||
|
|
|
|
$2 ~ /^LINUX_REBOOT_MAGIC[12]$/ ||
|
2011-05-18 17:33:41 -06:00
|
|
|
$2 !~ "NLA_TYPE_MASK" &&
|
2013-02-23 20:04:48 -07:00
|
|
|
$2 ~ /^(NETLINK|NLM|NLMSG|NLA|IFA|IFAN|RT|RTCF|RTN|RTPROT|RTNH|ARPHRD|ETH_P)_/ ||
|
2011-02-11 12:34:00 -07:00
|
|
|
$2 ~ /^SIOC/ ||
|
2011-06-22 16:07:20 -06:00
|
|
|
$2 ~ /^TIOC/ ||
|
2011-05-26 18:02:03 -06:00
|
|
|
$2 ~ /^(IFF|IFT|NET_RT|RTM|RTF|RTV|RTA|RTAX)_/ ||
|
2011-04-04 13:40:40 -06:00
|
|
|
$2 ~ /^BIOC/ ||
|
2011-11-18 23:17:40 -07:00
|
|
|
$2 ~ /^RUSAGE_(SELF|CHILDREN|THREAD)/ ||
|
|
|
|
$2 ~ /^RLIMIT_(AS|CORE|CPU|DATA|FSIZE|NOFILE|STACK)|RLIM_INFINITY/ ||
|
2011-04-21 14:58:20 -06:00
|
|
|
$2 !~ /^(BPF_TIMEVAL)$/ &&
|
2011-04-04 13:40:40 -06:00
|
|
|
$2 ~ /^(BPF|DLT)_/ ||
|
2011-02-11 12:34:00 -07:00
|
|
|
$2 !~ "WMESGLEN" &&
|
2011-11-10 17:08:28 -07:00
|
|
|
$2 ~ /^W[A-Z0-9]+$/ {printf("\t%s = C.%s\n", $2, $2)}
|
2010-05-03 12:11:01 -06:00
|
|
|
$2 ~ /^__WCOREFLAG$/ {next}
|
2011-11-10 17:08:28 -07:00
|
|
|
$2 ~ /^__W[A-Z0-9]+$/ {printf("\t%s = C.%s\n", substr($2,3), $2)}
|
2010-12-09 11:55:59 -07:00
|
|
|
|
2009-11-01 12:13:27 -07:00
|
|
|
{next}
|
|
|
|
' | sort
|
|
|
|
|
2011-11-10 17:08:28 -07:00
|
|
|
echo ')'
|
|
|
|
) >_const.go
|
2009-11-01 12:13:27 -07:00
|
|
|
|
os/signal: selective signal handling
Restore package os/signal, with new API:
Notify replaces Incoming, allowing clients
to ask for certain signals only. Also, signals
go to everyone who asks, not just one client.
This could plausibly move into package os now
that there are no magic side effects as a result
of the import.
Update runtime for new API: move common Unix
signal handling code into signal_unix.c.
(It's so easy to do this now that we don't have
to edit Makefiles!)
Tested on darwin,linux 386,amd64.
Fixes #1266.
R=r, dsymonds, bradfitz, iant, borman
CC=golang-dev
https://golang.org/cl/3749041
2012-02-13 11:52:37 -07:00
|
|
|
# Pull out the error names for later.
|
2009-11-01 12:13:27 -07:00
|
|
|
errors=$(
|
2010-04-30 00:34:06 -06:00
|
|
|
echo '#include <errno.h>' | $GCC -x c - -E -dM $ccflags |
|
2009-12-01 17:53:43 -07:00
|
|
|
awk '$1=="#define" && $2 ~ /^E[A-Z0-9_]+$/ { print $2 }' |
|
|
|
|
sort
|
2009-11-01 12:13:27 -07:00
|
|
|
)
|
2009-06-01 23:14:57 -06:00
|
|
|
|
os/signal: selective signal handling
Restore package os/signal, with new API:
Notify replaces Incoming, allowing clients
to ask for certain signals only. Also, signals
go to everyone who asks, not just one client.
This could plausibly move into package os now
that there are no magic side effects as a result
of the import.
Update runtime for new API: move common Unix
signal handling code into signal_unix.c.
(It's so easy to do this now that we don't have
to edit Makefiles!)
Tested on darwin,linux 386,amd64.
Fixes #1266.
R=r, dsymonds, bradfitz, iant, borman
CC=golang-dev
https://golang.org/cl/3749041
2012-02-13 11:52:37 -07:00
|
|
|
# Pull out the signal names for later.
|
|
|
|
signals=$(
|
|
|
|
echo '#include <signal.h>' | $GCC -x c - -E -dM $ccflags |
|
|
|
|
awk '$1=="#define" && $2 ~ /^SIG[A-Z0-9]+$/ { print $2 }' |
|
|
|
|
egrep -v '(SIGSTKSIZE|SIGSTKSZ|SIGRT)' |
|
|
|
|
sort
|
|
|
|
)
|
|
|
|
|
2011-11-13 20:44:52 -07:00
|
|
|
# Again, writing regexps to a file.
|
|
|
|
echo '#include <errno.h>' | $GCC -x c - -E -dM $ccflags |
|
|
|
|
awk '$1=="#define" && $2 ~ /^E[A-Z0-9_]+$/ { print "^\t" $2 "[ \t]*=" }' |
|
|
|
|
sort >_error.grep
|
os/signal: selective signal handling
Restore package os/signal, with new API:
Notify replaces Incoming, allowing clients
to ask for certain signals only. Also, signals
go to everyone who asks, not just one client.
This could plausibly move into package os now
that there are no magic side effects as a result
of the import.
Update runtime for new API: move common Unix
signal handling code into signal_unix.c.
(It's so easy to do this now that we don't have
to edit Makefiles!)
Tested on darwin,linux 386,amd64.
Fixes #1266.
R=r, dsymonds, bradfitz, iant, borman
CC=golang-dev
https://golang.org/cl/3749041
2012-02-13 11:52:37 -07:00
|
|
|
echo '#include <signal.h>' | $GCC -x c - -E -dM $ccflags |
|
|
|
|
awk '$1=="#define" && $2 ~ /^SIG[A-Z0-9]+$/ { print "^\t" $2 "[ \t]*=" }' |
|
|
|
|
egrep -v '(SIGSTKSIZE|SIGSTKSZ|SIGRT)' |
|
|
|
|
sort >_signal.grep
|
2011-11-13 20:44:52 -07:00
|
|
|
|
2009-08-13 14:22:37 -06:00
|
|
|
echo '// mkerrors.sh' "$@"
|
2009-06-01 23:14:57 -06:00
|
|
|
echo '// MACHINE GENERATED BY THE COMMAND ABOVE; DO NOT EDIT'
|
|
|
|
echo
|
2012-02-02 20:22:40 -07:00
|
|
|
go tool cgo -godefs -- "$@" _const.go >_error.out
|
os/signal: selective signal handling
Restore package os/signal, with new API:
Notify replaces Incoming, allowing clients
to ask for certain signals only. Also, signals
go to everyone who asks, not just one client.
This could plausibly move into package os now
that there are no magic side effects as a result
of the import.
Update runtime for new API: move common Unix
signal handling code into signal_unix.c.
(It's so easy to do this now that we don't have
to edit Makefiles!)
Tested on darwin,linux 386,amd64.
Fixes #1266.
R=r, dsymonds, bradfitz, iant, borman
CC=golang-dev
https://golang.org/cl/3749041
2012-02-13 11:52:37 -07:00
|
|
|
cat _error.out | grep -vf _error.grep | grep -vf _signal.grep
|
2011-11-13 20:44:52 -07:00
|
|
|
echo
|
|
|
|
echo '// Errors'
|
|
|
|
echo 'const ('
|
|
|
|
cat _error.out | grep -f _error.grep | sed 's/=\(.*\)/= Errno(\1)/'
|
|
|
|
echo ')'
|
2009-06-01 23:14:57 -06:00
|
|
|
|
os/signal: selective signal handling
Restore package os/signal, with new API:
Notify replaces Incoming, allowing clients
to ask for certain signals only. Also, signals
go to everyone who asks, not just one client.
This could plausibly move into package os now
that there are no magic side effects as a result
of the import.
Update runtime for new API: move common Unix
signal handling code into signal_unix.c.
(It's so easy to do this now that we don't have
to edit Makefiles!)
Tested on darwin,linux 386,amd64.
Fixes #1266.
R=r, dsymonds, bradfitz, iant, borman
CC=golang-dev
https://golang.org/cl/3749041
2012-02-13 11:52:37 -07:00
|
|
|
echo
|
|
|
|
echo '// Signals'
|
|
|
|
echo 'const ('
|
|
|
|
cat _error.out | grep -f _signal.grep | sed 's/=\(.*\)/= Signal(\1)/'
|
|
|
|
echo ')'
|
|
|
|
|
|
|
|
# Run C program to print error and syscall strings.
|
2009-06-01 23:14:57 -06:00
|
|
|
(
|
2009-08-24 12:03:23 -06:00
|
|
|
/bin/echo "
|
2009-06-01 23:14:57 -06:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <errno.h>
|
|
|
|
#include <ctype.h>
|
|
|
|
#include <string.h>
|
os/signal: selective signal handling
Restore package os/signal, with new API:
Notify replaces Incoming, allowing clients
to ask for certain signals only. Also, signals
go to everyone who asks, not just one client.
This could plausibly move into package os now
that there are no magic side effects as a result
of the import.
Update runtime for new API: move common Unix
signal handling code into signal_unix.c.
(It's so easy to do this now that we don't have
to edit Makefiles!)
Tested on darwin,linux 386,amd64.
Fixes #1266.
R=r, dsymonds, bradfitz, iant, borman
CC=golang-dev
https://golang.org/cl/3749041
2012-02-13 11:52:37 -07:00
|
|
|
#include <signal.h>
|
2009-06-01 23:14:57 -06:00
|
|
|
|
|
|
|
#define nelem(x) (sizeof(x)/sizeof((x)[0]))
|
|
|
|
|
|
|
|
enum { A = 'A', Z = 'Z', a = 'a', z = 'z' }; // avoid need for single quotes below
|
|
|
|
|
|
|
|
int errors[] = {
|
|
|
|
"
|
|
|
|
for i in $errors
|
|
|
|
do
|
2009-08-24 12:03:23 -06:00
|
|
|
/bin/echo ' '$i,
|
2009-06-01 23:14:57 -06:00
|
|
|
done
|
|
|
|
|
os/signal: selective signal handling
Restore package os/signal, with new API:
Notify replaces Incoming, allowing clients
to ask for certain signals only. Also, signals
go to everyone who asks, not just one client.
This could plausibly move into package os now
that there are no magic side effects as a result
of the import.
Update runtime for new API: move common Unix
signal handling code into signal_unix.c.
(It's so easy to do this now that we don't have
to edit Makefiles!)
Tested on darwin,linux 386,amd64.
Fixes #1266.
R=r, dsymonds, bradfitz, iant, borman
CC=golang-dev
https://golang.org/cl/3749041
2012-02-13 11:52:37 -07:00
|
|
|
/bin/echo "
|
|
|
|
};
|
|
|
|
|
|
|
|
int signals[] = {
|
|
|
|
"
|
|
|
|
for i in $signals
|
|
|
|
do
|
|
|
|
/bin/echo ' '$i,
|
|
|
|
done
|
|
|
|
|
2009-08-24 12:03:23 -06:00
|
|
|
# Use /bin/echo to avoid builtin echo,
|
|
|
|
# which interprets \n itself
|
|
|
|
/bin/echo '
|
2009-06-01 23:14:57 -06:00
|
|
|
};
|
|
|
|
|
2010-09-24 11:37:02 -06:00
|
|
|
static int
|
|
|
|
intcmp(const void *a, const void *b)
|
|
|
|
{
|
|
|
|
return *(int*)a - *(int*)b;
|
|
|
|
}
|
|
|
|
|
2009-06-01 23:14:57 -06:00
|
|
|
int
|
|
|
|
main(void)
|
|
|
|
{
|
|
|
|
int i, j, e;
|
os/signal: selective signal handling
Restore package os/signal, with new API:
Notify replaces Incoming, allowing clients
to ask for certain signals only. Also, signals
go to everyone who asks, not just one client.
This could plausibly move into package os now
that there are no magic side effects as a result
of the import.
Update runtime for new API: move common Unix
signal handling code into signal_unix.c.
(It's so easy to do this now that we don't have
to edit Makefiles!)
Tested on darwin,linux 386,amd64.
Fixes #1266.
R=r, dsymonds, bradfitz, iant, borman
CC=golang-dev
https://golang.org/cl/3749041
2012-02-13 11:52:37 -07:00
|
|
|
char buf[1024], *p;
|
2009-06-01 23:14:57 -06:00
|
|
|
|
|
|
|
printf("\n\n// Error table\n");
|
|
|
|
printf("var errors = [...]string {\n");
|
2010-09-24 11:37:02 -06:00
|
|
|
qsort(errors, nelem(errors), sizeof errors[0], intcmp);
|
2009-06-01 23:14:57 -06:00
|
|
|
for(i=0; i<nelem(errors); i++) {
|
|
|
|
e = errors[i];
|
2010-09-24 11:37:02 -06:00
|
|
|
if(i > 0 && errors[i-1] == e)
|
|
|
|
continue;
|
2009-06-01 23:14:57 -06:00
|
|
|
strcpy(buf, strerror(e));
|
|
|
|
// lowercase first letter: Bad -> bad, but STREAM -> STREAM.
|
|
|
|
if(A <= buf[0] && buf[0] <= Z && a <= buf[1] && buf[1] <= z)
|
|
|
|
buf[0] += a - A;
|
|
|
|
printf("\t%d: \"%s\",\n", e, buf);
|
|
|
|
}
|
|
|
|
printf("}\n\n");
|
os/signal: selective signal handling
Restore package os/signal, with new API:
Notify replaces Incoming, allowing clients
to ask for certain signals only. Also, signals
go to everyone who asks, not just one client.
This could plausibly move into package os now
that there are no magic side effects as a result
of the import.
Update runtime for new API: move common Unix
signal handling code into signal_unix.c.
(It's so easy to do this now that we don't have
to edit Makefiles!)
Tested on darwin,linux 386,amd64.
Fixes #1266.
R=r, dsymonds, bradfitz, iant, borman
CC=golang-dev
https://golang.org/cl/3749041
2012-02-13 11:52:37 -07:00
|
|
|
|
|
|
|
printf("\n\n// Signal table\n");
|
|
|
|
printf("var signals = [...]string {\n");
|
|
|
|
qsort(signals, nelem(signals), sizeof signals[0], intcmp);
|
|
|
|
for(i=0; i<nelem(signals); i++) {
|
|
|
|
e = signals[i];
|
|
|
|
if(i > 0 && signals[i-1] == e)
|
|
|
|
continue;
|
|
|
|
strcpy(buf, strsignal(e));
|
|
|
|
// lowercase first letter: Bad -> bad, but STREAM -> STREAM.
|
|
|
|
if(A <= buf[0] && buf[0] <= Z && a <= buf[1] && buf[1] <= z)
|
|
|
|
buf[0] += a - A;
|
|
|
|
// cut trailing : number.
|
|
|
|
p = strrchr(buf, ":"[0]);
|
|
|
|
if(p)
|
|
|
|
*p = '\0';
|
|
|
|
printf("\t%d: \"%s\",\n", e, buf);
|
|
|
|
}
|
|
|
|
printf("}\n\n");
|
|
|
|
|
2009-11-01 12:13:27 -07:00
|
|
|
return 0;
|
2009-06-01 23:14:57 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
'
|
|
|
|
) >_errors.c
|
|
|
|
|
os/signal: selective signal handling
Restore package os/signal, with new API:
Notify replaces Incoming, allowing clients
to ask for certain signals only. Also, signals
go to everyone who asks, not just one client.
This could plausibly move into package os now
that there are no magic side effects as a result
of the import.
Update runtime for new API: move common Unix
signal handling code into signal_unix.c.
(It's so easy to do this now that we don't have
to edit Makefiles!)
Tested on darwin,linux 386,amd64.
Fixes #1266.
R=r, dsymonds, bradfitz, iant, borman
CC=golang-dev
https://golang.org/cl/3749041
2012-02-13 11:52:37 -07:00
|
|
|
$GCC $ccflags -o _errors _errors.c && $GORUN ./_errors && rm -f _errors.c _errors _const.go _error.grep _signal.grep _error.out
|