[CRIU] [PATCH 1/7] x86: Teach syscall table generating script accept argument

Pavel Emelyanov xemul at parallels.com
Mon Dec 17 15:29:58 EST 2012


We'll have to generate syscall table in another form,
prepare for it
.
Signed-off-by: Pavel Emelyanov <xemul at parallels.com>
---
 arch/x86/Makefile           |    2 +-
 arch/x86/syscalls-x86-64.sh |   67 +++++++++++++++++++++++-------------------
 2 files changed, 38 insertions(+), 31 deletions(-)

diff --git a/arch/x86/Makefile b/arch/x86/Makefile
index d81e0f7..5896efe 100644
--- a/arch/x86/Makefile
+++ b/arch/x86/Makefile
@@ -17,7 +17,7 @@ CFLAGS		+= -c -fpie -Wstrict-prototypes -Wa,--noexecstack -D__ASSEMBLY__ -nostdl
 $(SYS-ASM): $(SYS-GEN) $(SYS-DEF) $(SYS-ASM-COMMON) $(SYS-TYPES)
 	$(E) "  GEN     " $@
 	$(Q) $(SH)			\
-		$(SYS-GEN)		\
+		$(SYS-GEN) --asm	\
 		$(SYS-DEF)		\
 		$(SYS-CODES)		\
 		$(SYS-PROTO)		\
diff --git a/arch/x86/syscalls-x86-64.sh b/arch/x86/syscalls-x86-64.sh
index 1372cd5..809967c 100644
--- a/arch/x86/syscalls-x86-64.sh
+++ b/arch/x86/syscalls-x86-64.sh
@@ -1,32 +1,39 @@
 #!/bin/sh
 
-in=$1
-codesout=$2
-protosout=$3
-asmout=$4
-asmcommon=$5
-prototypes=`echo $6 | sed -e 's/.*include\///g'`
-
-codesdef=`echo $codesout | sed -e 's/.*\/include\///g' | tr "[[:space:]].-" _`
-protosdef=`echo $protosout | sed -e 's/.*\/include\///g' | tr "[[:space:]].-" _`
-
-echo "/* Autogenerated, don't edit */"	>  $codesout
-echo "#ifndef $codesdef"		>> $codesout
-echo "#define $codesdef"		>> $codesout
-
-echo "/* Autogenerated, don't edit */"	>  $protosout
-echo "#ifndef $protosdef"		>> $protosout
-echo "#define $protosdef"		>> $protosout
-echo "#include \"$prototypes\""		>> $protosout
-echo "#include \"$codesout\""		>> $protosout
-
-echo "/* Autogenerated, don't edit */"	>  $asmout
-echo "#include \"$codesout\""		>> $asmout
-echo "#include \"$asmcommon\""		>> $asmout
-
-cat $in | egrep -v '^#' | sed -e 's/\t\{1,\}/|/g' | awk -F '|' '{print "#define", $1, $2}'		>> $codesout
-cat $in | egrep -v '^#' | sed -e 's/\t\{1,\}/|/g' | awk -F '|' '{print "extern long ", $3, $4, ";"}'	>> $protosout
-cat $in | egrep -v '^#' | sed -e 's/\t\{1,\}/|/g' | awk -F '|' '{print "SYSCALL(", $3, ",", $2, ")"}'	>> $asmout
-
-echo "#endif /* $codesdef */"		>> $codesout
-echo "#endif /* $protosdef */"		>> $protosout
+function gen_asm() {
+	in=$1
+	codesout=$2
+	protosout=$3
+	asmout=$4
+	asmcommon=$5
+	prototypes=`echo $6 | sed -e 's/.*include\///g'`
+
+	codesdef=`echo $codesout | sed -e 's/.*\/include\///g' | tr "[[:space:]].-" _`
+	protosdef=`echo $protosout | sed -e 's/.*\/include\///g' | tr "[[:space:]].-" _`
+
+	echo "/* Autogenerated, don't edit */"	>  $codesout
+	echo "#ifndef $codesdef"		>> $codesout
+	echo "#define $codesdef"		>> $codesout
+
+	echo "/* Autogenerated, don't edit */"	>  $protosout
+	echo "#ifndef $protosdef"		>> $protosout
+	echo "#define $protosdef"		>> $protosout
+	echo "#include \"$prototypes\""		>> $protosout
+	echo "#include \"$codesout\""		>> $protosout
+
+	echo "/* Autogenerated, don't edit */"	>  $asmout
+	echo "#include \"$codesout\""		>> $asmout
+	echo "#include \"$asmcommon\""		>> $asmout
+
+	cat $in | egrep -v '^#' | sed -e 's/\t\{1,\}/|/g' | awk -F '|' '{print "#define", $1, $2}'		>> $codesout
+	cat $in | egrep -v '^#' | sed -e 's/\t\{1,\}/|/g' | awk -F '|' '{print "extern long ", $3, $4, ";"}'	>> $protosout
+	cat $in | egrep -v '^#' | sed -e 's/\t\{1,\}/|/g' | awk -F '|' '{print "SYSCALL(", $3, ",", $2, ")"}'	>> $asmout
+
+	echo "#endif /* $codesdef */"		>> $codesout
+	echo "#endif /* $protosdef */"		>> $protosout
+}
+
+if [ "$1" = "--asm" ]; then
+	shift
+	gen_asm $@
+fi
-- 
1.7.1


More information about the CRIU mailing list