From owner-freebsd-standards Sat Dec 28 11:45:30 2002 Delivered-To: freebsd-standards@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 96A6837B401 for ; Sat, 28 Dec 2002 11:45:22 -0800 (PST) Received: from h00609772adf0.ne.client2.attbi.com (h00609772adf0.ne.client2.attbi.com [24.61.43.152]) by mx1.FreeBSD.org (Postfix) with ESMTP id AE04E43EDC for ; Sat, 28 Dec 2002 11:45:21 -0800 (PST) (envelope-from rodrigc@attbi.com) Received: from h00609772adf0.ne.client2.attbi.com (localhost [127.0.0.1]) by h00609772adf0.ne.client2.attbi.com (8.12.6/8.12.6) with ESMTP id gBSJjaVK004190 for ; Sat, 28 Dec 2002 14:45:36 -0500 (EST) (envelope-from rodrigc@h00609772adf0.ne.client2.attbi.com) Received: (from rodrigc@localhost) by h00609772adf0.ne.client2.attbi.com (8.12.6/8.12.6/Submit) id gBSJjZMi004189 for freebsd-standards@freebsd.org; Sat, 28 Dec 2002 14:45:35 -0500 (EST) Date: Sat, 28 Dec 2002 14:45:35 -0500 From: Craig Rodrigues To: freebsd-standards@freebsd.org Subject: Re: pthread.h: improved _POSIX_THREAD_PROCESS_SHARED check Message-ID: <20021228194535.GA4161@attbi.com> References: <20021225215044.GA12788@attbi.com> <20021225221430.GA12969@attbi.com> <200212261928.gBQJShrr049276@khavrinen.lcs.mit.edu> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="AhhlLboLdkugWU4S" Content-Disposition: inline In-Reply-To: <200212261928.gBQJShrr049276@khavrinen.lcs.mit.edu> User-Agent: Mutt/1.4i Sender: owner-freebsd-standards@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG --AhhlLboLdkugWU4S Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Thu, Dec 26, 2002 at 02:28:43PM -0500, Garrett Wollman wrote: > This patch is probably in the wrong direction. The functions should > either be declared unconditionally, or they should not be declared at > all (depending on how close we are to having support for these > interfaces). > > Since these are trivial interfaces, I think the correct approach is > probably as follows: > > 1) Implement *_getpshared() as always returning PTHREAD_PROCESS_PRIVATE. > > 2) Implement *_setpshared() to return success if pshared is > PTHREAD_PROCESS_PRIVATE and [EINVAL] otherwise. > > -GAWollman OK, how about this. -- Craig Rodrigues http://www.gis.net/~craigr rodrigc@attbi.com --AhhlLboLdkugWU4S Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="pthread.diff" Index: include/pthread.h =================================================================== RCS file: /home/ncvs/src/include/pthread.h,v retrieving revision 1.25 diff -u -r1.25 pthread.h --- include/pthread.h 2002/03/23 17:24:53 1.25 +++ include/pthread.h 2002/12/28 19:22:54 @@ -204,10 +204,8 @@ int pthread_condattr_destroy(pthread_condattr_t *); int pthread_condattr_init(pthread_condattr_t *); -#if defined(_POSIX_THREAD_PROCESS_SHARED) -int pthread_condattr_getpshared(pthread_condattr_t *, int *); +int pthread_condattr_getpshared(const pthread_condattr_t *__restrict, int *__restrict); int pthread_condattr_setpshared(pthread_condattr_t *, int); -#endif int pthread_cond_broadcast(pthread_cond_t *); int pthread_cond_destroy(pthread_cond_t *); @@ -265,12 +263,10 @@ int pthread_setprio(pthread_t, int); void pthread_yield(void); -#if defined(_POSIX_THREAD_PROCESS_SHARED) -int pthread_mutexattr_getpshared(pthread_mutexattr_t *, - int *pshared); +int pthread_mutexattr_getpshared(pthread_mutexattr_t *__restrict, + int *__restrict pshared); int pthread_mutexattr_setpshared(pthread_mutexattr_t *, int pshared); -#endif int pthread_mutexattr_getprioceiling(pthread_mutexattr_t *, int *); Index: lib/libc_r/uthread/Makefile.inc =================================================================== RCS file: /home/ncvs/src/lib/libc_r/uthread/Makefile.inc,v retrieving revision 1.34 diff -u -r1.34 Makefile.inc --- lib/libc_r/uthread/Makefile.inc 2002/10/26 13:55:35 1.34 +++ lib/libc_r/uthread/Makefile.inc 2002/12/28 19:22:54 @@ -37,7 +37,9 @@ uthread_close.c \ uthread_cond.c \ uthread_condattr_destroy.c \ + uthread_condattr_getpshared.c \ uthread_condattr_init.c \ + uthread_condattr_setpshared.c \ uthread_connect.c \ uthread_creat.c \ uthread_create.c \ @@ -85,6 +87,8 @@ uthread_mutex_prioceiling.c \ uthread_mutex_protocol.c \ uthread_mutexattr_destroy.c \ + uthread_mutexattr_getpshared.c \ + uthread_mutexattr_setpshared.c \ uthread_nanosleep.c \ uthread_once.c \ uthread_open.c \ --AhhlLboLdkugWU4S Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="pthread2.diff" --- /dev/null Sat Dec 28 14:33:00 2002 +++ uthread_mutexattr_setpshared.c Sat Dec 28 14:33:16 2002 @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2002 Craig Rodrigues + * 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, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by Daniel Eischen. + * 4. Neither the name of the author nor the names of any co-contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY CRAIG RODRIGUES AND CONTRIBUTORS ``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 AUTHOR OR CONTRIBUTORS 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 +#include +#include "pthread_private.h" + +__weak_reference(_pthread_mutexattr_setpshared, pthread_mutexattr_setpshared); + +int +_pthread_mutexattr_setpshared(pthread_mutexattr_t *attr, int pshared) +{ + /* Only PTHREAD_PROCESS_PRIVATE is supported. */ + if ((attr == NULL) || (pshared != PTHREAD_PROCESS_PRIVATE)) { + errno = EINVAL; + return -1; + } + + return(0); +} --- /dev/null Sat Dec 28 14:33:00 2002 +++ uthread_mutexattr_getpshared.c Sat Dec 28 14:19:46 2002 @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2002 Craig Rodrigues + * 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, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by Daniel Eischen. + * 4. Neither the name of the author nor the names of any co-contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY DANIEL EISCHEN AND CONTRIBUTORS ``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 AUTHOR OR CONTRIBUTORS 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 +#include +#include "pthread_private.h" + +__weak_reference(_pthread_mutexattr_getpshared, pthread_mutexattr_getpshared); + +int +_pthread_mutexattr_getpshared(const pthread_attr_t *__restrict attr, int *__restrict pshared) +{ + if ((attr == NULL) || (pshared == NULL)) { + errno = EINVAL; + return -1; + } + *pshared = PTHREAD_PROCESS_PRIVATE; + return 0; +} --- /dev/null Sat Dec 28 14:33:00 2002 +++ uthread_condattr_getpshared.c Sat Dec 28 14:07:59 2002 @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2002 Craig Rodrigues + * 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, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by Daniel Eischen. + * 4. Neither the name of the author nor the names of any co-contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY DANIEL EISCHEN AND CONTRIBUTORS ``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 AUTHOR OR CONTRIBUTORS 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 +#include +#include "pthread_private.h" + +__weak_reference(_pthread_condattr_getpshared, pthread_condattr_getpshared); + +int +_pthread_condattr_getpshared(const pthread_attr_t *__restrict attr, int *__restrict pshared) +{ + if ((attr == NULL) || (pshared == NULL)) { + errno = EINVAL; + return -1; + } + *pshared = PTHREAD_PROCESS_PRIVATE; + return 0; +} --- /dev/null Sat Dec 28 14:33:00 2002 +++ uthread_condattr_setpshared.c Sat Dec 28 14:33:54 2002 @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2002 Craig Rodrigues + * 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, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by Daniel Eischen. + * 4. Neither the name of the author nor the names of any co-contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY CRAIG RODRIGUES AND CONTRIBUTORS ``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 AUTHOR OR CONTRIBUTORS 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 +#include +#include "pthread_private.h" + +__weak_reference(_pthread_condattr_setpshared, pthread_condattr_setpshared); + +int +_pthread_condattr_setpshared(pthread_condattr_t *attr, int pshared) +{ + /* Only PTHREAD_PROCESS_PRIVATE is supported. */ + if ((attr == NULL) || (pshared != PTHREAD_PROCESS_PRIVATE)) { + errno = EINVAL; + return -1; + } + + return(0); +} --AhhlLboLdkugWU4S-- To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-standards" in the body of the message