Update to LGPL v2.1.
[jlayton/glibc.git] / sysdeps / unix / sysv / linux / s390 / s390-32 / socket.S
1 /* Copyright (C) 2000, 2001 Free Software Foundation, Inc.
2    Contributed by Martin Schwidefsky (schwidefsky@de.ibm.com).
3    This file is part of the GNU C Library.
4
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.
9
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.
14
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.  */
19
20 #include <sysdep.h>
21 #include <socketcall.h>
22
23 /* &%/$&!! preprocessor */
24 #define P(a, b) P2(a, b)
25 #define P2(a, b) a##b
26
27         .text
28 /* The socket-oriented system calls are handled unusally in Linux.
29    They are all gated through the single `socketcall' system call number.
30    `socketcall' takes two arguments: the first is the subcode, specifying
31    which socket function is being called; and the second is a pointer to
32    the arguments to the specific function.
33
34    The .S files for the other calls just #define socket and #include this.  */
35
36 #ifndef __socket
37 #ifndef NO_WEAK_ALIAS
38 #define __socket P(__,socket)
39 #else
40 #define __socket socket
41 #endif
42 #endif
43
44 #ifndef NARGS      /* the socket.o object is compiled directly ... */
45 #define NARGS 3
46 #endif
47
48 .globl __socket
49 ENTRY(__socket)
50
51         /* Save registers and setup stack.  */
52         stm     %r6,%r15,24(%r15)       /* save registers */
53         lr      %r1,%r15
54         l       %r0,4(0,%r15)           /* load eos */
55         ahi     %r15,-120               /* buy stack space */
56         st      %r1,0(0,%r15)           /* store back chain */
57         st      %r0,4(0,%r15)           /* store eos */
58
59         /* Reorder arguments */
60 #if (NARGS >= 6)
61         mvc     0x74(4,%r15),216(%r15)  /* move between parameter lists */
62 #endif
63 #if (NARGS >= 5)
64         st      %r6,0x70(0,%r15)        /* store into parameter list */
65 #endif
66 #if (NARGS >= 4)
67         st      %r5,0x6C(0,%r15)        /* store into parameter list */
68 #endif
69 #if (NARGS >= 3)
70         st      %r4,0x68(0,%r15)        /* store into parameter list */
71 #endif
72 #if (NARGS >= 2)
73         st      %r3,0x64(0,%r15)        /* store into parameter list */
74         st      %r2,0x60(0,%r15)
75 #endif
76         /* load subcode for socket syscall */
77         lhi     %r2,P(SOCKOP_,socket)
78         la      %r3,0x60(0,%r15)        /* load address of parameter list */
79
80         /* Do the system call trap.  */
81         svc     SYS_ify(socketcall)
82
83         l       %r15,0(0,%r15)          /* load back chain */
84         lm      %r6,15,24(%r15)         /* load registers */
85
86         /* gpr2 is < 0 if there was an error.  */
87         lhi     %r0,-125
88         clr     %r2,%r0
89         jnl     SYSCALL_ERROR_LABEL
90
91         /* Successful; return the syscall's value.  */
92         br      %r14
93
94 PSEUDO_END (__socket)
95
96 #ifndef NO_WEAK_ALIAS
97 weak_alias (__socket, socket)
98 #endif