Update copyright dates with scripts/update-copyrights.
[glibc.git] / sysdeps / unix / sysv / linux / sparc / sparc64 / socket.S
blobb680165653870b8394174212f24c4f3d6c8567b9
1 /* Copyright (C) 1997-2015 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, see
17    <http://www.gnu.org/licenses/>.  */
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 #ifndef NARGS
26 #ifdef socket
27 #error NARGS not defined
28 #endif
29 #define NARGS 3
30 #endif
32         .text
33 /* The socket-oriented system calls are handled unusually in Linux.
34    They are all gated through the single `socketcall' system call number.
35    `socketcall' takes two arguments: the first is the subcode, specifying
36    which socket function is being called; and the second is a pointer to
37    the arguments to the specific function.
39    The .S files for the other calls just #define socket and #include this.  */
41 #ifndef __socket
42 # ifndef NO_WEAK_ALIAS
43 #  define __socket P(__,socket)
44 # else
45 #  define __socket socket
46 # endif
47 #endif
49         .globl  __syscall_error
50 ENTRY(__socket)
52         /* Drop up to 6 arguments (recvfrom) into the memory allocated by
53            the caller for varargs, since that's really what we have.  */
54         stx     %o0, [%sp + STACK_BIAS + 128 + 0]
55         stx     %o1, [%sp + STACK_BIAS + 128 + 8]
56 #if NARGS > 2
57         stx     %o2, [%sp + STACK_BIAS + 128 + 16]
58 #if NARGS > 3
59         stx     %o3, [%sp + STACK_BIAS + 128 + 24]
60 #if NARGS > 4
61         stx     %o4, [%sp + STACK_BIAS + 128 + 32]
62 #if NARGS > 5
63         stx     %o5, [%sp + STACK_BIAS + 128 + 40]
64 #endif
65 #endif
66 #endif
67 #endif
69 #if defined NEED_CANCELLATION && defined CENABLE
70         SINGLE_THREAD_P
71         cmp     %g1, 0
72         bne     .Lsocket_cancel
73 #endif
74          mov    P(SOCKOP_,socket), %o0          /* arg 1: socket subfunction */
75         add     %sp, STACK_BIAS + 128, %o1      /* arg 2: parameter block */
76         LOADSYSCALL(socketcall)
77         ta      0x6d
79         bcc,pt  %xcc, 1f
80          mov    %o7, %g1
81         call    __syscall_error
82          mov    %g1, %o7
83 1:      retl
84          nop
86 #if defined NEED_CANCELLATION && defined CENABLE
87 .Lsocket_cancel:
88         save    %sp, -160, %sp
89         cfi_def_cfa_register (%fp)
90         cfi_window_save
91         cfi_register (%o7, %i7)
92         CENABLE
93          nop
94         mov     %o0, %l0
95         add     %sp, 160 + STACK_BIAS + 128, %o1
96         mov     P(SOCKOP_,socket), %o0
97         LOADSYSCALL(socketcall)
98         ta      0x6d
100         bcc,pt  %xcc, 1f
101          mov    %o0, %l1
102         CDISABLE;
103          mov    %l0, %o0;
104         call    __syscall_error;
105          mov    %l1, %o0;
106         ba,pt   %xcc, 2f
107          mov    -1, %l1;
108 1:      CDISABLE
109          mov    %l0, %o0
110 2:      jmpl    %i7 + 8, %g0
111          restore %g0, %l1, %o0
112 #endif
114 END(__socket)
116 #ifndef NO_WEAK_ALIAS
117 weak_alias (__socket, socket)
118 #endif