1
0
mirror of https://github.com/golang/go synced 2024-11-19 15:44:44 -07:00

syscall: make mkerrors.sh work with clang

LGTM=iant
R=golang-codereviews, minux.ma, gobot, iant
CC=golang-codereviews
https://golang.org/cl/67170043
This commit is contained in:
Mikio Hara 2014-02-24 16:34:51 +09:00
parent 2dcf8593ac
commit fe330cf5bb

View File

@ -11,7 +11,7 @@ unset LANG
export LC_ALL=C export LC_ALL=C
export LC_CTYPE=C export LC_CTYPE=C
GCC=gcc CC=${CC:-gcc}
uname=$(uname) uname=$(uname)
@ -194,7 +194,7 @@ ccflags="$@"
# The gcc command line prints all the #defines # The gcc command line prints all the #defines
# it encounters while processing the input # it encounters while processing the input
echo "${!indirect} $includes" | $GCC -x c - -E -dM $ccflags | echo "${!indirect} $includes" | $CC -x c - -E -dM $ccflags |
awk ' awk '
$1 != "#define" || $2 ~ /\(/ || $3 == "" {next} $1 != "#define" || $2 ~ /\(/ || $3 == "" {next}
@ -263,24 +263,24 @@ ccflags="$@"
# Pull out the error names for later. # Pull out the error names for later.
errors=$( errors=$(
echo '#include <errno.h>' | $GCC -x c - -E -dM $ccflags | echo '#include <errno.h>' | $CC -x c - -E -dM $ccflags |
awk '$1=="#define" && $2 ~ /^E[A-Z0-9_]+$/ { print $2 }' | awk '$1=="#define" && $2 ~ /^E[A-Z0-9_]+$/ { print $2 }' |
sort sort
) )
# Pull out the signal names for later. # Pull out the signal names for later.
signals=$( signals=$(
echo '#include <signal.h>' | $GCC -x c - -E -dM $ccflags | echo '#include <signal.h>' | $CC -x c - -E -dM $ccflags |
awk '$1=="#define" && $2 ~ /^SIG[A-Z0-9]+$/ { print $2 }' | awk '$1=="#define" && $2 ~ /^SIG[A-Z0-9]+$/ { print $2 }' |
egrep -v '(SIGSTKSIZE|SIGSTKSZ|SIGRT)' | egrep -v '(SIGSTKSIZE|SIGSTKSZ|SIGRT)' |
sort sort
) )
# Again, writing regexps to a file. # Again, writing regexps to a file.
echo '#include <errno.h>' | $GCC -x c - -E -dM $ccflags | echo '#include <errno.h>' | $CC -x c - -E -dM $ccflags |
awk '$1=="#define" && $2 ~ /^E[A-Z0-9_]+$/ { print "^\t" $2 "[ \t]*=" }' | awk '$1=="#define" && $2 ~ /^E[A-Z0-9_]+$/ { print "^\t" $2 "[ \t]*=" }' |
sort >_error.grep sort >_error.grep
echo '#include <signal.h>' | $GCC -x c - -E -dM $ccflags | echo '#include <signal.h>' | $CC -x c - -E -dM $ccflags |
awk '$1=="#define" && $2 ~ /^SIG[A-Z0-9]+$/ { print "^\t" $2 "[ \t]*=" }' | awk '$1=="#define" && $2 ~ /^SIG[A-Z0-9]+$/ { print "^\t" $2 "[ \t]*=" }' |
egrep -v '(SIGSTKSIZE|SIGSTKSZ|SIGRT)' | egrep -v '(SIGSTKSIZE|SIGSTKSZ|SIGRT)' |
sort >_signal.grep sort >_signal.grep
@ -390,4 +390,4 @@ main(void)
' '
) >_errors.c ) >_errors.c
$GCC $ccflags -o _errors _errors.c && $GORUN ./_errors && rm -f _errors.c _errors _const.go _error.grep _signal.grep _error.out $CC $ccflags -o _errors _errors.c && $GORUN ./_errors && rm -f _errors.c _errors _const.go _error.grep _signal.grep _error.out