2.9
[glibc/nacl-glibc.git] / sysdeps / unix / sysv / linux / i386 / paccept.S
blob02ad78dd47657c1bb5f3d479928cbaf344fa4c34
1 /* Copyright (C) 1995-1998,2002,2003,2005,2008 Free Software Foundation, Inc.
2    This file is part of the GNU C Library.
4    The GNU C Library is free software; you can redistribute it and/or
5    modify it under the terms of the GNU Lesser General Public
6    License as published by the Free Software Foundation; either
7    version 2.1 of the License, or (at your option) any later version.
9    The GNU C Library is distributed in the hope that it will be useful,
10    but WITHOUT ANY WARRANTY; without even the implied warranty of
11    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12    Lesser General Public License for more details.
14    You should have received a copy of the GNU Lesser General Public
15    License along with the GNU C Library; if not, write to the Free
16    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
17    02111-1307 USA.  */
19 #include <sysdep-cancel.h>
20 #include <socketcall.h>
21 #include <tls.h>
23 #define _NSIG 64
25 #define P(a, b) P2(a, b)
26 #define P2(a, b) a##b
28         .text
29 /* The socket-oriented system calls are handled unusally in Linux.
30    They are all gated through the single `socketcall' system call number.
31    `socketcall' takes two arguments: the first is the subcode, specifying
32    which socket function is being called; and the second is a pointer to
33    the arguments to the specific function.  */
35 ENTRY(do_paccept)
36 #ifdef SOCKOP_paccept
37         subl $6*4, %esp
38         cfi_adjust_cfa_offset(6*4)
40         movl (%eax), %ecx
41         movl %ecx, (%esp)
42         movl 4(%eax), %ecx
43         movl %ecx, 4(%esp)
44         movl 8(%eax), %ecx
45         movl %ecx, 8(%esp)
46         movl 12(%eax), %ecx
47         movl %ecx, 12(%esp)
48         movl $(_NSIG / 8), 16(%esp)
49         movl 16(%eax), %ecx
50         movl %ecx, 20(%esp)
52         movl $SYS_ify(socketcall), %eax /* System call number in %eax.  */
54         movl $SOCKOP_paccept, %ebx      /* Subcode is first arg to syscall.  */
55         movl %esp, %ecx                 /* Address of args is 2nd arg.  */
57         /* Do the system call trap.  */
58         ENTER_KERNEL
60         addl $6*4, %esp
61         cfi_adjust_cfa_offset(-6*4)
63         /* %eax is < 0 if there was an error.  */
64         cmpl $-125, %eax
65         jae SYSCALL_ERROR_LABEL
66 #else
67         movl $-ENOSYS, %eax
68         jmp SYSCALL_ERROR_LABEL
70         .section .gnu.glibc-stub.paccept
71         .previous
72         .section .gnu.warning.paccept
73         .string "warning: paccept is not implemented and will always fail"
74         .previous
75 #endif
76 L(pseudo_end):
77         ret
78 PSEUDO_END(do_paccept)
81         .globl paccept
82 ENTRY (paccept)
83 #ifdef CENABLE
84         SINGLE_THREAD_P
85         jne 1f
86 #endif
88         /* Save registers.  */
89         movl %ebx, %edx
90         cfi_register (3, 2)
92         lea 4(%esp), %eax
93         call do_paccept
95         /* Restore registers.  */
96         movl %edx, %ebx
97         cfi_restore (3)
99         ret
101 #ifdef CENABLE
102         /* We need one more register.  */
103 1:      pushl %esi
104         cfi_adjust_cfa_offset(4)
106         /* Enable asynchronous cancellation.  */
107         CENABLE
108         movl %eax, %esi
109         cfi_offset(6, -8)               /* %esi */
111         /* Save registers.  */
112         movl %ebx, %edx
113         cfi_register (3, 2)
115         lea 8(%esp), %eax
116         call do_paccept
118         /* Restore registers.  */
119         movl %edx, %ebx
120         cfi_restore (3)
122         /* Restore the cancellation.  */
123         xchgl %esi, %eax
124         CDISABLE
126         /* Restore registers.  */
127         movl %esi, %eax
128         popl %esi
129         cfi_restore (6)
130         cfi_adjust_cfa_offset(-4)
132         /* Successful; return the syscall's value.  */
133         ret
134 #endif
135 PSEUDO_END (paccept)