Subject: Re: THREAD SAFETY section
To: Todd Vierling <tv@pobox.com>
From: Klaus Klein <kleink@ira.uka.de>
List: tech-userlevel
Date: 09/11/1998 23:26:21
Todd Vierling <tv@pobox.com> writes:
> On 11 Sep 1998, Klaus Klein wrote:
>
> : > For instance, strtok() would be hard to make make thread-safe, I
> : > think.
>
> Partly, that's why strtok_r() was invented in various standards.
>
> : It wouldn't be hard; allocating a piece of thread-specific storage to
> : store the internal `last' pointer is easy enough.
>
> If we want to do so; however, I believe that strtok() is specifically said
> to be unsafe in the SUS98 under threads anyway....
That's correct, it's not required to be reentrant, hence strtok_r(),
and due to its unfortunate design forcing you to tokenize one string
at a time, even when using thread-specific storage, strtok() hardly
qualifies for such a change.
There are, however, some interfaces not required to be reentrant that
may be worthwhile to be converted as described above, i.e. strerror()
comes to mind.