Updated to fedora-glibc-20050620T1530
[glibc.git] / sysdeps / unix / sysv / linux / powerpc / powerpc32 / socket.S
blob72170c95c09299cfb07d0572597ba06ccad89ee5
1 /* Copyright (C) 1995, 1996, 1997, 1999, 2003 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>
22 #define P(a, b) P2(a, b)
23 #define P2(a, b) 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
33    defaults to 3.  */
35 #ifndef NARGS
36 #ifdef socket
37 #error NARGS not defined
38 #endif
39 #define NARGS 3
40 #endif
42 /* 0(r1) and 4(r1) are reserved by the ABI, 8(r1), 12(r1), 16(r1) are used
43    for temp saves.  44(r1) is used to save r30.  */
44 #define stackblock 20
46 #ifndef __socket
47 #define __socket P(__,socket)
48 #endif
50         .text
51 ENTRY(__socket)
52         cfi_startproc
53         stwu r1,-48(r1)
54         cfi_adjust_cfa_offset(48)
55 #if NARGS >= 1
56         stw  r3,stackblock(r1)
57 #endif
58 #if NARGS >= 2
59         stw  r4,4+stackblock(r1)
60 #endif
61 #if NARGS >= 3
62         stw  r5,8+stackblock(r1)
63 #endif
64 #if NARGS >= 4
65         stw  r6,12+stackblock(r1)
66 #endif
67 #if NARGS >= 5
68         stw  r7,16+stackblock(r1)
69 #endif
70 #if NARGS >= 6
71         stw  r8,20+stackblock(r1)
72 #endif
73 #if NARGS >= 7
74 #error too many arguments!
75 #endif
77 #if defined NEED_CANCELLATION && defined CENABLE
78         SINGLE_THREAD_P
79         bne-    .Lsocket_cancel
80 #endif
82         li      r3,P(SOCKOP_,socket)
83         addi    r4,r1,stackblock
84         DO_CALL(SYS_ify(socketcall))
85         addi    r1,r1,48
86         PSEUDO_RET
88 #if defined NEED_CANCELLATION && defined CENABLE
89 .Lsocket_cancel:
90         mflr    r9
91         stw     r9,52(r1)
92         cfi_offset (lr, 4)
93         CGOTSETUP
94         CENABLE
95         stw     r3,16(r1)
96         li      r3,P(SOCKOP_,socket)
97         addi    r4,r1,stackblock
98         DO_CALL(SYS_ify(socketcall))
99         mfcr    r0
100         stw     r3,8(r1)
101         stw     r0,12(r1)
102         lwz     r3,16(r1)
103         CDISABLE
104         lwz     r4,52(r1)
105         lwz     r0,12(r1)
106         lwz     r3,8(r1)
107         CGOTRESTORE
108         mtlr    r4
109         mtcr    r0
110         addi    r1,r1,48
111         PSEUDO_RET
112 #endif
113         cfi_endproc
115 PSEUDO_END (__socket)
117 weak_alias (__socket, socket)