[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: more support for multithread-safe libraries
From: |
Paul Eggert |
Subject: |
Re: more support for multithread-safe libraries |
Date: |
Mon, 15 Aug 2005 16:13:20 -0700 |
User-agent: |
Gnus/5.1007 (Gnus v5.10.7) Emacs/21.4 (gnu/linux) |
Bruno Haible <address@hidden> writes:
> Some multithread-safe libraries need not only locking, but also per-thread
> storage. I propose to add this module that provides TLS.
That sounds like a nice thing to add. Thanks. One quibble:
> # define gl_tls_key_init(NAME, DESTRUCTOR) \
> if (pthread_in_use ()) \
> { \
> if (pthread_key_create (&(NAME).key, DESTRUCTOR) != 0) \
> abort (); \
> } \
> else \
> (NAME).singlethread_value = NULL
This sort of macro will cause warnings with GCC and other compilers
if you use it in a context like this:
if (foo)
gl_tls_key_init (name, destructor);
because the compiler will warn about possible if-then-else nesting
problems. The usual do { ... } while (0) construct avoids this
problem.