From owner-freebsd-threads@FreeBSD.ORG Wed Mar 29 06:48:03 2006 Return-Path: X-Original-To: threads@freebsd.org Delivered-To: freebsd-threads@FreeBSD.ORG Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 1AF4116A400; Wed, 29 Mar 2006 06:48:03 +0000 (UTC) (envelope-from des@des.no) Received: from tim.des.no (tim.des.no [194.63.250.121]) by mx1.FreeBSD.org (Postfix) with ESMTP id BAC4443D48; Wed, 29 Mar 2006 06:48:00 +0000 (GMT) (envelope-from des@des.no) Received: from tim.des.no (localhost [127.0.0.1]) by spam.des.no (Postfix) with ESMTP id 825A12096; Wed, 29 Mar 2006 08:47:41 +0200 (CEST) X-Spam-Tests: AWL,BAYES_00,FORGED_RCVD_HELO X-Spam-Learn: ham X-Spam-Score: -2.4/3.0 X-Spam-Checker-Version: SpamAssassin 3.1.1 (2006-03-10) on tim.des.no Received: from xps.des.no (des.no [80.203.243.180]) by tim.des.no (Postfix) with ESMTP id CFF102081; Wed, 29 Mar 2006 08:47:40 +0200 (CEST) Received: by xps.des.no (Postfix, from userid 1001) id C321F33C8D; Wed, 29 Mar 2006 08:47:40 +0200 (CEST) From: des@des.no (Dag-Erling =?iso-8859-1?Q?Sm=F8rgrav?=) To: threads@freebsd.org Date: Wed, 29 Mar 2006 08:47:40 +0200 Message-ID: <86slp1u4qb.fsf@xps.des.no> User-Agent: Gnus/5.110003 (No Gnus v0.3) Emacs/21.3 (berkeley-unix) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Cc: jeff@freebsd.org, davidxu@freebsd.org Subject: libthr cleanup X-BeenThere: freebsd-threads@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Threading on FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 29 Mar 2006 06:48:03 -0000 --=-=-= Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable The attached patch brings libthr up to WARNS level 2. There is also a small amount of style and whitespace changes mixed in, mostly because I'm so conditioned to style(9) that my fingers sometimes do these things automatically. Parts of the patch go a little further than level 2, but we're nowhere near level 3 (or antything higher). The major obstacle is the umtx interface, which in my eyes is fundamentally broken. The _umtx_op() syscall is intended to replace _umtx_lock() and _umtx_unlock(), and support other operations like sleep, wakeup etc. This is the wrong way to go. If we applied this kind of thinking universally, we'd just define all our system calls as macro wrappers for __syscall(). Beyond these purely philosophical aspects, _umtx_op() seems designed to encourage poor coding practices. It's impossible to use in a type- safe manner: its first argument is supposed to be a struct umtx *, but I don't think there's a single instance in libthr where it is called with an actual struct umtx *. Instead, libthr uses umtx_t, which is defined as long. Sometimes, an umtx_t is passed as the third argument to _umtx_op() as well. Various fields in struct pthread, struct pthread_barrier and struct pthread_cond are declared as umtx_t. Some are used purely as cookies for passing to _umtx_op(); some are used as counters or state variables. It's a miracle libthr works at all. The kernel expects a pointer to a struct umtx; instead, it gets (mostly) a pointer to long. Luckily, struct umtx (which contains a single pointer) is the same size as long on all our platforms. _umtx_op() needs to be split into four system calls: int _umtx_lock_timeout(struct umtx *mtx, const struct timespec * __restrict timeout); int _umtx_unlock(struct umtx *mtx); int _umtx_wait_timeout(const void *cookie, struct umtx *mtx, const struct timespec * __restrict timeout); int _umtx_wake(const void *cookie); _umtx_unlock() already exists with the correct semantics; the rest are new. Note that we can't just add a struct timespec to _umtx_lock(), as that would break the upgrade path from RELENG_5; hence the _timeout suffix. I'm not sure the current implementation of UMTX_OP_WAIT / UMTX_OP_WAKE in the kernel is correct. Normally, a wait primitive (like msleep(), pthread_cond_wait() etc.) takes a cookie and a mutex, and unlocks the mutex while it's sleeping on the cookie. It looks like the umtx code originally worked like this, but I'm not sure it does anymore; it's hard to unravel, partly because I haven't quite figured out the queues yet and partly because I haven't had breakfast. DES --=20 Dag-Erling Sm=F8rgrav - des@des.no --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=libthr.diff Index: Makefile =================================================================== RCS file: /home/ncvs/src/lib/libthr/Makefile,v retrieving revision 1.18 diff -u -r1.18 Makefile --- Makefile 27 Mar 2006 05:58:58 -0000 1.18 +++ Makefile 28 Mar 2006 18:45:36 -0000 @@ -29,8 +29,8 @@ MAN= libthr.3 # enable extra internal consistancy checks -CFLAGS+=-D_PTHREADS_INVARIANTS -Wall -#CFLAGS+=-g +CFLAGS+=-D_PTHREADS_INVARIANTS +WARNS?=2 PRECIOUSLIB= Index: sys/thr_error.c =================================================================== RCS file: /home/ncvs/src/lib/libthr/sys/thr_error.c,v retrieving revision 1.2 diff -u -r1.2 thr_error.c --- sys/thr_error.c 2 Apr 2005 01:20:00 -0000 1.2 +++ sys/thr_error.c 28 Mar 2006 18:12:41 -0000 @@ -36,7 +36,6 @@ #include -#include "libc_private.h" #include "thr_private.h" #undef errno Index: thread/thr_atfork.c =================================================================== RCS file: /home/ncvs/src/lib/libthr/thread/thr_atfork.c,v retrieving revision 1.2 diff -u -r1.2 thr_atfork.c --- thread/thr_atfork.c 2 Apr 2005 01:20:00 -0000 1.2 +++ thread/thr_atfork.c 28 Mar 2006 18:12:41 -0000 @@ -26,10 +26,14 @@ * $FreeBSD: src/lib/libthr/thread/thr_atfork.c,v 1.2 2005/04/02 01:20:00 davidxu Exp $ */ +#include "namespace.h" +#include #include -#include #include -#include +#include +#include +#include "un-namespace.h" + #include "thr_private.h" __weak_reference(_pthread_atfork, pthread_atfork); Index: thread/thr_attr.c =================================================================== RCS file: /home/ncvs/src/lib/libthr/thread/thr_attr.c,v retrieving revision 1.4 diff -u -r1.4 thr_attr.c --- thread/thr_attr.c 9 Jan 2006 03:59:51 -0000 1.4 +++ thread/thr_attr.c 28 Mar 2006 18:12:41 -0000 @@ -96,11 +96,13 @@ * $FreeBSD: src/lib/libthr/thread/thr_attr.c,v 1.4 2006/01/09 03:59:51 davidxu Exp $ */ +#include "namespace.h" #include #include +#include #include #include -#include +#include "un-namespace.h" #include "thr_private.h" @@ -326,12 +328,12 @@ _thr_check_init(); /* Allocate memory for the attribute object: */ - if ((pattr = (pthread_attr_t) malloc(sizeof(struct pthread_attr))) == NULL) + if ((pattr = malloc(sizeof(*pattr))) == NULL) /* Insufficient memory: */ ret = ENOMEM; else { /* Initialise the attribute object with the defaults: */ - memcpy(pattr, &_pthread_attr_default, sizeof(struct pthread_attr)); + memcpy(pattr, &_pthread_attr_default, sizeof(*pattr)); /* Return a pointer to the attribute object: */ *attr = pattr; Index: thread/thr_autoinit.c =================================================================== RCS file: /home/ncvs/src/lib/libthr/thread/thr_autoinit.c,v retrieving revision 1.2 diff -u -r1.2 thr_autoinit.c --- thread/thr_autoinit.c 23 May 2003 09:48:20 -0000 1.2 +++ thread/thr_autoinit.c 28 Mar 2006 18:12:41 -0000 @@ -33,8 +33,6 @@ * $FreeBSD: src/lib/libthr/thread/thr_autoinit.c,v 1.2 2003/05/23 09:48:20 mtm Exp $ */ -#include - #include "thr_private.h" /* Index: thread/thr_barrier.c =================================================================== RCS file: /home/ncvs/src/lib/libthr/thread/thr_barrier.c,v retrieving revision 1.4 diff -u -r1.4 thr_barrier.c --- thread/thr_barrier.c 4 Apr 2005 23:43:53 -0000 1.4 +++ thread/thr_barrier.c 28 Mar 2006 18:12:41 -0000 @@ -26,9 +26,11 @@ * $FreeBSD: src/lib/libthr/thread/thr_barrier.c,v 1.4 2005/04/04 23:43:53 davidxu Exp $ */ +#include "namespace.h" #include -#include #include +#include +#include "un-namespace.h" #include "thr_private.h" @@ -54,10 +56,12 @@ int _pthread_barrier_init(pthread_barrier_t *barrier, - const pthread_barrierattr_t *attr, int count) + const pthread_barrierattr_t *attr, unsigned int count) { pthread_barrier_t bar; + (void)attr; + if (barrier == NULL || count <= 0) return (EINVAL); Index: thread/thr_barrierattr.c =================================================================== RCS file: /home/ncvs/src/lib/libthr/thread/thr_barrierattr.c,v retrieving revision 1.2 diff -u -r1.2 thr_barrierattr.c --- thread/thr_barrierattr.c 2 Apr 2005 01:20:00 -0000 1.2 +++ thread/thr_barrierattr.c 28 Mar 2006 18:12:41 -0000 @@ -28,9 +28,11 @@ * $FreeBSD: src/lib/libthr/thread/thr_barrierattr.c,v 1.2 2005/04/02 01:20:00 davidxu Exp $ */ +#include "namespace.h" #include -#include #include +#include +#include "un-namespace.h" #include "thr_private.h" Index: thread/thr_cancel.c =================================================================== RCS file: /home/ncvs/src/lib/libthr/thread/thr_cancel.c,v retrieving revision 1.12 diff -u -r1.12 thr_cancel.c --- thread/thr_cancel.c 25 Mar 2006 07:03:13 -0000 1.12 +++ thread/thr_cancel.c 28 Mar 2006 18:12:41 -0000 @@ -27,7 +27,9 @@ * */ +#include "namespace.h" #include +#include "un-namespace.h" #include "thr_private.h" @@ -78,7 +80,7 @@ newval = curthread->cancelflags; if (SHOULD_CANCEL(newval) && !THR_IN_CRITICAL(curthread)) - pthread_exit(PTHREAD_CANCELED); + _pthread_exit(PTHREAD_CANCELED); } int Index: thread/thr_clean.c =================================================================== RCS file: /home/ncvs/src/lib/libthr/thread/thr_clean.c,v retrieving revision 1.3 diff -u -r1.3 thr_clean.c --- thread/thr_clean.c 2 Apr 2005 01:20:00 -0000 1.3 +++ thread/thr_clean.c 28 Mar 2006 18:12:41 -0000 @@ -32,10 +32,13 @@ * $FreeBSD: src/lib/libthr/thread/thr_clean.c,v 1.3 2005/04/02 01:20:00 davidxu Exp $ */ -#include +#include "namespace.h" +#include #include -#include #include +#include +#include +#include "namespace.h" #include "thr_private.h" Index: thread/thr_concurrency.c =================================================================== RCS file: /home/ncvs/src/lib/libthr/thread/thr_concurrency.c,v retrieving revision 1.2 diff -u -r1.2 thr_concurrency.c --- thread/thr_concurrency.c 2 Apr 2005 01:20:00 -0000 1.2 +++ thread/thr_concurrency.c 28 Mar 2006 18:12:41 -0000 @@ -32,8 +32,10 @@ * $FreeBSD: src/lib/libthr/thread/thr_concurrency.c,v 1.2 2005/04/02 01:20:00 davidxu Exp $ */ +#include "namespace.h" #include #include +#include "un-namespace.h" #include "thr_private.h" Index: thread/thr_cond.c =================================================================== RCS file: /home/ncvs/src/lib/libthr/thread/thr_cond.c,v retrieving revision 1.16 diff -u -r1.16 thr_cond.c --- thread/thr_cond.c 2 Apr 2005 01:20:00 -0000 1.16 +++ thread/thr_cond.c 28 Mar 2006 18:12:41 -0000 @@ -26,11 +26,13 @@ * $FreeBSD: src/lib/libthr/thread/thr_cond.c,v 1.16 2005/04/02 01:20:00 davidxu Exp $ */ -#include +#include "namespace.h" #include -#include -#include #include +#include +#include +#include +#include "un-namespace.h" #include "thr_private.h" @@ -46,7 +48,11 @@ * Double underscore versions are cancellation points. Single underscore * versions are not and are provided for libc internal usage (which * shouldn't introduce cancellation points). + * XXX a sane person would have done it the other way around. */ +int __pthread_cond_timedwait(pthread_cond_t *, + pthread_mutex_t *, const struct timespec *); +int __pthread_cond_wait(pthread_cond_t *, pthread_mutex_t *); __weak_reference(__pthread_cond_wait, pthread_cond_wait); __weak_reference(__pthread_cond_timedwait, pthread_cond_timedwait); Index: thread/thr_condattr.c =================================================================== RCS file: /home/ncvs/src/lib/libthr/thread/thr_condattr.c,v retrieving revision 1.1 diff -u -r1.1 thr_condattr.c --- thread/thr_condattr.c 2 Apr 2005 01:20:00 -0000 1.1 +++ thread/thr_condattr.c 28 Mar 2006 18:12:41 -0000 @@ -32,10 +32,12 @@ * $FreeBSD: src/lib/libthr/thread/thr_condattr.c,v 1.1 2005/04/02 01:20:00 davidxu Exp $ */ -#include -#include +#include "namespace.h" #include #include +#include +#include +#include "un-namespace.h" #include "thr_private.h" Index: thread/thr_create.c =================================================================== RCS file: /home/ncvs/src/lib/libthr/thread/thr_create.c,v retrieving revision 1.28 diff -u -r1.28 thr_create.c --- thread/thr_create.c 27 Mar 2006 23:50:21 -0000 1.28 +++ thread/thr_create.c 28 Mar 2006 18:12:41 -0000 @@ -27,13 +27,18 @@ * $FreeBSD: src/lib/libthr/thread/thr_create.c,v 1.28 2006/03/27 23:50:21 davidxu Exp $ */ +#include "namespace.h" #include #include +#include +#include #include +#include +#include +#include #include #include -#include -#include +#include "un-namespace.h" #include "thr_private.h" @@ -230,7 +235,7 @@ * Parent thread have stored signal mask for us, * we should restore it now. */ - sigprocmask(SIG_SETMASK, &set, NULL); + __sys_sigprocmask(SIG_SETMASK, &set, NULL); } /* @@ -242,7 +247,7 @@ THR_UNLOCK(curthread); /* Run the current thread's start routine with argument: */ - pthread_exit(curthread->start_routine(curthread->arg)); + _pthread_exit(curthread->start_routine(curthread->arg)); /* This point should never be reached. */ PANIC("Thread has resumed after exit"); Index: thread/thr_detach.c =================================================================== RCS file: /home/ncvs/src/lib/libthr/thread/thr_detach.c,v retrieving revision 1.10 diff -u -r1.10 thr_detach.c --- thread/thr_detach.c 17 Dec 2005 09:42:45 -0000 1.10 +++ thread/thr_detach.c 28 Mar 2006 18:12:41 -0000 @@ -28,9 +28,11 @@ * */ +#include "namespace.h" #include #include #include +#include "un-namespace.h" #include "thr_private.h" Index: thread/thr_equal.c =================================================================== RCS file: /home/ncvs/src/lib/libthr/thread/thr_equal.c,v retrieving revision 1.1 diff -u -r1.1 thr_equal.c --- thread/thr_equal.c 1 Apr 2003 03:46:28 -0000 1.1 +++ thread/thr_equal.c 28 Mar 2006 18:12:41 -0000 @@ -31,7 +31,11 @@ * * $FreeBSD: src/lib/libthr/thread/thr_equal.c,v 1.1 2003/04/01 03:46:28 jeff Exp $ */ + +#include "namespace.h" #include +#include "un-namespace.h" + #include "thr_private.h" __weak_reference(_pthread_equal, pthread_equal); Index: thread/thr_exit.c =================================================================== RCS file: /home/ncvs/src/lib/libthr/thread/thr_exit.c,v retrieving revision 1.20 diff -u -r1.20 thr_exit.c --- thread/thr_exit.c 5 Jan 2006 13:51:22 -0000 1.20 +++ thread/thr_exit.c 28 Mar 2006 18:12:41 -0000 @@ -32,10 +32,15 @@ * $FreeBSD: src/lib/libthr/thread/thr_exit.c,v 1.20 2006/01/05 13:51:22 davidxu Exp $ */ +#include "namespace.h" +#include +#include +#include #include +#include #include #include -#include +#include "un-namespace.h" #include "thr_private.h" @@ -44,7 +49,7 @@ __weak_reference(_pthread_exit, pthread_exit); void -_thread_exit(char *fname, int lineno, char *msg) +_thread_exit(const char *fname, int lineno, const char *msg) { /* Write an error message to the standard error file descriptor: */ @@ -103,7 +108,7 @@ /* Save the return value: */ curthread->ret = status; while (curthread->cleanup != NULL) { - pthread_cleanup_pop(1); + _pthread_cleanup_pop(1); } if (curthread->attr.cleanup_attr != NULL) { curthread->attr.cleanup_attr(curthread->attr.arg_attr); Index: thread/thr_fork.c =================================================================== RCS file: /home/ncvs/src/lib/libthr/thread/thr_fork.c,v retrieving revision 1.3 diff -u -r1.3 thr_fork.c --- thread/thr_fork.c 12 Jan 2006 07:28:21 -0000 1.3 +++ thread/thr_fork.c 28 Mar 2006 18:12:41 -0000 @@ -60,12 +60,17 @@ * */ +#include "namespace.h" +#include +#include +#include #include -#include -#include -#include #include #include +#include +#include +#include +#include "un-namespace.h" #include "libc_private.h" #include "thr_private.h" @@ -94,6 +99,8 @@ return (0); } +pid_t _fork(void); + __weak_reference(_fork, fork); pid_t Index: thread/thr_getprio.c =================================================================== RCS file: /home/ncvs/src/lib/libthr/thread/thr_getprio.c,v retrieving revision 1.1 diff -u -r1.1 thr_getprio.c --- thread/thr_getprio.c 1 Apr 2003 03:46:28 -0000 1.1 +++ thread/thr_getprio.c 28 Mar 2006 18:12:41 -0000 @@ -31,8 +31,12 @@ * * $FreeBSD: src/lib/libthr/thread/thr_getprio.c,v 1.1 2003/04/01 03:46:28 jeff Exp $ */ + +#include "namespace.h" #include #include +#include "un-namespace.h" + #include "thr_private.h" __weak_reference(_pthread_getprio, pthread_getprio); @@ -43,7 +47,7 @@ int policy, ret; struct sched_param param; - if ((ret = pthread_getschedparam(pthread, &policy, ¶m)) == 0) + if ((ret = _pthread_getschedparam(pthread, &policy, ¶m)) == 0) ret = param.sched_priority; else { /* Invalid thread: */ Index: thread/thr_getschedparam.c =================================================================== RCS file: /home/ncvs/src/lib/libthr/thread/thr_getschedparam.c,v retrieving revision 1.3 diff -u -r1.3 thr_getschedparam.c --- thread/thr_getschedparam.c 2 Apr 2005 01:20:00 -0000 1.3 +++ thread/thr_getschedparam.c 28 Mar 2006 18:12:41 -0000 @@ -32,15 +32,17 @@ * $FreeBSD: src/lib/libthr/thread/thr_getschedparam.c,v 1.3 2005/04/02 01:20:00 davidxu Exp $ */ +#include "namespace.h" #include #include +#include "un-namespace.h" #include "thr_private.h" __weak_reference(_pthread_getschedparam, pthread_getschedparam); int -_pthread_getschedparam(pthread_t pthread, int *policy, +_pthread_getschedparam(pthread_t pthread, int *policy, struct sched_param *param) { struct pthread *curthread = _get_curthread(); Index: thread/thr_info.c =================================================================== RCS file: /home/ncvs/src/lib/libthr/thread/thr_info.c,v retrieving revision 1.7 diff -u -r1.7 thr_info.c --- thread/thr_info.c 5 Feb 2006 02:26:17 -0000 1.7 +++ thread/thr_info.c 28 Mar 2006 18:12:41 -0000 @@ -32,9 +32,15 @@ * $FreeBSD: src/lib/libthr/thread/thr_info.c,v 1.7 2006/02/05 02:26:17 davidxu Exp $ */ +#include "namespace.h" +#include +#include +#include +#include #include #include #include +#include "un-namespace.h" #include "thr_private.h" @@ -42,7 +48,7 @@ /* Set the thread name for debug. */ void -_pthread_set_name_np(pthread_t thread, char *name) +_pthread_set_name_np(pthread_t thread, const char *name) { struct pthread *curthread = _get_curthread(); int ret = 0; Index: thread/thr_init.c =================================================================== RCS file: /home/ncvs/src/lib/libthr/thread/thr_init.c,v retrieving revision 1.32 diff -u -r1.32 thr_init.c --- thread/thr_init.c 27 Mar 2006 23:50:21 -0000 1.32 +++ thread/thr_init.c 28 Mar 2006 18:41:34 -0000 @@ -35,11 +35,13 @@ #include "namespace.h" #include -#include #include +#include +#include #include #include -#include +#include +#include #include #include #include @@ -95,10 +97,10 @@ }; pid_t _thr_pid; -int _thr_guard_default; -int _thr_stack_default = THR_STACK_DEFAULT; -int _thr_stack_initial = THR_STACK_INITIAL; -int _thr_page_size; +size_t _thr_guard_default; +size_t _thr_stack_default = THR_STACK_DEFAULT; +size_t _thr_stack_initial = THR_STACK_INITIAL; +size_t _thr_page_size; int _gc_count; umtx_t _mutex_static_lock; umtx_t _cond_static_lock; @@ -389,9 +391,8 @@ * resource limits, so this stack needs an explicitly mapped * red zone to protect the thread stack that is just beyond. */ - if (mmap((void *)_usrstack - _thr_stack_initial - - _thr_guard_default, _thr_guard_default, 0, MAP_ANON, - -1, 0) == MAP_FAILED) + if (mmap((char *)_usrstack - _thr_stack_initial - _thr_guard_default, + _thr_guard_default, 0, MAP_ANON, -1, 0) == MAP_FAILED) PANIC("Cannot allocate red zone for initial thread"); /* @@ -403,7 +404,7 @@ * actually free() it; it just puts it in the free * stack queue for later reuse. */ - thread->attr.stackaddr_attr = (void *)_usrstack - _thr_stack_initial; + thread->attr.stackaddr_attr = (char *)_usrstack - _thr_stack_initial; thread->attr.stacksize_attr = _thr_stack_initial; thread->attr.guardsize_attr = _thr_guard_default; thread->attr.flags |= THR_STACK_USER; Index: thread/thr_join.c =================================================================== RCS file: /home/ncvs/src/lib/libthr/thread/thr_join.c,v retrieving revision 1.20 diff -u -r1.20 thr_join.c --- thread/thr_join.c 19 Dec 2005 03:20:55 -0000 1.20 +++ thread/thr_join.c 28 Mar 2006 18:12:41 -0000 @@ -27,8 +27,11 @@ * */ +#include "namespace.h" #include #include +#include +#include "un-namespace.h" #include "thr_private.h" Index: thread/thr_kern.c =================================================================== RCS file: /home/ncvs/src/lib/libthr/thread/thr_kern.c,v retrieving revision 1.20 diff -u -r1.20 thr_kern.c --- thread/thr_kern.c 25 Mar 2006 04:49:07 -0000 1.20 +++ thread/thr_kern.c 28 Mar 2006 18:12:41 -0000 @@ -27,9 +27,14 @@ * $FreeBSD: src/lib/libthr/thread/thr_kern.c,v 1.20 2006/03/25 04:49:07 davidxu Exp $ */ +#include "namespace.h" #include #include +#include +#include #include +#include +#include "un-namespace.h" #include "thr_private.h" @@ -63,7 +68,7 @@ _thr_signal_block(struct pthread *curthread) { sigset_t set; - + if (curthread->sigblock > 0) { curthread->sigblock++; return; Index: thread/thr_kill.c =================================================================== RCS file: /home/ncvs/src/lib/libthr/thread/thr_kill.c,v retrieving revision 1.1 diff -u -r1.1 thr_kill.c --- thread/thr_kill.c 2 Apr 2005 01:20:00 -0000 1.1 +++ thread/thr_kill.c 28 Mar 2006 18:12:41 -0000 @@ -32,9 +32,13 @@ * $FreeBSD: src/lib/libthr/thread/thr_kill.c,v 1.1 2005/04/02 01:20:00 davidxu Exp $ */ +#include "namespace.h" +#include +#include #include #include #include +#include "un-namespace.h" #include "thr_private.h" Index: thread/thr_list.c =================================================================== RCS file: /home/ncvs/src/lib/libthr/thread/thr_list.c,v retrieving revision 1.7 diff -u -r1.7 thr_list.c --- thread/thr_list.c 24 Mar 2006 04:34:06 -0000 1.7 +++ thread/thr_list.c 28 Mar 2006 18:12:41 -0000 @@ -27,15 +27,16 @@ * $FreeBSD: src/lib/libthr/thread/thr_list.c,v 1.7 2006/03/24 04:34:06 davidxu Exp $ */ +#include "namespace.h" #include #include - +#include #include #include -#include +#include "un-namespace.h" -#include "thr_private.h" #include "libc_private.h" +#include "thr_private.h" /*#define DEBUG_THREAD_LIST */ #ifdef DEBUG_THREAD_LIST @@ -217,8 +218,10 @@ } static void -thr_destroy(struct pthread *curthread __unused, struct pthread *thread) +thr_destroy(struct pthread *curthread, struct pthread *thread) { + (void)curthread; + free(thread); } @@ -312,6 +315,8 @@ void _thr_ref_delete_unlocked(struct pthread *curthread, struct pthread *thread) { + (void)curthread; + if (thread != NULL) { thread->refcount--; if ((thread->refcount == 0) && thread->state == PS_DEAD && @@ -326,6 +331,8 @@ { struct pthread *pthread; + (void)curthread; + if (thread == NULL) /* Invalid thread: */ return (EINVAL); @@ -334,7 +341,7 @@ if (pthread) { if (include_dead == 0 && pthread->state == PS_DEAD) { pthread = NULL; - } + } } /* Return zero if the thread exists: */ Index: thread/thr_main_np.c =================================================================== RCS file: /home/ncvs/src/lib/libthr/thread/thr_main_np.c,v retrieving revision 1.2 diff -u -r1.2 thr_main_np.c --- thread/thr_main_np.c 2 Apr 2005 01:20:00 -0000 1.2 +++ thread/thr_main_np.c 28 Mar 2006 18:12:41 -0000 @@ -27,8 +27,10 @@ * $FreeBSD: src/lib/libthr/thread/thr_main_np.c,v 1.2 2005/04/02 01:20:00 davidxu Exp $ */ +#include "namespace.h" #include #include +#include "un-namespace.h" #include "thr_private.h" @@ -44,5 +46,5 @@ if (!_thr_initial) return (-1); else - return (pthread_equal(pthread_self(), _thr_initial) ? 1 : 0); + return (_pthread_equal(_pthread_self(), _thr_initial) ? 1 : 0); } Index: thread/thr_multi_np.c =================================================================== RCS file: /home/ncvs/src/lib/libthr/thread/thr_multi_np.c,v retrieving revision 1.1 diff -u -r1.1 thr_multi_np.c --- thread/thr_multi_np.c 1 Apr 2003 03:46:29 -0000 1.1 +++ thread/thr_multi_np.c 28 Mar 2006 18:12:41 -0000 @@ -31,8 +31,13 @@ * * $FreeBSD: src/lib/libthr/thread/thr_multi_np.c,v 1.1 2003/04/01 03:46:29 jeff Exp $ */ + +#include "namespace.h" #include #include +#include "un-namespace.h" + +#include "thr_private.h" __weak_reference(_pthread_multi_np, pthread_multi_np); @@ -45,6 +50,6 @@ * XXX - Do we want to do this? * __is_threaded = 1; */ - pthread_resume_all_np(); + _pthread_resume_all_np(); return (0); } Index: thread/thr_mutex.c =================================================================== RCS file: /home/ncvs/src/lib/libthr/thread/thr_mutex.c,v retrieving revision 1.40 diff -u -r1.40 thr_mutex.c --- thread/thr_mutex.c 27 Mar 2006 23:50:21 -0000 1.40 +++ thread/thr_mutex.c 28 Mar 2006 18:12:42 -0000 @@ -33,12 +33,15 @@ * $FreeBSD: src/lib/libthr/thread/thr_mutex.c,v 1.40 2006/03/27 23:50:21 davidxu Exp $ */ -#include -#include -#include +#include "namespace.h" #include #include +#include #include +#include +#include +#include "un-namespace.h" + #include "thr_private.h" #if defined(_PTHREADS_INVARIANTS) @@ -69,6 +72,11 @@ const struct timespec *abstime); static int mutex_unlock_common(pthread_mutex_t *, int); +int __pthread_mutex_init(pthread_mutex_t *, const pthread_mutexattr_t *); +int __pthread_mutex_lock(pthread_mutex_t *); +int __pthread_mutex_timedlock(pthread_mutex_t *, const struct timespec *); +int __pthread_mutex_trylock(pthread_mutex_t *); + __weak_reference(__pthread_mutex_init, pthread_mutex_init); __weak_reference(__pthread_mutex_lock, pthread_mutex_lock); __weak_reference(__pthread_mutex_timedlock, pthread_mutex_timedlock); @@ -465,10 +473,12 @@ { int ret; + (void)curthread; + switch (m->m_type) { case PTHREAD_MUTEX_ERRORCHECK: case PTHREAD_MUTEX_NORMAL: - ret = EBUSY; + ret = EBUSY; break; case PTHREAD_MUTEX_RECURSIVE: @@ -490,10 +500,12 @@ static int mutex_self_lock(struct pthread *curthread, pthread_mutex_t m, - const struct timespec *abstime) + const struct timespec *abstime) { struct timespec ts1, ts2; - int ret; + int ret; + + (void)curthread; switch (m->m_type) { case PTHREAD_MUTEX_ERRORCHECK: @@ -507,7 +519,7 @@ * POSIX specifies that mutexes should return * EDEADLK if a recursive lock is detected. */ - ret = EDEADLK; + ret = EDEADLK; } break; @@ -599,10 +611,12 @@ int _pthread_mutex_getprioceiling(pthread_mutex_t *mutex, - int *prioceiling) + int *prioceiling) { int ret; + (void)prioceiling; + if (*mutex == NULL) ret = EINVAL; else if ((*mutex)->m_protocol != PTHREAD_PRIO_PROTECT) @@ -615,7 +629,7 @@ int _pthread_mutex_setprioceiling(pthread_mutex_t *mutex, - int prioceiling, int *old_ceiling) + int prioceiling, int *old_ceiling) { int ret = 0; int tmp; @@ -624,10 +638,10 @@ ret = EINVAL; else if ((*mutex)->m_protocol != PTHREAD_PRIO_PROTECT) ret = EINVAL; - else if ((ret = pthread_mutex_lock(mutex)) == 0) { + else if ((ret = _pthread_mutex_lock(mutex)) == 0) { tmp = (*mutex)->m_prio; (*mutex)->m_prio = prioceiling; - ret = pthread_mutex_unlock(mutex); + ret = _pthread_mutex_unlock(mutex); /* Return the old ceiling. */ *old_ceiling = tmp; Index: thread/thr_mutex_prioceiling.c =================================================================== RCS file: /home/ncvs/src/lib/libthr/thread/thr_mutex_prioceiling.c,v retrieving revision 1.4 diff -u -r1.4 thr_mutex_prioceiling.c --- thread/thr_mutex_prioceiling.c 2 Apr 2005 01:20:00 -0000 1.4 +++ thread/thr_mutex_prioceiling.c 28 Mar 2006 18:12:42 -0000 @@ -32,10 +32,13 @@ * $FreeBSD: src/lib/libthr/thread/thr_mutex_prioceiling.c,v 1.4 2005/04/02 01:20:00 davidxu Exp $ */ -#include -#include +#include "namespace.h" #include #include +#include +#include +#include "un-namespace.h" + #include "thr_private.h" __weak_reference(_pthread_mutexattr_getprioceiling, pthread_mutexattr_getprioceiling); Index: thread/thr_mutex_protocol.c =================================================================== RCS file: /home/ncvs/src/lib/libthr/thread/thr_mutex_protocol.c,v retrieving revision 1.3 diff -u -r1.3 thr_mutex_protocol.c --- thread/thr_mutex_protocol.c 2 Apr 2005 01:20:00 -0000 1.3 +++ thread/thr_mutex_protocol.c 28 Mar 2006 18:12:42 -0000 @@ -32,10 +32,13 @@ * $FreeBSD: src/lib/libthr/thread/thr_mutex_protocol.c,v 1.3 2005/04/02 01:20:00 davidxu Exp $ */ -#include -#include +#include "namespace.h" #include #include +#include +#include +#include "un-namespace.h" + #include "thr_private.h" __weak_reference(_pthread_mutexattr_getprotocol, pthread_mutexattr_getprotocol); Index: thread/thr_mutexattr.c =================================================================== RCS file: /home/ncvs/src/lib/libthr/thread/thr_mutexattr.c,v retrieving revision 1.4 diff -u -r1.4 thr_mutexattr.c --- thread/thr_mutexattr.c 27 Mar 2006 23:50:21 -0000 1.4 +++ thread/thr_mutexattr.c 28 Mar 2006 18:12:42 -0000 @@ -65,10 +65,14 @@ * */ -#include -#include +#include "namespace.h" #include #include +#include +#include +#include +#include "un-namespace.h" + #include "thr_private.h" __weak_reference(_pthread_mutexattr_init, pthread_mutexattr_init); @@ -90,12 +94,10 @@ int ret; pthread_mutexattr_t pattr; - if ((pattr = (pthread_mutexattr_t) - malloc(sizeof(struct pthread_mutex_attr))) == NULL) { + if ((pattr = malloc(sizeof(*pattr))) == NULL) { ret = ENOMEM; } else { - memcpy(pattr, &_pthread_mutexattr_default, - sizeof(struct pthread_mutex_attr)); + memcpy(pattr, &_pthread_mutexattr_default, sizeof(*pattr)); *attr = pattr; ret = 0; } Index: thread/thr_printf.c =================================================================== RCS file: /home/ncvs/src/lib/libthr/thread/thr_printf.c,v retrieving revision 1.5 diff -u -r1.5 thr_printf.c --- thread/thr_printf.c 2 Apr 2005 01:20:00 -0000 1.5 +++ thread/thr_printf.c 28 Mar 2006 18:12:42 -0000 @@ -26,10 +26,12 @@ * $FreeBSD: src/lib/libthr/thread/thr_printf.c,v 1.5 2005/04/02 01:20:00 davidxu Exp $ */ +#include "namespace.h" +#include #include #include #include -#include +#include "un-namespace.h" #include "thr_private.h" Index: thread/thr_private.h =================================================================== RCS file: /home/ncvs/src/lib/libthr/thread/thr_private.h,v retrieving revision 1.59 diff -u -r1.59 thr_private.h --- thread/thr_private.h 27 Mar 2006 23:50:21 -0000 1.59 +++ thread/thr_private.h 28 Mar 2006 18:41:51 -0000 @@ -32,29 +32,12 @@ #ifndef _THR_PRIVATE_H #define _THR_PRIVATE_H -/* - * Include files. - */ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - #ifndef __hidden #define __hidden __attribute__((visibility("hidden"))) #endif +#include + #include "pthread_md.h" #include "thr_umtx.h" #include "thread_db.h" @@ -68,11 +51,15 @@ /* * Kernel fatal error handler macro. */ -#define PANIC(string) _thread_exit(__FILE__,__LINE__,string) +#define PANIC(string) _thread_exit(__FILE__, __LINE__, string) /* Output debug messages like this: */ -#define stdout_debug(args...) _thread_printf(STDOUT_FILENO, ##args) -#define stderr_debug(args...) _thread_printf(STDOUT_FILENO, ##args) +#ifdef STDOUT_FILENO +#define stdout_debug(...) _thread_printf(STDOUT_FILENO, __VA_ARGS__) +#endif +#ifdef STDERR_FILENO +#define stderr_debug(...) _thread_printf(STDERR_FILENO, __VA_ARGS__) +#endif #ifdef _PTHREADS_INVARIANTS #define THR_ASSERT(cond, msg) do { \ @@ -203,7 +190,7 @@ */ struct pthread_cleanup { struct pthread_cleanup *next; - void (*routine)(); + void (*routine)(void *); void *routine_arg; int onstack; }; @@ -239,7 +226,7 @@ #define THR_STACK_USER 0x100 /* 0xFF reserved for */ int flags; void *arg_attr; - void (*cleanup_attr)(); + void (*cleanup_attr)(void *); void *stackaddr_attr; size_t stacksize_attr; size_t guardsize_attr; @@ -625,10 +612,10 @@ extern struct pthread_cond_attr _pthread_condattr_default __hidden; extern pid_t _thr_pid __hidden; -extern int _thr_guard_default __hidden; -extern int _thr_stack_default __hidden; -extern int _thr_stack_initial __hidden; -extern int _thr_page_size __hidden; +extern size_t _thr_guard_default __hidden; +extern size_t _thr_stack_default __hidden; +extern size_t _thr_stack_initial __hidden; +extern size_t _thr_page_size __hidden; /* Garbage thread count. */ extern int _gc_count __hidden; @@ -650,37 +637,11 @@ void _mutex_fork(struct pthread *curthread) __hidden; void _mutex_unlock_private(struct pthread *) __hidden; void _libpthread_init(struct pthread *) __hidden; -void *_pthread_getspecific(pthread_key_t); -int _pthread_cond_init(pthread_cond_t *, const pthread_condattr_t *); -int _pthread_cond_destroy(pthread_cond_t *); -int _pthread_cond_wait(pthread_cond_t *, pthread_mutex_t *); -int _pthread_cond_timedwait(pthread_cond_t *, pthread_mutex_t *, - const struct timespec *); -int _pthread_cond_signal(pthread_cond_t *); -int _pthread_cond_broadcast(pthread_cond_t *); int _pthread_create(pthread_t * thread, const pthread_attr_t * attr, void *(*start_routine) (void *), void *arg); -int _pthread_key_create(pthread_key_t *, void (*) (void *)); -int _pthread_key_delete(pthread_key_t); -int _pthread_mutex_destroy(pthread_mutex_t *); -int _pthread_mutex_init(pthread_mutex_t *, const pthread_mutexattr_t *); -int _pthread_mutex_lock(pthread_mutex_t *); -int _pthread_mutex_trylock(pthread_mutex_t *); -int _pthread_mutex_unlock(pthread_mutex_t *); -int _pthread_mutexattr_init(pthread_mutexattr_t *); -int _pthread_mutexattr_destroy(pthread_mutexattr_t *); -int _pthread_mutexattr_settype(pthread_mutexattr_t *, int); -int _pthread_once(pthread_once_t *, void (*) (void)); -int _pthread_rwlock_init(pthread_rwlock_t *, const pthread_rwlockattr_t *); -int _pthread_rwlock_destroy (pthread_rwlock_t *); -struct pthread *_pthread_self(void); -int _pthread_setspecific(pthread_key_t, const void *); -void _pthread_testcancel(void); void _pthread_yield(void); -void _pthread_cleanup_push(void (*routine) (void *), void *routine_arg); -void _pthread_cleanup_pop(int execute); struct pthread *_thr_alloc(struct pthread *) __hidden; -void _thread_exit(char *, int, char *) __hidden __dead2; +void _thread_exit(const char *, int, const char *) __hidden __dead2; void _thr_exit_cleanup(void) __hidden; int _thr_ref_add(struct pthread *, struct pthread *, int) __hidden; void _thr_ref_delete(struct pthread *, struct pthread *) __hidden; @@ -718,6 +679,7 @@ void _thr_report_death(struct pthread *curthread) __hidden; void _thread_bp_create(void); void _thread_bp_death(void); +void _thread_seterrno(pthread_t, int); /* #include */ #ifdef _SYS_AIO_H_ Index: thread/thr_pspinlock.c =================================================================== RCS file: /home/ncvs/src/lib/libthr/thread/thr_pspinlock.c,v retrieving revision 1.1 diff -u -r1.1 thr_pspinlock.c --- thread/thr_pspinlock.c 2 Apr 2005 01:20:00 -0000 1.1 +++ thread/thr_pspinlock.c 28 Mar 2006 18:12:42 -0000 @@ -26,9 +26,12 @@ * $FreeBSD: src/lib/libthr/thread/thr_pspinlock.c,v 1.1 2005/04/02 01:20:00 davidxu Exp $ */ +#include "namespace.h" #include #include #include +#include "un-namespace.h" + #include "thr_private.h" #define SPIN_COUNT 100000 Index: thread/thr_resume_np.c =================================================================== RCS file: /home/ncvs/src/lib/libthr/thread/thr_resume_np.c,v retrieving revision 1.9 diff -u -r1.9 thr_resume_np.c --- thread/thr_resume_np.c 5 Jan 2006 13:51:22 -0000 1.9 +++ thread/thr_resume_np.c 28 Mar 2006 18:12:42 -0000 @@ -32,8 +32,11 @@ * $FreeBSD: src/lib/libthr/thread/thr_resume_np.c,v 1.9 2006/01/05 13:51:22 davidxu Exp $ */ +#include "namespace.h" #include #include +#include +#include "un-namespace.h" #include "thr_private.h" Index: thread/thr_rtld.c =================================================================== RCS file: /home/ncvs/src/lib/libthr/thread/thr_rtld.c,v retrieving revision 1.2 diff -u -r1.2 thr_rtld.c --- thread/thr_rtld.c 25 Mar 2006 05:14:21 -0000 1.2 +++ thread/thr_rtld.c 28 Mar 2006 18:13:54 -0000 @@ -30,8 +30,10 @@ /* * A lockless rwlock for rtld. */ -#include + +#include "namespace.h" #include +#include "un-namespace.h" #include "rtld_lock.h" #include "thr_private.h" @@ -167,6 +169,8 @@ static int _thr_rtld_set_flag(int mask) { + (void)mask; + /* * The caller's code in rtld-elf is broken, it is not signal safe, * just return zero to fool it. @@ -177,6 +181,8 @@ static int _thr_rtld_clr_flag(int mask) { + (void)mask; + return (0); } @@ -190,7 +196,7 @@ curthread = _get_curthread(); /* force to resolve _umtx_op PLT */ - _umtx_op((struct umtx *)&dummy, UMTX_OP_WAKE, 1, 0, 0); + _umtx_op((struct umtx *)(void *)&dummy, UMTX_OP_WAKE, 1, 0, 0); li.lock_create = _thr_rtld_lock_create; li.lock_destroy = _thr_rtld_lock_destroy; Index: thread/thr_rwlock.c =================================================================== RCS file: /home/ncvs/src/lib/libthr/thread/thr_rwlock.c,v retrieving revision 1.8 diff -u -r1.8 thr_rwlock.c --- thread/thr_rwlock.c 2 Apr 2005 01:20:00 -0000 1.8 +++ thread/thr_rwlock.c 28 Mar 2006 18:12:42 -0000 @@ -26,13 +26,13 @@ * $FreeBSD: src/lib/libthr/thread/thr_rwlock.c,v 1.8 2005/04/02 01:20:00 davidxu Exp $ */ +#include "namespace.h" #include #include -#include - -#include "namespace.h" #include +#include #include "un-namespace.h" + #include "thr_private.h" /* maximum number of times a read lock may be obtained */ @@ -58,6 +58,8 @@ pthread_rwlock_t prwlock; int ret; + (void)attr; + /* allocate rwlock object */ prwlock = (pthread_rwlock_t)malloc(sizeof(struct pthread_rwlock)); Index: thread/thr_rwlockattr.c =================================================================== RCS file: /home/ncvs/src/lib/libthr/thread/thr_rwlockattr.c,v retrieving revision 1.1 diff -u -r1.1 thr_rwlockattr.c --- thread/thr_rwlockattr.c 1 Apr 2003 03:46:29 -0000 1.1 +++ thread/thr_rwlockattr.c 28 Mar 2006 18:12:42 -0000 @@ -26,10 +26,12 @@ * $FreeBSD: src/lib/libthr/thread/thr_rwlockattr.c,v 1.1 2003/04/01 03:46:29 jeff Exp $ */ +#include "namespace.h" #include +#include #include +#include "un-namespace.h" -#include #include "thr_private.h" __weak_reference(_pthread_rwlockattr_destroy, pthread_rwlockattr_destroy); Index: thread/thr_self.c =================================================================== RCS file: /home/ncvs/src/lib/libthr/thread/thr_self.c,v retrieving revision 1.3 diff -u -r1.3 thr_self.c --- thread/thr_self.c 2 Apr 2005 01:20:00 -0000 1.3 +++ thread/thr_self.c 28 Mar 2006 18:12:42 -0000 @@ -32,7 +32,9 @@ * $FreeBSD: src/lib/libthr/thread/thr_self.c,v 1.3 2005/04/02 01:20:00 davidxu Exp $ */ +#include "namespace.h" #include +#include "un-namespace.h" #include "thr_private.h" Index: thread/thr_sem.c =================================================================== RCS file: /home/ncvs/src/lib/libthr/thread/thr_sem.c,v retrieving revision 1.7 diff -u -r1.7 thr_sem.c --- thread/thr_sem.c 28 Mar 2006 21:46:55 -0000 1.7 +++ thread/thr_sem.c 29 Mar 2006 05:53:54 -0000 @@ -36,10 +36,10 @@ #include #include #include +#include <_semaphore.h> #include #include #include -#include <_semaphore.h> #include "un-namespace.h" #include "thr_private.h" @@ -76,7 +76,7 @@ return (NULL); } - sem = (sem_t)malloc(sizeof(struct sem)); + sem = malloc(sizeof(*sem)); if (sem == NULL) { errno = ENOSPC; return (NULL); Index: thread/thr_seterrno.c =================================================================== RCS file: /home/ncvs/src/lib/libthr/thread/thr_seterrno.c,v retrieving revision 1.2 diff -u -r1.2 thr_seterrno.c --- thread/thr_seterrno.c 2 Apr 2005 01:20:00 -0000 1.2 +++ thread/thr_seterrno.c 28 Mar 2006 18:12:42 -0000 @@ -32,13 +32,15 @@ * $FreeBSD: src/lib/libthr/thread/thr_seterrno.c,v 1.2 2005/04/02 01:20:00 davidxu Exp $ */ +#include "namespace.h" #include +#include "un-namespace.h" #include "thr_private.h" /* * This function needs to reference the global error variable which is - * normally hidden from the user. + * normally hidden from the user. */ #undef errno extern int errno; @@ -53,7 +55,7 @@ else /* * Threads other than the initial thread always use the error - * field in the thread structureL + * field in the thread structure */ thread->error = error; } Index: thread/thr_setprio.c =================================================================== RCS file: /home/ncvs/src/lib/libthr/thread/thr_setprio.c,v retrieving revision 1.1 diff -u -r1.1 thr_setprio.c --- thread/thr_setprio.c 1 Apr 2003 03:46:29 -0000 1.1 +++ thread/thr_setprio.c 28 Mar 2006 18:14:25 -0000 @@ -31,7 +31,11 @@ * * $FreeBSD: src/lib/libthr/thread/thr_setprio.c,v 1.1 2003/04/01 03:46:29 jeff Exp $ */ + +#include "namespace.h" #include +#include "un-namespace.h" + #include "thr_private.h" __weak_reference(_pthread_setprio, pthread_setprio); @@ -42,9 +46,9 @@ int ret, policy; struct sched_param param; - if ((ret = pthread_getschedparam(pthread, &policy, ¶m)) == 0) { + if ((ret = _pthread_getschedparam(pthread, &policy, ¶m)) == 0) { param.sched_priority = prio; - ret = pthread_setschedparam(pthread, policy, ¶m); + ret = _pthread_setschedparam(pthread, policy, ¶m); } /* Return the error status: */ Index: thread/thr_setschedparam.c =================================================================== RCS file: /home/ncvs/src/lib/libthr/thread/thr_setschedparam.c,v retrieving revision 1.10 diff -u -r1.10 thr_setschedparam.c --- thread/thr_setschedparam.c 27 Mar 2006 23:50:21 -0000 1.10 +++ thread/thr_setschedparam.c 28 Mar 2006 18:12:42 -0000 @@ -32,9 +32,11 @@ * $FreeBSD: src/lib/libthr/thread/thr_setschedparam.c,v 1.10 2006/03/27 23:50:21 davidxu Exp $ */ -#include +#include "namespace.h" #include +#include #include +#include "un-namespace.h" #include "thr_private.h" @@ -45,7 +47,7 @@ * in kernel, doing it in userland is no-op. */ int -_pthread_setschedparam(pthread_t pthread, int policy, +_pthread_setschedparam(pthread_t pthread, int policy, const struct sched_param *param) { struct pthread *curthread = _get_curthread(); Index: thread/thr_sig.c =================================================================== RCS file: /home/ncvs/src/lib/libthr/thread/thr_sig.c,v retrieving revision 1.17 diff -u -r1.17 thr_sig.c --- thread/thr_sig.c 26 Mar 2006 01:57:03 -0000 1.17 +++ thread/thr_sig.c 28 Mar 2006 18:40:17 -0000 @@ -26,15 +26,17 @@ * $FreeBSD: src/lib/libthr/thread/thr_sig.c,v 1.17 2006/03/26 01:57:03 davidxu Exp $ */ +#include "namespace.h" #include -#include #include -#include +#include #include #include -#include -#include #include +#include +#include +#include +#include "un-namespace.h" #include "thr_private.h" @@ -205,6 +207,11 @@ return (ret); } +int __sigwait(const sigset_t *, int *); +int __sigtimedwait(const sigset_t *, siginfo_t *, + const struct timespec *); +int __sigwaitinfo(const sigset_t *, siginfo_t *); + __weak_reference(__sigwait, sigwait); __weak_reference(__sigtimedwait, sigtimedwait); __weak_reference(__sigwaitinfo, sigwaitinfo); Index: thread/thr_sigmask.c =================================================================== RCS file: /home/ncvs/src/lib/libthr/thread/thr_sigmask.c,v retrieving revision 1.1 diff -u -r1.1 thr_sigmask.c --- thread/thr_sigmask.c 2 Apr 2005 01:20:00 -0000 1.1 +++ thread/thr_sigmask.c 28 Mar 2006 18:12:42 -0000 @@ -32,9 +32,12 @@ * $FreeBSD: src/lib/libthr/thread/thr_sigmask.c,v 1.1 2005/04/02 01:20:00 davidxu Exp $ */ +#include "namespace.h" #include #include #include +#include "un-namespace.h" + #include "thr_private.h" __weak_reference(_pthread_sigmask, pthread_sigmask); Index: thread/thr_single_np.c =================================================================== RCS file: /home/ncvs/src/lib/libthr/thread/thr_single_np.c,v retrieving revision 1.1 diff -u -r1.1 thr_single_np.c --- thread/thr_single_np.c 2 Apr 2005 01:20:00 -0000 1.1 +++ thread/thr_single_np.c 28 Mar 2006 18:16:18 -0000 @@ -32,8 +32,10 @@ * $FreeBSD: src/lib/libthr/thread/thr_single_np.c,v 1.1 2005/04/02 01:20:00 davidxu Exp $ */ +#include "namespace.h" #include #include +#include "un-namespace.h" __weak_reference(_pthread_single_np, pthread_single_np); @@ -41,7 +43,7 @@ { /* Enter single-threaded (non-POSIX) scheduling mode: */ - pthread_suspend_all_np(); + _pthread_suspend_all_np(); /* * XXX - Do we want to do this? * __is_threaded = 0; Index: thread/thr_spec.c =================================================================== RCS file: /home/ncvs/src/lib/libthr/thread/thr_spec.c,v retrieving revision 1.3 diff -u -r1.3 thr_spec.c --- thread/thr_spec.c 2 Apr 2005 01:20:00 -0000 1.3 +++ thread/thr_spec.c 28 Mar 2006 18:19:36 -0000 @@ -32,11 +32,16 @@ * $FreeBSD: src/lib/libthr/thread/thr_spec.c,v 1.3 2005/04/02 01:20:00 davidxu Exp $ */ +#include "namespace.h" +#include +#include +#include +#include #include #include #include -#include -#include +#include +#include "un-namespace.h" #include "thr_private.h" @@ -98,7 +103,7 @@ return (ret); } -void +void _thread_cleanupspecific(void) { struct pthread *curthread = _get_curthread(); @@ -168,7 +173,7 @@ return (new_data); } -int +int _pthread_setspecific(pthread_key_t key, const void *value) { struct pthread *pthread; @@ -218,7 +223,7 @@ } else { /* * This key has not been used before, so return NULL - * instead: + * instead: */ data = NULL; } Index: thread/thr_spinlock.c =================================================================== RCS file: /home/ncvs/src/lib/libthr/thread/thr_spinlock.c,v retrieving revision 1.12 diff -u -r1.12 thr_spinlock.c --- thread/thr_spinlock.c 13 Jan 2006 06:14:04 -0000 1.12 +++ thread/thr_spinlock.c 28 Mar 2006 18:19:50 -0000 @@ -33,10 +33,11 @@ * */ +#include "namespace.h" #include -#include -#include #include +#include +#include "un-namespace.h" #include "thr_private.h" @@ -83,6 +84,8 @@ void _spinlock_debug(spinlock_t *lck, char *fname, int lineno) { + (void)fname; + (void)lineno; _spinlock(lck); } Index: thread/thr_stack.c =================================================================== RCS file: /home/ncvs/src/lib/libthr/thread/thr_stack.c,v retrieving revision 1.6 diff -u -r1.6 thr_stack.c --- thread/thr_stack.c 2 Apr 2005 01:20:00 -0000 1.6 +++ thread/thr_stack.c 28 Mar 2006 18:43:35 -0000 @@ -27,11 +27,13 @@ * $FreeBSD: src/lib/libthr/thread/thr_stack.c,v 1.6 2005/04/02 01:20:00 davidxu Exp $ */ +#include "namespace.h" #include #include #include #include #include +#include "un-namespace.h" #include "thr_private.h" @@ -189,11 +191,11 @@ else { /* Allocate a stack from usrstack. */ if (last_stack == NULL) - last_stack = _usrstack - _thr_stack_initial - + last_stack = (char *)_usrstack - _thr_stack_initial - _thr_guard_default; /* Allocate a new stack. */ - stackaddr = last_stack - stacksize - guardsize; + stackaddr = (char *)last_stack - stacksize - guardsize; /* * Even if stack allocation fails, we don't want to try to @@ -202,7 +204,7 @@ * likely reason for an mmap() error is a stack overflow of * the adjacent thread stack. */ - last_stack -= (stacksize + guardsize); + last_stack = (char *)last_stack - (stacksize + guardsize); /* Release the lock before mmap'ing it. */ THREAD_LIST_UNLOCK(curthread); @@ -236,8 +238,8 @@ if ((attr != NULL) && ((attr->flags & THR_STACK_USER) == 0) && (attr->stackaddr_attr != NULL)) { - spare_stack = (attr->stackaddr_attr + attr->stacksize_attr - - sizeof(struct stack)); + spare_stack = (struct stack *)((char *)attr->stackaddr_attr + + attr->stacksize_attr - sizeof(struct stack)); spare_stack->stacksize = round_up(attr->stacksize_attr); spare_stack->guardsize = round_up(attr->guardsize_attr); spare_stack->stackaddr = attr->stackaddr_attr; Index: thread/thr_suspend_np.c =================================================================== RCS file: /home/ncvs/src/lib/libthr/thread/thr_suspend_np.c,v retrieving revision 1.6 diff -u -r1.6 thr_suspend_np.c --- thread/thr_suspend_np.c 20 Feb 2006 09:02:40 -0000 1.6 +++ thread/thr_suspend_np.c 28 Mar 2006 18:28:48 -0000 @@ -32,8 +32,14 @@ * $FreeBSD: src/lib/libthr/thread/thr_suspend_np.c,v 1.6 2006/02/20 09:02:40 davidxu Exp $ */ +#include "namespace.h" +#include +#include +#include #include #include +#include +#include "un-namespace.h" #include "thr_private.h" @@ -55,8 +61,7 @@ ret = EDEADLK; /* Add a reference to the thread: */ - else if ((ret = _thr_ref_add(curthread, thread, /*include dead*/0)) - == 0) { + else if ((ret = _thr_ref_add(curthread, thread, 0)) == 0) { /* Lock the threads scheduling queue: */ THR_THREAD_LOCK(curthread, thread); suspend_common(curthread, thread, 1); Index: thread/thr_switch_np.c =================================================================== RCS file: /home/ncvs/src/lib/libthr/thread/thr_switch_np.c,v retrieving revision 1.1 diff -u -r1.1 thr_switch_np.c --- thread/thr_switch_np.c 2 Apr 2005 01:20:00 -0000 1.1 +++ thread/thr_switch_np.c 28 Mar 2006 18:12:42 -0000 @@ -32,9 +32,11 @@ * $FreeBSD: src/lib/libthr/thread/thr_switch_np.c,v 1.1 2005/04/02 01:20:00 davidxu Exp $ */ +#include "namespace.h" #include #include #include +#include "un-namespace.h" #include "thr_private.h" @@ -45,11 +47,13 @@ int _pthread_switch_add_np(pthread_switch_routine_t routine) { + (void)routine; return (ENOTSUP); } int _pthread_switch_delete_np(pthread_switch_routine_t routine) { + (void)routine; return (ENOTSUP); } Index: thread/thr_symbols.c =================================================================== RCS file: /home/ncvs/src/lib/libthr/thread/thr_symbols.c,v retrieving revision 1.3 diff -u -r1.3 thr_symbols.c --- thread/thr_symbols.c 1 Sep 2005 15:21:23 -0000 1.3 +++ thread/thr_symbols.c 28 Mar 2006 18:12:42 -0000 @@ -32,10 +32,12 @@ * $FreeBSD: src/lib/libthr/thread/thr_symbols.c,v 1.3 2005/09/01 15:21:23 stefanf Exp $ */ +#include "namespace.h" #include #include #include #include +#include "un-namespace.h" #include "thr_private.h" Index: thread/thr_syscalls.c =================================================================== RCS file: /home/ncvs/src/lib/libthr/thread/thr_syscalls.c,v retrieving revision 1.12 diff -u -r1.12 thr_syscalls.c --- thread/thr_syscalls.c 2 Nov 2005 14:06:29 -0000 1.12 +++ thread/thr_syscalls.c 28 Mar 2006 18:21:30 -0000 @@ -64,6 +64,7 @@ * */ +#include "namespace.h" #include #include #include @@ -72,6 +73,7 @@ #include #include #include +#include #include #include #include @@ -87,6 +89,7 @@ #include #include #include +#include "un-namespace.h" #include "thr_private.h" Index: thread/thr_umtx.c =================================================================== RCS file: /home/ncvs/src/lib/libthr/thread/thr_umtx.c,v retrieving revision 1.1 diff -u -r1.1 thr_umtx.c --- thread/thr_umtx.c 2 Apr 2005 01:20:00 -0000 1.1 +++ thread/thr_umtx.c 28 Mar 2006 18:12:42 -0000 @@ -43,10 +43,10 @@ const struct timespec *timeout) { if (timeout && (timeout->tv_sec < 0 || (timeout->tv_sec == 0 && - timeout->tv_nsec <= 0))) + timeout->tv_nsec <= 0))) return (ETIMEDOUT); if (_umtx_op((struct umtx *)mtx, UMTX_OP_LOCK, id, 0, - (void *)timeout) == 0) + __DECONST(void *, timeout)) == 0) return (0); return (errno); } @@ -63,10 +63,9 @@ _thr_umtx_wait(volatile umtx_t *mtx, long id, const struct timespec *timeout) { if (timeout && (timeout->tv_sec < 0 || (timeout->tv_sec == 0 && - timeout->tv_nsec <= 0))) + timeout->tv_nsec <= 0))) return (ETIMEDOUT); - if (_umtx_op((struct umtx *)mtx, UMTX_OP_WAIT, id, 0, - (void*) timeout) == 0) + if (_umtx_op((struct umtx *)mtx, UMTX_OP_WAIT, id, 0, __DECONST(void *, timeout)) == 0) return (0); return (errno); } Index: thread/thr_umtx.h =================================================================== RCS file: /home/ncvs/src/lib/libthr/thread/thr_umtx.h,v retrieving revision 1.3 diff -u -r1.3 thr_umtx.h --- thread/thr_umtx.h 21 Dec 2005 03:53:29 -0000 1.3 +++ thread/thr_umtx.h 28 Mar 2006 18:12:42 -0000 @@ -29,6 +29,9 @@ #ifndef _THR_FBSD_UMTX_H_ #define _THR_FBSD_UMTX_H_ +#include +#include +#include #include typedef long umtx_t; Index: thread/thr_yield.c =================================================================== RCS file: /home/ncvs/src/lib/libthr/thread/thr_yield.c,v retrieving revision 1.1 diff -u -r1.1 thr_yield.c --- thread/thr_yield.c 1 Apr 2003 03:46:29 -0000 1.1 +++ thread/thr_yield.c 28 Mar 2006 18:12:42 -0000 @@ -31,7 +31,11 @@ * * $FreeBSD: src/lib/libthr/thread/thr_yield.c,v 1.1 2003/04/01 03:46:29 jeff Exp $ */ + +#include "namespace.h" #include +#include "un-namespace.h" + #include "thr_private.h" __weak_reference(_pthread_yield, pthread_yield); --=-=-=--