null pthread_t

Terry Lambert tlambert2 at mindspring.com
Thu Jul 10 03:25:56 PDT 2003


Brooks Davis wrote:
> Since FreeBSD uses pointers instead of integers for pthread_t's, this
> generates warnings which go away if you replace -1 with NULL, but
> it seems like that is likely to do bad things on linux.  Is there a
> portable NULL-equivalent pthread_t?  I'm not seeing anything jump out at
> me in the headers.

pthread_t PTHREAD_NULL;	/* global NULL equivalent */

pthread_t ptr;


	...

	if( ptr == PTHREAD_NULL)

Basically, the type will be a BSS zero'ed global "NULL" in both
compilation environments, and the comparison will "just work"
because the type will be right.

-- Terry


More information about the freebsd-threads mailing list