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 |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 // The F__initStatus field is used to hold the result of the | 60 // The F__initStatus field is used to hold the result of the |
61 // pthread_key_create() call, where a zero value indicates success, | 61 // pthread_key_create() call, where a zero value indicates success, |
62 // and a nonzero value indicates failure or that ICE_TLS_INIT_FIELD() | 62 // and a nonzero value indicates failure or that ICE_TLS_INIT_FIELD() |
63 // was never called. | 63 // was never called. |
64 // The F__key field is used as the argument to | 64 // The F__key field is used as the argument to |
65 // pthread_getspecific() and pthread_setspecific(). | 65 // pthread_getspecific() and pthread_setspecific(). |
66 | 66 |
67 #include <pthread.h> | 67 #include <pthread.h> |
68 | 68 |
69 #define ICE_TLS_DECLARE_FIELD(Type, FieldName) \ | 69 #define ICE_TLS_DECLARE_FIELD(Type, FieldName) \ |
70 typedef Type FieldName##__type; \ | 70 using FieldName##__type = Type; \ |
71 static pthread_key_t FieldName##__key; \ | 71 static pthread_key_t FieldName##__key; \ |
72 static int FieldName##__initStatus | 72 static int FieldName##__initStatus |
73 #define ICE_TLS_DEFINE_FIELD(Type, ClassName, FieldName) \ | 73 #define ICE_TLS_DEFINE_FIELD(Type, ClassName, FieldName) \ |
74 pthread_key_t ClassName::FieldName##__key; \ | 74 pthread_key_t ClassName::FieldName##__key; \ |
75 int ClassName::FieldName##__initStatus = 1 | 75 int ClassName::FieldName##__initStatus = 1 |
76 #define ICE_TLS_INIT_FIELD(FieldName) \ | 76 #define ICE_TLS_INIT_FIELD(FieldName) \ |
77 if (FieldName##__initStatus) { \ | 77 if (FieldName##__initStatus) { \ |
78 FieldName##__initStatus = pthread_key_create(&FieldName##__key, nullptr); \ | 78 FieldName##__initStatus = pthread_key_create(&FieldName##__key, nullptr); \ |
79 if (FieldName##__initStatus) \ | 79 if (FieldName##__initStatus) \ |
80 llvm::report_fatal_error("Failed to create pthread key"); \ | 80 llvm::report_fatal_error("Failed to create pthread key"); \ |
(...skipping 11 matching lines...) Expand all Loading... |
92 static ICE_ATTRIBUTE_TLS Type FieldName | 92 static ICE_ATTRIBUTE_TLS Type FieldName |
93 #define ICE_TLS_DEFINE_FIELD(Type, ClassName, FieldName) \ | 93 #define ICE_TLS_DEFINE_FIELD(Type, ClassName, FieldName) \ |
94 ICE_ATTRIBUTE_TLS Type ClassName::FieldName = nullptr | 94 ICE_ATTRIBUTE_TLS Type ClassName::FieldName = nullptr |
95 #define ICE_TLS_INIT_FIELD(FieldName) | 95 #define ICE_TLS_INIT_FIELD(FieldName) |
96 #define ICE_TLS_GET_FIELD(FieldName) (FieldName) | 96 #define ICE_TLS_GET_FIELD(FieldName) (FieldName) |
97 #define ICE_TLS_SET_FIELD(FieldName, Value) (FieldName = (Value)) | 97 #define ICE_TLS_SET_FIELD(FieldName, Value) (FieldName = (Value)) |
98 | 98 |
99 #endif // !ICE_THREAD_LOCAL_HACK | 99 #endif // !ICE_THREAD_LOCAL_HACK |
100 | 100 |
101 #endif // SUBZERO_SRC_ICETLS_H | 101 #endif // SUBZERO_SRC_ICETLS_H |
OLD | NEW |