building pjproject with musl (and suggested fixes)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

I tried build pjproject on Alpine Linux (musl libc) and got a couple or
compile errors that seems trivial to fix:

../src/pj/os_core_unix.c: In function 'init_mutex':
../src/pj/os_core_unix.c:1107:40: error: 'PTHREAD_MUTEX_FAST_NP' undeclared (first use in this function)
  rc = pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_FAST_NP);
                                        ^

It seems like PTHREAD_MUTEXT_FAST_NP is not specified in the posix standard:
http://www.unix.com/man-page/POSIX/3posix/pthread_mutexattr_settype/


When looking at GNU libc sources it looks like PTHREAD_MUTEX_FAST_NP is
a synonym with the POSIX's PTHREAD_MUTEX_NORMAL:
http://code.woboq.org/userspace/glibc/nptl/sysdeps/pthread/pthread.h.html#41

I suggest that we just replace PTHREAD_MUTEX_FAST_NP with
PTHREAD_MUTEX_NORMAL. (looks like the #ifdef spagethi there could be
simplified too while at it)

Same with PTHREAD_MUTEX_RECURSIVE_NP and PTHREAD_MUTEX_RECURSIVE.


Next error was due to the use of an internal struct field
__sched_priority:

../src/samples/siprtp.c:1136:7: error: 'struct sched_param' has no member named '__sched_priority'
     tp.__sched_priority = max_prio;
       ^

variables and fields that starts with __ are for internal use and
should in general not be used in applications. Looking at what POSIX
says about it:

The <sched.h> header shall define the sched_param structure, which contains the scheduling parameters required for implementation of each supported scheduling policy. This structure shall contain at least the following member:

[THR]
int       sched_priority        Process or thread execution scheduling priority. 
[Option End]

http://pubs.opengroup.org/onlinepubs/007904975/basedefs/sched.h.html


It looks like GNU libc defines macro for it:
http://code.metager.de/source/xref/google/chromiumos/third_party/glibc/posix/sched.h#34

So I suggest replace __sched_priority with sched_priority.

After fixing those in my source tree, it built. You have done a great
work when it comes to portability!

Thanks!

-nc





[Index of Archives]     [Asterisk Users]     [Asterisk App Development]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [Linux API]
  Powered by Linux