The pshared attribute is not mentioned on the pthread_mutexattr_* manual page, although "man pthread_mutexattr_getpshared" gets you that page. Also, the functions pthread_mutexattr_{get,set}pshared are not implemented, even though POSIX requires them (yes, even if you don't support anything but PTHREAD_PROCESS_PRIVATE). Fix: Add the pthread_mutexattr_{g,s}etpshared() functions, just like the rwlock has. Add mention of them to the man page. How-To-Repeat: man pthread_mutexattr_getpshared search for pshared Attempt to compile the following program: #include <pthread.h> int main(int argc, char **argv) { pthread_mutexattr_t ma; pthread_mutexattr_init(&ma); pthread_mutexattr_setpshared(&ma, PTHREAD_PROCESS_PRIVATE); exit(0); }
Responsible Changed From-To: freebsd-bugs->jasone I'll look at this.
Responsible Changed From-To: jasone->freebsd-bugs
Howdy, The following patch should help. I created it based on the prototypes in /usr/include/pthread.h and by looking at similar code in the devel/linuxthreads port and the Darwin CVS repository. Feel free to make it look like the functions in uthread_rwlockattr.c if you like. Regards, Chris Knight --- lib/libc_r/uthread/Makefile.inc.old Wed Sep 20 21:28:52 2000 +++ lib/libc_r/uthread/Makefile.inc Thu Jun 20 16:47:39 2002 @@ -31,6 +31,7 @@ uthread_cond.c \ uthread_condattr_destroy.c \ uthread_condattr_init.c \ + uthread_condattr_pshared.c \ uthread_connect.c \ uthread_creat.c \ uthread_create.c \ @@ -77,6 +78,7 @@ uthread_mutex_prioceiling.c \ uthread_mutex_protocol.c \ uthread_mutexattr_destroy.c \ + uthread_mutexattr_pshared.c \ uthread_nanosleep.c \ uthread_once.c \ uthread_open.c \ --- /dev/null Thu Jun 20 16:03:00 2002 +++ lib/libc_r/uthread/uthread_condattr_pshared.c Thu Jun 20 16:34:23 2002 @@ -0,0 +1,57 @@ +/* + * Copyright (C) 2002 Chris Knight <chris@aims.com.au>. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice(s), this list of conditions and the following disclaimer as + * the first lines of this file unmodified other than the possible + * addition of one or more copyright notices. + * 2. Redistributions in binary form must reproduce the above copyright + * notice(s), this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER(S) ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR + * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE + * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, + * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * $FreeBSD$ + */ +#include <stdlib.h> +#include <errno.h> +#ifdef _THREAD_SAFE +#include <pthread.h> +#include "pthread_private.h" + +#if defined(_POSIX_THREAD_PROCESS_SHARED) +int +pthread_condattr_getpshared(pthread_condattr_t *attr, int *pshared) +{ + /* not possible to share a condvar, return private */ + *pshared = PTHREAD_PROCESS_PRIVATE; + return (ESUCCESS); +} + +int +pthread_condattr_setpshared(pthread_condattr_t *attr, int pshared) +{ + int ret = EINVAL; + + /* not possible to share a condvar, return success if set private */ + if (pshared == PTHREAD_PROCESS_PRIVATE) + ret = ESUCCESS; + return (ret); +} +#endif +#endif --- /dev/null Thu Jun 20 16:03:00 2002 +++ lib/libc_r/uthread/uthread_mutexattr_pshared.c Thu Jun 20 16:36:55 2002 @@ -0,0 +1,57 @@ +/* + * Copyright (C) 2002 Chris Knight <chris@aims.com.au>. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice(s), this list of conditions and the following disclaimer as + * the first lines of this file unmodified other than the possible + * addition of one or more copyright notices. + * 2. Redistributions in binary form must reproduce the above copyright + * notice(s), this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER(S) ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR + * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE + * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, + * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * $FreeBSD$ + */ +#include <stdlib.h> +#include <errno.h> +#ifdef _THREAD_SAFE +#include <pthread.h> +#include "pthread_private.h" + +#if defined(_POSIX_THREAD_PROCESS_SHARED) +int +pthread_mutexattr_getpshared(pthread_mutexattr_t *attr, int *pshared) +{ + /* not possible to share a mutex, return private */ + *pshared = PTHREAD_PROCESS_PRIVATE; + return (ESUCCESS); +} + +int +pthread_mutexattr_setpshared(pthread_mutexattr_t *attr, int pshared) +{ + int ret = EINVAL; + + /* not possible to share a mutex, return success if set private */ + if (pshared == PTHREAD_PROCESS_PRIVATE) + ret = ESUCCESS; + return (ret); +} +#endif +#endif
Responsible Changed From-To: freebsd-bugs->freebsd-threads Assign to threads mailing list
State Changed From-To: open->suspended Awaiting patches.
See r296162