This is the mail archive of the
crossgcc@sourceware.org
mailing list for the crossgcc project.
See the CrossGCC FAQ for lots
more information.
OSELAS.Toolchain-2011.03.0: PTHREAD_PRIO_INHERIT undeclared for arm-1136jfs-linux-gcc
- From: Daniel Lehne <daniel dot lehne at amk-drives dot bg>
- To: crossgcc at sourceware dot org
- Date: Wed, 04 Jan 2012 13:34:16 +0200
- Subject: OSELAS.Toolchain-2011.03.0: PTHREAD_PRIO_INHERIT undeclared for arm-1136jfs-linux-gcc
Hello,
in c++ the protocol PTHREAD_PRIO_INHERIT protocol for mutexes is
available, but for c it is not available.
I've traced it up to features.h which declares __USE_UNIX98 for
_XOPEN_SOURCE = 500. Once __USE_UNIX98 is set the protocols are
available in pthread.h. How it is activated by c++, i don't know. It is
confusing, because pthread_mutexattr_setprotocol() is declared but the
protocols not.
simple example - reproduce on compile everytime:
/* test of problem PTHREAD_PRIO_INHERIT undeclared in pthread.h (only in
gcc, cpp with g++ no problem) */
/* toolchain:
OSELAS.Toolchain-2011.03.0/arm-1136jfs-linux-gnueabi/gcc-4.5.2-glibc-2.13-binutils-2.21-kernel-2.6.36-sanitized/bin/arm-1136jfs-linux-gnueabi-gcc
*/
/* linked libs: pthread */
#include <pthread.h>
int main(int argc, char* argv[])
{
int iRet;
pthread_mutexattr_t csAttr;
iRet = pthread_mutexattr_init(&csAttr);
if (iRet == 0)
iRet = pthread_mutexattr_settype(&csAttr, PTHREAD_MUTEX_ERRORCHECK);
if (iRet == 0)
iRet = pthread_mutexattr_setprotocol(&csAttr,
PTHREAD_PRIO_INHERIT); // error: PTHREAD_PRIO_INHERIT undeclared
pthread_mutexattr_destroy(&csAttr);
return 0;
}
This example was build with the following configuration and output:
Building file: ../main.c
Invoking: GCC C Compiler
/opt/OSELAS.Toolchain-2011.03.0/arm-1136jfs-linux-gnueabi/gcc-4.5.2-glibc-2.13-binutils-2.21-kernel-2.6.36-sanitized/bin/arm-1136jfs-linux-gnueabi-gcc
-O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"main.d" -MT"main.d"
-o"main.o" "../main.c"
../main.c: In function 'main':
../main.c:14:51: error: 'PTHREAD_PRIO_INHERIT' undeclared (first use in
this function)
../main.c:14:51: note: each undeclared identifier is reported only once
for each function it appears in
make: *** [main.o] Error 1
make: Target `all' not remade because of errors.
Why this protocol is only for __USE_UNIX98 allowed? Is there a solution
to use this protocol PTHREAD_PRIO_INHERIT with gcc?
Best regards!
--
For unsubscribe information see http://sourceware.org/lists.html#faq