This is the mail archive of the newlib@sourceware.org mailing list for the newlib project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: pthread.h: Add missing PTHREAD_RWLOCK_INITIALIZER


On 11/12/2012 11:51 AM, Corinna Vinschen wrote:
On Nov 12 18:44, Ralf Corsepius wrote:
On 11/12/2012 06:19 PM, Joel Sherrill wrote:
Hi

Attached is a very simple 1 line patch which adds the
missing constant PTHREAD_RWLOCK_INITIALIZER and
makes it have the same value as the other similar
constants.

OK to commit?
No.

2012-11-12 Joel Sherrill <joel.sherrill@oarcorp.com>

* libc/include/pthread.h: Add PTHREAD_RWLOCK_INITIALIZER.

Is it your intention to initialize to -1?

If so, initialization to 0xffffffff would not return -1 on platforms
with size > 32 bit.

Also, your construct would fail on platforms with sizeof(ptr) < 32bit.
sys/types.h defines pthread_rwlock_t as __uint32_t.

The Open Group page I cited has the intended usage and it is NOT about a pointer.

pthread_rwlock_t rwlock=PTHREAD_RWLOCK_INITIALIZER;

All PTHREAD_XXX_INITIALIZER values are defined by Open Group to be used
the same  way.  newlib's pthread.h has macros which define them exactly
the same way.

FWIW: Sorry if someone got this twice. The mail list manager rejected it because
the Open Group example resulted in the message being in html, not text.
Corinna



--
Joel Sherrill, Ph.D.             Director of Research&  Development
joel.sherrill@OARcorp.com        On-Line Applications Research
Ask me about RTEMS: a free RTOS  Huntsville AL 35805
    Support Available             (256) 722-9985


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]