2.9
[glibc/nacl-glibc.git] / sysdeps / unix / sysv / linux / sparc / sparc64 / socket.S
blob353705b4aced96b131dc8dc0815b6cacce44349a
1 /* Copyright (C) 1997, 1998, 2002, 2004 Free Software Foundation, Inc.
2    This file is part of the GNU C Library.
3    Contributed by Miguel de Icaza <miguel@gnu.ai.mit.edu>, 1997.
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
7    License as published by the Free Software Foundation; either
8    version 2.1 of the 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, write to the Free
17    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
18    02111-1307 USA.  */
20 #include <sysdep-cancel.h>
21 #include <socketcall.h>
23 #define P(a, b) P2(a, b)
24 #define P2(a, b) a##b
26 #ifndef NARGS
27 #ifdef socket
28 #error NARGS not defined
29 #endif
30 #define NARGS 3
31 #endif
33         .text
34 /* The socket-oriented system calls are handled unusually in Linux.
35    They are all gated through the single `socketcall' system call number.
36    `socketcall' takes two arguments: the first is the subcode, specifying
37    which socket function is being called; and the second is a pointer to
38    the arguments to the specific function.
40    The .S files for the other calls just #define socket and #include this.  */
42 #ifndef __socket
43 # ifndef NO_WEAK_ALIAS
44 #  define __socket P(__,socket)
45 # else
46 #  define __socket socket
47 # endif
48 #endif
50         .globl  __syscall_error
51 ENTRY(__socket)
53         /* Drop up to 6 arguments (recvfrom) into the memory allocated by
54            the caller for varargs, since that's really what we have.  */
55         stx     %o0, [%sp + STACK_BIAS + 128 + 0]
56         stx     %o1, [%sp + STACK_BIAS + 128 + 8]
57 #if NARGS > 2
58         stx     %o2, [%sp + STACK_BIAS + 128 + 16]
59 #if NARGS > 3
60         stx     %o3, [%sp + STACK_BIAS + 128 + 24]
61 #if NARGS > 4
62         stx     %o4, [%sp + STACK_BIAS + 128 + 32]
63 #if NARGS > 5
64         stx     %o5, [%sp + STACK_BIAS + 128 + 40]
65 #endif
66 #endif
67 #endif
68 #endif
70 #if defined NEED_CANCELLATION && defined CENABLE
71         SINGLE_THREAD_P
72         cmp     %g1, 0
73         bne     .Lsocket_cancel
74 #endif
75          mov    P(SOCKOP_,socket), %o0          /* arg 1: socket subfunction */
76         add     %sp, STACK_BIAS + 128, %o1      /* arg 2: parameter block */
77         LOADSYSCALL(socketcall)
78         ta      0x6d
80         bcc,pt  %xcc, 1f
81          mov    %o7, %g1
82         call    __syscall_error
83          mov    %g1, %o7
84 1:      retl
85          nop
87 #if defined NEED_CANCELLATION && defined CENABLE
88 .Lsocket_cancel:
89         save    %sp, -160, %sp
90         cfi_def_cfa_register (%fp)
91         cfi_window_save
92         cfi_register (%o7, %i7)
93         CENABLE
94          nop
95         mov     %o0, %l0
96         add     %sp, 160 + STACK_BIAS + 128, %o1
97         mov     P(SOCKOP_,socket), %o0
98         LOADSYSCALL(socketcall)
99         ta      0x6d
101         bcc,pt  %xcc, 1f
102          mov    %o0, %l1
103         CDISABLE;
104          mov    %l0, %o0;
105         call    __syscall_error;
106          mov    %l1, %o0;
107         ba,pt   %xcc, 2f
108          mov    -1, %l1;
109 1:      CDISABLE
110          mov    %l0, %o0
111 2:      jmpl    %i7 + 8, %g0
112          restore %g0, %l1, %o0
113 #endif
115 END(__socket)
117 #ifndef NO_WEAK_ALIAS
118 weak_alias (__socket, socket)
119 #endif