Geant4  10.01.p01
tls.hh
Go to the documentation of this file.
1 //
2 // ********************************************************************
3 // * License and Disclaimer *
4 // * *
5 // * The Geant4 software is copyright of the Copyright Holders of *
6 // * the Geant4 Collaboration. It is provided under the terms and *
7 // * conditions of the Geant4 Software License, included in the file *
8 // * LICENSE and available at http://cern.ch/geant4/license . These *
9 // * include a list of copyright holders. *
10 // * *
11 // * Neither the authors of this software system, nor their employing *
12 // * institutes,nor the agencies providing financial support for this *
13 // * work make any representation or warranty, express or implied, *
14 // * regarding this software system or assume any liability for its *
15 // * use. Please see the license in the file LICENSE and URL above *
16 // * for the full disclaimer and the limitation of liability. *
17 // * *
18 // * This code implementation is the result of the scientific and *
19 // * technical work of the GEANT4 collaboration. *
20 // * By using, copying, modifying or distributing the software (or *
21 // * any work based on the software) you agree to acknowledge its *
22 // * use in resulting scientific publications, and indicate your *
23 // * acceptance of all terms of the Geant4 Software license. *
24 // ********************************************************************
25 //
26 // $Id$
27 //
28 // Thread Local Storage typedefs
29 
30 // History:
31 // 01.10.2012 G.Cosmo - Created
32 
33 #ifndef G4_TLS
34 #define G4_TLS
35 
36 #if defined (G4MULTITHREADED)
37  #if ( defined(__MACH__) && defined(__clang__) && defined(__x86_64__) ) || \
38  ( defined(__linux__) && defined(__clang__) )
39  #if (defined (G4USE_STD11) && __has_feature(cxx_thread_local))
40  # define G4ThreadLocalStatic static thread_local
41  # define G4ThreadLocal thread_local
42  #else
43  # define G4ThreadLocalStatic static __thread
44  # define G4ThreadLocal __thread
45  #endif
46  #elif ( (defined(__linux__) || defined(__MACH__)) && \
47  defined(__GNUC__) && __GNUC__>=4 && __GNUC_MINOR__<9 )
48  #if defined (G4USE_STD11)
49  # define G4ThreadLocalStatic static __thread
50  # define G4ThreadLocal thread_local
51  #else
52  # define G4ThreadLocalStatic static __thread
53  # define G4ThreadLocal __thread
54  #endif
55  #elif ( (defined(__linux__) || defined(__MACH__)) && \
56  defined(__GNUC__) && __GNUC__>=4 && __GNUC_MINOR__>=9 )
57  #if defined (G4USE_STD11)
58  # define G4ThreadLocalStatic static thread_local
59  # define G4ThreadLocal thread_local
60  #else
61  # define G4ThreadLocalStatic static __thread
62  # define G4ThreadLocal __thread
63  #endif
64  #elif ( (defined(__linux__) || defined(__MACH__)) && \
65  defined(__INTEL_COMPILER) )
66  #if (defined (G4USE_STD11) && __INTEL_COMPILER>=1500)
67  # define G4ThreadLocalStatic static thread_local
68  # define G4ThreadLocal thread_local
69  #else
70  # define G4ThreadLocalStatic static __thread
71  # define G4ThreadLocal __thread
72  #endif
73  #elif defined(_AIX)
74  #if defined (G4USE_STD11)
75  # define G4ThreadLocalStatic static thread_local
76  # define G4ThreadLocal thread_local
77  #else
78  # define G4ThreadLocalStatic static __thread
79  # define G4ThreadLocal __thread
80  #endif
81  #elif defined(WIN32)
82  # define G4ThreadLocalStatic static __declspec(thread)
83  # define G4ThreadLocal __declspec(thread)
84  #else
85  # error "No Thread Local Storage (TLS) technology supported for this platform. Use sequential build !"
86  #endif
87 #else
88  # define G4ThreadLocalStatic static
89  # define G4ThreadLocal
90 #endif
91 
92 #endif