diff options
Diffstat (limited to 'klibc/klibc/arch/i386/socketcall.S')
-rw-r--r-- | klibc/klibc/arch/i386/socketcall.S | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/klibc/klibc/arch/i386/socketcall.S b/klibc/klibc/arch/i386/socketcall.S new file mode 100644 index 0000000000..6bac1e6913 --- /dev/null +++ b/klibc/klibc/arch/i386/socketcall.S @@ -0,0 +1,38 @@ +# +# socketcall.S +# +# On i386, the main (only?) user of socketcall(2), the memory array +# socketcall(2) needs is conveniently already assembled for us on +# the stack. Capitalize on that to make a common socketcall stub. +# + +#include <asm/unistd.h> + +#ifdef __i386__ + + .text + .align 4 + .globl __socketcall_common + .type __socketcall_common, @function + +__socketcall_common: + pushl %ebx + movzbl %al,%ebx # The socketcall number is passed in in %al + leal 8(%esp),%ecx # Argument pointer + movl $__NR_socketcall, %eax + int $0x80 + cmpl $-125,%eax # Error return? + popl %ebx + jb 1f + neg %eax + movl %eax,errno + xorl %eax,%eax + decl %eax # Return = -1 +1: + ret + + .size __socketcall_common,.-__socketcall_common + +#endif + + |