WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
Xen

xen-devel

[Top] [All Lists]

[Xen-devel] [PATCH] Partial fix for compat build non-portability

To: xen-devel@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-devel] [PATCH] Partial fix for compat build non-portability
From: john.levon@xxxxxxx
Date: 2007年1月10日 09:29:21 -0700
Delivery-date: 2007年1月10日 09:29:41 -0800
Envelope-to: www-data@xxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
# HG changeset patch
# User john.levon@xxxxxxx
# Date 1168450090 28800
# Node ID 09c345f40063806e220e7f2ebf90c4e7371eefe0
# Parent 9865145e53eb02ddc2e2792f80bb7d54bc754a65
Partial fix for compat build non-portability.
Signed-off-by: John Levon <john.levon@xxxxxxx>
diff --git a/xen/include/Makefile b/xen/include/Makefile
--- a/xen/include/Makefile
+++ b/xen/include/Makefile
@@ -2,8 +2,28 @@ ifneq ($(CONFIG_COMPAT),)
 
 compat-arch-$(CONFIG_X86) := x86_32
 
-headers-y := $(shell echo public/*.h | sed -e 
's,[^[:space:]]*-[^[:space:]]*,,g' -e 's,public/,compat/,g')
-headers-y := $(filter-out %/dom0_ops.h,$(headers-y))
+headers-y := \
+ compat/acm.h \
+ compat/acm_ops.h \
+ compat/callback.h \
+ compat/domctl.h \
+ compat/elfnote.h \
+ compat/event_channel.h \
+ compat/features.h \
+ compat/grant_table.h \
+ compat/kexec.h \
+ compat/memory.h \
+ compat/nmi.h \
+ compat/physdev.h \
+ compat/platform.h \
+ compat/sched.h \
+ compat/sysctl.h \
+ compat/trace.h \
+ compat/vcpu.h \
+ compat/version.h \
+ compat/xen.h \
+ compat/xencomm.h \
+ compat/xenoprof.h
 headers-$(CONFIG_X86) += compat/arch-x86/xen.h
 headers-$(CONFIG_X86) += compat/arch-x86/xen-$(compat-arch-y).h
 headers-y += compat/arch-$(compat-arch-y).h compat/xlat.h
@@ -21,24 +41,14 @@ all: $(headers-y)
 all: $(headers-y)
 
 compat/%.h: compat/%.i Makefile
- id=_$$(echo $@ | sed 
'y,abcdefghijklmnopqrstuvwxyz-/.,ABCDEFGHIJKLMNOPQRSTUVWXYZ___,'); \
+ id=_$$(echo $@ | tr '[:lower:]-/.' '[:upper:]___'); \
 echo "#ifndef $$id" >$@.new; \
 echo "#define $$id" >>$@.new; \
 echo "#include <xen/compat.h>" >>$@.new; \
 $(if $(filter-out compat/arch-%.h,$@),echo "#include <$(patsubst 
compat/%,public/%,$@)>" >>$@.new;) \
 $(if $(prefix-y),echo "$(prefix-y)" >>$@.new;) \
- grep -v '^# [[:digit:]]' $< | \
- sed -e 's,__InClUdE__,#include,' \
- -e 's,"xen-compat.h",<public/xen-compat.h>,' \
- -e 
's,\(struct\|union\|enum\)[[:space:]]\+\(xen_\?\)\?\([[:alpha:]_]\),1円 
compat_3,円g' \
- -e 's,@KeeP@,,g' \
- -e 's,_t\([^[:alnum:]_]\|$$\),_compat_t1,円g' \
- -e 's,\(8\|16\|32\|64\)_compat_t\([^[:alnum:]_]\|$$\),1円_t2,円g' \
- -e 
's,\(^\|[^[:alnum:]_]\)xen_\?\([[:alnum:]_]*\)_compat_t\([^[:alnum:]_]\|$$\),1円compat_2円_t3,円g'
 \
- -e 's,\(^\|[^[:alnum:]_]\)XEN_\?,1円COMPAT_,' \
- -e 's,\(^\|[^[:alnum:]_]\)Xen_\?,1円Compat_,' \
- -e 's,\(^\|[^[:alnum:]]\)long\([^[:alnum:]]\|$$\),1円int2,円g' | \
- uniq >>$@.new; \
+ grep -v '^# [0-9]' $< | \
+ $(BASEDIR)/tools/compat-build-header.py | uniq >>$@.new; \
 $(if $(suffix-y),echo "$(suffix-y)" >>$@.new;) \
 echo "#endif /* $$id */" >>$@.new
 mv -f $@.new $@
@@ -49,17 +59,11 @@ compat/%.c: public/%.h xlat.lst Makefile
 compat/%.c: public/%.h xlat.lst Makefile
 mkdir -p $(@D)
 grep -v 'DEFINE_XEN_GUEST_HANDLE(long)' $< | \
- sed -e 's,^[[:space:]]*#[[:space:]]*include[[:space:]]\+,__InClUdE__ ,' 
\
- -e 
's,^[[:space:]]*#[[:space:]]*define[[:space:]]\+\([[:upper:]_]*_GUEST_HANDLE\),#define
 HIDE_1,円' \
- -e 
's,^[[:space:]]*#[[:space:]]*define[[:space:]]\+\([[:lower:]_]*_guest_handle\),#define
 hide_1,円' \
- -e 's,XEN_GUEST_HANDLE\(_[[:xdigit:]]\+\)\?,COMPAT_HANDLE,g' \
- $(foreach n,$(shell sed -n 
's,^[[:space:]]*?[[:space:]]\+\([[:alnum:]_]*\)[[:space:]].*,1,円p' xlat.lst), \
- -e 
's,\(struct\|union\)[[:space:]]\+\(xen_\?\)\?$n[[:space:]]\+\([[:alpha:]_]\),1円 
@KeeP@2円$n 3,円g') \
- >$@.new
+ $(BASEDIR)/tools/compat-build-source.py >$@.new
 mv -f $@.new $@
 
 compat/xlat.h: xlat.lst $(filter-out compat/xlat.h,$(headers-y)) 
