]> granicus.if.org Git - p11-kit/commitdiff
Fix build against older pthreads implementations
authorBaruch Siach <baruch@tkos.co.il>
Mon, 5 May 2014 06:32:23 +0000 (09:32 +0300)
committerStef Walter <stef@thewalter.net>
Thu, 14 Aug 2014 15:37:49 +0000 (17:37 +0200)
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

common/compat.c

index 9314d20b356da606ea57c9361a4aaaf5232bd0b4..1c8ab876d0c8fdbaa1fb7deba2426795afb3ab6a 100644 (file)
 
 #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>