Wed Oct 8 08:27:07 2008 UTC ()
Adjust the compat stuff slightly so that the changes are mostly self
contained (Makefile, pthread_compat.c).


(ad)
diff -r1.53 -r1.54 src/lib/libpthread/Makefile
diff -r1.21 -r1.22 src/lib/libpthread/pthread_cancelstub.c
diff -r1.1 -r1.2 src/lib/libpthread/pthread_compat.c

cvs diff -r1.53 -r1.54 src/lib/libpthread/Makefile (expand / switch to unified diff)

--- src/lib/libpthread/Makefile 2008/09/29 08:48:15 1.53
+++ src/lib/libpthread/Makefile 2008/10/08 08:27:07 1.54
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1# $NetBSD: Makefile,v 1.53 2008/09/29 08:48:15 ad Exp $ 1# $NetBSD: Makefile,v 1.54 2008/10/08 08:27:07 ad Exp $
2# 2#
3 3
4WARNS= 4 4WARNS= 4
5 5
6.include <bsd.own.mk> 6.include <bsd.own.mk>
7 7
8.if exists(${.CURDIR}/arch/${MACHINE_ARCH}) 8.if exists(${.CURDIR}/arch/${MACHINE_ARCH})
9ARCHSUBDIR= ${MACHINE_ARCH} 9ARCHSUBDIR= ${MACHINE_ARCH}
10.elif exists(${.CURDIR}/arch/${MACHINE_CPU})  10.elif exists(${.CURDIR}/arch/${MACHINE_CPU})
11ARCHSUBDIR= ${MACHINE_CPU} 11ARCHSUBDIR= ${MACHINE_CPU}
12.else 12.else
13.BEGIN: 13.BEGIN:
14 @echo "WARNING: no ARCHSUBDIR for ${MACHINE_ARCH}/${MACHINE_CPU}; skipping..." 14 @echo "WARNING: no ARCHSUBDIR for ${MACHINE_ARCH}/${MACHINE_CPU}; skipping..."
@@ -58,27 +58,26 @@ SRCS+= pthread_rwlock.c @@ -58,27 +58,26 @@ SRCS+= pthread_rwlock.c
58SRCS+= pthread_specific.c 58SRCS+= pthread_specific.c
59SRCS+= pthread_spin.c 59SRCS+= pthread_spin.c
60SRCS+= pthread_tsd.c 60SRCS+= pthread_tsd.c
61SRCS+= res_state.c 61SRCS+= res_state.c
62SRCS+= sem.c 62SRCS+= sem.c
63# Architecture-dependent files 63# Architecture-dependent files
64SRCS+= _context_u.S 64SRCS+= _context_u.S
65.if exists(${ARCHDIR}/pthread_md.c) 65.if exists(${ARCHDIR}/pthread_md.c)
66SRCS+= pthread_md.c 66SRCS+= pthread_md.c
67.endif 67.endif
68 68
69.if defined(PTHREAD__COMPAT) 69.if defined(PTHREAD__COMPAT)
70SRCS+= pthread_compat.c 70SRCS+= pthread_compat.c
71CPPFLAGS+= -DPTHREAD__COMPAT 
72.PATH.c: ${.CURDIR}/../../common/lib/libc/arch/${ARCHSUBDIR}/atomic 71.PATH.c: ${.CURDIR}/../../common/lib/libc/arch/${ARCHSUBDIR}/atomic
73.PATH.S: ${.CURDIR}/../../common/lib/libc/arch/${ARCHSUBDIR}/atomic 72.PATH.S: ${.CURDIR}/../../common/lib/libc/arch/${ARCHSUBDIR}/atomic
74.PATH.c: ${.CURDIR}/../../common/lib/libc/atomic 73.PATH.c: ${.CURDIR}/../../common/lib/libc/atomic
75.PATH.c: ${.CURDIR}/../libc/misc 74.PATH.c: ${.CURDIR}/../libc/misc
76.include "../../common/lib/libc/arch/${ARCHSUBDIR}/atomic/Makefile.inc" 75.include "../../common/lib/libc/arch/${ARCHSUBDIR}/atomic/Makefile.inc"
77.endif 76.endif
78 77
79# The TSD routines are used in the implementation of profiling, and so 78# The TSD routines are used in the implementation of profiling, and so
80# can't be profiled themselves. 79# can't be profiled themselves.
81COPTS.pthread_specific.c+= -fomit-frame-pointer -falign-functions=32 80COPTS.pthread_specific.c+= -fomit-frame-pointer -falign-functions=32
82pthread_specific.po: pthread_specific.o 81pthread_specific.po: pthread_specific.o
83 ${_MKTARGET_CREATE} 82 ${_MKTARGET_CREATE}
84 cp pthread_specific.o pthread_specific.po 83 cp pthread_specific.o pthread_specific.po

