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 context 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,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.53 2008/09/29 08:48:15 ad Exp $
+#	$NetBSD: Makefile,v 1.54 2008/10/08 08:27:07 ad Exp $
 #
 
 WARNS=	4
@@ -68,7 +68,6 @@
 
 .if defined(PTHREAD__COMPAT)
 SRCS+=		pthread_compat.c
-CPPFLAGS+=	-DPTHREAD__COMPAT
 .PATH.c:	${.CURDIR}/../../common/lib/libc/arch/${ARCHSUBDIR}/atomic
 .PATH.S:	${.CURDIR}/../../common/lib/libc/arch/${ARCHSUBDIR}/atomic
 .PATH.c:	${.CURDIR}/../../common/lib/libc/atomic

cvs diff -r1.21 -r1.22 src/lib/libpthread/pthread_cancelstub.c (expand / switch to context 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,4 +1,4 @@
-/*	$NetBSD: pthread_cancelstub.c,v 1.21 2008/09/29 08:48:15 ad Exp $	*/
+/*	$NetBSD: pthread_cancelstub.c,v 1.22 2008/10/08 08:27:07 ad Exp $	*/
 
 /*-
  * Copyright (c) 2002, 2007 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: pthread_cancelstub.c,v 1.21 2008/09/29 08:48:15 ad Exp $");
+__RCSID("$NetBSD: pthread_cancelstub.c,v 1.22 2008/10/08 08:27:07 ad Exp $");
 
 #ifndef lint
 
@@ -131,6 +131,21 @@
 }
 
 int
+aio_suspend(const struct aiocb * const list[], int nent,
+    const struct timespec *timeout)
+{
+	int retval;
+	pthread_t self;
+
+	self = pthread__self();
+	TESTCANCEL(self);
+	retval = _sys_aio_suspend(list, nent, timeout);
+	TESTCANCEL(self);
+
+	return retval;
+}
+
+int
 close(int d)
 {
 	int retval;
@@ -217,7 +232,65 @@
 	return retval;
 }
 
+int
+mq_send(mqd_t mqdes, const char *msg_ptr, size_t msg_len, unsigned msg_prio)
+{
+	int retval;
+	pthread_t self;
+
+	self = pthread__self();
+	TESTCANCEL(self);
+	retval = _sys_mq_send(mqdes, msg_ptr, msg_len, msg_prio);
+	TESTCANCEL(self);
+
+	return retval;
+}
+
 ssize_t
+mq_receive(mqd_t mqdes, char *msg_ptr, size_t msg_len, unsigned *msg_prio)
+{
+	ssize_t retval;
+	pthread_t self;
+
+	self = pthread__self();
+	TESTCANCEL(self);
+	retval = _sys_mq_receive(mqdes, msg_ptr, msg_len, msg_prio);
+	TESTCANCEL(self);
+
+	return retval;
+}
+
+int
+mq_timedsend(mqd_t mqdes, const char *msg_ptr, size_t msg_len,
+    unsigned msg_prio, const struct timespec *abst)
+{
+	int retval;
+	pthread_t self;
+
+	self = pthread__self();
+	TESTCANCEL(self);
+	retval = _sys_mq_timedsend(mqdes, msg_ptr, msg_len, msg_prio, abst);
+	TESTCANCEL(self);
+
+	return retval;
+}
+
+ssize_t
+mq_timedreceive(mqd_t mqdes, char *msg_ptr, size_t msg_len, unsigned *msg_prio,
+    const struct timespec *abst)
+{
+	ssize_t retval;
+	pthread_t self;
+
+	self = pthread__self();
+	TESTCANCEL(self);
+	retval = _sys_mq_timedreceive(mqdes, msg_ptr, msg_len, msg_prio, abst);
+	TESTCANCEL(self);
+
+	return retval;
+}
+
+ssize_t
 msgrcv(int msgid, void *msgp, size_t msgsz, long msgtyp, int msgflg)
 {
 	ssize_t retval;
@@ -467,11 +540,16 @@
 	return retval;
 }
 
+__strong_alias(_aio_suspend, aio_suspend)
 __strong_alias(_close, close)
 __strong_alias(_fcntl, fcntl)
 __strong_alias(_fdatasync, fdatasync)
 __strong_alias(_fsync, fsync)
 __weak_alias(fsync_range, _fsync_range)
+__strong_alias(_mq_send, mq_send)
+__strong_alias(_mq_receive, mq_receive)
+__strong_alias(_mq_timedsend, mq_timedsend)
+__strong_alias(_mq_timedreceive, mq_timedreceive)
 __strong_alias(_msgrcv, msgrcv)
 __strong_alias(_msgsnd, msgsnd)
 __strong_alias(___msync13, __msync13)
@@ -487,86 +565,5 @@
 __strong_alias(_wait4, wait4)
 __strong_alias(_write, write)
 __strong_alias(_writev, writev)
-
-#ifndef PTHREAD__COMPAT
-int
-aio_suspend(const struct aiocb * const list[], int nent,
-    const struct timespec *timeout)
-{
-	int retval;
-	pthread_t self;
-
-	self = pthread__self();
-	TESTCANCEL(self);
-	retval = _sys_aio_suspend(list, nent, timeout);
-	TESTCANCEL(self);
-
-	return retval;
-}
-
-int
-mq_send(mqd_t mqdes, const char *msg_ptr, size_t msg_len, unsigned msg_prio)
-{
-	int retval;
-	pthread_t self;
-
-	self = pthread__self();
-	TESTCANCEL(self);
-	retval = _sys_mq_send(mqdes, msg_ptr, msg_len, msg_prio);
-	TESTCANCEL(self);
-
-	return retval;
-}
-
-ssize_t
-mq_receive(mqd_t mqdes, char *msg_ptr, size_t msg_len, unsigned *msg_prio)
-{
-	ssize_t retval;
-	pthread_t self;
-
-	self = pthread__self();
-	TESTCANCEL(self);
-	retval = _sys_mq_receive(mqdes, msg_ptr, msg_len, msg_prio);
-	TESTCANCEL(self);
-
-	return retval;
-}
-
-int
-mq_timedsend(mqd_t mqdes, const char *msg_ptr, size_t msg_len,
-    unsigned msg_prio, const struct timespec *abst)
-{
-	int retval;
-	pthread_t self;
-
-	self = pthread__self();
-	TESTCANCEL(self);
-	retval = _sys_mq_timedsend(mqdes, msg_ptr, msg_len, msg_prio, abst);
-	TESTCANCEL(self);
-
-	return retval;
-}
-
-ssize_t
-mq_timedreceive(mqd_t mqdes, char *msg_ptr, size_t msg_len, unsigned *msg_prio,
-    const struct timespec *abst)
-{
-	ssize_t retval;
-	pthread_t self;
-
-	self = pthread__self();
-	TESTCANCEL(self);
-	retval = _sys_mq_timedreceive(mqdes, msg_ptr, msg_len, msg_prio, abst);
-	TESTCANCEL(self);
-
-	return retval;
-}
-
-__strong_alias(_aio_suspend, aio_suspend)
-__strong_alias(_mq_send, mq_send)
-__strong_alias(_mq_receive, mq_receive)
-__strong_alias(_mq_timedsend, mq_timedsend)
-__strong_alias(_mq_timedreceive, mq_timedreceive)
-#endif	/* !PTHREAD__COMPAT */
 
 #endif	/* !lint */

cvs diff -r1.1 -r1.2 src/lib/libpthread/pthread_compat.c (expand / switch to context 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,4 +1,4 @@
-/*	$NetBSD: pthread_compat.c,v 1.1 2008/09/29 08:48:15 ad Exp $	*/
+/*	$NetBSD: pthread_compat.c,v 1.2 2008/10/08 08:27:07 ad Exp $	*/
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -29,11 +29,16 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 
+/*
+ * libc symbols that are not present before NetBSD 5.0.
+ */
+
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: pthread_compat.c,v 1.1 2008/09/29 08:48:15 ad Exp $");
+__RCSID("$NetBSD: pthread_compat.c,v 1.2 2008/10/08 08:27:07 ad Exp $");
 
 #include <sys/param.h>
 #include <sys/syscall.h>
+#include <sys/aio.h>
 
 #include <lwp.h>
 #include <unistd.h>
@@ -46,14 +51,23 @@
 
 void	__libc_thr_init(void);
 void	__libc_atomic_init(void);
+
 int	_sys_sched_yield(void);
+int	_sys_aio_suspend(const struct aiocb * const[], int,
+			 const struct timespec *);
+int	_sys_mq_send(mqd_t, const char *, size_t, unsigned);
+ssize_t	_sys_mq_receive(mqd_t, char *, size_t, unsigned *);
+int	_sys_mq_timedsend(mqd_t, const char *, size_t, unsigned,
+			  const struct timespec *);
+ssize_t	_sys_mq_timedreceive(mqd_t, char *, size_t, unsigned *,
+			     const struct timespec *);
 
 static void
 __pthread_init(void)
 {
 
-	__libc_thr_init();
 	__libc_atomic_init();
+	__libc_thr_init();
 }
 
 int
@@ -88,7 +102,7 @@
 _lwp_unpark_all(const lwpid_t *a, size_t b, const void *c)
 {
 
-	return syscall(SYS__lwp_unpark_all, a, b, c);
+	return (ssize_t)syscall(SYS__lwp_unpark_all, a, b, c);
 }
 
 int
@@ -152,4 +166,42 @@
 {
 
 	return syscall(SYS__sched_getparam, a, b, c, d);
+}
+
+int
+_sys_aio_suspend(const struct aiocb * const a[], int b,
+		 const struct timespec *c)
+{
+
+	return syscall(SYS_aio_suspend, a, b, c);
+}
+
+int
+_sys_mq_send(mqd_t a, const char *b, size_t c, unsigned d)
+{
+
+	return syscall(SYS_mq_send, a, b, c, d);
+}
+
+ssize_t
+_sys_mq_receive(mqd_t a, char *b, size_t c, unsigned *d)
+{
+
+	return (ssize_t)syscall(SYS_mq_receive, a, b, c, d);
+}
+
+int
+_sys_mq_timedsend(mqd_t a, const char *b, size_t c, unsigned d,
+		  const struct timespec *e)
+{
+
+	return syscall(SYS_mq_timedsend, a, b,c ,d, e);
+}
+
+ssize_t
+_sys_mq_timedreceive(mqd_t a, char *b, size_t c, unsigned *d,
+		     const struct timespec *e)
+{
+
+	return (ssize_t)syscall(SYS_mq_timedreceive, a, b, c, d, e);
 }