File klibc-i386-socketcall-compat.patch of Package klibc

diff -Ndurp klibc/usr/klibc/arch/i386/Kbuild klibc-i386-socketcall-compat/usr/klibc/arch/i386/Kbuild
--- klibc/usr/klibc/arch/i386/Kbuild	2016-08-10 23:43:45.495354572 +0300
+++ klibc-i386-socketcall-compat/usr/klibc/arch/i386/Kbuild	2016-08-11 02:03:18.907950883 +0300
@@ -2,7 +2,7 @@
 # klibc .o files for i386
 #
 
-klib-y := setjmp.o syscall.o varsyscall.o
+klib-y := socketcall.o setjmp.o syscall.o varsyscall.o
 klib-y += open.o openat.o vfork.o
 klib-y += libgcc/__ashldi3.o libgcc/__ashrdi3.o libgcc/__lshrdi3.o
 klib-y += libgcc/__muldi3.o  libgcc/__negdi2.o
diff -Ndurp klibc/usr/klibc/arch/i386/socketcall.S klibc-i386-socketcall-compat/usr/klibc/arch/i386/socketcall.S
--- klibc/usr/klibc/arch/i386/socketcall.S	1970-01-01 03:00:00.000000000 +0300
+++ klibc-i386-socketcall-compat/usr/klibc/arch/i386/socketcall.S	2016-08-11 02:03:18.908950883 +0300
@@ -0,0 +1,55 @@
+#
+# socketcall.S
+#
+# Socketcalls use the following convention:
+# %eax = __NR_socketcall
+# %ebx = socketcall number
+# %ecx = pointer to arguments (up to 6)
+#
+
+#include <asm/unistd.h>
+
+#ifdef __i386__
+
+	.text
+	.align 4
+	.globl __socketcall_common
+	.type __socketcall_common, @function
+
+__socketcall_common:
+	xchgl	%ebx,(%esp)	# The stub passes the socketcall # on stack
+
+#ifdef	_REGPARM
+	pushl	16(%esp)	# Arg 6
+	pushl	16(%esp)	# Arg 5
+	pushl	16(%esp)	# Arg 4
+	pushl	%ecx
+	pushl	%edx
+	pushl	%eax
+	movl	%esp,%ecx
+#else
+	leal	8(%esp),%ecx	# Arguments already contiguous on-stack
+#endif
+
+	movl	$__NR_socketcall,%eax
+	call	*__syscall_entry
+
+#ifdef	_REGPARM
+	addl	$6*4, %esp
+#endif
+
+	cmpl	$-4095,%eax	# Error return?
+
+	popl	%ebx
+
+	jb	1f
+
+	negl	%eax
+	movl	%eax,errno
+	orl	$-1,%eax	# Return -1
+1:
+	ret
+
+	.size __socketcall_common,.-__socketcall_common
+
+#endif
diff -Ndurp klibc/usr/klibc/socketcalls.pl klibc-i386-socketcall-compat/usr/klibc/socketcalls.pl
--- klibc/usr/klibc/socketcalls.pl	2016-08-10 23:43:45.496354572 +0300
+++ klibc-i386-socketcall-compat/usr/klibc/socketcalls.pl	2016-08-11 02:04:03.606954067 +0300
@@ -60,7 +60,7 @@ while ( defined($line = <FILE>) ) {
 
 	print OUT "#if defined(DO_THIS_SOCKETCALL) && defined(SYS_\U${name}\E)\n\n";
 
-	print OUT "extern long __socketcall(int, const unsigned long *);\n\n";
+	print OUT "extern long __socketcall_common(int, const unsigned long *);\n\n";
 
 	print OUT "$type ${name}(", join(', ', @cargs), ")\n";
 	print OUT "{\n";
@@ -68,7 +68,7 @@ while ( defined($line = <FILE>) ) {
 	for ( $i = 0 ; $i < $nargs ; $i++ ) {
 	    print OUT "    args[$i] = (unsigned long)a$i;\n";
 	}
-	print OUT "    return ($type) __socketcall(SYS_\U${name}\E, args);\n";
+	print OUT "    return ($type) __socketcall_common(SYS_\U${name}\E, args);\n";
 	print OUT "}\n\n";
 
 	print OUT "#endif\n";
openSUSE Build Service is sponsored by