Linux pthread_mutexattr_init?
Loic Domaigne
loic-dev@gmx.net
Tue Feb 1 06:14:00 GMT 2005
Hi!
> I'm using glibc-2.3.3 on i386 platform running kernel 2.6.11. The man
> page for pthread_mutexattr_init indicates I can use the
> PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP type of Mutex however the only
> type I can successfully build my program with is
> PTHREAD_MUTEX_INITIALIZER.
>
> #include <pthread.h>
> pthread_mutex_t Q_lock = PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP;
>
> Causes the following error when I compile my pgm with gcc.
>
> global.c:471: error: `PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP'
> undeclared here (not in a function)
>
>
> Is the man page incorrect? Does Linux/glibc support the
> PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP? If so is there a trick to using
> other than the default PTHREAD_MUTEX_INITIALIZER type of mutex?
It is not an error in the man page. You must enable the GNU extension with
the flag -D_GNU_SOURCE to gcc in order to access such non portable (hence
the ending in "_NP") features.
HTH,
Loic.
--
--
// Sender address goes to /dev/null (!!)
// Use my 32/64 bits, ANSI C89, compliant email-address instead:
unsigned y[]=
{0,34432,26811,16721,41866,63119,61007,48155,26147,10986};
void x(z){putchar(z);}; unsigned t;
main(i){if(i<10){t=(y[i]*47560)%65521;x(t>>8);x(t&255);main(++i);}}
GMX im TV ... Die Gedanken sind frei ... Schon gesehen?
Jetzt Spot online ansehen: http://www.gmx.net/de/go/tv-spot
More information about the Libc-alpha
mailing list