diff options
author | Andreas Schneider <asn@cryptomilk.org> | 2013-07-14 12:34:30 +0200 |
---|---|---|
committer | Andreas Schneider <asn@cryptomilk.org> | 2013-07-14 12:36:35 +0200 |
commit | 73309f19e582a712e78f54988fc51dbc5ab60bf4 (patch) | |
tree | ced9f0106753410aed6ab49d134936acbea0f65e | |
parent | 6ad80bb4b2c1680e9447703b55b6a97b345e1f37 (diff) | |
download | libssh-73309f19e582a712e78f54988fc51dbc5ab60bf4.tar.gz libssh-73309f19e582a712e78f54988fc51dbc5ab60bf4.tar.xz libssh-73309f19e582a712e78f54988fc51dbc5ab60bf4.zip |
cmake: Check if we have Thread Local Storage support.
-rw-r--r-- | ConfigureChecks.cmake | 14 | ||||
-rw-r--r-- | config.h.cmake | 3 | ||||
-rw-r--r-- | include/libssh/priv.h | 8 |
3 files changed, 25 insertions, 0 deletions
diff --git a/ConfigureChecks.cmake b/ConfigureChecks.cmake index b0485d9..f73fc56 100644 --- a/ConfigureChecks.cmake +++ b/ConfigureChecks.cmake @@ -165,6 +165,20 @@ if (CMAKE_HAVE_THREADS_LIBRARY) endif (CMAKE_HAVE_THREADS_LIBRARY) # OPTIONS +check_c_source_compiles(" +__thread int tls; + +int main(void) { + return 0; +}" HAVE_GCC_THREAD_LOCAL_STORAGE) + +check_c_source_compiles(" +__declspec(thread) int tls; + +int main(void) { + return 0; +}" HAVE_MSC_THREAD_LOCAL_STORAGE) + if (WITH_DEBUG_CRYPTO) set(DEBUG_CRYPTO 1) endif (WITH_DEBUG_CRYPTO) diff --git a/config.h.cmake b/config.h.cmake index cea26f0..0c7c0ac 100644 --- a/config.h.cmake +++ b/config.h.cmake @@ -120,6 +120,9 @@ /**************************** OPTIONS ****************************/ +#cmakedefine HAVE_GCC_THREAD_LOCAL_STORAGE 1 +#cmakedefine HAVE_MSC_THREAD_LOCAL_STORAGE 1 + /* Define to 1 if you want to enable GSSAPI */ #cmakedefine WITH_GSSAPI 1 diff --git a/include/libssh/priv.h b/include/libssh/priv.h index 7168cf5..d797402 100644 --- a/include/libssh/priv.h +++ b/include/libssh/priv.h @@ -130,6 +130,14 @@ int gettimeofday(struct timeval *__p, void *__t); #endif #endif +#if defined(HAVE_GCC_THREAD_LOCAL_STORAGE) +# define LIBSSH_THREAD __thread +#elif defined(HAVE_MSC_THREAD_LOCAL_STORAGE) +# define LIBSSH_THREAD __declspec(thread) +#else +# define LIBSSH_THREAD +#endif + #define enter_function() (void)session #define leave_function() (void)session |