Andrew Piskorski uttered:

On Tue, Jun 27, 2006 at 04:14:37PM +0100, Christian Smith wrote:

Anyway, it's not difficult to provide thread local storage. HP-UX's
netdb.h functions (gethostbyname etc.) are fully re-entrant despite
returning 'static' data, for example. Other UNIXs got hamstrung with
various getXbyY_r implementations, with horrible semantics.

Well yes, the *_r functions are often pretty ugly to use.  But they
work great if what you want to do is build your own thread local
storage version on top!

I've always assumed there's some good reason for the existence and use
of *_r functions rather than equivalent thread local storage versions,
although I've never been sure just what it is.


Mainly because the _r functions were hacked by lazy types who couldn't be bothered to use TLS (or TLS wasn't available). The _r functions weren't particularly well thought out, leaving the client to allocate the storage (arguably good) without telling the client how big the storage has to actually be (definitely bad). It is this type of implementation issue that should be completely hidden from the client, hence my preferred use of TLS for 'static' buffers managed by the API.

Grr, I'm definitely sounding like I'm ranting now:)


Christian

--
    /"\
    \ /    ASCII RIBBON CAMPAIGN - AGAINST HTML MAIL
     X                           - AGAINST MS ATTACHMENTS
    / \

Reply via email to