| OLD | NEW |
| 1 //===- subzero/src/IceTLS.h - thread_local workaround -----------*- C++ -*-===// | 1 //===- subzero/src/IceTLS.h - thread_local workaround -----------*- C++ -*-===// |
| 2 // | 2 // |
| 3 // The Subzero Code Generator | 3 // The Subzero Code Generator |
| 4 // | 4 // |
| 5 // This file is distributed under the University of Illinois Open Source | 5 // This file is distributed under the University of Illinois Open Source |
| 6 // License. See LICENSE.TXT for details. | 6 // License. See LICENSE.TXT for details. |
| 7 // | 7 // |
| 8 //===----------------------------------------------------------------------===// | 8 //===----------------------------------------------------------------------===// |
| 9 /// | 9 /// |
| 10 /// \file | 10 /// \file |
| 11 /// This file defines macros for working around the lack of support for | 11 /// This file defines macros for working around the lack of support for |
| 12 /// thread_local in MacOS 10.6. It assumes std::thread is written in terms of | 12 /// thread_local in MacOS 10.6. It assumes std::thread is written in terms of |
| 13 /// pthread. Define ICE_THREAD_LOCAL_HACK to enable the pthread workarounds. | 13 /// pthread. Define ICE_THREAD_LOCAL_HACK to enable the pthread workarounds. |
| 14 /// | 14 /// |
| 15 //===----------------------------------------------------------------------===// | 15 //===----------------------------------------------------------------------===// |
| 16 | 16 |
| 17 #ifndef SUBZERO_SRC_ICETLS_H | 17 #ifndef SUBZERO_SRC_ICETLS_H |
| 18 #define SUBZERO_SRC_ICETLS_H | 18 #define SUBZERO_SRC_ICETLS_H |
| 19 | 19 |
| 20 | |
| 21 /// | 20 /// |
| 22 /// @defgroup /IceTLS Defines 5 macros for unifying thread_local and pthread: | 21 /// @defgroup /IceTLS Defines 5 macros for unifying thread_local and pthread: |
| 23 /// @{ | 22 /// @{ |
| 24 /// | 23 /// |
| 25 /// \def ICE_TLS_DECLARE_FIELD(Type, FieldName) | 24 /// \def ICE_TLS_DECLARE_FIELD(Type, FieldName) |
| 26 /// Declare a static thread_local field inside the current class definition. | 25 /// Declare a static thread_local field inside the current class definition. |
| 27 /// "Type" needs to be a pointer type, such as int* or class Foo*. | 26 /// "Type" needs to be a pointer type, such as int* or class Foo*. |
| 28 /// | 27 /// |
| 29 /// \def ICE_TLS_DEFINE_FIELD(Type, ClassName, FieldName) | 28 /// \def ICE_TLS_DEFINE_FIELD(Type, ClassName, FieldName) |
| 30 /// Define a static thread_local field outside of its class definition. The | 29 /// Define a static thread_local field outside of its class definition. The |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 89 pthread_setspecific(FieldName##__key, (Value))) | 88 pthread_setspecific(FieldName##__key, (Value))) |
| 90 | 89 |
| 91 #else // !ICE_THREAD_LOCAL_HACK | 90 #else // !ICE_THREAD_LOCAL_HACK |
| 92 | 91 |
| 93 #if defined(_MSC_VER) | 92 #if defined(_MSC_VER) |
| 94 #define ICE_ATTRIBUTE_TLS __declspec(thread) | 93 #define ICE_ATTRIBUTE_TLS __declspec(thread) |
| 95 #else // !_MSC_VER | 94 #else // !_MSC_VER |
| 96 #define ICE_ATTRIBUTE_TLS thread_local | 95 #define ICE_ATTRIBUTE_TLS thread_local |
| 97 #endif // !_MSC_VER | 96 #endif // !_MSC_VER |
| 98 | 97 |
| 99 | |
| 100 #define ICE_TLS_DECLARE_FIELD(Type, FieldName) \ | 98 #define ICE_TLS_DECLARE_FIELD(Type, FieldName) \ |
| 101 static ICE_ATTRIBUTE_TLS Type FieldName | 99 static ICE_ATTRIBUTE_TLS Type FieldName |
| 102 #define ICE_TLS_DEFINE_FIELD(Type, ClassName, FieldName) \ | 100 #define ICE_TLS_DEFINE_FIELD(Type, ClassName, FieldName) \ |
| 103 ICE_ATTRIBUTE_TLS Type ClassName::FieldName = nullptr | 101 ICE_ATTRIBUTE_TLS Type ClassName::FieldName = nullptr |
| 104 #define ICE_TLS_INIT_FIELD(FieldName) | 102 #define ICE_TLS_INIT_FIELD(FieldName) |
| 105 #define ICE_TLS_GET_FIELD(FieldName) (FieldName) | 103 #define ICE_TLS_GET_FIELD(FieldName) (FieldName) |
| 106 #define ICE_TLS_SET_FIELD(FieldName, Value) (FieldName = (Value)) | 104 #define ICE_TLS_SET_FIELD(FieldName, Value) (FieldName = (Value)) |
| 107 | 105 |
| 108 #endif // !ICE_THREAD_LOCAL_HACK | 106 #endif // !ICE_THREAD_LOCAL_HACK |
| 109 | 107 |
| 110 /// | 108 /// |
| 111 /// @} | 109 /// @} |
| 112 /// | 110 /// |
| 113 | 111 |
| 114 #endif // SUBZERO_SRC_ICETLS_H | 112 #endif // SUBZERO_SRC_ICETLS_H |
| OLD | NEW |