C11 threads ABI questions - enum values

Juan Manuel Torres Palma j.m.torrespalma@gmail.com
Thu Oct 2 18:42:00 GMT 2014


> "Standalone implementations" like this are pretty easy to do because
> they avoid all of the issues that make it difficult, but they can't
> conform to the requirements of C. I don't mean to discourage you, just
> to say that "most of the hard work is ahead". :-)

No, It doesn't discourage me at all but motivates me to keep learning
and trying to understand how it all works since I'm pretty stubborn ;)

> No, that can't be done, because the pthread names are not valid to be
> exposed by threads.h. Also, the pthread function names cannot be
> exposed in the external namespace as a result of using the threads.h
> functions, so in order to implement C11 threads in terms of pthreads,
> you need to make namespace-safe (e.g. prefixed by __) names for all of
> the pthread functions you'll use, and call those instead from the
> implementations of the C11 functions.
>
> For the objects, you simply need to define them again with the same
> definitions.
>

Ok so if I'm not mistaken I have to rename all the pthreads functions
that I'm using in my code, like for example pthread_create to
__pthread_create in all pthread related files, and also create macros
to keep compatibility with pthread old code like:

#define pthread_create __pthread_create

and then in the threads.h code i can just do #undef of all them. Would
that be the correct approach?

PS: Is there any guide or manual to learn to write system libraries?
I'm used to write user applications and it's getting a little tough ;)

Cheers.


-- 
Juan Manuel "Lolo" Torres Palma.
Computer Science Student at Universidad de Granada.



More information about the Libc-alpha mailing list