]>
Commit | Line | Data |
---|---|---|
b168057a | 1 | /* Copyright (C) 1995-2015 Free Software Foundation, Inc. |
2f6d1f1b | 2 | This file is part of the GNU C Library. |
28f540f4 | 3 | |
2f6d1f1b | 4 | The GNU C Library is free software; you can redistribute it and/or |
41bdb6e2 AJ |
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. | |
28f540f4 | 8 | |
2f6d1f1b UD |
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 | |
41bdb6e2 | 12 | Lesser General Public License for more details. |
28f540f4 | 13 | |
41bdb6e2 | 14 | You should have received a copy of the GNU Lesser General Public |
59ba27a6 PE |
15 | License along with the GNU C Library; if not, see |
16 | <http://www.gnu.org/licenses/>. */ | |
28f540f4 | 17 | |
6ee8d334 | 18 | #include <sysdep-cancel.h> |
5107cf1d | 19 | #include <socketcall.h> |
6ee8d334 | 20 | #include <tls.h> |
28f540f4 | 21 | |
d2f5be2a UD |
22 | #define P(a, b) P2(a, b) |
23 | #define P2(a, b) a##b | |
24 | ||
c14e4c32 | 25 | .text |
f93fc0b7 | 26 | /* The socket-oriented system calls are handled unusally in Linux/i386. |
28f540f4 RM |
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 | |
439d1d45 | 30 | the arguments to the specific function. |
28f540f4 RM |
31 | |
32 | The .S files for the other calls just #define socket and #include this. */ | |
33 | ||
74015205 | 34 | #ifndef __socket |
6ee8d334 UD |
35 | # ifndef NO_WEAK_ALIAS |
36 | # define __socket P(__,socket) | |
37 | # else | |
38 | # define __socket socket | |
39 | # endif | |
74015205 UD |
40 | #endif |
41 | ||
42 | .globl __socket | |
43 | ENTRY (__socket) | |
6ee8d334 | 44 | #if defined NEED_CANCELLATION && defined CENABLE |
bd499a3b | 45 | SINGLE_THREAD_P |
6ee8d334 UD |
46 | jne 1f |
47 | #endif | |
28f540f4 RM |
48 | |
49 | /* Save registers. */ | |
439d1d45 | 50 | movl %ebx, %edx |
f60db8ed | 51 | cfi_register (3, 2) |
28f540f4 | 52 | |
d2f5be2a | 53 | movl $SYS_ify(socketcall), %eax /* System call number in %eax. */ |
28f540f4 RM |
54 | |
55 | /* Use ## so `socket' is a separate token that might be #define'd. */ | |
d2f5be2a | 56 | movl $P(SOCKOP_,socket), %ebx /* Subcode is first arg to syscall. */ |
215dbbb1 | 57 | lea 4(%esp), %ecx /* Address of args is 2nd arg. */ |
28f540f4 RM |
58 | |
59 | /* Do the system call trap. */ | |
f051627f | 60 | ENTER_KERNEL |
28f540f4 RM |
61 | |
62 | /* Restore registers. */ | |
439d1d45 | 63 | movl %edx, %ebx |
f60db8ed | 64 | cfi_restore (3) |
28f540f4 RM |
65 | |
66 | /* %eax is < 0 if there was an error. */ | |
6ed0492f | 67 | cmpl $-125, %eax |
c0fb8a56 | 68 | jae SYSCALL_ERROR_LABEL |
28f540f4 RM |
69 | |
70 | /* Successful; return the syscall's value. */ | |
71 | ret | |
6ed0492f | 72 | |
6ee8d334 UD |
73 | |
74 | #if defined NEED_CANCELLATION && defined CENABLE | |
75 | /* We need one more register. */ | |
76 | 1: pushl %esi | |
f60db8ed | 77 | cfi_adjust_cfa_offset(4) |
6ee8d334 UD |
78 | |
79 | /* Enable asynchronous cancellation. */ | |
9634cf9d | 80 | CENABLE |
6ee8d334 | 81 | movl %eax, %esi |
f60db8ed | 82 | cfi_offset(6, -8) /* %esi */ |
6ee8d334 UD |
83 | |
84 | /* Save registers. */ | |
85 | movl %ebx, %edx | |
f60db8ed | 86 | cfi_register (3, 2) |
6ee8d334 UD |
87 | |
88 | movl $SYS_ify(socketcall), %eax /* System call number in %eax. */ | |
89 | ||
90 | /* Use ## so `socket' is a separate token that might be #define'd. */ | |
91 | movl $P(SOCKOP_,socket), %ebx /* Subcode is first arg to syscall. */ | |
92 | lea 8(%esp), %ecx /* Address of args is 2nd arg. */ | |
93 | ||
94 | /* Do the system call trap. */ | |
f051627f | 95 | ENTER_KERNEL |
6ee8d334 | 96 | |
26a026b9 UD |
97 | /* Restore registers. */ |
98 | movl %edx, %ebx | |
f60db8ed | 99 | cfi_restore (3) |
26a026b9 | 100 | |
6ee8d334 UD |
101 | /* Restore the cancellation. */ |
102 | xchgl %esi, %eax | |
9634cf9d | 103 | CDISABLE |
6ee8d334 UD |
104 | |
105 | /* Restore registers. */ | |
106 | movl %esi, %eax | |
6ee8d334 | 107 | popl %esi |
f60db8ed UD |
108 | cfi_restore (6) |
109 | cfi_adjust_cfa_offset(-4) | |
6ee8d334 UD |
110 | |
111 | /* %eax is < 0 if there was an error. */ | |
112 | cmpl $-125, %eax | |
113 | jae SYSCALL_ERROR_LABEL | |
114 | ||
115 | /* Successful; return the syscall's value. */ | |
116 | ret | |
117 | #endif | |
74015205 | 118 | PSEUDO_END (__socket) |
d2f5be2a | 119 | |
50304ef0 | 120 | #ifndef NO_WEAK_ALIAS |
74015205 | 121 | weak_alias (__socket, socket) |
50304ef0 | 122 | #endif |