Date: Tue, 15 Mar 2005 22:31:28 -0500 (EST) From: Craig Rodrigues <rodrigc@crodrigues.org> To: FreeBSD-gnats-submit@freebsd.org Cc: freebsd-threads@freebsd.org Subject: <sys/types.h> does not define pthread types Message-ID: <200503160331.j2G3VSmV066994@h00609772adf0.ne.client2.attbi.com>
next in thread | raw e-mail | index | archive | help
>Submitter-Id: current-users >Originator: Craig Rodrigues >Organization: >Confidential: no >Synopsis: <sys/types.h> does not define pthread types >Severity: serious >Priority: medium >Category: standards >Class: sw-bug >Release: FreeBSD 6.0-CURRENT i386 >Environment: System: FreeBSD dibbler.crodrigues.org 6.0-CURRENT FreeBSD 6.0-CURRENT #0: Tue Mar 15 03:41:34 EST 2005 rodrigc@dibbler.crodrigues.org:/opt/home/rodrigc/xfs/xfs_kernel/sys/i386/compile/XFS_KERNEL i386 >Description: According to: http://www.opengroup.org/onlinepubs/009695399/basedefs/sys/types.h.html #include <sys/types.h> should include the definitions of pthread types. This was reported by Brooks Davis: http://lists.freebsd.org/pipermail/freebsd-threads/2005-March/002951.html FreeBSD's <sys/types> currently does not do this, breaking compilation of some software like GridEngine. Creating a new private <sys/_pthreadtypes.h> header file which is included by <sys/types.h> and <pthread.h> should solve this problem. >How-To-Repeat: >Fix: --- src/include/pthread.h.orig Tue Mar 15 11:10:39 2005 +++ src/include/pthread.h Tue Mar 15 22:08:29 2005 @@ -44,6 +44,7 @@ #include <sys/signal.h> #include <limits.h> #include <sched.h> +#include <sys/_pthreadtypes.h> /* * Run-time invariant values: @@ -81,62 +82,6 @@ #define PTHREAD_CANCEL_DEFERRED 0 #define PTHREAD_CANCEL_ASYNCHRONOUS 2 #define PTHREAD_CANCELED ((void *) 1) - -/* - * Forward structure definitions. - * - * These are mostly opaque to the user. - */ -struct pthread; -struct pthread_attr; -struct pthread_cond; -struct pthread_cond_attr; -struct pthread_mutex; -struct pthread_mutex_attr; -struct pthread_once; -struct pthread_rwlock; -struct pthread_rwlockattr; -struct pthread_barrier; -struct pthread_barrier_attr; -struct pthread_spinlock; - -/* - * Primitive system data type definitions required by P1003.1c. - * - * Note that P1003.1c specifies that there are no defined comparison - * or assignment operators for the types pthread_attr_t, pthread_cond_t, - * pthread_condattr_t, pthread_mutex_t, pthread_mutexattr_t. - */ -typedef struct pthread *pthread_t; -typedef struct pthread_attr *pthread_attr_t; -typedef struct pthread_mutex *pthread_mutex_t; -typedef struct pthread_mutex_attr *pthread_mutexattr_t; -typedef struct pthread_cond *pthread_cond_t; -typedef struct pthread_cond_attr *pthread_condattr_t; -typedef int pthread_key_t; -typedef struct pthread_once pthread_once_t; -typedef struct pthread_rwlock *pthread_rwlock_t; -typedef struct pthread_rwlockattr *pthread_rwlockattr_t; -typedef struct pthread_barrier *pthread_barrier_t; -typedef struct pthread_barrierattr *pthread_barrierattr_t; -typedef struct pthread_spinlock *pthread_spinlock_t; - -/* - * Additional type definitions: - * - * Note that P1003.1c reserves the prefixes pthread_ and PTHREAD_ for - * use in header symbols. - */ -typedef void *pthread_addr_t; -typedef void *(*pthread_startroutine_t)(void *); - -/* - * Once definitions. - */ -struct pthread_once { - int state; - pthread_mutex_t mutex; -}; /* * Flags for once initialization. --- src/sys/sys/_pthreadtypes.h.orig Tue Mar 15 22:13:13 2005 +++ src/sys/sys/_pthreadtypes.h Tue Mar 15 22:12:14 2005 @@ -0,0 +1,96 @@ +/* + * Copyright (c) 1993, 1994 by Chris Provenzano, proven@mit.edu + * Copyright (c) 1995-1998 by John Birrell <jb@cimlogic.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, 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 Chris Provenzano. + * 4. The name of Chris Provenzano may not be used to endorse or promote + * products derived from this software without specific prior written + * permission. + * + * THIS SOFTWARE IS PROVIDED BY CHRIS PROVENZANO ``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 CHRIS PROVENZANO 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$ + */ + +#ifndef _SYS__PTHREADTYPES_H_ +#define _SYS__PTHREADTYPES_H_ + +/* + * Forward structure definitions. + * + * These are mostly opaque to the user. + */ +struct pthread; +struct pthread_attr; +struct pthread_cond; +struct pthread_cond_attr; +struct pthread_mutex; +struct pthread_mutex_attr; +struct pthread_once; +struct pthread_rwlock; +struct pthread_rwlockattr; +struct pthread_barrier; +struct pthread_barrier_attr; +struct pthread_spinlock; + +/* + * Primitive system data type definitions required by P1003.1c. + * + * Note that P1003.1c specifies that there are no defined comparison + * or assignment operators for the types pthread_attr_t, pthread_cond_t, + * pthread_condattr_t, pthread_mutex_t, pthread_mutexattr_t. + */ +typedef struct pthread *pthread_t; +typedef struct pthread_attr *pthread_attr_t; +typedef struct pthread_mutex *pthread_mutex_t; +typedef struct pthread_mutex_attr *pthread_mutexattr_t; +typedef struct pthread_cond *pthread_cond_t; +typedef struct pthread_cond_attr *pthread_condattr_t; +typedef int pthread_key_t; +typedef struct pthread_once pthread_once_t; +typedef struct pthread_rwlock *pthread_rwlock_t; +typedef struct pthread_rwlockattr *pthread_rwlockattr_t; +typedef struct pthread_barrier *pthread_barrier_t; +typedef struct pthread_barrierattr *pthread_barrierattr_t; +typedef struct pthread_spinlock *pthread_spinlock_t; + +/* + * Additional type definitions: + * + * Note that P1003.1c reserves the prefixes pthread_ and PTHREAD_ for + * use in header symbols. + */ +typedef void *pthread_addr_t; +typedef void *(*pthread_startroutine_t)(void *); + +/* + * Once definitions. + */ +struct pthread_once { + int state; + pthread_mutex_t mutex; +}; + +#endif /* _SYS__PTHREADTYPES_H_ */ + --- src/sys/sys/types.h.orig Tue Mar 15 22:16:05 2005 +++ src/sys/sys/types.h Tue Mar 15 22:16:22 2005 @@ -44,6 +44,9 @@ #include <machine/endian.h> #include <sys/_types.h> +/* Pthread types */ +#include <sys/_pthreadtypes.h> + #if __BSD_VISIBLE typedef unsigned char u_char; typedef unsigned short u_short;
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200503160331.j2G3VSmV066994>