1 From ba1057d74aac6c2dde5477bd6a2deea79f14962c Mon Sep 17 00:00:00 2001
2 From: Luca Ceresoli <luca@lucaceresoli.net>
3 Date: Sat, 12 Mar 2016 15:19:34 +0100
4 Subject: [PATCH 1/2] Use mutex types compatible with musl (fixes musl build)
6 PTHREAD_MUTEX_FAST_NP and PTHREAD_MUTEX_RECURSIVE_NP are not defined
7 in the musl C library. Use values that map to the same mutex type in
8 GNU libc and uClibc-ng.
10 Fixes the following build errors when building with musl:
12 ../src/pj/os_core_unix.c: In function 'init_mutex':
13 ../src/pj/os_core_unix.c:1128:40: error: 'PTHREAD_MUTEX_FAST_NP' undeclared (first use in this function)
14 rc = pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_FAST_NP);
16 ../src/pj/os_core_unix.c:1128:40: note: each undeclared identifier is reported only once for each function it appears in
17 ../src/pj/os_core_unix.c:1138:40: error: 'PTHREAD_MUTEX_RECURSIVE_NP' undeclared (first use in this function)
18 rc = pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE_NP);
22 http://git.alpinelinux.org/cgit/aports/plain/main/pjproject/musl-fixes.patch
24 Signed-off-by: Luca Ceresoli <luca@lucaceresoli.net>
26 pjlib/src/pj/os_core_unix.c | 4 ++--
27 1 file changed, 2 insertions(+), 2 deletions(-)
29 diff --git a/pjlib/src/pj/os_core_unix.c b/pjlib/src/pj/os_core_unix.c
30 index 1c87b2f..f08ba27 100644
31 --- a/pjlib/src/pj/os_core_unix.c
32 +++ b/pjlib/src/pj/os_core_unix.c
33 @@ -1125,7 +1125,7 @@ static pj_status_t init_mutex(pj_mutex_t *mutex, const char *name, int type)
34 if (type == PJ_MUTEX_SIMPLE) {
35 #if (defined(PJ_LINUX) && PJ_LINUX!=0) || \
36 defined(PJ_HAS_PTHREAD_MUTEXATTR_SETTYPE)
37 - rc = pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_FAST_NP);
38 + rc = pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_NORMAL);
39 #elif (defined(PJ_RTEMS) && PJ_RTEMS!=0) || \
40 defined(PJ_PTHREAD_MUTEXATTR_T_HAS_RECURSIVE)
41 /* Nothing to do, default is simple */
42 @@ -1135,7 +1135,7 @@ static pj_status_t init_mutex(pj_mutex_t *mutex, const char *name, int type)
44 #if (defined(PJ_LINUX) && PJ_LINUX!=0) || \
45 defined(PJ_HAS_PTHREAD_MUTEXATTR_SETTYPE)
46 - rc = pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE_NP);
47 + rc = pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE);
48 #elif (defined(PJ_RTEMS) && PJ_RTEMS!=0) || \
49 defined(PJ_PTHREAD_MUTEXATTR_T_HAS_RECURSIVE)
50 // Phil Torre <ptorre@zetron.com>: