Update copyright notices with scripts/update-copyrights
[glibc.git] / sysdeps / unix / sysv / linux / s390 / s390-32 / socket.S
blobf3ebb5a55f6d76c0c19fad66fda05f3522e5d34d
1 /* Copyright (C) 2000-2014 Free Software Foundation, Inc.
2    Contributed by Martin Schwidefsky (schwidefsky@de.ibm.com).
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
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 /* &%/$&!! preprocessor */
23 #define P(a, b) P2(a, b)
24 #define P2(a, b) a##b
26         .text
27 /* The socket-oriented system calls are handled unusally in Linux.
28    They are all gated through the single `socketcall' system call number.
29    `socketcall' takes two arguments: the first is the subcode, specifying
30    which socket function is being called; and the second is a pointer to
31    the arguments to the specific function.
33    The .S files for the other calls just #define socket and #include this.  */
35 #ifndef __socket
36 #ifndef NO_WEAK_ALIAS
37 #define __socket P(__,socket)
38 #else
39 #define __socket socket
40 #endif
41 #endif
43 #ifndef NARGS      /* the socket.o object is compiled directly ... */
44 #define NARGS 3
45 #endif
47 .globl __socket
48 ENTRY(__socket)
49         /* Save registers and setup stack.  */
50         stm     %r6,%r15,24(%r15)       /* save registers */
51         cfi_offset (%r15, -36)
52         cfi_offset (%r14, -40)
53         cfi_offset (%r13, -44)
54         cfi_offset (%r12, -48)
55         cfi_offset (%r11, -52)
56         cfi_offset (%r10, -56)
57         cfi_offset (%r9, -60)
58         cfi_offset (%r8, -64)
59         cfi_offset (%r7, -68)
60         cfi_offset (%r6, -72)
61         lr      %r1,%r15
62         l       %r0,4(0,%r15)           /* load eos */
63         ahi     %r15,-120               /* buy stack space */
64         cfi_adjust_cfa_offset (120)
65         st      %r1,0(0,%r15)           /* store back chain */
66         st      %r0,4(0,%r15)           /* store eos */
68         /* Reorder arguments */
69 #if (NARGS >= 6)
70         mvc     0x74(4,%r15),216(%r15)  /* move between parameter lists */
71 #endif
72 #if (NARGS >= 5)
73         st      %r6,0x70(0,%r15)        /* store into parameter list */
74 #endif
75 #if (NARGS >= 4)
76         st      %r5,0x6C(0,%r15)        /* store into parameter list */
77 #endif
78 #if (NARGS >= 3)
79         st      %r4,0x68(0,%r15)        /* store into parameter list */
80 #endif
81 #if (NARGS >= 2)
82         st      %r3,0x64(0,%r15)        /* store into parameter list */
83         st      %r2,0x60(0,%r15)
84 #endif
86 #if defined NEED_CANCELLATION && defined CENABLE
87         SINGLE_THREAD_P (%r4)
88         jne     L(socket_cancel)
89 #endif
91         /* load subcode for socket syscall */
92         lhi     %r2,P(SOCKOP_,socket)
93         la      %r3,0x60(0,%r15)        /* load address of parameter list */
95         /* Do the system call trap.  */
96         svc     SYS_ify(socketcall)
99         l       %r15,0(0,%r15)          /* load back chain */
100         lm      %r6,15,24(%r15)         /* load registers */
102         /* gpr2 is < 0 if there was an error.  */
103         lhi     %r0,-125
104         clr     %r2,%r0
105         jnl     SYSCALL_ERROR_LABEL
107         /* Successful; return the syscall's value.  */
108         br      %r14
110 #if defined NEED_CANCELLATION && defined CENABLE
111 L(socket_cancel):
112         basr    %r13,0
113 1:      l       %r1,2f-1b(%r13)
114         /* call CENABLE.  */
115         bas     %r14,0(%r13,%r1)
116         lr      %r0,%r2
118         /* load subcode for socket syscall */
119         lhi     %r2,P(SOCKOP_,socket)
120         la      %r3,0x60(0,%r15)        /* load address of parameter list */
122         /* Do the system call trap.  */
123         svc     SYS_ify(socketcall)
125         l       %r3,3f-1b(%r13)
126         lr      %r12,%r2
127         lr      %r2,%r0
128         /* call CDISABLE.  */
129         bas     %r14,0(%r13,%r3)
130         lr      %r2,%r12
131         j       4b
133 2:      .long   CENABLE-1b
134 3:      .long   CDISABLE-1b
135 #endif
137         SYSCALL_ERROR_HANDLER
138 END (__socket)
140 #ifndef NO_WEAK_ALIAS
141 weak_alias (__socket, socket)
142 #endif