chiark / gitweb /
Make run_directory.c stat the place it is going to try to run.
[elogind.git] / klibc / klibc / arch / i386 / syscall.S
1 /*
2  * arch/i386/syscall.S
3  *
4  * Common tail-handling code for system calls.  Because of __syscalldecl
5  * we are using the stack even on if we are compiling with regparm.
6  *
7  * The arguments are on the stack; the system call number in %eax.
8  */
9
10 #define ARG(n)  (4*n+20)(%esp)
11         
12         .text
13         .align  4
14         .globl  __syscall_common
15         .type   __syscall_common,@function
16 __syscall_common:
17 #ifdef _REGPARM
18         xchgl   %ebx,(%esp)
19 #else
20         popl    %eax
21         pushl   %ebx
22 #endif
23         pushl   %esi
24         pushl   %edi
25         pushl   %ebp
26
27 #ifdef _REGPARM
28         xchgl   %eax,%ebx
29         xchgl   %ecx,%edx
30         movl    ARG(0),%esi
31         movl    ARG(1),%edi
32         movl    ARG(2),%ebp
33 #else
34         movl    ARG(0),%ebx             # Syscall arguments
35         movl    ARG(1),%ecx
36         movl    ARG(2),%edx
37         movl    ARG(3),%esi
38         movl    ARG(4),%edi
39         movl    ARG(5),%ebp
40 #endif
41         int     $0x80
42
43         cmpl    $-4096,%eax
44
45         popl    %ebp
46         popl    %edi
47         popl    %esi
48         popl    %ebx
49
50         jb      1f
51
52         # Error return, must set errno
53         negl    %eax
54         movl    %eax,errno
55         orl     $-1,%eax                # Return -1
56
57 1:
58         ret
59
60         .size   __syscall_common,.-__syscall_common