This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: C11 threads ABI questions - enum values


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]