Question over POSIX compliancy of pthread_once_t
Jilles Tjoelker
jilles at stack.nl
Sun Jun 20 22:52:16 UTC 2010
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
More information about the freebsd-standards
mailing list