cvs commit: src/lib/libc/gen Makefile.inc errlst.c src/lib/libc/i386/sys cerror.S ptrace.S src/lib/libc/sys Makefile.inc __error.c src/lib/libc_r/sys Makefile.inc uthread_error.c src/lib/libc_r/uthread Makefile.inc ...

Joerg Sonnenberger joerg at britannica.bec.de
Tue May 3 11:18:54 PDT 2005


On Tue, May 03, 2005 at 11:14:59AM -0700, Matthew Dillon wrote:
> 
> :I'm not sure if we can make e.g. strtok simply thread safe by using
> :TLS, but I want to use it to get e.g. the resolver fully thread-safe.
> :This is also the right time to work on our NSS implementation. Once
> :that works, we can move rpc, yp and perhaps even the resolver out of
> :libc.
> :
> :Joerg
> 
>     Sure we can:
> 
> char *
> strtok(char *s, const char *delim)
> {
>     static char *last;
>     
>     return strtok_r(s, delim, &last);
> }
> 
>     To
> 
> char *
> strtok(char *s, const char *delim)
> {
>     __thread static char *last;
>     
>     return strtok_r(s, delim, &last);
> }
> 
>     Poof.  Thread safe.

But with a different semantic in a threaded environment.
That's why we have to be a bit careful. Unlikely to be a
problem here, but something we have to keep in mind.

Joerg





More information about the Commits mailing list