aboutsummaryrefslogtreecommitdiffstats
path: root/xen/tools
diff options
context:
space:
mode:
authorEmmanuel Ackaouy <ack@xensource.com>2007-01-10 17:56:54 +0000
committerEmmanuel Ackaouy <ack@xensource.com>2007-01-10 17:56:54 +0000
commit2736a406e4eac36a6de7a3b5e08b7f30da038f35 (patch)
treed469b1f23a86bb92ea03ac598d6b7c1e3278875b /xen/tools
parent7220350010061dfd1c354397d7a25ec6829ae88a (diff)
downloadxen-2736a406e4eac36a6de7a3b5e08b7f30da038f35.tar.gz
xen-2736a406e4eac36a6de7a3b5e08b7f30da038f35.tar.bz2
xen-2736a406e4eac36a6de7a3b5e08b7f30da038f35.zip
[XEN] Partial fix for compat build non-portability.
Signed-off-by: John Levon <john.levon@sun.com>
Diffstat (limited to 'xen/tools')
-rwxr-xr-xxen/tools/compat-build-header.py21
-rwxr-xr-xxen/tools/compat-build-source.py27
-rw-r--r--xen/tools/get-fields.sh37
3 files changed, 70 insertions, 15 deletions
diff --git a/xen/tools/compat-build-header.py b/xen/tools/compat-build-header.py
new file mode 100755
index 0000000000..6fb795eaaa
--- /dev/null
+++ b/xen/tools/compat-build-header.py
@@ -0,0 +1,21 @@
+#!/usr/bin/python
+
+import re,sys
+
+pats = [
+ [ r"__InClUdE__", r"#include" ],
+ [ r"\"xen-compat.h\"", r"<public/xen-compat.h>" ],
+ [ r"(struct|union|enum)\s+(xen_?)?(\w)", r"\1 compat_\3" ],
+ [ r"@KeeP@", r"" ],
+ [ r"_t([^\w]|$)", r"_compat_t\1" ],
+ [ r"(8|16|32|64)_compat_t([^\w]|$)", r"\1_t\2" ],
+ [ r"(^|[^\w])xen_?(\w*)_compat_t([^\w]|$$)", r"\1compat_\2_t\3" ],
+ [ r"(^|[^\w])XEN_?", r"\1COMPAT_" ],
+ [ r"(^|[^\w])Xen_?", r"\1Compat_" ],
+ [ r"(^|[^\w])long([^\w]|$$)", r"\1int\2" ]
+];
+
+for line in sys.stdin.readlines():
+ for pat in pats:
+ line = re.subn(pat[0], pat[1], line)[0]
+ print line.rstrip()
diff --git a/xen/tools/compat-build-source.py b/xen/tools/compat-build-source.py
new file mode 100755
index 0000000000..449e738188
--- /dev/null
+++ b/xen/tools/compat-build-source.py
@@ -0,0 +1,27 @@
+#!/usr/bin/python
+
+import re,sys
+
+pats = [
+ [ r"^\s*#\s*include\s+", r"__InClUdE__ " ],
+ [ r"^\s*#\s*define\s+([A-Z_]*_GUEST_HANDLE)", r"#define HIDE_\1" ],
+ [ r"^\s*#\s*define\s+([a-z_]*_guest_handle)", r"#define hide_\1" ],
+ [ r"XEN_GUEST_HANDLE(_[0-9A-Fa-f]+)?", r"COMPAT_HANDLE" ],
+];
+
+xlats = []
+
+xlatf = open('xlat.lst', 'r')
+for line in xlatf.readlines():
+ match = re.subn(r"^\s*\?\s+(\w*)\s.*", r"\1", line.rstrip())
+ if match[1]:
+ xlats.append(match[0])
+xlatf.close()
+
+for line in sys.stdin.readlines():
+ for pat in pats:
+ line = re.subn(pat[0], pat[1], line)[0]
+ for xlat in xlats:
+ line = re.subn(r"(struct|union)\s+(%s|xen_%s)\s+(\w)" % (xlat, xlat),
+ r"\1 @KeeP@\2 \3", line.rstrip())[0]
+ print line.rstrip()
diff --git a/xen/tools/get-fields.sh b/xen/tools/get-fields.sh
index 01af5eaaf3..d272c84e0b 100644
--- a/xen/tools/get-fields.sh
+++ b/xen/tools/get-fields.sh
@@ -1,7 +1,10 @@
-#!/bin/sh
+#!/bin/bash
test -n "$1" -a -n "$2" -a -n "$3"
set -ef
+SED=sed
+[ -x /usr/xpg4/bin/sed ] && SED=/usr/xpg4/bin/sed
+
get_fields() {
local level=1 aggr=0 name= fields=
for token in $2
@@ -90,11 +93,15 @@ handle_field() {
then
echo -n "$1(_d_)->$3 = (_s_)->$3;"
else
- echo -n "$1XLAT_${2}_HNDL_$(echo $3 | sed 's,\.,_,g')(_d_, _s_);"
+ echo -n "$1XLAT_${2}_HNDL_$(echo $3 | $SED 's,\.,_,g')(_d_, _s_);"
fi
- elif [ -z "$(echo "$5" | sed 's,[^{}],,g')" ]
+ elif [ -z "$(echo "$5" | $SED 's,[^{}],,g')" ]
then
- local tag=$(echo "$5" | sed 's,[[:space:]]*\(struct\|union\)[[:space:]]\+\(compat_\)\?\([[:alnum:]_]\+\)[[:space:]].*,\3,')
+ local tag=$(echo "$5" | python -c '
+import re,sys
+for line in sys.stdin.readlines():
+ print re.subn(r"\s*(struct|union)\s+(compat_)?(\w+)\s.*", r"\3", line)[0].rstrip()
+')
echo " \\"
echo -n "${1}XLAT_$tag(&(_d_)->$3, &(_s_)->$3);"
else
@@ -110,7 +117,7 @@ handle_field() {
if [ $kind = union ]
then
echo " \\"
- echo -n "${1}switch ($(echo $3 | sed 's,\.,_,g')) {"
+ echo -n "${1}switch ($(echo $3 | $SED 's,\.,_,g')) {"
fi
fi
;;
@@ -158,12 +165,12 @@ handle_field() {
id=$token
;;
[\,\;])
- if [ $level == 2 -a -n "$(echo $id | sed 's,^_pad[[:digit:]]*,,')" ]
+ if [ $level == 2 -a -n "$(echo $id | $SED 's,^_pad[[:digit:]]*,,')" ]
then
if [ $kind = union ]
then
echo " \\"
- echo -n "${1}case XLAT_${2}_$(echo $3.$id | sed 's,\.,_,g'):"
+ echo -n "${1}case XLAT_${2}_$(echo $3.$id | $SED 's,\.,_,g'):"
handle_field "$1 " $2 $3.$id "$type" "$fields"
elif [ -z "$array" -a -z "$array_type" ]
then
@@ -202,7 +209,7 @@ copy_array() {
}
handle_array() {
- local i="i$(echo $4 | sed 's,[^;], ,g' | wc -w)"
+ local i="i$(echo $4 | $SED 's,[^;], ,g' | wc -w | $SED 's,[[:space:]]*,,g')"
echo " \\"
echo "$1{ \\"
echo "$1 unsigned int $i; \\"
@@ -272,7 +279,7 @@ build_body() {
fi
;;
[\,\;])
- if [ $level == 2 -a -n "$(echo $id | sed 's,^_pad[[:digit:]]*,,')" ]
+ if [ $level == 2 -a -n "$(echo $id | $SED 's,^_pad[[:digit:]]*,,')" ]
then
if [ -z "$array" -a -z "$array_type" ]
then
@@ -300,10 +307,10 @@ build_body() {
}
check_field() {
- if [ -z "$(echo "$4" | sed 's,[^{}],,g')" ]
+ if [ -z "$(echo "$4" | $SED 's,[^{}],,g')" ]
then
echo "; \\"
- local n=$(echo $3 | sed 's,[^.], ,g' | wc -w)
+ local n=$(echo $3 | $SED 's,[^.], ,g' | wc -w | $SED 's,[[:space:]]*,,g')
if [ -n "$4" ]
then
for n in $4
@@ -325,7 +332,7 @@ check_field() {
then
echo -n " CHECK_FIELD_($1, $2, $3)"
else
- echo -n " CHECK_SUBFIELD_${n}_($1, $2, $(echo $3 | sed 's!\.!, !g'))"
+ echo -n " CHECK_SUBFIELD_${n}_($1, $2, $(echo $3 | $SED 's!\.!, !g'))"
fi
else
local level=1 fields= id= token
@@ -345,7 +352,7 @@ check_field() {
id=$token
;;
[\,\;])
- if [ $level == 2 -a -n "$(echo $id | sed 's,^_pad[[:digit:]]*,,')" ]
+ if [ $level == 2 -a -n "$(echo $id | $SED 's,^_pad[[:digit:]]*,,')" ]
then
check_field $1 $2 $3.$id "$fields"
test "$token" != ";" || fields= id=
@@ -390,7 +397,7 @@ build_check() {
test $level != 2 -o $arrlvl != 1 || id=$token
;;
[\,\;])
- if [ $level == 2 -a -n "$(echo $id | sed 's,^_pad[[:digit:]]*,,')" ]
+ if [ $level == 2 -a -n "$(echo $id | $SED 's,^_pad[[:digit:]]*,,')" ]
then
check_field $kind $1 $id "$fields"
test "$token" != ";" || fields= id=
@@ -402,7 +409,7 @@ build_check() {
echo ""
}
-fields="$(get_fields $(echo $2 | sed 's,^compat_xen,compat_,') "$(sed -e 's,^[[:space:]]#.*,,' -e 's!\([]\[,;:{}]\)! \1 !g' $3)")"
+fields="$(get_fields $(echo $2 | $SED 's,^compat_xen,compat_,') "$($SED -e 's,^[[:space:]]#.*,,' -e 's!\([]\[,;:{}]\)! \1 !g' $3)")"
if [ -z "$fields" ]
then
echo "Fields of '$2' not found in '$3'" >&2