Logo ROOT  
Reference Guide
TMCtls.h
Go to the documentation of this file.
1// @(#)root/vmc:$Id$
2// Author: Ivana Hrivnacova, 29/04/2014
3
4/*************************************************************************
5 * Copyright (C) 2014, Rene Brun and Fons Rademakers. *
6 * All rights reserved. *
7 * *
8 * For the licensing terms see $ROOTSYS/LICENSE. *
9 * For the list of contributors see $ROOTSYS/README/CREDITS. *
10 *************************************************************************/
11
12// ********************************************************************
13// * License and Disclaimer *
14// * *
15// * The Geant4 software is copyright of the Copyright Holders of *
16// * the Geant4 Collaboration. It is provided under the terms and *
17// * conditions of the Geant4 Software License, included in the file *
18// * LICENSE and available at http://cern.ch/geant4/license . These *
19// * include a list of copyright holders. *
20// * *
21// * Neither the authors of this software system, nor their employing *
22// * institutes,nor the agencies providing financial support for this *
23// * work make any representation or warranty, express or implied, *
24// * regarding this software system or assume any liability for its *
25// * use. Please see the license in the file LICENSE and URL above *
26// * for the full disclaimer and the limitation of liability. *
27// * *
28// * This code implementation is the result of the scientific and *
29// * technical work of the GEANT4 collaboration. *
30// * By using, copying, modifying or distributing the software (or *
31// * any work based on the software) you agree to acknowledge its *
32// * use in resulting scientific publications, and indicate your *
33// * acceptance of all terms of the Geant4 Software license. *
34// ********************************************************************
35
36#ifndef ROOT_TMCtls
37#define ROOT_TMCtls
38
39// Thread Local Storage typedefs
40//
41// According to Geant4 tls.hh and G4Threading.hh
42
43// Always build with thread support but keep a possibility to introduce
44// a build option
45#define VMC_MULTITHREADED 1
46
47#if ( defined (VMC_MULTITHREADED) )
48
49#if (defined(__MACH__) && defined(__clang__) && defined(__x86_64__)) || (defined(__linux__) && defined(__clang__))
50#if (__has_feature(cxx_thread_local))
51#define TMCThreadLocalStatic static thread_local
52#define TMCThreadLocal thread_local
53#else
54#define TMCThreadLocalStatic static __thread
55#define TMCThreadLocal __thread
56#endif
57
58#elif ((defined(__linux__) || defined(__MACH__)) && !defined(__INTEL_COMPILER) && defined(__GNUC__) && \
59 (__GNUC__ >= 4 && __GNUC_MINOR__ < 9))
60#define TMCThreadLocalStatic static __thread
61#define TMCThreadLocal thread_local
62
63#elif ((defined(__linux__) || defined(__MACH__)) && !defined(__INTEL_COMPILER) && defined(__GNUC__) && \
64 (__GNUC__ >= 4 && __GNUC_MINOR__ >= 9) || \
65 __GNUC__ >= 5)
66#define TMCThreadLocalStatic static thread_local
67#define TMCThreadLocal thread_local
68
69#elif ((defined(__linux__) || defined(__MACH__)) && defined(__INTEL_COMPILER))
70#if (__INTEL_COMPILER >= 1500)
71#define TMCThreadLocalStatic static thread_local
72#define TMCThreadLocal thread_local
73#else
74#define TMCThreadLocalStatic static __thread
75#define TMCThreadLocal __thread
76#endif
77#else
78//# error "No Thread Local Storage (TLS) technology supported for this platform. Use sequential build !"
79#define TMCThreadLocalStatic static
80#define TMCThreadLocal
81#endif
82#else
83#define TMCThreadLocalStatic static
84#define TMCThreadLocal
85#endif
86
87#endif //ROOT_TMCtls