| @@ -1,572 +1,569 @@ | | | @@ -1,572 +1,569 @@ |
1 | /* $NetBSD: pthread_cancelstub.c,v 1.21 2008/09/29 08:48:15 ad Exp $ */ | | 1 | /* $NetBSD: pthread_cancelstub.c,v 1.22 2008/10/08 08:27:07 ad Exp $ */ |
2 | | | 2 | |
3 | /*- | | 3 | /*- |
4 | * Copyright (c) 2002, 2007 The NetBSD Foundation, Inc. | | 4 | * Copyright (c) 2002, 2007 The NetBSD Foundation, Inc. |
5 | * All rights reserved. | | 5 | * All rights reserved. |
6 | * | | 6 | * |
7 | * This code is derived from software contributed to The NetBSD Foundation | | 7 | * This code is derived from software contributed to The NetBSD Foundation |
8 | * by Nathan J. Williams and Andrew Doran. | | 8 | * by Nathan J. Williams and Andrew Doran. |
9 | * | | 9 | * |
10 | * Redistribution and use in source and binary forms, with or without | | 10 | * Redistribution and use in source and binary forms, with or without |
11 | * modification, are permitted provided that the following conditions | | 11 | * modification, are permitted provided that the following conditions |
12 | * are met: | | 12 | * are met: |
13 | * 1. Redistributions of source code must retain the above copyright | | 13 | * 1. Redistributions of source code must retain the above copyright |
14 | * notice, this list of conditions and the following disclaimer. | | 14 | * notice, this list of conditions and the following disclaimer. |
15 | * 2. Redistributions in binary form must reproduce the above copyright | | 15 | * 2. Redistributions in binary form must reproduce the above copyright |
16 | * notice, this list of conditions and the following disclaimer in the | | 16 | * notice, this list of conditions and the following disclaimer in the |
17 | * documentation and/or other materials provided with the distribution. | | 17 | * documentation and/or other materials provided with the distribution. |
18 | * | | 18 | * |
19 | * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS | | 19 | * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS |
20 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED | | 20 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED |
21 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | | 21 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
22 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS | | 22 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS |
23 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | | 23 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
24 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | | 24 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
25 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | | 25 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
26 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | | 26 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
27 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | | 27 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
28 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | | 28 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
29 | * POSSIBILITY OF SUCH DAMAGE. | | 29 | * POSSIBILITY OF SUCH DAMAGE. |
30 | */ | | 30 | */ |
31 | | | 31 | |
32 | #include <sys/cdefs.h> | | 32 | #include <sys/cdefs.h> |
33 | __RCSID("$NetBSD: pthread_cancelstub.c,v 1.21 2008/09/29 08:48:15 ad Exp $"); | | 33 | __RCSID("$NetBSD: pthread_cancelstub.c,v 1.22 2008/10/08 08:27:07 ad Exp $"); |
34 | | | 34 | |
35 | #ifndef lint | | 35 | #ifndef lint |
36 | | | 36 | |
37 | | | 37 | |
38 | /* | | 38 | /* |
39 | * This is necessary because the names are always weak (they are not | | 39 | * This is necessary because the names are always weak (they are not |
40 | * POSIX functions). | | 40 | * POSIX functions). |
41 | */ | | 41 | */ |
42 | #define fsync_range _fsync_range | | 42 | #define fsync_range _fsync_range |
43 | #define pollts _pollts | | 43 | #define pollts _pollts |
44 | | | 44 | |
45 | /* | | 45 | /* |
46 | * XXX this is necessary to get the prototypes for the __sigsuspend14 | | 46 | * XXX this is necessary to get the prototypes for the __sigsuspend14 |
47 | * XXX and __msync13 internal names, instead of the application-visible | | 47 | * XXX and __msync13 internal names, instead of the application-visible |
48 | * XXX sigsuspend and msync names. It's kind of gross, but we're pretty | | 48 | * XXX sigsuspend and msync names. It's kind of gross, but we're pretty |
49 | * XXX intimate with libc already. | | 49 | * XXX intimate with libc already. |
50 | */ | | 50 | */ |
51 | #define __LIBC12_SOURCE__ | | 51 | #define __LIBC12_SOURCE__ |
52 | | | 52 | |
53 | #include <sys/msg.h> | | 53 | #include <sys/msg.h> |
54 | #include <sys/types.h> | | 54 | #include <sys/types.h> |
55 | #include <sys/uio.h> | | 55 | #include <sys/uio.h> |
56 | #include <sys/wait.h> | | 56 | #include <sys/wait.h> |
57 | #include <aio.h> | | 57 | #include <aio.h> |
58 | #include <fcntl.h> | | 58 | #include <fcntl.h> |
59 | #include <mqueue.h> | | 59 | #include <mqueue.h> |
60 | #include <poll.h> | | 60 | #include <poll.h> |
61 | #include <stdarg.h> | | 61 | #include <stdarg.h> |
62 | #include <unistd.h> | | 62 | #include <unistd.h> |
63 | | | 63 | |
64 | #include <signal.h> | | 64 | #include <signal.h> |
65 | #include <sys/mman.h> | | 65 | #include <sys/mman.h> |
66 | #include <sys/select.h> | | 66 | #include <sys/select.h> |
67 | #include <sys/socket.h> | | 67 | #include <sys/socket.h> |
68 | | | 68 | |
69 | #include <compat/sys/mman.h> | | 69 | #include <compat/sys/mman.h> |
70 | | | 70 | |
71 | #include "pthread.h" | | 71 | #include "pthread.h" |
72 | #include "pthread_int.h" | | 72 | #include "pthread_int.h" |
73 | | | 73 | |
74 | int pthread__cancel_stub_binder; | | 74 | int pthread__cancel_stub_binder; |
75 | | | 75 | |
76 | int _sys_accept(int, struct sockaddr *, socklen_t *); | | 76 | int _sys_accept(int, struct sockaddr *, socklen_t *); |
77 | int _sys_aio_suspend(const struct aiocb * const [], int, | | 77 | int _sys_aio_suspend(const struct aiocb * const [], int, |
78 | const struct timespec *); | | 78 | const struct timespec *); |
79 | int _sys_close(int); | | 79 | int _sys_close(int); |
80 | int _sys_connect(int, const struct sockaddr *, socklen_t); | | 80 | int _sys_connect(int, const struct sockaddr *, socklen_t); |
81 | int _sys_fcntl(int, int, ...); | | 81 | int _sys_fcntl(int, int, ...); |
82 | int _sys_fdatasync(int); | | 82 | int _sys_fdatasync(int); |
83 | int _sys_fsync(int); | | 83 | int _sys_fsync(int); |
84 | int _sys_fsync_range(int, int, off_t, off_t); | | 84 | int _sys_fsync_range(int, int, off_t, off_t); |
85 | int _sys_mq_send(mqd_t, const char *, size_t, unsigned); | | 85 | int _sys_mq_send(mqd_t, const char *, size_t, unsigned); |
86 | ssize_t _sys_mq_receive(mqd_t, char *, size_t, unsigned *); | | 86 | ssize_t _sys_mq_receive(mqd_t, char *, size_t, unsigned *); |
87 | int _sys_mq_timedsend(mqd_t, const char *, size_t, unsigned, | | 87 | int _sys_mq_timedsend(mqd_t, const char *, size_t, unsigned, |
88 | const struct timespec *); | | 88 | const struct timespec *); |
89 | ssize_t _sys_mq_timedreceive(mqd_t, char *, size_t, unsigned *, | | 89 | ssize_t _sys_mq_timedreceive(mqd_t, char *, size_t, unsigned *, |
90 | const struct timespec *); | | 90 | const struct timespec *); |
91 | ssize_t _sys_msgrcv(int, void *, size_t, long, int); | | 91 | ssize_t _sys_msgrcv(int, void *, size_t, long, int); |
92 | int _sys_msgsnd(int, const void *, size_t, int); | | 92 | int _sys_msgsnd(int, const void *, size_t, int); |
93 | int _sys___msync13(void *, size_t, int); | | 93 | int _sys___msync13(void *, size_t, int); |
94 | int _sys_open(const char *, int, ...); | | 94 | int _sys_open(const char *, int, ...); |
95 | int _sys_poll(struct pollfd *, nfds_t, int); | | 95 | int _sys_poll(struct pollfd *, nfds_t, int); |
96 | int _sys_pollts(struct pollfd *, nfds_t, const struct timespec *, | | 96 | int _sys_pollts(struct pollfd *, nfds_t, const struct timespec *, |
97 | const sigset_t *); | | 97 | const sigset_t *); |
98 | ssize_t _sys_pread(int, void *, size_t, off_t); | | 98 | ssize_t _sys_pread(int, void *, size_t, off_t); |
99 | int _sys_pselect(int, fd_set *, fd_set *, fd_set *, | | 99 | int _sys_pselect(int, fd_set *, fd_set *, fd_set *, |
100 | const struct timespec *, const sigset_t *); | | 100 | const struct timespec *, const sigset_t *); |
101 | ssize_t _sys_pwrite(int, const void *, size_t, off_t); | | 101 | ssize_t _sys_pwrite(int, const void *, size_t, off_t); |
102 | ssize_t _sys_read(int, void *, size_t); | | 102 | ssize_t _sys_read(int, void *, size_t); |
103 | ssize_t _sys_readv(int, const struct iovec *, int); | | 103 | ssize_t _sys_readv(int, const struct iovec *, int); |
104 | int _sys_select(int, fd_set *, fd_set *, fd_set *, struct timeval *); | | 104 | int _sys_select(int, fd_set *, fd_set *, fd_set *, struct timeval *); |
105 | int _sys_wait4(pid_t, int *, int, struct rusage *); | | 105 | int _sys_wait4(pid_t, int *, int, struct rusage *); |
106 | ssize_t _sys_write(int, const void *, size_t); | | 106 | ssize_t _sys_write(int, const void *, size_t); |
107 | ssize_t _sys_writev(int, const struct iovec *, int); | | 107 | ssize_t _sys_writev(int, const struct iovec *, int); |
108 | int _sys___sigsuspend14(const sigset_t *); | | 108 | int _sys___sigsuspend14(const sigset_t *); |
109 | int _sigtimedwait(const sigset_t * __restrict, siginfo_t * __restrict, | | 109 | int _sigtimedwait(const sigset_t * __restrict, siginfo_t * __restrict, |
110 | const struct timespec * __restrict); | | 110 | const struct timespec * __restrict); |
111 | int __sigsuspend14(const sigset_t *); | | 111 | int __sigsuspend14(const sigset_t *); |
112 | | | 112 | |
113 | #define TESTCANCEL(id) do { \ | | 113 | #define TESTCANCEL(id) do { \ |
114 | if (__predict_false((id)->pt_cancel)) \ | | 114 | if (__predict_false((id)->pt_cancel)) \ |
115 | pthread__cancelled(); \ | | 115 | pthread__cancelled(); \ |
116 | } while (/*CONSTCOND*/0) | | 116 | } while (/*CONSTCOND*/0) |
117 | | | 117 | |
118 | | | 118 | |
119 | int | | 119 | int |
120 | accept(int s, struct sockaddr *addr, socklen_t *addrlen) | | 120 | accept(int s, struct sockaddr *addr, socklen_t *addrlen) |
121 | { | | 121 | { |
122 | int retval; | | 122 | int retval; |
123 | pthread_t self; | | 123 | pthread_t self; |
124 | | | 124 | |
125 | self = pthread__self(); | | 125 | self = pthread__self(); |
126 | TESTCANCEL(self); | | 126 | TESTCANCEL(self); |
127 | retval = _sys_accept(s, addr, addrlen); | | 127 | retval = _sys_accept(s, addr, addrlen); |
128 | TESTCANCEL(self); | | 128 | TESTCANCEL(self); |
129 | | | 129 | |
130 | return retval; | | 130 | return retval; |
131 | } | | 131 | } |
132 | | | 132 | |
133 | int | | 133 | int |
| | | 134 | aio_suspend(const struct aiocb * const list[], int nent, |
| | | 135 | const struct timespec *timeout) |
| | | 136 | { |
| | | 137 | int retval; |
| | | 138 | pthread_t self; |
| | | 139 | |
| | | 140 | self = pthread__self(); |
| | | 141 | TESTCANCEL(self); |
| | | 142 | retval = _sys_aio_suspend(list, nent, timeout); |
| | | 143 | TESTCANCEL(self); |
| | | 144 | |
| | | 145 | return retval; |
| | | 146 | } |
| | | 147 | |
| | | 148 | int |
134 | close(int d) | | 149 | close(int d) |
135 | { | | 150 | { |
136 | int retval; | | 151 | int retval; |
137 | pthread_t self; | | 152 | pthread_t self; |
138 | | | 153 | |
139 | self = pthread__self(); | | 154 | self = pthread__self(); |
140 | TESTCANCEL(self); | | 155 | TESTCANCEL(self); |
141 | retval = _sys_close(d); | | 156 | retval = _sys_close(d); |
142 | TESTCANCEL(self); | | 157 | TESTCANCEL(self); |
143 | | | 158 | |
144 | return retval; | | 159 | return retval; |
145 | } | | 160 | } |
146 | | | 161 | |
147 | int | | 162 | int |
148 | connect(int s, const struct sockaddr *addr, socklen_t namelen) | | 163 | connect(int s, const struct sockaddr *addr, socklen_t namelen) |
149 | { | | 164 | { |
150 | int retval; | | 165 | int retval; |
151 | pthread_t self; | | 166 | pthread_t self; |
152 | | | 167 | |
153 | self = pthread__self(); | | 168 | self = pthread__self(); |
154 | TESTCANCEL(self); | | 169 | TESTCANCEL(self); |
155 | retval = _sys_connect(s, addr, namelen); | | 170 | retval = _sys_connect(s, addr, namelen); |
156 | TESTCANCEL(self); | | 171 | TESTCANCEL(self); |
157 | | | 172 | |
158 | return retval; | | 173 | return retval; |
159 | } | | 174 | } |
160 | | | 175 | |
161 | int | | 176 | int |
162 | fcntl(int fd, int cmd, ...) | | 177 | fcntl(int fd, int cmd, ...) |
163 | { | | 178 | { |
164 | int retval; | | 179 | int retval; |
165 | pthread_t self; | | 180 | pthread_t self; |
166 | va_list ap; | | 181 | va_list ap; |
167 | | | 182 | |
168 | self = pthread__self(); | | 183 | self = pthread__self(); |
169 | TESTCANCEL(self); | | 184 | TESTCANCEL(self); |
170 | va_start(ap, cmd); | | 185 | va_start(ap, cmd); |
171 | retval = _sys_fcntl(fd, cmd, va_arg(ap, void *)); | | 186 | retval = _sys_fcntl(fd, cmd, va_arg(ap, void *)); |
172 | va_end(ap); | | 187 | va_end(ap); |
173 | TESTCANCEL(self); | | 188 | TESTCANCEL(self); |
174 | | | 189 | |
175 | return retval; | | 190 | return retval; |
176 | } | | 191 | } |
177 | | | 192 | |
178 | int | | 193 | int |
179 | fdatasync(int d) | | 194 | fdatasync(int d) |
180 | { | | 195 | { |
181 | int retval; | | 196 | int retval; |
182 | pthread_t self; | | 197 | pthread_t self; |
183 | | | 198 | |
184 | self = pthread__self(); | | 199 | self = pthread__self(); |
185 | TESTCANCEL(self); | | 200 | TESTCANCEL(self); |
186 | retval = _sys_fdatasync(d); | | 201 | retval = _sys_fdatasync(d); |
187 | TESTCANCEL(self); | | 202 | TESTCANCEL(self); |
188 | | | 203 | |
189 | return retval; | | 204 | return retval; |
190 | } | | 205 | } |
191 | | | 206 | |
192 | int | | 207 | int |
193 | fsync(int d) | | 208 | fsync(int d) |
194 | { | | 209 | { |
195 | int retval; | | 210 | int retval; |
196 | pthread_t self; | | 211 | pthread_t self; |
197 | | | 212 | |
198 | self = pthread__self(); | | 213 | self = pthread__self(); |
199 | TESTCANCEL(self); | | 214 | TESTCANCEL(self); |
200 | retval = _sys_fsync(d); | | 215 | retval = _sys_fsync(d); |
201 | TESTCANCEL(self); | | 216 | TESTCANCEL(self); |
202 | | | 217 | |
203 | return retval; | | 218 | return retval; |
204 | } | | 219 | } |
205 | | | 220 | |
206 | int | | 221 | int |
207 | fsync_range(int d, int f, off_t s, off_t e) | | 222 | fsync_range(int d, int f, off_t s, off_t e) |
208 | { | | 223 | { |
209 | int retval; | | 224 | int retval; |
210 | pthread_t self; | | 225 | pthread_t self; |
211 | | | 226 | |
212 | self = pthread__self(); | | 227 | self = pthread__self(); |
213 | TESTCANCEL(self); | | 228 | TESTCANCEL(self); |
214 | retval = _sys_fsync_range(d, f, s, e); | | 229 | retval = _sys_fsync_range(d, f, s, e); |
215 | TESTCANCEL(self); | | 230 | TESTCANCEL(self); |
216 | | | 231 | |
217 | return retval; | | 232 | return retval; |
218 | } | | 233 | } |
219 | | | 234 | |
| | | 235 | int |
| | | 236 | mq_send(mqd_t mqdes, const char *msg_ptr, size_t msg_len, unsigned msg_prio) |
| | | 237 | { |
| | | 238 | int retval; |
| | | 239 | pthread_t self; |
| | | 240 | |
| | | 241 | self = pthread__self(); |
| | | 242 | TESTCANCEL(self); |
| | | 243 | retval = _sys_mq_send(mqdes, msg_ptr, msg_len, msg_prio); |
| | | 244 | TESTCANCEL(self); |
| | | 245 | |
| | | 246 | return retval; |
| | | 247 | } |
| | | 248 | |
| | | 249 | ssize_t |
| | | 250 | mq_receive(mqd_t mqdes, char *msg_ptr, size_t msg_len, unsigned *msg_prio) |
| | | 251 | { |
| | | 252 | ssize_t retval; |
| | | 253 | pthread_t self; |
| | | 254 | |
| | | 255 | self = pthread__self(); |
| | | 256 | TESTCANCEL(self); |
| | | 257 | retval = _sys_mq_receive(mqdes, msg_ptr, msg_len, msg_prio); |
| | | 258 | TESTCANCEL(self); |
| | | 259 | |
| | | 260 | return retval; |
| | | 261 | } |
| | | 262 | |
| | | 263 | int |
| | | 264 | mq_timedsend(mqd_t mqdes, const char *msg_ptr, size_t msg_len, |
| | | 265 | unsigned msg_prio, const struct timespec *abst) |
| | | 266 | { |
| | | 267 | int retval; |
| | | 268 | pthread_t self; |
| | | 269 | |
| | | 270 | self = pthread__self(); |
| | | 271 | TESTCANCEL(self); |
| | | 272 | retval = _sys_mq_timedsend(mqdes, msg_ptr, msg_len, msg_prio, abst); |
| | | 273 | TESTCANCEL(self); |
| | | 274 | |
| | | 275 | return retval; |
| | | 276 | } |
| | | 277 | |
| | | 278 | ssize_t |
| | | 279 | mq_timedreceive(mqd_t mqdes, char *msg_ptr, size_t msg_len, unsigned *msg_prio, |
| | | 280 | const struct timespec *abst) |
| | | 281 | { |
| | | 282 | ssize_t retval; |
| | | 283 | pthread_t self; |
| | | 284 | |
| | | 285 | self = pthread__self(); |
| | | 286 | TESTCANCEL(self); |
| | | 287 | retval = _sys_mq_timedreceive(mqdes, msg_ptr, msg_len, msg_prio, abst); |
| | | 288 | TESTCANCEL(self); |
| | | 289 | |
| | | 290 | return retval; |
| | | 291 | } |
| | | 292 | |
220 | ssize_t | | 293 | ssize_t |
221 | msgrcv(int msgid, void *msgp, size_t msgsz, long msgtyp, int msgflg) | | 294 | msgrcv(int msgid, void *msgp, size_t msgsz, long msgtyp, int msgflg) |
222 | { | | 295 | { |
223 | ssize_t retval; | | 296 | ssize_t retval; |
224 | pthread_t self; | | 297 | pthread_t self; |
225 | | | 298 | |
226 | self = pthread__self(); | | 299 | self = pthread__self(); |
227 | TESTCANCEL(self); | | 300 | TESTCANCEL(self); |
228 | retval = _sys_msgrcv(msgid, msgp, msgsz, msgtyp, msgflg); | | 301 | retval = _sys_msgrcv(msgid, msgp, msgsz, msgtyp, msgflg); |
229 | TESTCANCEL(self); | | 302 | TESTCANCEL(self); |
230 | | | 303 | |
231 | return retval; | | 304 | return retval; |
232 | } | | 305 | } |
233 | | | 306 | |
234 | int | | 307 | int |
235 | msgsnd(int msgid, const void *msgp, size_t msgsz, int msgflg) | | 308 | msgsnd(int msgid, const void *msgp, size_t msgsz, int msgflg) |
236 | { | | 309 | { |
237 | int retval; | | 310 | int retval; |
238 | pthread_t self; | | 311 | pthread_t self; |
239 | | | 312 | |
240 | self = pthread__self(); | | 313 | self = pthread__self(); |
241 | TESTCANCEL(self); | | 314 | TESTCANCEL(self); |
242 | retval = _sys_msgsnd(msgid, msgp, msgsz, msgflg); | | 315 | retval = _sys_msgsnd(msgid, msgp, msgsz, msgflg); |
243 | TESTCANCEL(self); | | 316 | TESTCANCEL(self); |
244 | | | 317 | |
245 | return retval; | | 318 | return retval; |
246 | } | | 319 | } |
247 | | | 320 | |
248 | int | | 321 | int |
249 | __msync13(void *addr, size_t len, int flags) | | 322 | __msync13(void *addr, size_t len, int flags) |
250 | { | | 323 | { |
251 | int retval; | | 324 | int retval; |
252 | pthread_t self; | | 325 | pthread_t self; |
253 | | | 326 | |
254 | self = pthread__self(); | | 327 | self = pthread__self(); |
255 | TESTCANCEL(self); | | 328 | TESTCANCEL(self); |
256 | retval = _sys___msync13(addr, len, flags); | | 329 | retval = _sys___msync13(addr, len, flags); |
257 | TESTCANCEL(self); | | 330 | TESTCANCEL(self); |
258 | | | 331 | |
259 | return retval; | | 332 | return retval; |
260 | } | | 333 | } |
261 | | | 334 | |
262 | int | | 335 | int |
263 | open(const char *path, int flags, ...) | | 336 | open(const char *path, int flags, ...) |
264 | { | | 337 | { |
265 | int retval; | | 338 | int retval; |
266 | pthread_t self; | | 339 | pthread_t self; |
267 | va_list ap; | | 340 | va_list ap; |
268 | | | 341 | |
269 | self = pthread__self(); | | 342 | self = pthread__self(); |
270 | TESTCANCEL(self); | | 343 | TESTCANCEL(self); |
271 | va_start(ap, flags); | | 344 | va_start(ap, flags); |
272 | retval = _sys_open(path, flags, va_arg(ap, mode_t)); | | 345 | retval = _sys_open(path, flags, va_arg(ap, mode_t)); |
273 | va_end(ap); | | 346 | va_end(ap); |
274 | TESTCANCEL(self); | | 347 | TESTCANCEL(self); |
275 | | | 348 | |
276 | return retval; | | 349 | return retval; |
277 | } | | 350 | } |
278 | | | 351 | |
279 | int | | 352 | int |
280 | poll(struct pollfd *fds, nfds_t nfds, int timeout) | | 353 | poll(struct pollfd *fds, nfds_t nfds, int timeout) |
281 | { | | 354 | { |
282 | int retval; | | 355 | int retval; |
283 | pthread_t self; | | 356 | pthread_t self; |
284 | | | 357 | |
285 | self = pthread__self(); | | 358 | self = pthread__self(); |
286 | TESTCANCEL(self); | | 359 | TESTCANCEL(self); |
287 | retval = _sys_poll(fds, nfds, timeout); | | 360 | retval = _sys_poll(fds, nfds, timeout); |
288 | TESTCANCEL(self); | | 361 | TESTCANCEL(self); |
289 | | | 362 | |
290 | return retval; | | 363 | return retval; |
291 | } | | 364 | } |
292 | | | 365 | |
293 | int | | 366 | int |
294 | pollts(struct pollfd *fds, nfds_t nfds, const struct timespec *ts, | | 367 | pollts(struct pollfd *fds, nfds_t nfds, const struct timespec *ts, |
295 | const sigset_t *sigmask) | | 368 | const sigset_t *sigmask) |
296 | { | | 369 | { |
297 | int retval; | | 370 | int retval; |
298 | pthread_t self; | | 371 | pthread_t self; |
299 | | | 372 | |
300 | self = pthread__self(); | | 373 | self = pthread__self(); |
301 | TESTCANCEL(self); | | 374 | TESTCANCEL(self); |
302 | retval = _sys_pollts(fds, nfds, ts, sigmask); | | 375 | retval = _sys_pollts(fds, nfds, ts, sigmask); |
303 | TESTCANCEL(self); | | 376 | TESTCANCEL(self); |
304 | | | 377 | |
305 | return retval; | | 378 | return retval; |
306 | } | | 379 | } |
307 | | | 380 | |
308 | ssize_t | | 381 | ssize_t |
309 | pread(int d, void *buf, size_t nbytes, off_t offset) | | 382 | pread(int d, void *buf, size_t nbytes, off_t offset) |
310 | { | | 383 | { |
311 | ssize_t retval; | | 384 | ssize_t retval; |
312 | pthread_t self; | | 385 | pthread_t self; |
313 | | | 386 | |
314 | self = pthread__self(); | | 387 | self = pthread__self(); |
315 | TESTCANCEL(self); | | 388 | TESTCANCEL(self); |
316 | retval = _sys_pread(d, buf, nbytes, offset); | | 389 | retval = _sys_pread(d, buf, nbytes, offset); |
317 | TESTCANCEL(self); | | 390 | TESTCANCEL(self); |
318 | | | 391 | |
319 | return retval; | | 392 | return retval; |
320 | } | | 393 | } |
321 | | | 394 | |
322 | int | | 395 | int |
323 | pselect(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, | | 396 | pselect(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, |
324 | const struct timespec *timeout, const sigset_t *sigmask) | | 397 | const struct timespec *timeout, const sigset_t *sigmask) |
325 | { | | 398 | { |
326 | int retval; | | 399 | int retval; |
327 | pthread_t self; | | 400 | pthread_t self; |
328 | | | 401 | |
329 | self = pthread__self(); | | 402 | self = pthread__self(); |
330 | TESTCANCEL(self); | | 403 | TESTCANCEL(self); |
331 | retval = _sys_pselect(nfds, readfds, writefds, exceptfds, timeout, | | 404 | retval = _sys_pselect(nfds, readfds, writefds, exceptfds, timeout, |
332 | sigmask); | | 405 | sigmask); |
333 | TESTCANCEL(self); | | 406 | TESTCANCEL(self); |
334 | | | 407 | |
335 | return retval; | | 408 | return retval; |
336 | } | | 409 | } |
337 | | | 410 | |
338 | ssize_t | | 411 | ssize_t |
339 | pwrite(int d, const void *buf, size_t nbytes, off_t offset) | | 412 | pwrite(int d, const void *buf, size_t nbytes, off_t offset) |
340 | { | | 413 | { |
341 | ssize_t retval; | | 414 | ssize_t retval; |
342 | pthread_t self; | | 415 | pthread_t self; |
343 | | | 416 | |
344 | self = pthread__self(); | | 417 | self = pthread__self(); |
345 | TESTCANCEL(self); | | 418 | TESTCANCEL(self); |
346 | retval = _sys_pwrite(d, buf, nbytes, offset); | | 419 | retval = _sys_pwrite(d, buf, nbytes, offset); |
347 | TESTCANCEL(self); | | 420 | TESTCANCEL(self); |
348 | | | 421 | |
349 | return retval; | | 422 | return retval; |
350 | } | | 423 | } |
351 | | | 424 | |
352 | #ifdef _FORTIFY_SOURCE | | 425 | #ifdef _FORTIFY_SOURCE |
353 | #undef read | | 426 | #undef read |
354 | #endif | | 427 | #endif |
355 | | | 428 | |
356 | ssize_t | | 429 | ssize_t |
357 | read(int d, void *buf, size_t nbytes) | | 430 | read(int d, void *buf, size_t nbytes) |
358 | { | | 431 | { |
359 | ssize_t retval; | | 432 | ssize_t retval; |
360 | pthread_t self; | | 433 | pthread_t self; |
361 | | | 434 | |
362 | self = pthread__self(); | | 435 | self = pthread__self(); |
363 | TESTCANCEL(self); | | 436 | TESTCANCEL(self); |
364 | retval = _sys_read(d, buf, nbytes); | | 437 | retval = _sys_read(d, buf, nbytes); |
365 | TESTCANCEL(self); | | 438 | TESTCANCEL(self); |
366 | | | 439 | |
367 | return retval; | | 440 | return retval; |
368 | } | | 441 | } |
369 | | | 442 | |
370 | ssize_t | | 443 | ssize_t |
371 | readv(int d, const struct iovec *iov, int iovcnt) | | 444 | readv(int d, const struct iovec *iov, int iovcnt) |
372 | { | | 445 | { |
373 | ssize_t retval; | | 446 | ssize_t retval; |
374 | pthread_t self; | | 447 | pthread_t self; |
375 | | | 448 | |
376 | self = pthread__self(); | | 449 | self = pthread__self(); |
377 | TESTCANCEL(self); | | 450 | TESTCANCEL(self); |
378 | retval = _sys_readv(d, iov, iovcnt); | | 451 | retval = _sys_readv(d, iov, iovcnt); |
379 | TESTCANCEL(self); | | 452 | TESTCANCEL(self); |
380 | | | 453 | |
381 | return retval; | | 454 | return retval; |
382 | } | | 455 | } |
383 | | | 456 | |
384 | int | | 457 | int |
385 | select(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, | | 458 | select(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, |
386 | struct timeval *timeout) | | 459 | struct timeval *timeout) |
387 | { | | 460 | { |
388 | int retval; | | 461 | int retval; |
389 | pthread_t self; | | 462 | pthread_t self; |
390 | | | 463 | |
391 | self = pthread__self(); | | 464 | self = pthread__self(); |
392 | TESTCANCEL(self); | | 465 | TESTCANCEL(self); |
393 | retval = _sys_select(nfds, readfds, writefds, exceptfds, timeout); | | 466 | retval = _sys_select(nfds, readfds, writefds, exceptfds, timeout); |
394 | TESTCANCEL(self); | | 467 | TESTCANCEL(self); |
395 | | | 468 | |
396 | return retval; | | 469 | return retval; |
397 | } | | 470 | } |
398 | | | 471 | |
399 | pid_t | | 472 | pid_t |
400 | wait4(pid_t wpid, int *status, int options, struct rusage *rusage) | | 473 | wait4(pid_t wpid, int *status, int options, struct rusage *rusage) |
401 | { | | 474 | { |
402 | pid_t retval; | | 475 | pid_t retval; |
403 | pthread_t self; | | 476 | pthread_t self; |
404 | | | 477 | |
405 | self = pthread__self(); | | 478 | self = pthread__self(); |
406 | TESTCANCEL(self); | | 479 | TESTCANCEL(self); |
407 | retval = _sys_wait4(wpid, status, options, rusage); | | 480 | retval = _sys_wait4(wpid, status, options, rusage); |
408 | TESTCANCEL(self); | | 481 | TESTCANCEL(self); |
409 | | | 482 | |
410 | return retval; | | 483 | return retval; |
411 | } | | 484 | } |
412 | | | 485 | |
413 | ssize_t | | 486 | ssize_t |
414 | write(int d, const void *buf, size_t nbytes) | | 487 | write(int d, const void *buf, size_t nbytes) |
415 | { | | 488 | { |
416 | ssize_t retval; | | 489 | ssize_t retval; |
417 | pthread_t self; | | 490 | pthread_t self; |
418 | | | 491 | |
419 | self = pthread__self(); | | 492 | self = pthread__self(); |
420 | TESTCANCEL(self); | | 493 | TESTCANCEL(self); |
421 | retval = _sys_write(d, buf, nbytes); | | 494 | retval = _sys_write(d, buf, nbytes); |
422 | TESTCANCEL(self); | | 495 | TESTCANCEL(self); |
423 | | | 496 | |
424 | return retval; | | 497 | return retval; |
425 | } | | 498 | } |
426 | | | 499 | |
427 | ssize_t | | 500 | ssize_t |
428 | writev(int d, const struct iovec *iov, int iovcnt) | | 501 | writev(int d, const struct iovec *iov, int iovcnt) |
429 | { | | 502 | { |
430 | ssize_t retval; | | 503 | ssize_t retval; |
431 | pthread_t self; | | 504 | pthread_t self; |
432 | | | 505 | |
433 | self = pthread__self(); | | 506 | self = pthread__self(); |
434 | TESTCANCEL(self); | | 507 | TESTCANCEL(self); |
435 | retval = _sys_writev(d, iov, iovcnt); | | 508 | retval = _sys_writev(d, iov, iovcnt); |
436 | TESTCANCEL(self); | | 509 | TESTCANCEL(self); |
437 | | | 510 | |
438 | return retval; | | 511 | return retval; |
439 | } | | 512 | } |
440 | | | 513 | |
441 | int | | 514 | int |
442 | __sigsuspend14(const sigset_t *sigmask) | | 515 | __sigsuspend14(const sigset_t *sigmask) |
443 | { | | 516 | { |
444 | pthread_t self; | | 517 | pthread_t self; |
445 | int retval; | | 518 | int retval; |
446 | | | 519 | |
447 | self = pthread__self(); | | 520 | self = pthread__self(); |
448 | TESTCANCEL(self); | | 521 | TESTCANCEL(self); |
449 | retval = _sys___sigsuspend14(sigmask); | | 522 | retval = _sys___sigsuspend14(sigmask); |
450 | TESTCANCEL(self); | | 523 | TESTCANCEL(self); |
451 | | | 524 | |
452 | return retval; | | 525 | return retval; |
453 | } | | 526 | } |
454 | | | 527 | |
455 | int | | 528 | int |
456 | sigtimedwait(const sigset_t * __restrict set, siginfo_t * __restrict info, | | 529 | sigtimedwait(const sigset_t * __restrict set, siginfo_t * __restrict info, |
457 | const struct timespec * __restrict timeout) | | 530 | const struct timespec * __restrict timeout) |
458 | { | | 531 | { |
459 | pthread_t self; | | 532 | pthread_t self; |
460 | int retval; | | 533 | int retval; |
461 | | | 534 | |
462 | self = pthread__self(); | | 535 | self = pthread__self(); |
463 | TESTCANCEL(self); | | 536 | TESTCANCEL(self); |
464 | retval = _sigtimedwait(set, info, timeout); | | 537 | retval = _sigtimedwait(set, info, timeout); |
465 | TESTCANCEL(self); | | 538 | TESTCANCEL(self); |
466 | | | 539 | |
467 | return retval; | | 540 | return retval; |
468 | } | | 541 | } |
469 | | | 542 | |
| | | 543 | __strong_alias(_aio_suspend, aio_suspend) |
470 | __strong_alias(_close, close) | | 544 | __strong_alias(_close, close) |
471 | __strong_alias(_fcntl, fcntl) | | 545 | __strong_alias(_fcntl, fcntl) |
472 | __strong_alias(_fdatasync, fdatasync) | | 546 | __strong_alias(_fdatasync, fdatasync) |
473 | __strong_alias(_fsync, fsync) | | 547 | __strong_alias(_fsync, fsync) |
474 | __weak_alias(fsync_range, _fsync_range) | | 548 | __weak_alias(fsync_range, _fsync_range) |
| | | 549 | __strong_alias(_mq_send, mq_send) |
| | | 550 | __strong_alias(_mq_receive, mq_receive) |
| | | 551 | __strong_alias(_mq_timedsend, mq_timedsend) |
| | | 552 | __strong_alias(_mq_timedreceive, mq_timedreceive) |
475 | __strong_alias(_msgrcv, msgrcv) | | 553 | __strong_alias(_msgrcv, msgrcv) |
476 | __strong_alias(_msgsnd, msgsnd) | | 554 | __strong_alias(_msgsnd, msgsnd) |
477 | __strong_alias(___msync13, __msync13) | | 555 | __strong_alias(___msync13, __msync13) |
478 | __strong_alias(_open, open) | | 556 | __strong_alias(_open, open) |
479 | __strong_alias(_poll, poll) | | 557 | __strong_alias(_poll, poll) |
480 | __weak_alias(pollts, _pollts) | | 558 | __weak_alias(pollts, _pollts) |
481 | __strong_alias(_pread, pread) | | 559 | __strong_alias(_pread, pread) |
482 | __strong_alias(_pselect, pselect) | | 560 | __strong_alias(_pselect, pselect) |
483 | __strong_alias(_pwrite, pwrite) | | 561 | __strong_alias(_pwrite, pwrite) |
484 | __strong_alias(_read, read) | | 562 | __strong_alias(_read, read) |
485 | __strong_alias(_readv, readv) | | 563 | __strong_alias(_readv, readv) |
486 | __strong_alias(_select, select) | | 564 | __strong_alias(_select, select) |
487 | __strong_alias(_wait4, wait4) | | 565 | __strong_alias(_wait4, wait4) |
488 | __strong_alias(_write, write) | | 566 | __strong_alias(_write, write) |
489 | __strong_alias(_writev, writev) | | 567 | __strong_alias(_writev, writev) |
490 | | | 568 | |
491 | #ifndef PTHREAD__COMPAT | | | |
492 | int | | | |
493 | aio_suspend(const struct aiocb * const list[], int nent, | | | |
494 | const struct timespec *timeout) | | | |
495 | { | | | |
496 | int retval; | | | |
497 | pthread_t self; | | | |
498 | | | | |
499 | self = pthread__self(); | | | |
500 | TESTCANCEL(self); | | | |
501 | retval = _sys_aio_suspend(list, nent, timeout); | | | |
502 | TESTCANCEL(self); | | | |
503 | | | | |
504 | return retval; | | | |
505 | } | | | |
506 | | | | |
507 | int | | | |
508 | mq_send(mqd_t mqdes, const char *msg_ptr, size_t msg_len, unsigned msg_prio) | | | |
509 | { | | | |
510 | int retval; | | | |
511 | pthread_t self; | | | |
512 | | | | |
513 | self = pthread__self(); | | | |
514 | TESTCANCEL(self); | | | |
515 | retval = _sys_mq_send(mqdes, msg_ptr, msg_len, msg_prio); | | | |
516 | TESTCANCEL(self); | | | |
517 | | | | |
518 | return retval; | | | |
519 | } | | | |
520 | | | | |
521 | ssize_t | | | |
522 | mq_receive(mqd_t mqdes, char *msg_ptr, size_t msg_len, unsigned *msg_prio) | | | |
523 | { | | | |
524 | ssize_t retval; | | | |
525 | pthread_t self; | | | |
526 | | | | |
527 | self = pthread__self(); | | | |
528 | TESTCANCEL(self); | | | |
529 | retval = _sys_mq_receive(mqdes, msg_ptr, msg_len, msg_prio); | | | |
530 | TESTCANCEL(self); | | | |
531 | | | | |
532 | return retval; | | | |
533 | } | | | |
534 | | | | |
535 | int | | | |
536 | mq_timedsend(mqd_t mqdes, const char *msg_ptr, size_t msg_len, | | | |
537 | unsigned msg_prio, const struct timespec *abst) | | | |
538 | { | | | |
539 | int retval; | | | |
540 | pthread_t self; | | | |
541 | | | | |
542 | self = pthread__self(); | | | |
543 | TESTCANCEL(self); | | | |
544 | retval = _sys_mq_timedsend(mqdes, msg_ptr, msg_len, msg_prio, abst); | | | |
545 | TESTCANCEL(self); | | | |
546 | | | | |
547 | return retval; | | | |
548 | } | | | |
549 | | | | |
550 | ssize_t | | | |
551 | mq_timedreceive(mqd_t mqdes, char *msg_ptr, size_t msg_len, unsigned *msg_prio, | | | |
552 | const struct timespec *abst) | | | |
553 | { | | | |
554 | ssize_t retval; | | | |
555 | pthread_t self; | | | |
556 | | | | |
557 | self = pthread__self(); | | | |
558 | TESTCANCEL(self); | | | |
559 | retval = _sys_mq_timedreceive(mqdes, msg_ptr, msg_len, msg_prio, abst); | | | |
560 | TESTCANCEL(self); | | | |
561 | | | | |
562 | return retval; | | | |
563 | } | | | |
564 | | | | |
565 | __strong_alias(_aio_suspend, aio_suspend) | | | |
566 | __strong_alias(_mq_send, mq_send) | | | |
567 | __strong_alias(_mq_receive, mq_receive) | | | |
568 | __strong_alias(_mq_timedsend, mq_timedsend) | | | |
569 | __strong_alias(_mq_timedreceive, mq_timedreceive) | | | |
570 | #endif /* !PTHREAD__COMPAT */ | | | |
571 | | | | |
572 | #endif /* !lint */ | | 569 | #endif /* !lint */ |