[zeromq-dev] libzmq and TLS (thread local static) ?

Laurent Alebarde l.alebarde at free.fr
Wed Jan 29 14:39:46 CET 2014

Hi Devs,

I assume every function in the libzmq API is thread safe, but there are 
static variables in the code and no use of __thread ? Are all static 
variables defined in libzmq global to all threads ?

If I add a static variable which need to be thread local, say inside 
zmq::proxy, is it all right to add something like this in zmq.h ?

#if (__cplusplus > 199711L) || (defined(__STDCXX_VERSION__) && 
(__STDCXX_VERSION__ >= 201001L))
#define _TTHREAD_CPP0X_

#if !defined(_TTHREAD_CPP0X_) && !defined(thread_local)
#if defined(__GNUC__) || defined(__INTEL_COMPILER) || 
defined(__SUNPRO_CC) || defined(__IBMCPP__)
#define thread_local __thread
#define thread_local __declspec(thread)

Found here: 
About __thread and thread_local: 


static __thread char *p;


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.zeromq.org/pipermail/zeromq-dev/attachments/20140129/38beb740/attachment.htm>

More information about the zeromq-dev mailing list