Skip to content

Commit

Permalink
Added TMCThreadLocalStatic type (according to Geant4 tls.hh)
Browse files Browse the repository at this point in the history
  • Loading branch information
ihrivnac committed Sep 15, 2017
1 parent 3c545d9 commit 7218db3
Showing 1 changed file with 35 additions and 10 deletions.
45 changes: 35 additions & 10 deletions montecarlo/vmc/inc/TMCtls.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,19 +45,44 @@
#define VMC_MULTITHREADED 1

#if ( defined (VMC_MULTITHREADED) )
#if ( ( defined(__MACH__) && defined(__clang__) && defined(__x86_64__) ) || \
( defined(__MACH__) && defined(__GNUC__) && __GNUC__>=4 && __GNUC_MINOR__>=7 ) || \
defined(__linux__) || defined(_AIX) ) && ( !defined(__CINT__) )
// #if ( defined(__linux__) ) && ( !defined(__CINT__) )
// Multi-threaded build: for POSIX systems
#include <pthread.h>
#define TMCThreadLocal __thread

#if ( defined(__MACH__) && defined(__clang__) && defined(__x86_64__) ) || \
( defined(__linux__) && defined(__clang__) )
#if (__has_feature(cxx_thread_local))
# define TMCThreadLocalStatic static thread_local
# define TMCThreadLocal thread_local
#else
# define TMCThreadLocalStatic static __thread
# define TMCThreadLocal __thread
#endif

#elif ( (defined(__linux__) || defined(__MACH__)) && \
!defined(__INTEL_COMPILER) && defined(__GNUC__) && (__GNUC__>=4 && __GNUC_MINOR__<9))
# define TMCThreadLocalStatic static __thread
# define TMCThreadLocal thread_local

#elif ( (defined(__linux__) || defined(__MACH__)) && \
!defined(__INTEL_COMPILER) && defined(__GNUC__) && (__GNUC__>=4 && __GNUC_MINOR__>=9) || __GNUC__>=5 )
# define TMCThreadLocalStatic static thread_local
# define TMCThreadLocal thread_local

#elif ( (defined(__linux__) || defined(__MACH__)) && \
defined(__INTEL_COMPILER) )
#if (__INTEL_COMPILER>=1500)
# define TMCThreadLocalStatic static thread_local
# define TMCThreadLocal thread_local
#else
# define TMCThreadLocalStatic static __thread
# define TMCThreadLocal __thread
#endif
#else
//# error "No Thread Local Storage (TLS) technology supported for this platform. Use sequential build !"
#define TMCThreadLocal
//# error "No Thread Local Storage (TLS) technology supported for this platform. Use sequential build !"
# define TMCThreadLocalStatic static
# define TMCThreadLocal
#endif
#else
#define TMCThreadLocal
# define TMCThreadLocalStatic static
# define TMCThreadLocal
#endif

#endif //ROOT_TMCtls

0 comments on commit 7218db3

Please sign in to comment.