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: Rich Felker <dalias at libc dot org>
- To: libc-alpha at sourceware dot org
- Date: Thu, 2 Oct 2014 10:57:20 -0400
- 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>
On Thu, Oct 02, 2014 at 09:12:13AM +0200, Juan Manuel Torres Palma wrote:
> Hi guys.
>
> I'm working on a early implementation at the moment since I'm done
> with my internship but I still have some doubts:
>
> -How can I use pthread_* functions for my threads.h functions? I
> guessed that would be including the pthread.h in threads.c but then we
> cannot map objects between both in header file.
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.
> -Is it some pthread refactoring needed? I remember a time ago somebody
> suggested that idea.
I think the glibc team would prefer that it be done without any actual
code refactoring in the same step as adding C11 threads. I'm not sure
if there's any that should be done as an earlier step, though. One
thing that comes to mind is the trouble of getting the 'int' return
value of threads out through the POSIX layer that uses 'void *' for
return values.
> I have a small and dummy standalone implementation working, not
> integrated in glibc code yet, but still have the issues that user can
> call pthread functions from main so i guess some help would be
> appreciated. I know these doubts are pretty simple but I'm some kind
> of newbie and I'm trying to learn the best way to solve it.
"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". :-)
Rich