From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 24328 invoked by alias); 4 Jan 2012 18:06:48 -0000 Received: (qmail 24316 invoked by uid 22791); 4 Jan 2012 18:06:47 -0000 X-SWARE-Spam-Status: No, hits=-2.5 required=5.0 tests=AWL,BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW X-Spam-Check-By: sourceware.org Received: from mail-iy0-f169.google.com (HELO mail-iy0-f169.google.com) (209.85.210.169) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 04 Jan 2012 18:06:34 +0000 Received: by iacb35 with SMTP id b35so36330674iac.0 for ; Wed, 04 Jan 2012 10:06:33 -0800 (PST) Received: by 10.50.85.199 with SMTP id j7mr68766165igz.25.1325700393525; Wed, 04 Jan 2012 10:06:33 -0800 (PST) Received: from sakrah.homelinux.org (99-57-141-118.lightspeed.sntcca.sbcglobal.net. [99.57.141.118]) by mx.google.com with ESMTPS id g7sm16384451igv.7.2012.01.04.10.06.31 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 04 Jan 2012 10:06:32 -0800 (PST) Date: Wed, 04 Jan 2012 18:06:00 -0000 From: Khem Raj To: Daniel Lehne Cc: crossgcc@sourceware.org Subject: Re: OSELAS.Toolchain-2011.03.0: PTHREAD_PRIO_INHERIT undeclared for arm-1136jfs-linux-gcc Message-ID: <20120104180655.GC32676@sakrah.homelinux.org> References: <4F043938.80908@amk-drives.bg> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <4F043938.80908@amk-drives.bg> User-Agent: Mutt/1.5.20 (2009-06-14) X-IsSubscribed: yes Mailing-List: contact crossgcc-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: crossgcc-owner@sourceware.org X-SW-Source: 2012-01/txt/msg00009.txt.bz2 On (04/01/12 13:34), Daniel Lehne wrote: > 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 > > 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? add #define _GNU_SOURCE at the top of your source file. -- For unsubscribe information see http://sourceware.org/lists.html#faq