This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: threads.h implementation issues
- From: Rich Felker <dalias at libc dot org>
- To: Juan Manuel Torres Palma <j dot m dot torrespalma at gmail dot com>
- Cc: libc-alpha at sourceware dot org
- Date: Wed, 29 Oct 2014 09:16:23 -0400
- Subject: Re: threads.h implementation issues
- Authentication-results: sourceware.org; auth=none
- References: <CAD82F-r6+-rDWuKycWkAX1e_U0rFRh2CkURaigwqMTynSt7yaw at mail dot gmail dot com> <20141027221931 dot GN22465 at brightrain dot aerifal dot cx> <CAD82F-ro-Df6zHei_vR7_0szbGsm690p2xC+RTK=KVQ=+294Lg at mail dot gmail dot com>
On Wed, Oct 29, 2014 at 08:23:57AM +0100, Juan Manuel Torres Palma wrote:
> > 3. Cast int->uintptr_t->void*->uintptr_t->int to round-trip the int
> > result via a value of type void*. This assumes that any value of
> > int can be represented in uintptr_t, and that any value of
> > uintptr_t can be represented in void*. I think this is acceptable
> > but others may disagree.
>
> That worked amazingly good, thanks.
>
> > That should be fine, but you need to keep nanosleep out of the
> > namespace, so either use __nanosleep (if it exists) or an inline
> > syscall.
>
> I thought that nanosleep is part of <time.h> that is automatically
> included with threads.h, so there must be no namespace problems. If
> there is, please let me know why.
nanosleep is part of POSIX that's exposed by POSIX's version of
time.h. It's not part of ISO C and not in any namespace reserved by
ISO C.
> One more question. I made a function named __thrd_err_map, that I use
> to match errors between those received by pthread_* functions and is
> only used in the definition file (.c), so I'm also including
> <errno.h>. Any inconvenience on that?
Including it from where? It can't be included from threads.h. But it
shouldn't need to be. Mapping of errors needs to take place internally
in the library, not as part of the calling application.
Rich