This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: C11 threads ABI questions - enum values
- From: Juan Manuel Torres Palma <j dot m dot torrespalma at gmail dot com>
- To: Rich Felker <dalias at libc dot org>
- Cc: libc-alpha at sourceware dot org
- Date: Thu, 2 Oct 2014 20:42:25 +0200
- Subject: Re: C11 threads ABI questions - enum values
- Authentication-results: sourceware.org; auth=none
- References: <20140727203825 dot GA13146 at brightrain dot aerifal dot cx> <alpine dot LNX dot 2 dot 00 dot 1408181622440 dot 743 at monopod dot intra dot ispras dot ru> <20140818192714 dot GS12888 at brightrain dot aerifal dot cx> <20141001211308 dot 88F742C397E at topped-with-meat dot com> <20141001211606 dot GN23797 at brightrain dot aerifal dot cx> <20141001213022 dot 798942C3AAD at topped-with-meat dot com> <20141002001720 dot GO23797 at brightrain dot aerifal dot cx> <CAD82F-q1n9f35dGU86HUwZ4fSGdVageQ=ankpJXVwrUSJk5o0g at mail dot gmail dot com> <20141002145720 dot GQ23797 at brightrain dot aerifal dot cx>
> "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.