blob: 34361588e2720360717ef79206156552b32a9110 (
plain) (
tree)
|
|
# -*- sh -*-
# See LICENSE file for copyright and license details.
parallelindex=0
p () {
(
set +ev
pid=$$-$parallelindex
a=.a-$pid.tmp
b=.b-$pid.tmp
log=.x-$pid.tmp
( set -ev ; $t "$@" ) > $log 2>&1
r=$?
test $r = 0 || cat -- $log >&2
rm -f -- .?-$pid.tmp
exit $r
) &
eval parallelpid$(( ++parallelindex ))=$!
}
await () {
while (( parallelindex )); do
parallelvar=parallelpid$(( parallelindex-- ))
eval wait '$'$parallelvar
done
}
stderr () {
("$@") 2>&1 >/dev/null
}
getlist () {
getlist_list="$1"
shift 1
if test $# = 0; then set cat; fi
"$@" < libsyscalls.h \
| tr , '\n' \
| sed -n 's/^[[:space:]]*LIBSYSCALLS_'"${getlist_list}"'_\([A-Z0-9_]\{1,\}\([[:space:]]*=[[:space:]]*[[:space:]0-9A-Fa-fxXULul()^&|!*/<>~+-]\{1,\}\)\{0,1\}\)\([^A-Za-z0-9_].*\)*$/\1/p' \
| tr = ' ' \
| (i=0; while read name value; do
if test -n "$value"; then
i=$(( $(printf '%s\n' "$value" | tr -d 'ULul') ))
i=$(printf '%s\n' "$i" | cut -d . -f 1)
fi
printf '%i %s\n' $(( i++ )) $name;
done)
}
getnamelist () {
getlist "$@" | cut -d ' ' -f 2
}
getnumlist () {
getlist "$@" | cut -d ' ' -f 1
}
getname () {
(getlist "$1" | grep "^$2 " | cut -d ' ' -f 2 | tee /dev/stderr | grep . >/dev/null) 2>&1
}
getnum () {
(getlist "$1" | grep " $2"\$ | cut -d ' ' -f 1 | tee /dev/stderr | grep . >/dev/null) 2>&1
}
lookupname () {
(printf '%s\n' "$1" | grep "^$2 " | cut -d ' ' -f 2 | tee /dev/stderr | grep . >/dev/null) 2>&1
}
lookupnum () {
(printf '%s\n' "$1" | grep " $2"\$ | cut -d ' ' -f 1 | tee /dev/stderr | grep . >/dev/null) 2>&1
}
issupported () {
if test $# = 1; then
printf '%s\n' ${SUPPORTED_OSES} | grep -i "^$1"\$ > /dev/null
else
printf '%s\n' ${SUPPORTED_OSES} | grep -i "^$1"\$ > /dev/null &&
env | sed -n 's/^SUPPORTED_'"$1"'_ARCHES=//p' | xargs printf '%s\n' | grep -i "^$2"\$ > /dev/null
fi
}
cpp_enum_clean () {
$CPP < libsyscalls.h 2>/dev/null | grep -v '#' | tr '\n,{}' ' \n\n\n'
}
min () {
printf '%s\n' "$@" | tr -d + | sort -n | sed -n 1p
}
|