[klibc] [patch] s390: fix six parameter handling in sysstub.ph

Heiko Carstens heiko.carstens at de.ibm.com
Fri Jul 7 01:49:02 PDT 2006


From: Peter Oberparleiter <peter.oberparleiter at de.ibm.com>,
      Heiko Carstens <heiko.carstens at de.ibm.com>

Change s390's sysstub.ph so it can also handle syscalls with six parameters.

Signed-off-by: Peter Oberparleiter <peter.oberparleiter at de.ibm.com>
Signed-off-by: Heiko Carstens <heiko.carstens at de.ibm.com>
---

 usr/klibc/arch/s390/sysstub.ph |   73 ++++++++++++++++++++++++++---------------
 1 file changed, 48 insertions(+), 25 deletions(-)

diff --git a/usr/klibc/arch/s390/sysstub.ph b/usr/klibc/arch/s390/sysstub.ph
index 880a0da..79f3068 100644
--- a/usr/klibc/arch/s390/sysstub.ph
+++ b/usr/klibc/arch/s390/sysstub.ph
@@ -7,33 +7,56 @@ #
 
 sub make_sysstub($$$$$@) {
     my($outputdir, $fname, $type, $sname, $stype, @args) = @_;
+    my($t);
+    my($r, $llregs) = (0, ($typesize{'void *'} == 8) ? 1 : 2);
 
-    open(OUT, '>', "${outputdir}/${fname}.S");
-    print OUT "#include <asm/unistd.h>\n";
-    print OUT "\n";
-    print OUT "\t.type ${fname},\@function\n";
-    print OUT "\t.globl ${fname}\n";
-    print OUT "${fname}:\n";
-    print OUT ".if __NR_${sname} < 256\n";
-    print OUT "\tsvc __NR_${sname}\n";
-    print OUT ".else\n";
-    print OUT "\tla %r1,__NR_${sname}\n";
-    print OUT "\tsvc 0\n";
-    print OUT ".endif\n";
-
-    print OUT "#ifndef __s390x__\n";
-
-    print OUT "\tbras %r3,1f\n";
-    print OUT "\t.long __syscall_common\n";
-    print OUT "1:\tl %r3,0(%r3)\n";
-    print OUT "\tbr %r3\n";
+    foreach $t (@args) {
+	    $r += ($typesize{$t} == 8) ? $llregs : 1;
+    }
 
-    print OUT "#else\n";
-
-    print OUT "\tbrasl %r3,__syscall_common\n";
-
-    print OUT "#endif\n";
-    print OUT "\t.size ${fname},.-${fname}\n";
+    open(OUT, '>', "${outputdir}/${fname}.S");
+    print OUT <<EOF;
+#include <asm/unistd.h>
+
+	.type ${fname},\@function
+	.globl ${fname}
+${fname}:
+.if ${r} > 6
+.print "System call with more than six parameters not supported yet."
+.err
+.endif
+.if ${r} == 6
+#ifndef __s390x__
+	st	%r7,56(%r15)
+	l	%r7,96(%r15)
+#else
+	stg	%r7,80(%r15)
+	lg	%r7,160(%r15)
+#endif
+.endif
+.if __NR_${sname} < 256
+	svc	__NR_${sname}
+.else
+	la	%r1,__NR_${sname}
+	svc	0
+.endif
+.if ${r} == 6
+#ifndef __s390x__
+	l	%r7,56(%r15)
+#else
+	lg	%r7,160(%r15)
+#endif
+.endif
+#ifndef __s390x__
+	bras	%r3,1f
+	.long	__syscall_common
+1:	l	%r3,0(%r3)
+	br	%r3
+#else
+	brasl	%r3,__syscall_common
+#endif
+	.size	${fname},.-${fname}
+EOF
     close(OUT);
 }
 



More information about the klibc mailing list