$(BASEDIR)/tools/get-fields.sh Makefile
- grep -v '^[[:space:]]*#' xlat.lst | \
+ grep -v '^[ ]*#' xlat.lst | \
 while read what name hdr; do \
 $(SHELL) $(BASEDIR)/tools/get-fields.sh "$$what" compat_$$name 
$$(echo compat/$$hdr | sed 's,@arch@,$(compat-arch-y),g') || exit $$?; \
 done >$@.new
diff --git a/xen/tools/compat-build-header.py b/xen/tools/compat-build-header.py
new file mode 100755
--- /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_t1円" ],
+ [ r"(8|16|32|64)_compat_t([^\w]|$)", r"1円_t2円" ],
+ [ r"(^|[^\w])xen_?(\w*)_compat_t([^\w]|$$)", r"1円compat_2円_t3円" ],
+ [ r"(^|[^\w])XEN_?", r"1円COMPAT_" ],
+ [ r"(^|[^\w])Xen_?", r"1円Compat_" ],
+ [ r"(^|[^\w])long([^\w]|$$)", r"1円int2円" ]
+];
+
+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
--- /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
--- a/xen/tools/get-fields.sh
+++ b/xen/tools/get-fields.sh
@@ -1,6 +1,9 @@
-#!/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=
@@ -90,11 +93,15 @@ handle_field() {
 then
 echo -n "1ドル(_d_)->3ドル = (_s_)->3ドル;"
 else
- echo -n "1ドルXLAT_${2}_HNDL_$(echo 3ドル | sed 
's,\.,_,g')(_d_, _s_);"
+ echo -n "1ドルXLAT_${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
_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel
<Prev in Thread] Current Thread [Next in Thread>
Previous by Date: [Xen-devel] Re: [PATCH] Re: compat BUG , Emmanuel Ackaouy
Next by Date: Re: [Xen-devel] [PATCH] Partial fix for compat build non-portability , John Levon
Previous by Thread: [Xen-devel] [PATCH] linux/i386: eliminate KM_SWIOTLB , Jan Beulich
Next by Thread: Re: [Xen-devel] [PATCH] Partial fix for compat build non-portability , John Levon
Indexes: [Date] [Thread] [Top] [All Lists]

Copyright ©, Citrix Systems Inc. All rights reserved. Legal and Privacy
Citrix This site is hosted by Citrix

AltStyle によって変換されたページ (->オリジナル) /