1 /* Copyright (C) 2009-2014 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public License as
7 published by the Free Software Foundation; either version 2.1 of the
8 License, or (at your option) any later version.
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
19 #include <sysdep-cancel.h>
20 #include <socketcall.h>
22 #define P(a, b) P2(a, b)
25 /* The socket-oriented system calls are handled unusally in Linux.
26 They are all gated through the single `socketcall' system call number.
27 `socketcall' takes two arguments: the first is the subcode, specifying
28 which socket function is being called; and the second is a pointer to
29 the arguments to the specific function.
31 The .S files for the other calls just #define socket and #include this.
32 They also #define a 'number-of-arguments' word in NARGS, which
37 # error NARGS not defined
43 0 - r15 (return address)
44 4 - 12 args to syscall
45 16 - scratch for cancellation state
46 20 - scratch for return value
48 #define stackadjust 24
51 # ifndef NO_WEAK_ALIAS
52 # define __socket P(__,socket)
54 # define __socket socket
60 addik r1,r1,-stackadjust
63 swi r5,r1,stackadjust+4
66 swi r6,r1,stackadjust+8
69 swi r7,r1,stackadjust+12
72 swi r8,r1,stackadjust+16
75 swi r9,r1,stackadjust+20
78 swi r10,r1,stackadjust+24
80 /* The rest of the args (if any) are on the caller's stack already. */
82 #if defined NEED_CANCELLATION && defined CENABLE
84 bnei r12,L(socket_cancel)
87 addik r12,r0,SYS_ify(socketcall)
88 addik r5,r0,P(SOCKOP_,socket)
89 addik r6,r1,stackadjust+4
93 addik r1,r1,stackadjust
96 bgei r4,SYSCALL_ERROR_LABEL
100 #if defined NEED_CANCELLATION && defined CENABLE
104 addik r12,r0,SYS_ify(socketcall)
105 addik r5,r0,P(SOCKOP_,socket)
106 addik r6,r1,stackadjust+4
114 addik r1,r1,stackadjust
117 bgei r4,SYSCALL_ERROR_LABEL
122 PSEUDO_END (__socket)
124 #ifndef NO_WEAK_ALIAS
125 weak_alias (__socket, socket)