--- Coro-Multicore/xthread.h 2015/06/29 16:00:36 1.2 +++ Coro-Multicore/xthread.h 2015/07/05 03:50:57 1.3 @@ -168,5 +168,17 @@ #endif +#if __linux && __GNUC__ >= 4 && __GLIBC__ >= 2 && __GLIBC_MINOR__ >= 9 +# define X_TLS_DECLARE(varname) __thread void *varname +# define X_TLS_INIT(varname) +# define X_TLS_SET(varname,value) varname = (value) +# define X_TLS_GET(varname) varname +#else +# define X_TLS_DECLARE(varname) pthread_key_t varname +# define X_TLS_INIT(varname) do { if (pthread_key_create (&(varname), 0)) abort (); } while (0) +# define X_TLS_SET(varname,value) pthread_setspecific (varname, (value)) +# define X_TLS_GET(varname) pthread_getspecific (varname) +#endif + #endif