Test for stack alignment.
[glibc.git] / sysdeps / unix / sysv / linux / m68k / socket.S
blob1d10f33e1729634d8ec999d890ee8d1aaa09e794
1 /* Copyright (C) 1996, 1997, 1998 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         .text
26 /* The socket-oriented system calls are handled unusally in Linux.
27    They are all gated through the single `socketcall' system call number.
28    `socketcall' takes two arguments: the first is the subcode, specifying
29    which socket function is being called; and the second is a pointer to
30    the arguments to the specific function.
32    The .S files for the other calls just #define socket and #include this.  */
34 #ifndef __socket
35 #ifndef NO_WEAK_ALIAS
36 #define __socket P(__,socket)
37 #else
38 #define __socket socket
39 #endif
40 #endif
42 .globl __socket
43 ENTRY (__socket)
44 #if defined NEED_CANCELLATION && defined CENABLE
45         SINGLE_THREAD_P
46         jne 1f
47 #endif
49         /* Save registers.  */
50         move.l %d2, %a0
52         move.l #SYS_ify (socketcall), %d0 /* System call number in %d0.  */
54         /* Use ## so `socket' is a separate token that might be #define'd.  */
55         move.l #P (SOCKOP_,socket), %d1 /* Subcode is first arg to syscall.  */
56         lea 4(%sp), %a1                 /* Address of args is 2nd arg.  */
57         move.l %a1, %d2
59         /* Do the system call trap.  */
60         trap #0
62         /* Restore registers.  */
63         move.l %a0, %d2
65         /* %d0 is < 0 if there was an error.  */
66         tst.l %d0
67         jmi SYSCALL_ERROR_LABEL
69         /* Successful; return the syscall's value.  */
70         rts
72 #if defined NEED_CANCELLATION && defined CENABLE
73 1:      /* Enable asynchronous cancellation.  */
74         CENABLE
76         /* Save registers.  */
77         move.l %d2, -(%sp)
78         move.l %d0, -(%sp)
80         move.l #SYS_ify (socketcall), %d0 /* System call number in %d0.  */
82         /* Use ## so `socket' is a separate token that might be #define'd.  */
83         move.l #P (SOCKOP_,socket), %d1 /* Subcode is first arg to syscall.  */
84         lea 4+8(%sp), %a1               /* Address of args is 2nd arg.  */
85         move.l %a1, %d2
87         /* Do the system call trap.  */
88         trap #0
90         /* Restore cancellation.  */
91         move.l %d0, %d2
92         CDISABLE
93         addq.l #4, %sp
94         move.l %d2, %d0
96         /* Restore registers.  */
97         move.l (%sp)+, %d2
99         /* %d0 is < 0 if there was an error.  */
100         tst.l %d0
101         jmi SYSCALL_ERROR_LABEL
103         /* Successful; return the syscall's value.  */
104         rts
105 #endif
106         
107 PSEUDO_END (__socket)
109 #ifndef NO_WEAK_ALIAS
110 weak_alias (__socket, socket)
111 #endif