2010-04-23 08:56:59     sem_timedwait and __USE_XOPEN2K

Document created by Aaronwu Employee on Sep 26, 2013
Version 1Show Document
  • View in full screen mode

2010-04-23 08:56:59     sem_timedwait and __USE_XOPEN2K

Jeppe Ledet-Pedersen (DENMARK)

Message: 88816   

 

Hi

 

I'm trying to port a piece of code from x86 to a blackfin, but when I compile the code using bfin-linux-uclibc-gcc i get "implicit declaration of function ‘sem_timedwait’" errors. The code compiles without warnings or errors using regular gcc. I have tried with the newest bfin-linux-uclibc SVN snapshot toolchain, but the problem persists.

 

I have looked at semaphore.h in the include dir, and found sem_timedwait to be encapsulated in this check:

 

#ifdef __USE_XOPEN2K

extern int sem_timedwait (sem_t *__restrict __sem, __const struct timespec *__restrict __abstime);

#endif

 

I have looked at the man page for feature_test_macros to figure out what __USE_XOPEN2K means, but without luck.

 

Can you help me?

 

Thank you in advance.

 

/Jeppe

QuoteReplyEditDelete

 

 

2010-04-23 10:00:06     Re: sem_timedwait and __USE_XOPEN2K

Jeppe Ledet-Pedersen (DENMARK)

Message: 88819   

 

If I compile my program with -D_GNU_SOURCE it appears to work.

QuoteReplyEditDelete

 

 

2010-04-23 11:19:55     Re: sem_timedwait and __USE_XOPEN2K

Mike Frysinger (UNITED STATES)

Message: 88826   

 

the man page for the function explains how to properly get the prototype.

 

man sem_timedwait

<read the feature test macro section>

QuoteReplyEditDelete

 

 

2010-04-23 13:19:11     Re: sem_timedwait and __USE_XOPEN2K

Jeppe Ledet-Pedersen (DENMARK)

Message: 88833   

 

Yes, sem_timedwait() requires _POSIX_C_SOURCE >= 200112L or _XOPEN_SOURCE >= 600 to be defined. According to this site http://www.gnu.org/s/libc/manual/html_node/Feature-Test-Macros.html, defining _GNU_SOURCE should enable every extension. Is this the wrong approach?

QuoteReplyEditDelete

 

 

2010-04-23 13:22:03     Re: sem_timedwait and __USE_XOPEN2K

Mike Frysinger (UNITED STATES)

Message: 88834   

 

it's up to you to determine what is appropriate -- a GNU specific extension or a POSIX standard define

QuoteReplyEditDelete

 

 

2010-04-23 13:40:05     Re: sem_timedwait and __USE_XOPEN2K

Jeppe Ledet-Pedersen (DENMARK)

Message: 88835   

 

Ok, thanks Mike.

Attachments

    Outcomes