[RFC] Fixing pthread_* namespace issues for thrd_* symbols

Szabolcs Nagy nsz@port70.net
Fri May 1 13:10:00 GMT 2015


* Juan Manuel Torres Palma <j.m.torrespalma@gmail.com> [2015-05-01 13:49:44 +0200]:
> > how do you plan to solve the namespace issue for the pthread types?
> 
> Most pthread types (some of them will be required for C11 types) are
> architecture dependent, so my plan was to create a new header file
> (keeping all the architecture dependent defines and types here)
> including definitions of types like __pthread_t.
> 
> Then the pthread.h will include it and do:
> typedef __pthread_mutex_t pthread__mutex_t;
> 

that will break the c++ abi of pthreads

(we had the same problem back when c11 threads were implemented
in musl libc and ended up duplicating the typedefs i think..
you may want to look at the discussions on the musl list around
the alternatives

i think the type duplication within the implementation is ok,
but not pedantically correct on the abstract c language level:
wrappers redeclare the __pthread* functions with incompatible
types to be able to pass c11 type pointers

for future reference: all types in libc api should have type tag
in the implementation reserved namespace (ie __ prefixed) to
allow fixes like c11 threads later despite the hideous c++ abi)

> For other types like pthread_t that basically are unsigned long, will
> just copy the type:
> typedef unsigned long thrd_t;
> 
> Cheers.
> 
> -- 
> Juan Manuel Torres Palma.
> Computer Science Student at Universidad de Granada.



More information about the Libc-alpha mailing list