Baruch Siach | 4d7249b | 2014-05-05 13:34:48 +0300 | [diff] [blame] | 1 | From 05b6a7550756ffdced25a6c51cf2222bad9e59e7 Mon Sep 17 00:00:00 2001 |
| 2 | Message-Id: <05b6a7550756ffdced25a6c51cf2222bad9e59e7.1399285491.git.baruch@tkos.co.il> |
| 3 | From: Baruch Siach <baruch@tkos.co.il> |
| 4 | Date: Mon, 5 May 2014 09:32:23 +0300 |
| 5 | Subject: [PATCH] Fix build against older pthreads implementations |
| 6 | |
| 7 | Older pthreads implementations like glibc NPTL prior to version 2.12, and |
| 8 | uClibc linuxthreads (both), need _XOPEN_SOURCE to expose |
| 9 | pthread_mutexattr_settype() and THREAD_MUTEX_DEFAULT. The value 600 (SuSv3, |
| 10 | POSIX.1-2001) is equivalent to _POSIX_C_SOURCE 200112L. |
| 11 | |
| 12 | Fixes the following build error: |
| 13 | |
| 14 | CC compat.lo |
| 15 | compat.c: In function 'p11_mutex_init': |
| 16 | compat.c:164:2: warning: implicit declaration of function 'pthread_mutexattr_settype' [-Wimplicit-function-declaration] |
| 17 | compat.c:164:2: warning: nested extern declaration of 'pthread_mutexattr_settype' [-Wnested-externs] |
| 18 | compat.c:164:36: error: 'PTHREAD_MUTEX_DEFAULT' undeclared (first use in this function) |
| 19 | |
| 20 | Patch status: sent upstream |
| 21 | |
| 22 | Signed-off-by: Baruch Siach <baruch@tkos.co.il> |
| 23 | --- |
| 24 | common/compat.h | 6 ++++++ |
| 25 | common/message.c | 6 ------ |
| 26 | 2 files changed, 6 insertions(+), 6 deletions(-) |
| 27 | |
| 28 | diff --git a/common/compat.h b/common/compat.h |
| 29 | index d7fe414a46bf..fbc1dc1d4f0f 100644 |
| 30 | --- a/common/compat.h |
| 31 | +++ b/common/compat.h |
| 32 | @@ -37,6 +37,12 @@ |
| 33 | |
| 34 | #include "config.h" |
| 35 | |
| 36 | +/* |
| 37 | + * Oh god. glibc is nasty. Changes behavior and definitions of POSIX |
| 38 | + * functions to completely different signatures depending on defines |
| 39 | + */ |
| 40 | +#define _XOPEN_SOURCE 600 |
| 41 | + |
| 42 | #include <sys/types.h> |
| 43 | #include <sys/stat.h> |
| 44 | |
| 45 | diff --git a/common/message.c b/common/message.c |
| 46 | index 35f2764487a9..e68dfac561c8 100644 |
| 47 | --- a/common/message.c |
| 48 | +++ b/common/message.c |
| 49 | @@ -37,12 +37,6 @@ |
| 50 | |
| 51 | #include "config.h" |
| 52 | |
| 53 | -/* |
| 54 | - * Oh god. glibc is nasty. Changes behavior and definitions of POSIX |
| 55 | - * functions to completely different signatures depending on defines |
| 56 | - */ |
| 57 | -#define _POSIX_C_SOURCE 200112L |
| 58 | - |
| 59 | #include "compat.h" |
| 60 | #define P11_DEBUG_FLAG P11_DEBUG_LIB |
| 61 | #include "debug.h" |
| 62 | -- |
| 63 | 2.0.0.rc0 |
| 64 | |