POSIX barriers and rwlocks

Joel Sherrill joel.sherrill@oarcorp.com
Thu Jul 27 22:46:00 GMT 2006


Jeff Johnston wrote:

> Joel Sherrill wrote:
>
>> Hi,
>>
>> I am in the process of preparing a patch
>> to add POSIX barriers and rwlocks to newlib's
>> pthread.h and sys/types.h.
>> The glibc headers have them protected with the
>> ifdef __USE_XOPEN2K.  As far as I can tell, this
>> is always defined since a simple program which
>> doesn't define this can use barriers.
>>
>> How should these definitions be wrapper in newlib?
>>
>> --joel
>
>
> Glibc's features.h sets __USE_XOPEN2K if _POSIX_C_SOURCE is >= 
> 200112L.  _POSIX_C_SOURCE gets defaulted to 200112L if __STRICT_ANSI__ 
> is not defined or _XOPEN_SOURCE >= 600.
>
> I don't think newlib should go down the path that glibc did for all 
> the various compliance levels.  Thus, the wrapper could be something 
> simple and encompassing like __WANT_POSIX_APIS__ that can be used 
> generally in shared newlib header files for optional POSIX APIs.
>

Doing more research, I found 
http://people.redhat.com/~drepper/posix-option-groups.html and
it appears the OS conditional code in newlib's sys/features.h should 
define these as appropriate to
indicate functionality:

    * _POSIX_BARRIERS
    * _POSIX_SPIN_LOCKS
    * _POSIX_THREAD_CPUTIME
    * _POSIX_THREAD_SPORADIC_SERVER


Right now sys/features.h defines the appropriate POSIX flags and 
pthread.h just trips prototypes
from those. So I  believe it would be consistent to just do that for 
these as well.

FWIW Ulrich's page seems to be the clearest listing of these flags I 
have ever seen. :)

--joel

> -- Jeff J.




More information about the Newlib mailing list