Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 21 Jun 2010 00:52:15 +0200
From:      Jilles Tjoelker <jilles@stack.nl>
To:        Garrett Cooper <yanefbsd@gmail.com>
Cc:        standards@freebsd.org
Subject:   Re: Question over POSIX compliancy of pthread_once_t
Message-ID:  <20100620225215.GA4116@stack.nl>
In-Reply-To: <AANLkTinaZRQuNdKOpp-Ma50kHjbO45cOGq7ah521f9eS@mail.gmail.com>
References:  <AANLkTinaZRQuNdKOpp-Ma50kHjbO45cOGq7ah521f9eS@mail.gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help
On Sun, Jun 20, 2010 at 01:52:22AM -0700, Garrett Cooper wrote:
> PTHREAD_ONCE_INIT / pthread_once_t isn't tersely defined according to
> pthread(3) or sys/types.h at on the opengroup pages [1, 2, 3]

> FreeBSD defines it as follows:

> /usr/include/pthread.h:#define PTHREAD_ONCE_INIT   { PTHREAD_NEEDS_INIT, NULL }

> /* ... */

> /*
>  * Once definitions.
>  */
> struct pthread_once {
>         int             state;
>         pthread_mutex_t mutex;
> };

> glibc-2.7 has PTHREAD_ONCE_INIT defined differently [4]:

>   208 /* Single execution handling.  */
>   209 #define PTHREAD_ONCE_INIT 0

> I can't determine which one is semantically correct.

Both are correct in their respective implementations, as they are valid
initializers for the corresponding pthread_once_t. POSIX does not
require pthread_once_t to be an integer type, it may also be a struct.

-- 
Jilles Tjoelker



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20100620225215.GA4116>