cvs diff -r1.21 -r1.22 src/lib/libpthread/pthread_cancelstub.c (expand / switch to unified diff)

--- src/lib/libpthread/pthread_cancelstub.c 2008/09/29 08:48:15 1.21
+++ src/lib/libpthread/pthread_cancelstub.c 2008/10/08 08:27:07 1.22
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
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.
@@ -20,27 +20,27 @@ @@ -20,27 +20,27 @@
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
@@ -121,26 +121,41 @@ accept(int s, struct sockaddr *addr, soc @@ -121,26 +121,41 @@ accept(int s, struct sockaddr *addr, soc
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
133int 133int
 134aio_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
 148int
134close(int d) 149close(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
@@ -207,26 +222,84 @@ int @@ -207,26 +222,84 @@ int
207fsync_range(int d, int f, off_t s, off_t e) 222fsync_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
 235int
 236mq_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
 249ssize_t
 250mq_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
 263int
 264mq_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
 278ssize_t
 279mq_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
220ssize_t 293ssize_t
221msgrcv(int msgid, void *msgp, size_t msgsz, long msgtyp, int msgflg) 294msgrcv(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}
@@ -457,116 +530,40 @@ sigtimedwait(const sigset_t * __restrict @@ -457,116 +530,40 @@ sigtimedwait(const sigset_t * __restrict
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 
492int 
493aio_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 
507int 
508mq_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 
521ssize_t 
522mq_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 
535int 
536mq_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 
550ssize_t 
551mq_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 */

cvs diff -r1.1 -r1.2 src/lib/libpthread/pthread_compat.c (expand / switch to unified diff)

--- src/lib/libpthread/pthread_compat.c 2008/09/29 08:48:15 1.1
+++ src/lib/libpthread/pthread_compat.c 2008/10/08 08:27:07 1.2
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: pthread_compat.c,v 1.1 2008/09/29 08:48:15 ad Exp $ */ 1/* $NetBSD: pthread_compat.c,v 1.2 2008/10/08 08:27:07 ad Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 2008 The NetBSD Foundation, Inc. 4 * Copyright (c) 2008 The NetBSD Foundation, Inc.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * This code is derived from software developed for The NetBSD Foundation 7 * This code is derived from software developed for The NetBSD Foundation
8 * by Andrew Doran. 8 * by 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.
@@ -19,51 +19,65 @@ @@ -19,51 +19,65 @@
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/*
 33 * libc symbols that are not present before NetBSD 5.0.
 34 */
 35
32#include <sys/cdefs.h> 36#include <sys/cdefs.h>
33__RCSID("$NetBSD: pthread_compat.c,v 1.1 2008/09/29 08:48:15 ad Exp $"); 37__RCSID("$NetBSD: pthread_compat.c,v 1.2 2008/10/08 08:27:07 ad Exp $");
34 38
35#include <sys/param.h> 39#include <sys/param.h>
36#include <sys/syscall.h> 40#include <sys/syscall.h>
 41#include <sys/aio.h>
37 42
38#include <lwp.h> 43#include <lwp.h>
39#include <unistd.h> 44#include <unistd.h>
40#include <sched.h> 45#include <sched.h>
41 46
42#include "pthread.h" 47#include "pthread.h"
43#include "pthread_int.h" 48#include "pthread_int.h"
44 49
45static void __pthread_init(void) __attribute__((__constructor__, __used__)); 50static void __pthread_init(void) __attribute__((__constructor__, __used__));
46 51
47void __libc_thr_init(void); 52void __libc_thr_init(void);
48void __libc_atomic_init(void); 53void __libc_atomic_init(void);
 54
49int _sys_sched_yield(void); 55int _sys_sched_yield(void);
 56int _sys_aio_suspend(const struct aiocb * const[], int,
 57 const struct timespec *);
 58int _sys_mq_send(mqd_t, const char *, size_t, unsigned);
 59ssize_t _sys_mq_receive(mqd_t, char *, size_t, unsigned *);
 60int _sys_mq_timedsend(mqd_t, const char *, size_t, unsigned,
 61 const struct timespec *);
 62ssize_t _sys_mq_timedreceive(mqd_t, char *, size_t, unsigned *,
 63 const struct timespec *);
50 64
51static void 65static void
52__pthread_init(void) 66__pthread_init(void)
53{ 67{
54 68
55 __libc_thr_init(); 
56 __libc_atomic_init(); 69 __libc_atomic_init();
 70 __libc_thr_init();
57} 71}
58 72
59int 73int
60_lwp_kill(lwpid_t a, int b) 74_lwp_kill(lwpid_t a, int b)
61{ 75{
62 76
63 return syscall(SYS__lwp_kill, a, b); 77 return syscall(SYS__lwp_kill, a, b);
64} 78}
65 79
66int 80int
67_lwp_detach(lwpid_t a) 81_lwp_detach(lwpid_t a)
68{ 82{
69 83
@@ -78,27 +92,27 @@ _lwp_park(const struct timespec *a, lwpi @@ -78,27 +92,27 @@ _lwp_park(const struct timespec *a, lwpi
78} 92}
79 93
80int 94int
81_lwp_unpark(lwpid_t a, const void *b) 95_lwp_unpark(lwpid_t a, const void *b)
82{ 96{
83 97
84 return syscall(SYS__lwp_unpark, a, b); 98 return syscall(SYS__lwp_unpark, a, b);
85} 99}
86 100
87ssize_t 101ssize_t
88_lwp_unpark_all(const lwpid_t *a, size_t b, const void *c) 102_lwp_unpark_all(const lwpid_t *a, size_t b, const void *c)
89{ 103{
90 104
91 return syscall(SYS__lwp_unpark_all, a, b, c); 105 return (ssize_t)syscall(SYS__lwp_unpark_all, a, b, c);
92} 106}
93 107
94int 108int
95_lwp_setname(lwpid_t a, const char *b) 109_lwp_setname(lwpid_t a, const char *b)
96{ 110{
97 111
98 return syscall(SYS__lwp_setname, a, b); 112 return syscall(SYS__lwp_setname, a, b);
99} 113}
100 114
101int 115int
102_lwp_getname(lwpid_t a, char *b, size_t c) 116_lwp_getname(lwpid_t a, char *b, size_t c)
103{ 117{
104 118
@@ -143,13 +157,51 @@ _sched_getaffinity(pid_t a, lwpid_t b, s @@ -143,13 +157,51 @@ _sched_getaffinity(pid_t a, lwpid_t b, s
143int 157int
144_sched_setparam(pid_t a, lwpid_t b, int c, const struct sched_param *d) 158_sched_setparam(pid_t a, lwpid_t b, int c, const struct sched_param *d)
145{ 159{
146 160
147 return syscall(SYS__sched_setparam, a, b, c, d); 161 return syscall(SYS__sched_setparam, a, b, c, d);
148} 162}
149 163
150int 164int
151_sched_getparam(pid_t a, lwpid_t b, int *c, struct sched_param *d) 165_sched_getparam(pid_t a, lwpid_t b, int *c, struct sched_param *d)
152{ 166{
153 167
154 return syscall(SYS__sched_getparam, a, b, c, d); 168 return syscall(SYS__sched_getparam, a, b, c, d);
155} 169}
 170
 171int
 172_sys_aio_suspend(const struct aiocb * const a[], int b,
 173 const struct timespec *c)
 174{
 175
 176 return syscall(SYS_aio_suspend, a, b, c);
 177}
 178
 179int
 180_sys_mq_send(mqd_t a, const char *b, size_t c, unsigned d)
 181{
 182
 183 return syscall(SYS_mq_send, a, b, c, d);
 184}
 185
 186ssize_t
 187_sys_mq_receive(mqd_t a, char *b, size_t c, unsigned *d)
 188{
 189
 190 return (ssize_t)syscall(SYS_mq_receive, a, b, c, d);
 191}
 192
 193int
 194_sys_mq_timedsend(mqd_t a, const char *b, size_t c, unsigned d,
 195 const struct timespec *e)
 196{
 197
 198 return syscall(SYS_mq_timedsend, a, b,c ,d, e);
 199}
 200
 201ssize_t
 202_sys_mq_timedreceive(mqd_t a, char *b, size_t c, unsigned *d,
 203 const struct timespec *e)
 204{
 205
 206 return (ssize_t)syscall(SYS_mq_timedreceive, a, b, c, d, e);
 207}