1 /* Copyright (C) 1995, 1996, 1997, 1998, 2003, 2004, 2005
2 Free Software Foundation, Inc.
4 This file is part of the GNU C Library.
6 The GNU C Library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Lesser General Public
8 License as published by the Free Software Foundation; either
9 version 2.1 of the License, or (at your option) any later version.
11 The GNU C Library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Lesser General Public License for more details.
16 You should have received a copy of the GNU Lesser General Public
17 License along with the GNU C Library; if not, write to the Free
18 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
21 #include <sysdep-cancel.h>
22 #include <socketcall.h>
24 #define P(a, b) P2(a, b)
28 /* The socket-oriented system calls are handled unusally in Linux.
29 They are all gated through the single `socketcall' system call number.
30 `socketcall' takes two arguments: the first is the subcode, specifying
31 which socket function is being called; and the second is a pointer to
32 the arguments to the specific function.
34 The .S files for the other calls just #define socket and #include this. */
37 # ifndef NO_WEAK_ALIAS
38 # define __socket P(__,socket)
40 # define __socket socket
44 #define PUSHARGS_1 str a1, [sp, $-4]!
45 #define PUSHARGS_2 stmfd sp!, {a1, a2}
46 #define PUSHARGS_3 stmfd sp!, {a1, a2, a3}
47 #define PUSHARGS_4 stmfd sp!, {a1, a2, a3, a4}
48 #define PUSHARGS_5 stmfd sp!, {a1, a2, a3, a4} /* Caller has already pushed arg 5 */
49 #define PUSHARGS_6 stmfd sp!, {a1, a2, a3, a4}
51 #define POPARGS_1 add sp, sp, #4
52 #define POPARGS_2 add sp, sp, #8
53 #define POPARGS_3 add sp, sp, #12
54 #define POPARGS_4 add sp, sp, #16
55 #define POPARGS_5 add sp, sp, #16
56 #define POPARGS_6 add sp, sp, #16
59 #define NARGS 3 /* If we were called with no wrapper, this is really socket() */
62 #if defined NEED_CANCELLATION && defined CENABLE
68 /* This code previously moved sp into ip and stored the args using
69 stmdb ip!, {a1-a4}. It did not modify sp, so the stack never had
70 to be restored after the syscall completed. It saved an
71 instruction and meant no stack cleanup work was required.
73 This will not work in the case of a socket call being interrupted
74 by a signal. If the signal handler uses any stack the arguments
75 to socket will be trashed. The results of a restart of any
76 socket call are then unpredictable. */
78 /* Push args onto the stack. */
81 #if defined NEED_CANCELLATION && defined CENABLE
86 /* Do the system call trap. */
87 mov a1, $P(SOCKOP_,socket)
89 swi SYS_ify(socketcall)
91 /* Pop args off the stack */
94 /* r0 is < 0 if there was an error. */
97 b PLTJMP(SYSCALL_ERROR)
99 #if defined NEED_CANCELLATION && defined CENABLE
105 mov r0, #P(SOCKOP_,socket)
107 swi SYS_ify(socketcall)
117 /* r0 is < 0 if there was an error. */
120 b PLTJMP(SYSCALL_ERROR)
123 PSEUDO_END (__socket)
125 #ifndef NO_WEAK_ALIAS
126 weak_alias (__socket, socket)