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 (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,179 +1,178 @@ @@ -1,179 +1,178 @@
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..."
15.endif 15.endif
16 16
17INCS= pthread.h pthread_types.h pthread_queue.h 17INCS= pthread.h pthread_types.h pthread_queue.h
18INCSDIR=/usr/include 18INCSDIR=/usr/include
19 19
20.if defined(ARCHSUBDIR) 20.if defined(ARCHSUBDIR)
21 21
22ARCHDIR= ${.CURDIR}/arch/${ARCHSUBDIR} 22ARCHDIR= ${.CURDIR}/arch/${ARCHSUBDIR}
23.PATH: ${ARCHDIR} 23.PATH: ${ARCHDIR}
24 24
25CPPFLAGS+= -I${ARCHDIR} -I${.CURDIR} -I${.OBJDIR} -D_LIBC 25CPPFLAGS+= -I${ARCHDIR} -I${.CURDIR} -I${.OBJDIR} -D_LIBC
26CPPFLAGS+= -D__LIBPTHREAD_SOURCE__ 26CPPFLAGS+= -D__LIBPTHREAD_SOURCE__
27 27
28# XXX: This crappy poke at libc's internals needs to be fixed. 28# XXX: This crappy poke at libc's internals needs to be fixed.
29# We need to put this *after our own includes, so that our "assym.h" 29# We need to put this *after our own includes, so that our "assym.h"
30# gets picked, instead of the libc one 30# gets picked, instead of the libc one
31CPPFLAGS+=-I${NETBSDSRCDIR}/sys -I${.CURDIR}/../libc 31CPPFLAGS+=-I${NETBSDSRCDIR}/sys -I${.CURDIR}/../libc
32 32
33DPSRCS+= assym.h 33DPSRCS+= assym.h
34CLEANFILES+= assym.h 34CLEANFILES+= assym.h
35 35
36assym.h: ${ARCHDIR}/genassym.cf pthread.h pthread_int.h pthread_md.h 36assym.h: ${ARCHDIR}/genassym.cf pthread.h pthread_int.h pthread_md.h
37 ${_MKTARGET_CREATE} 37 ${_MKTARGET_CREATE}
38 ${TOOL_GENASSYM} -- ${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} \ 38 ${TOOL_GENASSYM} -- ${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} \
39 < ${ARCHDIR}/genassym.cf > assym.h.tmp && \ 39 < ${ARCHDIR}/genassym.cf > assym.h.tmp && \
40 mv -f assym.h.tmp assym.h 40 mv -f assym.h.tmp assym.h
41 41
42LIB= pthread 42LIB= pthread
43 43
44# 44#
45# NOTE: When you create a new file for libpthread, make sure that pthread.c 45# NOTE: When you create a new file for libpthread, make sure that pthread.c
46# gets a reference to a symbol in that file. Otherwise, Unix's stupid static 46# gets a reference to a symbol in that file. Otherwise, Unix's stupid static
47# library semantics will end up discarding potentially important objects. 47# library semantics will end up discarding potentially important objects.
48# 48#
49SRCS= pthread.c  49SRCS= pthread.c
50SRCS+= pthread_attr.c 50SRCS+= pthread_attr.c
51SRCS+= pthread_barrier.c 51SRCS+= pthread_barrier.c
52SRCS+= pthread_cancelstub.c 52SRCS+= pthread_cancelstub.c
53SRCS+= pthread_cond.c 53SRCS+= pthread_cond.c
54SRCS+= pthread_lock.c  54SRCS+= pthread_lock.c
55SRCS+= pthread_misc.c 55SRCS+= pthread_misc.c
56SRCS+= pthread_mutex.c 56SRCS+= pthread_mutex.c
57SRCS+= pthread_rwlock.c 57SRCS+= 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
85 84
86# Internal spinlock routines are performance critical. Don't profile them, 85# Internal spinlock routines are performance critical. Don't profile them,
87# it's incompatibile with -fomit-frame-pointer. 86# it's incompatibile with -fomit-frame-pointer.
88COPTS.pthread_lock.c+= -fomit-frame-pointer -falign-functions=32 87COPTS.pthread_lock.c+= -fomit-frame-pointer -falign-functions=32
89pthread_lock.po: pthread_lock.o 88pthread_lock.po: pthread_lock.o
90 ${_MKTARGET_CREATE} 89 ${_MKTARGET_CREATE}
91 cp pthread_lock.o pthread_lock.po 90 cp pthread_lock.o pthread_lock.po
92 91
93COPTS.pthread_mutex.c+= -fomit-frame-pointer -falign-functions=32 92COPTS.pthread_mutex.c+= -fomit-frame-pointer -falign-functions=32
94pthread_mutex.po: pthread_mutex.o 93pthread_mutex.po: pthread_mutex.o
95 ${_MKTARGET_CREATE} 94 ${_MKTARGET_CREATE}
96 cp pthread_mutex.o pthread_mutex.po 95 cp pthread_mutex.o pthread_mutex.po
97 96
98COPTS.pthread.c += -Wno-stack-protector 97COPTS.pthread.c += -Wno-stack-protector
99 98
100_context_u.po: _context_u.o 99_context_u.po: _context_u.o
101 ${_MKTARGET_CREATE} 100 ${_MKTARGET_CREATE}
102 cp _context_u.o _context_u.po 101 cp _context_u.o _context_u.po
103 102
104MAN+= affinity.3 pthread.3 \ 103MAN+= affinity.3 pthread.3 \
105 pthread_attr.3 \ 104 pthread_attr.3 \
106 pthread_attr_getname_np.3 \ 105 pthread_attr_getname_np.3 \
107 pthread_attr_setcreatesuspend_np.3 \ 106 pthread_attr_setcreatesuspend_np.3 \
108 pthread_attr_setname_np.3 \ 107 pthread_attr_setname_np.3 \
109 pthread_barrier_destroy.3 pthread_barrier_init.3 \ 108 pthread_barrier_destroy.3 pthread_barrier_init.3 \
110 pthread_barrier_wait.3 pthread_barrierattr.3 \ 109 pthread_barrier_wait.3 pthread_barrierattr.3 \
111 pthread_cancel.3 pthread_cleanup_push.3 \ 110 pthread_cancel.3 pthread_cleanup_push.3 \
112 pthread_cond_broadcast.3 pthread_cond_destroy.3 pthread_cond_init.3 \ 111 pthread_cond_broadcast.3 pthread_cond_destroy.3 pthread_cond_init.3 \
113 pthread_cond_wait.3 \ 112 pthread_cond_wait.3 \
114 pthread_condattr.3 pthread_create.3 pthread_detach.3 pthread_equal.3 \ 113 pthread_condattr.3 pthread_create.3 pthread_detach.3 pthread_equal.3 \
115 pthread_exit.3 \ 114 pthread_exit.3 \
116 pthread_getname_np.3 \ 115 pthread_getname_np.3 \
117 pthread_getspecific.3 pthread_join.3 \ 116 pthread_getspecific.3 pthread_join.3 \
118 pthread_key_create.3 pthread_key_delete.3 pthread_kill.3 \ 117 pthread_key_create.3 pthread_key_delete.3 pthread_kill.3 \
119 pthread_mutex_destroy.3 pthread_mutex_init.3 pthread_mutex_lock.3 \ 118 pthread_mutex_destroy.3 pthread_mutex_init.3 pthread_mutex_lock.3 \
120 pthread_mutex_unlock.3 pthread_mutexattr.3 \ 119 pthread_mutex_unlock.3 pthread_mutexattr.3 \
121 pthread_once.3 pthread_rwlock_destroy.3 pthread_rwlock_init.3 \ 120 pthread_once.3 pthread_rwlock_destroy.3 pthread_rwlock_init.3 \
122 pthread_rwlock_rdlock.3 pthread_rwlock_unlock.3 \ 121 pthread_rwlock_rdlock.3 pthread_rwlock_unlock.3 \
123 pthread_rwlock_wrlock.3 pthread_rwlockattr.3 \ 122 pthread_rwlock_wrlock.3 pthread_rwlockattr.3 \
124 pthread_schedparam.3 pthread_self.3 \ 123 pthread_schedparam.3 pthread_self.3 \
125 pthread_setname_np.3 \ 124 pthread_setname_np.3 \
126 pthread_setspecific.3 pthread_sigmask.3 pthread_spin_destroy.3 \ 125 pthread_setspecific.3 pthread_sigmask.3 pthread_spin_destroy.3 \
127 pthread_spin_init.3 pthread_spin_lock.3 pthread_spin_unlock.3 \ 126 pthread_spin_init.3 pthread_spin_lock.3 pthread_spin_unlock.3 \
128 pthread_suspend_np.3 pthread_testcancel.3 127 pthread_suspend_np.3 pthread_testcancel.3
129 128
130MLINKS+= affinity.3 pthread_setaffinity_np.3 129MLINKS+= affinity.3 pthread_setaffinity_np.3
131MLINKS+= affinity.3 pthread_getaffinity_np.3 130MLINKS+= affinity.3 pthread_getaffinity_np.3
132MLINKS+= pthread_attr.3 pthread_attr_init.3 131MLINKS+= pthread_attr.3 pthread_attr_init.3
133MLINKS+= pthread_attr.3 pthread_attr_destroy.3 132MLINKS+= pthread_attr.3 pthread_attr_destroy.3
134MLINKS+= pthread_attr.3 pthread_attr_setdetachstate.3 133MLINKS+= pthread_attr.3 pthread_attr_setdetachstate.3
135MLINKS+= pthread_attr.3 pthread_attr_getdetachstate.3 134MLINKS+= pthread_attr.3 pthread_attr_getdetachstate.3
136MLINKS+= pthread_attr.3 pthread_attr_setschedparam.3 135MLINKS+= pthread_attr.3 pthread_attr_setschedparam.3
137MLINKS+= pthread_attr.3 pthread_attr_getschedparam.3 136MLINKS+= pthread_attr.3 pthread_attr_getschedparam.3
138MLINKS+= pthread_barrierattr.3 pthread_barrierattr_init.3 137MLINKS+= pthread_barrierattr.3 pthread_barrierattr_init.3
139MLINKS+= pthread_barrierattr.3 pthread_barrierattr_destroy.3 138MLINKS+= pthread_barrierattr.3 pthread_barrierattr_destroy.3
140MLINKS+= pthread_cleanup_push.3 pthread_cleanup_pop.3 139MLINKS+= pthread_cleanup_push.3 pthread_cleanup_pop.3
141MLINKS+= pthread_cond_broadcast.3 pthread_cond_signal.3 140MLINKS+= pthread_cond_broadcast.3 pthread_cond_signal.3
142MLINKS+= pthread_cond_wait.3 pthread_cond_timedwait.3 141MLINKS+= pthread_cond_wait.3 pthread_cond_timedwait.3
143MLINKS+= pthread_condattr.3 pthread_condattr_init.3 142MLINKS+= pthread_condattr.3 pthread_condattr_init.3
144MLINKS+= pthread_condattr.3 pthread_condattr_destroy.3 143MLINKS+= pthread_condattr.3 pthread_condattr_destroy.3
145MLINKS+= pthread_mutex_lock.3 pthread_mutex_trylock.3 144MLINKS+= pthread_mutex_lock.3 pthread_mutex_trylock.3
146MLINKS+= pthread_mutexattr.3 pthread_mutexattr_init.3 145MLINKS+= pthread_mutexattr.3 pthread_mutexattr_init.3
147MLINKS+= pthread_mutexattr.3 pthread_mutexattr_destroy.3 146MLINKS+= pthread_mutexattr.3 pthread_mutexattr_destroy.3
148MLINKS+= pthread_mutexattr.3 pthread_mutexattr_settype.3 147MLINKS+= pthread_mutexattr.3 pthread_mutexattr_settype.3
149MLINKS+= pthread_mutexattr.3 pthread_mutexattr_gettype.3 148MLINKS+= pthread_mutexattr.3 pthread_mutexattr_gettype.3
150MLINKS+= pthread_rwlock_rdlock.3 pthread_rwlock_timedrdlock.3 149MLINKS+= pthread_rwlock_rdlock.3 pthread_rwlock_timedrdlock.3
151MLINKS+= pthread_rwlock_rdlock.3 pthread_rwlock_tryrdlock.3 150MLINKS+= pthread_rwlock_rdlock.3 pthread_rwlock_tryrdlock.3
152MLINKS+= pthread_rwlock_wrlock.3 pthread_rwlock_timedwrlock.3 151MLINKS+= pthread_rwlock_wrlock.3 pthread_rwlock_timedwrlock.3
153MLINKS+= pthread_rwlock_wrlock.3 pthread_rwlock_trywrlock.3 152MLINKS+= pthread_rwlock_wrlock.3 pthread_rwlock_trywrlock.3
154MLINKS+= pthread_rwlockattr.3 pthread_rwlockattr_init.3 153MLINKS+= pthread_rwlockattr.3 pthread_rwlockattr_init.3
155MLINKS+= pthread_rwlockattr.3 pthread_rwlockattr_destroy.3 154MLINKS+= pthread_rwlockattr.3 pthread_rwlockattr_destroy.3
156MLINKS+= pthread_schedparam.3 pthread_setschedparam.3 155MLINKS+= pthread_schedparam.3 pthread_setschedparam.3
157MLINKS+= pthread_schedparam.3 pthread_getschedparam.3 156MLINKS+= pthread_schedparam.3 pthread_getschedparam.3
158MLINKS+= pthread_spin_lock.3 pthread_spin_trylock.3 157MLINKS+= pthread_spin_lock.3 pthread_spin_trylock.3
159MLINKS+= pthread_suspend_np.3 pthread_resume_np.3 158MLINKS+= pthread_suspend_np.3 pthread_resume_np.3
160MLINKS+= pthread_testcancel.3 pthread_setcancelstate.3 159MLINKS+= pthread_testcancel.3 pthread_setcancelstate.3
161MLINKS+= pthread_testcancel.3 pthread_setcanceltype.3 160MLINKS+= pthread_testcancel.3 pthread_setcanceltype.3
162 161
163pthread_switch.S _context_u.S: assym.h 162pthread_switch.S _context_u.S: assym.h
164 163
165.include <bsd.lib.mk> 164.include <bsd.lib.mk>
166 165
167.else 166.else
168 167
169.include <bsd.man.mk> 168.include <bsd.man.mk>
170.include <bsd.files.mk> 169.include <bsd.files.mk>
171.include <bsd.inc.mk> 170.include <bsd.inc.mk>
172 171
173.endif 172.endif
174 173
175# WARNS=2 sets -Wcast-qual. This causes problems for one of 174# WARNS=2 sets -Wcast-qual. This causes problems for one of
176# pthread_setspecific() and pthread_getspecific(), since the constness 175# pthread_setspecific() and pthread_getspecific(), since the constness
177# of the argument to setspecific() has to be discarded *somewhere* 176# of the argument to setspecific() has to be discarded *somewhere*
178# before returning it from getspecific(). 177# before returning it from getspecific().
179CFLAGS+= -Wno-cast-qual 178CFLAGS+= -Wno-cast-qual

cvs diff -r1.21 -r1.22 src/lib/libpthread/pthread_cancelstub.c (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,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
74int pthread__cancel_stub_binder; 74int pthread__cancel_stub_binder;
75 75
76int _sys_accept(int, struct sockaddr *, socklen_t *); 76int _sys_accept(int, struct sockaddr *, socklen_t *);
77int _sys_aio_suspend(const struct aiocb * const [], int, 77int _sys_aio_suspend(const struct aiocb * const [], int,
78 const struct timespec *); 78 const struct timespec *);
79int _sys_close(int); 79int _sys_close(int);
80int _sys_connect(int, const struct sockaddr *, socklen_t); 80int _sys_connect(int, const struct sockaddr *, socklen_t);
81int _sys_fcntl(int, int, ...); 81int _sys_fcntl(int, int, ...);
82int _sys_fdatasync(int); 82int _sys_fdatasync(int);
83int _sys_fsync(int); 83int _sys_fsync(int);
84int _sys_fsync_range(int, int, off_t, off_t); 84int _sys_fsync_range(int, int, off_t, off_t);
85int _sys_mq_send(mqd_t, const char *, size_t, unsigned); 85int _sys_mq_send(mqd_t, const char *, size_t, unsigned);
86ssize_t _sys_mq_receive(mqd_t, char *, size_t, unsigned *); 86ssize_t _sys_mq_receive(mqd_t, char *, size_t, unsigned *);
87int _sys_mq_timedsend(mqd_t, const char *, size_t, unsigned, 87int _sys_mq_timedsend(mqd_t, const char *, size_t, unsigned,
88 const struct timespec *); 88 const struct timespec *);
89ssize_t _sys_mq_timedreceive(mqd_t, char *, size_t, unsigned *, 89ssize_t _sys_mq_timedreceive(mqd_t, char *, size_t, unsigned *,
90 const struct timespec *); 90 const struct timespec *);
91ssize_t _sys_msgrcv(int, void *, size_t, long, int); 91ssize_t _sys_msgrcv(int, void *, size_t, long, int);
92int _sys_msgsnd(int, const void *, size_t, int); 92int _sys_msgsnd(int, const void *, size_t, int);
93int _sys___msync13(void *, size_t, int); 93int _sys___msync13(void *, size_t, int);
94int _sys_open(const char *, int, ...); 94int _sys_open(const char *, int, ...);
95int _sys_poll(struct pollfd *, nfds_t, int); 95int _sys_poll(struct pollfd *, nfds_t, int);
96int _sys_pollts(struct pollfd *, nfds_t, const struct timespec *, 96int _sys_pollts(struct pollfd *, nfds_t, const struct timespec *,
97 const sigset_t *); 97 const sigset_t *);
98ssize_t _sys_pread(int, void *, size_t, off_t); 98ssize_t _sys_pread(int, void *, size_t, off_t);
99int _sys_pselect(int, fd_set *, fd_set *, fd_set *, 99int _sys_pselect(int, fd_set *, fd_set *, fd_set *,
100 const struct timespec *, const sigset_t *); 100 const struct timespec *, const sigset_t *);
101ssize_t _sys_pwrite(int, const void *, size_t, off_t); 101ssize_t _sys_pwrite(int, const void *, size_t, off_t);
102ssize_t _sys_read(int, void *, size_t); 102ssize_t _sys_read(int, void *, size_t);
103ssize_t _sys_readv(int, const struct iovec *, int); 103ssize_t _sys_readv(int, const struct iovec *, int);
104int _sys_select(int, fd_set *, fd_set *, fd_set *, struct timeval *); 104int _sys_select(int, fd_set *, fd_set *, fd_set *, struct timeval *);
105int _sys_wait4(pid_t, int *, int, struct rusage *); 105int _sys_wait4(pid_t, int *, int, struct rusage *);
106ssize_t _sys_write(int, const void *, size_t); 106ssize_t _sys_write(int, const void *, size_t);
107ssize_t _sys_writev(int, const struct iovec *, int); 107ssize_t _sys_writev(int, const struct iovec *, int);
108int _sys___sigsuspend14(const sigset_t *); 108int _sys___sigsuspend14(const sigset_t *);
109int _sigtimedwait(const sigset_t * __restrict, siginfo_t * __restrict, 109int _sigtimedwait(const sigset_t * __restrict, siginfo_t * __restrict,
110 const struct timespec * __restrict); 110 const struct timespec * __restrict);
111int __sigsuspend14(const sigset_t *); 111int __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
119int 119int
120accept(int s, struct sockaddr *addr, socklen_t *addrlen) 120accept(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
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
147int 162int
148connect(int s, const struct sockaddr *addr, socklen_t namelen) 163connect(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
161int 176int
162fcntl(int fd, int cmd, ...) 177fcntl(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
178int 193int
179fdatasync(int d) 194fdatasync(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
192int 207int
193fsync(int d) 208fsync(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
206int 221int
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}
233 306
234int 307int
235msgsnd(int msgid, const void *msgp, size_t msgsz, int msgflg) 308msgsnd(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
248int 321int
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
262int 335int
263open(const char *path, int flags, ...) 336open(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
279int 352int
280poll(struct pollfd *fds, nfds_t nfds, int timeout) 353poll(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
293int 366int
294pollts(struct pollfd *fds, nfds_t nfds, const struct timespec *ts, 367pollts(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
308ssize_t 381ssize_t
309pread(int d, void *buf, size_t nbytes, off_t offset) 382pread(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
322int 395int
323pselect(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds,  396pselect(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
338ssize_t 411ssize_t
339pwrite(int d, const void *buf, size_t nbytes, off_t offset) 412pwrite(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
356ssize_t 429ssize_t
357read(int d, void *buf, size_t nbytes) 430read(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
370ssize_t 443ssize_t
371readv(int d, const struct iovec *iov, int iovcnt) 444readv(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
384int 457int
385select(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds,  458select(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
399pid_t 472pid_t
400wait4(pid_t wpid, int *status, int options, struct rusage *rusage) 473wait4(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
413ssize_t 486ssize_t
414write(int d, const void *buf, size_t nbytes) 487write(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
427ssize_t 500ssize_t
428writev(int d, const struct iovec *iov, int iovcnt) 501writev(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
441int 514int
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
455int 528int
456sigtimedwait(const sigset_t * __restrict set, siginfo_t * __restrict info, 529sigtimedwait(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 
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 (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,155 +1,207 @@ @@ -1,155 +1,207 @@
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.
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/*
 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
70 return syscall(SYS__lwp_detach, a); 84 return syscall(SYS__lwp_detach, a);
71} 85}
72 86
73int 87int
74_lwp_park(const struct timespec *a, lwpid_t b, const void *c, const void *d) 88_lwp_park(const struct timespec *a, lwpid_t b, const void *c, const void *d)
75{ 89{
76 90
77 return syscall(SYS__lwp_park, a, b, c, d); 91 return syscall(SYS__lwp_park, a, b, c, d);
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
105 return syscall(SYS__lwp_getname, a, b, c); 119 return syscall(SYS__lwp_getname, a, b, c);
106} 120}
107 121
108int 122int
109_lwp_ctl(int a, struct lwpctl **b) 123_lwp_ctl(int a, struct lwpctl **b)
110{ 124{
111 125
112 return syscall(SYS__lwp_ctl, a, b); 126 return syscall(SYS__lwp_ctl, a, b);
113} 127}
114 128
115int 129int
116_sys_sched_yield(void) 130_sys_sched_yield(void)
117{ 131{
118 132
119 return syscall(SYS_sched_yield); 133 return syscall(SYS_sched_yield);
120} 134}
121 135
122int 136int
123sched_yield(void) 137sched_yield(void)
124{ 138{
125 139
126 return syscall(SYS_sched_yield); 140 return syscall(SYS_sched_yield);
127} 141}
128 142
129int 143int
130_sched_setaffinity(pid_t a, lwpid_t b, size_t c, const cpuset_t *d) 144_sched_setaffinity(pid_t a, lwpid_t b, size_t c, const cpuset_t *d)
131{ 145{
132 146
133 return syscall(SYS__sched_setaffinity, a, b, c, d); 147 return syscall(SYS__sched_setaffinity, a, b, c, d);
134} 148}
135 149
136int 150int
137_sched_getaffinity(pid_t a, lwpid_t b, size_t c, cpuset_t *d) 151_sched_getaffinity(pid_t a, lwpid_t b, size_t c, cpuset_t *d)
138{ 152{
139 153
140 return syscall(SYS__sched_getaffinity, a, b, c, d); 154 return syscall(SYS__sched_getaffinity, a, b, c, d);
141} 155}
142 156
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}