Skip to content

Commit

Permalink
Fix build against older pthreads implementations
Browse files Browse the repository at this point in the history
Older pthreads implementations like glibc NPTL prior to version 2.12, and
uClibc linuxthreads (both), need _XOPEN_SOURCE to expose
pthread_mutexattr_settype() and THREAD_MUTEX_DEFAULT. The value 600 (SuSv3,
POSIX.1-2001) is equivalent to _POSIX_C_SOURCE 200112L.

Fixes the following build error:

  CC       compat.lo
compat.c: In function 'p11_mutex_init':
compat.c:164:2: warning: implicit declaration of function 'pthread_mutexattr_settype' [-Wimplicit-function-declaration]
compat.c:164:2: warning: nested extern declaration of 'pthread_mutexattr_settype' [-Wnested-externs]
compat.c:164:36: error: 'PTHREAD_MUTEX_DEFAULT' undeclared (first use in this function)

https://bugs.freedesktop.org/show_bug.cgi?id=82617
  • Loading branch information
baruchsiach authored and stefwalter committed Aug 14, 2014
1 parent ea10b26 commit bf8dfa9
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions common/compat.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,12 @@

#include "config.h"

/*
* This is needed to expose pthread_mutexattr_settype and PTHREAD_MUTEX_DEFAULT
* on older pthreads implementations
*/
#define _XOPEN_SOURCE 600

#include "compat.h"

#include <assert.h>
Expand Down

0 comments on commit bf8dfa9

Please sign in to comment.