From: Navarrop Date: Fri, 22 Apr 2011 14:54:10 +0000 (+0200) Subject: Check if __thread is available. X-Git-Tag: v3_6_rc3~105 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/e67e55eccc3bc7d8597219ff9a4b5d91eadc6569 Check if __thread is available. --- diff --git a/CMakeLists.txt b/CMakeLists.txt index 4991906dc8..9fd7c9c67d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -23,7 +23,6 @@ set(GCC_NEED_VERSION "4.0") ### SET THE LIBRARY EXTENSION AND GCC VERSION if(APPLE) #MAC - set(GCC_NEED_VERSION "4.5") set(LIB_EXE "dylib") else(APPLE) if(WIN32) #WINDOWS diff --git a/buildtools/Cmake/CompleteInFiles.cmake b/buildtools/Cmake/CompleteInFiles.cmake index 842a2c67c8..d067965679 100644 --- a/buildtools/Cmake/CompleteInFiles.cmake +++ b/buildtools/Cmake/CompleteInFiles.cmake @@ -83,6 +83,15 @@ CHECK_FUNCTION_EXISTS(vasprintf HAVE_VASPRINTF) CHECK_FUNCTION_EXISTS(makecontext HAVE_MAKECONTEXT) CHECK_FUNCTION_EXISTS(mmap HAVE_MMAP) +#Check if __thread is defined +exec_program("${CMAKE_C_COMPILER} -lpthread ${CMAKE_HOME_DIRECTORY}/buildtools/Cmake/test_prog/prog_thread_storage.c" + OUTPUT_VARIABLE HAVE_thread_storage_run) +if(HAVE_thread_storage_run) + set(HAVE_THREAD_LOCAL_STORAGE 0) +else(HAVE_thread_storage_run) + set(HAVE_THREAD_LOCAL_STORAGE 1) +endif(HAVE_thread_storage_run) + # Our usage of mmap is Linux-specific (flag MAP_ANONYMOUS), but kFreeBSD uses a GNU libc IF(NOT "${CMAKE_SYSTEM}" MATCHES "Linux" AND NOT "${CMAKE_SYSTEM}" MATCHES "kFreeBSD") SET(HAVE_MMAP 0) diff --git a/buildtools/Cmake/gras_config.h.in b/buildtools/Cmake/gras_config.h.in index 4777ae1576..2443ae7aa1 100644 --- a/buildtools/Cmake/gras_config.h.in +++ b/buildtools/Cmake/gras_config.h.in @@ -16,6 +16,9 @@ #cmakedefine SIZEOF_INT @SIZEOF_INT@ #cmakedefine SIZEOF_VOIDP @SIZEOF_VOIDP@ +/* If __thread is available */ +#cmakedefine HAVE_THREAD_LOCAL_STORAGE @HAVE_THREAD_LOCAL_STORAGE@ + #ifndef __STRICT_ANSI__ #cmakedefine __STRICT_ANSI__ @__STRICT_ANSI__@ #endif diff --git a/include/simgrid_config.h.in b/include/simgrid_config.h.in index 8006704efa..4c1feb7d61 100644 --- a/include/simgrid_config.h.in +++ b/include/simgrid_config.h.in @@ -125,5 +125,9 @@ XBT_PUBLIC(char *) bprintf(const char *fmt, ...) _XBT_GNUC_PRINTF(1, 2); /* Tracking of latency bound */ #cmakedefine HAVE_LATENCY_BOUND_TRACKING @HAVE_LATENCY_BOUND_TRACKING@ +/* If __thread is available */ +#cmakedefine HAVE_THREAD_LOCAL_STORAGE @HAVE_THREAD_LOCAL_STORAGE@ + + SG_END_DECL() #endif /* SIMGRID_PUBLIC_CONFIG_H */ diff --git a/include/simix/context.h b/include/simix/context.h index 712b07a9e8..1cc8dd46ca 100644 --- a/include/simix/context.h +++ b/include/simix/context.h @@ -60,10 +60,6 @@ extern smx_ctx_factory_initializer_t smx_factory_initializer_to_use; extern char* smx_context_factory_name; extern int smx_context_stack_size; -#if defined(CONTEXT_THREADS) && !defined(APPLE) -#define HAVE_THREAD_LOCAL_STORAGE 1 -#endif - #ifdef HAVE_THREAD_LOCAL_STORAGE extern __thread smx_context_t smx_current_context; #else