blob: a31f2368d50efb4a26ae0887d96eb34ecf16c456 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
|
# -*- sh -*-
# See LICENSE file for copyright and license details.
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/^\s*LIBSYSCALLS_'"${getlist_list}"'_\([A-Z0-9_]\+\(\s*=\s*[ 0-9A-Fa-fxXULul()^&|!*/<>~+-]\+\)\?\)\b.*$/\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
}
|