Tom Lane <[EMAIL PROTECTED]> writes:

> Greg Stark <[EMAIL PROTECTED]> writes:
> > On the other hand, things like, getpwnam, strtok, etc have non-thread-safe
> > APIs. They can never be made thread-safe. The *_r versions of these functions
> > are standardized and required. If they don't exist then the platform simply
> > does not support threads.
> 
> This statement is simply false.  A platform can build thread-safe
> versions of those "unsafe" APIs if it makes the return values point
> to thread-local storage.  Some BSDs do it that way.  Accordingly, any
> simplistic "we must have _r to be thread-safe" approach is incorrect.

Except there are standards that describe things like strtok_r and such. If the
OS doesn't have those standard functions at all then it probably doesn't have
a thread-safe strtok. 

Moreover I was somewhat disturbed when I read that in port/thread.c. It seems
rather a dramatic non-standard API change for these functions. It must break
programs and libraries that expect these to have global state accessible from
any thread. I suspect if I check back in the BSD mailing lists there were
flamewars over this at the time.

Generally I would prefer to use standards-dictated _r functions than depend on
non-standard thread-local api extensions. Especially since many platforms have
slow thread-local storage implementations.

In any case I think I'm bowing out of this discussion. It seems like a simple
matter has gotten way out of hand and I feel like a troll here. Sorry for
fueling the confusion.

-- 
greg


---------------------------(end of broadcast)---------------------------
TIP 2: you can get off all lists at once with the unregister command
    (send "unregister YourEmailAddressHere" to [EMAIL PROTECTED])

Reply via email to