summaryrefslogtreecommitdiffstats
path: root/libc/arch-x86/bionic/syscall.S
blob: 71abe6b3fd4b956d76da4dfdfc265d81afa5d8f0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
/*
 * Generic syscall call.
 * Upon entry
 *	%eax: system call number
 *	%ebx: arg0 to system call
 *	%ecx: arg..
 *	%edx: arg..
 *	%esi: arg..
 *	%edi: arg..
 * We push these (to save them) load them up with the
 * values from the calling frame (not all will actually be valid)
 * and make the syscall.
 */

#include <sys/linux-syscalls.h>

    .text
    .type syscall, @function
    .globl syscall
    .align 4

syscall:
    push    %eax
    push    %ebx
    push    %ecx
    push    %edx
    push    %esi
    push    %edi
    mov     28(%esp),%eax
    mov     32(%esp),%ebx
    mov     36(%esp),%ecx
    mov     40(%esp),%edx
    mov     44(%esp),%esi
    mov     48(%esp),%edi

    int     $0x80

    cmpl    $-129, %eax
    jb      1f
    negl    %eax
    pushl   %eax
    call    __set_errno
    addl    $4, %esp
    orl     $-1, %eax
1:
    pop    %edi
    pop    %esi
    pop    %edx
    pop    %ecx
    pop    %ebx
    pop    %eax
    ret