direct-io.hg

changeset 13324:b61be7771104

[XEN] Partial fix for compat build non-portability.

Signed-off-by: John Levon <john.levon@sun.com>
author Emmanuel Ackaouy <ack@xensource.com>
date Wed Jan 10 17:56:54 2007 +0000 (2007-01-10)
parents aa127e545b73
children e66f047bc97e
files xen/include/Makefile xen/tools/compat-build-header.py xen/tools/compat-build-source.py xen/tools/get-fields.sh
line diff
     1.1 --- a/xen/include/Makefile	Wed Jan 10 17:26:58 2007 +0000
     1.2 +++ b/xen/include/Makefile	Wed Jan 10 17:56:54 2007 +0000
     1.3 @@ -2,8 +2,28 @@ ifneq ($(CONFIG_COMPAT),)
     1.4  
     1.5  compat-arch-$(CONFIG_X86) := x86_32
     1.6  
     1.7 -headers-y                 := $(shell echo public/*.h | sed -e 's,[^[:space:]]*-[^[:space:]]*,,g' -e 's,public/,compat/,g')
     1.8 -headers-y                 := $(filter-out %/dom0_ops.h,$(headers-y))
     1.9 +headers-y := \
    1.10 +    compat/acm.h \
    1.11 +    compat/acm_ops.h \
    1.12 +    compat/callback.h \
    1.13 +    compat/domctl.h \
    1.14 +    compat/elfnote.h \
    1.15 +    compat/event_channel.h \
    1.16 +    compat/features.h \
    1.17 +    compat/grant_table.h \
    1.18 +    compat/kexec.h \
    1.19 +    compat/memory.h \
    1.20 +    compat/nmi.h \
    1.21 +    compat/physdev.h \
    1.22 +    compat/platform.h \
    1.23 +    compat/sched.h \
    1.24 +    compat/sysctl.h \
    1.25 +    compat/trace.h \
    1.26 +    compat/vcpu.h \
    1.27 +    compat/version.h \
    1.28 +    compat/xen.h \
    1.29 +    compat/xencomm.h \
    1.30 +    compat/xenoprof.h
    1.31  headers-$(CONFIG_X86)     += compat/arch-x86/xen.h
    1.32  headers-$(CONFIG_X86)     += compat/arch-x86/xen-$(compat-arch-y).h
    1.33  headers-y                 += compat/arch-$(compat-arch-y).h compat/xlat.h
    1.34 @@ -21,24 +41,14 @@ endif
    1.35  all: $(headers-y)
    1.36  
    1.37  compat/%.h: compat/%.i Makefile
    1.38 -	id=_$$(echo $@ | sed 'y,abcdefghijklmnopqrstuvwxyz-/.,ABCDEFGHIJKLMNOPQRSTUVWXYZ___,'); \
    1.39 +	id=_$$(echo $@ | tr '[:lower:]-/.' '[:upper:]___'); \
    1.40  	echo "#ifndef $$id" >$@.new; \
    1.41  	echo "#define $$id" >>$@.new; \
    1.42  	echo "#include <xen/compat.h>" >>$@.new; \
    1.43  	$(if $(filter-out compat/arch-%.h,$@),echo "#include <$(patsubst compat/%,public/%,$@)>" >>$@.new;) \
    1.44  	$(if $(prefix-y),echo "$(prefix-y)" >>$@.new;) \
    1.45 -	grep -v '^# [[:digit:]]' $< | \
    1.46 -	sed -e 's,__InClUdE__,#include,' \
    1.47 -	    -e 's,"xen-compat.h",<public/xen-compat.h>,' \
    1.48 -	    -e 's,\(struct\|union\|enum\)[[:space:]]\+\(xen_\?\)\?\([[:alpha:]_]\),\1 compat_\3,g' \
    1.49 -	    -e 's,@KeeP@,,g' \
    1.50 -	    -e 's,_t\([^[:alnum:]_]\|$$\),_compat_t\1,g' \
    1.51 -	    -e 's,\(8\|16\|32\|64\)_compat_t\([^[:alnum:]_]\|$$\),\1_t\2,g' \
    1.52 -	    -e 's,\(^\|[^[:alnum:]_]\)xen_\?\([[:alnum:]_]*\)_compat_t\([^[:alnum:]_]\|$$\),\1compat_\2_t\3,g' \
    1.53 -	    -e 's,\(^\|[^[:alnum:]_]\)XEN_\?,\1COMPAT_,' \
    1.54 -	    -e 's,\(^\|[^[:alnum:]_]\)Xen_\?,\1Compat_,' \
    1.55 -	    -e 's,\(^\|[^[:alnum:]]\)long\([^[:alnum:]]\|$$\),\1int\2,g' | \
    1.56 -	uniq >>$@.new; \
    1.57 +	grep -v '^# [0-9]' $< | \
    1.58 +	$(BASEDIR)/tools/compat-build-header.py | uniq >>$@.new; \
    1.59  	$(if $(suffix-y),echo "$(suffix-y)" >>$@.new;) \
    1.60  	echo "#endif /* $$id */" >>$@.new
    1.61  	mv -f $@.new $@
    1.62 @@ -49,17 +59,11 @@ compat/%.i: compat/%.c Makefile
    1.63  compat/%.c: public/%.h xlat.lst Makefile
    1.64  	mkdir -p $(@D)
    1.65  	grep -v 'DEFINE_XEN_GUEST_HANDLE(long)' $< | \
    1.66 -	sed -e 's,^[[:space:]]*#[[:space:]]*include[[:space:]]\+,__InClUdE__ ,' \
    1.67 -	    -e 's,^[[:space:]]*#[[:space:]]*define[[:space:]]\+\([[:upper:]_]*_GUEST_HANDLE\),#define HIDE_\1,' \
    1.68 -	    -e 's,^[[:space:]]*#[[:space:]]*define[[:space:]]\+\([[:lower:]_]*_guest_handle\),#define hide_\1,' \
    1.69 -	    -e 's,XEN_GUEST_HANDLE\(_[[:xdigit:]]\+\)\?,COMPAT_HANDLE,g' \
    1.70 -	    $(foreach n,$(shell sed -n 's,^[[:space:]]*?[[:space:]]\+\([[:alnum:]_]*\)[[:space:]].*,\1,p' xlat.lst), \
    1.71 -	                -e 's,\(struct\|union\)[[:space:]]\+\(xen_\?\)\?$n[[:space:]]\+\([[:alpha:]_]\),\1 @KeeP@\2$n \3,g') \
    1.72 -	    >$@.new
    1.73 +        $(BASEDIR)/tools/compat-build-source.py >$@.new
    1.74  	mv -f $@.new $@
    1.75  
    1.76  compat/xlat.h: xlat.lst $(filter-out compat/xlat.h,$(headers-y)) $(BASEDIR)/tools/get-fields.sh Makefile
    1.77 -	grep -v '^[[:space:]]*#' xlat.lst | \
    1.78 +	grep -v '^[	 ]*#' xlat.lst | \
    1.79  	while read what name hdr; do \
    1.80  		$(SHELL) $(BASEDIR)/tools/get-fields.sh "$$what" compat_$$name $$(echo compat/$$hdr | sed 's,@arch@,$(compat-arch-y),g') || exit $$?; \
    1.81  	done >$@.new
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/xen/tools/compat-build-header.py	Wed Jan 10 17:56:54 2007 +0000
     2.3 @@ -0,0 +1,21 @@
     2.4 +#!/usr/bin/python
     2.5 +
     2.6 +import re,sys
     2.7 +
     2.8 +pats = [
     2.9 + [ r"__InClUdE__", r"#include" ],
    2.10 + [ r"\"xen-compat.h\"", r"<public/xen-compat.h>" ],
    2.11 + [ r"(struct|union|enum)\s+(xen_?)?(\w)", r"\1 compat_\3" ],
    2.12 + [ r"@KeeP@", r"" ],
    2.13 + [ r"_t([^\w]|$)", r"_compat_t\1" ],
    2.14 + [ r"(8|16|32|64)_compat_t([^\w]|$)", r"\1_t\2" ],
    2.15 + [ r"(^|[^\w])xen_?(\w*)_compat_t([^\w]|$$)", r"\1compat_\2_t\3" ],
    2.16 + [ r"(^|[^\w])XEN_?", r"\1COMPAT_" ],
    2.17 + [ r"(^|[^\w])Xen_?", r"\1Compat_" ],
    2.18 + [ r"(^|[^\w])long([^\w]|$$)", r"\1int\2" ]
    2.19 +];
    2.20 +
    2.21 +for line in sys.stdin.readlines():
    2.22 +    for pat in pats:
    2.23 +        line = re.subn(pat[0], pat[1], line)[0]
    2.24 +    print line.rstrip()
     3.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.2 +++ b/xen/tools/compat-build-source.py	Wed Jan 10 17:56:54 2007 +0000
     3.3 @@ -0,0 +1,27 @@
     3.4 +#!/usr/bin/python
     3.5 +
     3.6 +import re,sys
     3.7 +
     3.8 +pats = [
     3.9 + [ r"^\s*#\s*include\s+", r"__InClUdE__ " ],
    3.10 + [ r"^\s*#\s*define\s+([A-Z_]*_GUEST_HANDLE)", r"#define HIDE_\1" ],
    3.11 + [ r"^\s*#\s*define\s+([a-z_]*_guest_handle)", r"#define hide_\1" ],
    3.12 + [ r"XEN_GUEST_HANDLE(_[0-9A-Fa-f]+)?", r"COMPAT_HANDLE" ],
    3.13 +];
    3.14 +
    3.15 +xlats = []
    3.16 +
    3.17 +xlatf = open('xlat.lst', 'r')
    3.18 +for line in xlatf.readlines():
    3.19 +    match = re.subn(r"^\s*\?\s+(\w*)\s.*", r"\1", line.rstrip())
    3.20 +    if match[1]:
    3.21 +        xlats.append(match[0])
    3.22 +xlatf.close()
    3.23 +
    3.24 +for line in sys.stdin.readlines():
    3.25 +    for pat in pats:
    3.26 +        line = re.subn(pat[0], pat[1], line)[0]
    3.27 +    for xlat in xlats:
    3.28 +        line = re.subn(r"(struct|union)\s+(%s|xen_%s)\s+(\w)" % (xlat, xlat),
    3.29 +            r"\1 @KeeP@\2 \3", line.rstrip())[0]
    3.30 +    print line.rstrip()
     4.1 --- a/xen/tools/get-fields.sh	Wed Jan 10 17:26:58 2007 +0000
     4.2 +++ b/xen/tools/get-fields.sh	Wed Jan 10 17:56:54 2007 +0000
     4.3 @@ -1,7 +1,10 @@
     4.4 -#!/bin/sh
     4.5 +#!/bin/bash
     4.6  test -n "$1" -a -n "$2" -a -n "$3"
     4.7  set -ef
     4.8  
     4.9 +SED=sed
    4.10 +[ -x /usr/xpg4/bin/sed ] && SED=/usr/xpg4/bin/sed
    4.11 +
    4.12  get_fields() {
    4.13  	local level=1 aggr=0 name= fields=
    4.14  	for token in $2
    4.15 @@ -90,11 +93,15 @@ handle_field() {
    4.16  		then
    4.17  			echo -n "$1(_d_)->$3 = (_s_)->$3;"
    4.18  		else
    4.19 -			echo -n "$1XLAT_${2}_HNDL_$(echo $3 | sed 's,\.,_,g')(_d_, _s_);"
    4.20 +			echo -n "$1XLAT_${2}_HNDL_$(echo $3 | $SED 's,\.,_,g')(_d_, _s_);"
    4.21  		fi
    4.22 -	elif [ -z "$(echo "$5" | sed 's,[^{}],,g')" ]
    4.23 +	elif [ -z "$(echo "$5" | $SED 's,[^{}],,g')" ]
    4.24  	then
    4.25 -		local tag=$(echo "$5" | sed 's,[[:space:]]*\(struct\|union\)[[:space:]]\+\(compat_\)\?\([[:alnum:]_]\+\)[[:space:]].*,\3,')
    4.26 +		local tag=$(echo "$5" | python -c '
    4.27 +import re,sys
    4.28 +for line in sys.stdin.readlines():
    4.29 +    print re.subn(r"\s*(struct|union)\s+(compat_)?(\w+)\s.*", r"\3", line)[0].rstrip()
    4.30 +')
    4.31  		echo " \\"
    4.32  		echo -n "${1}XLAT_$tag(&(_d_)->$3, &(_s_)->$3);"
    4.33  	else
    4.34 @@ -110,7 +117,7 @@ handle_field() {
    4.35  					if [ $kind = union ]
    4.36  					then
    4.37  						echo " \\"
    4.38 -						echo -n "${1}switch ($(echo $3 | sed 's,\.,_,g')) {"
    4.39 +						echo -n "${1}switch ($(echo $3 | $SED 's,\.,_,g')) {"
    4.40  					fi
    4.41  				fi
    4.42  				;;
    4.43 @@ -158,12 +165,12 @@ handle_field() {
    4.44  				id=$token
    4.45  				;;
    4.46  			[\,\;])
    4.47 -				if [ $level == 2 -a -n "$(echo $id | sed 's,^_pad[[:digit:]]*,,')" ]
    4.48 +				if [ $level == 2 -a -n "$(echo $id | $SED 's,^_pad[[:digit:]]*,,')" ]
    4.49  				then
    4.50  					if [ $kind = union ]
    4.51  					then
    4.52  						echo " \\"
    4.53 -						echo -n "${1}case XLAT_${2}_$(echo $3.$id | sed 's,\.,_,g'):"
    4.54 +						echo -n "${1}case XLAT_${2}_$(echo $3.$id | $SED 's,\.,_,g'):"
    4.55  						handle_field "$1    " $2 $3.$id "$type" "$fields"
    4.56  					elif [ -z "$array" -a -z "$array_type" ]
    4.57  					then
    4.58 @@ -202,7 +209,7 @@ copy_array() {
    4.59  }
    4.60  
    4.61  handle_array() {
    4.62 -	local i="i$(echo $4 | sed 's,[^;], ,g' | wc -w)"
    4.63 +	local i="i$(echo $4 | $SED 's,[^;], ,g' | wc -w | $SED 's,[[:space:]]*,,g')"
    4.64  	echo " \\"
    4.65  	echo "$1{ \\"
    4.66  	echo "$1    unsigned int $i; \\"
    4.67 @@ -272,7 +279,7 @@ build_body() {
    4.68  			fi
    4.69  			;;
    4.70  		[\,\;])
    4.71 -			if [ $level == 2 -a -n "$(echo $id | sed 's,^_pad[[:digit:]]*,,')" ]
    4.72 +			if [ $level == 2 -a -n "$(echo $id | $SED 's,^_pad[[:digit:]]*,,')" ]
    4.73  			then
    4.74  				if [ -z "$array" -a -z "$array_type" ]
    4.75  				then
    4.76 @@ -300,10 +307,10 @@ build_body() {
    4.77  }
    4.78  
    4.79  check_field() {
    4.80 -	if [ -z "$(echo "$4" | sed 's,[^{}],,g')" ]
    4.81 +	if [ -z "$(echo "$4" | $SED 's,[^{}],,g')" ]
    4.82  	then
    4.83  		echo "; \\"
    4.84 -		local n=$(echo $3 | sed 's,[^.], ,g' | wc -w)
    4.85 +		local n=$(echo $3 | $SED 's,[^.], ,g' | wc -w | $SED 's,[[:space:]]*,,g')
    4.86  		if [ -n "$4" ]
    4.87  		then
    4.88  			for n in $4
    4.89 @@ -325,7 +332,7 @@ check_field() {
    4.90  		then
    4.91  			echo -n "    CHECK_FIELD_($1, $2, $3)"
    4.92  		else
    4.93 -			echo -n "    CHECK_SUBFIELD_${n}_($1, $2, $(echo $3 | sed 's!\.!, !g'))"
    4.94 +			echo -n "    CHECK_SUBFIELD_${n}_($1, $2, $(echo $3 | $SED 's!\.!, !g'))"
    4.95  		fi
    4.96  	else
    4.97  		local level=1 fields= id= token
    4.98 @@ -345,7 +352,7 @@ check_field() {
    4.99  				id=$token
   4.100  				;;
   4.101  			[\,\;])
   4.102 -				if [ $level == 2 -a -n "$(echo $id | sed 's,^_pad[[:digit:]]*,,')" ]
   4.103 +				if [ $level == 2 -a -n "$(echo $id | $SED 's,^_pad[[:digit:]]*,,')" ]
   4.104  				then
   4.105  					check_field $1 $2 $3.$id "$fields"
   4.106  					test "$token" != ";" || fields= id=
   4.107 @@ -390,7 +397,7 @@ build_check() {
   4.108  			test $level != 2 -o $arrlvl != 1 || id=$token
   4.109  			;;
   4.110  		[\,\;])
   4.111 -			if [ $level == 2 -a -n "$(echo $id | sed 's,^_pad[[:digit:]]*,,')" ]
   4.112 +			if [ $level == 2 -a -n "$(echo $id | $SED 's,^_pad[[:digit:]]*,,')" ]
   4.113  			then
   4.114  				check_field $kind $1 $id "$fields"
   4.115  				test "$token" != ";" || fields= id=
   4.116 @@ -402,7 +409,7 @@ build_check() {
   4.117  	echo ""
   4.118  }
   4.119  
   4.120 -fields="$(get_fields $(echo $2 | sed 's,^compat_xen,compat_,') "$(sed -e 's,^[[:space:]]#.*,,' -e 's!\([]\[,;:{}]\)! \1 !g' $3)")"
   4.121 +fields="$(get_fields $(echo $2 | $SED 's,^compat_xen,compat_,') "$($SED -e 's,^[[:space:]]#.*,,' -e 's!\([]\[,;:{}]\)! \1 !g' $3)")"
   4.122  if [ -z "$fields" ]
   4.123  then
   4.124  	echo "Fields of '$2' not found in '$3'" >&2