| 1 | // Copyright 2017 The Abseil Authors. | 
|---|
| 2 | // | 
|---|
| 3 | // Licensed under the Apache License, Version 2.0 (the "License"); | 
|---|
| 4 | // you may not use this file except in compliance with the License. | 
|---|
| 5 | // You may obtain a copy of the License at | 
|---|
| 6 | // | 
|---|
| 7 | //      https://www.apache.org/licenses/LICENSE-2.0 | 
|---|
| 8 | // | 
|---|
| 9 | // Unless required by applicable law or agreed to in writing, software | 
|---|
| 10 | // distributed under the License is distributed on an "AS IS" BASIS, | 
|---|
| 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | 
|---|
| 12 | // See the License for the specific language governing permissions and | 
|---|
| 13 | // limitations under the License. | 
|---|
| 14 |  | 
|---|
| 15 | #ifndef ABSL_BASE_INTERNAL_PER_THREAD_TLS_H_ | 
|---|
| 16 | #define ABSL_BASE_INTERNAL_PER_THREAD_TLS_H_ | 
|---|
| 17 |  | 
|---|
| 18 | // This header defines two macros: | 
|---|
| 19 | // | 
|---|
| 20 | // If the platform supports thread-local storage: | 
|---|
| 21 | // | 
|---|
| 22 | // * ABSL_PER_THREAD_TLS_KEYWORD is the C keyword needed to declare a | 
|---|
| 23 | //   thread-local variable | 
|---|
| 24 | // * ABSL_PER_THREAD_TLS is 1 | 
|---|
| 25 | // | 
|---|
| 26 | // Otherwise: | 
|---|
| 27 | // | 
|---|
| 28 | // * ABSL_PER_THREAD_TLS_KEYWORD is empty | 
|---|
| 29 | // * ABSL_PER_THREAD_TLS is 0 | 
|---|
| 30 | // | 
|---|
| 31 | // Microsoft C supports thread-local storage. | 
|---|
| 32 | // GCC supports it if the appropriate version of glibc is available, | 
|---|
| 33 | // which the programmer can indicate by defining ABSL_HAVE_TLS | 
|---|
| 34 |  | 
|---|
| 35 | #include "absl/base/port.h"  // For ABSL_HAVE_TLS | 
|---|
| 36 |  | 
|---|
| 37 | #if defined(ABSL_PER_THREAD_TLS) | 
|---|
| 38 | #error ABSL_PER_THREAD_TLS cannot be directly set | 
|---|
| 39 | #elif defined(ABSL_PER_THREAD_TLS_KEYWORD) | 
|---|
| 40 | #error ABSL_PER_THREAD_TLS_KEYWORD cannot be directly set | 
|---|
| 41 | #elif defined(ABSL_HAVE_TLS) | 
|---|
| 42 | #define ABSL_PER_THREAD_TLS_KEYWORD __thread | 
|---|
| 43 | #define ABSL_PER_THREAD_TLS 1 | 
|---|
| 44 | #elif defined(_MSC_VER) | 
|---|
| 45 | #define ABSL_PER_THREAD_TLS_KEYWORD __declspec(thread) | 
|---|
| 46 | #define ABSL_PER_THREAD_TLS 1 | 
|---|
| 47 | #else | 
|---|
| 48 | #define ABSL_PER_THREAD_TLS_KEYWORD | 
|---|
| 49 | #define ABSL_PER_THREAD_TLS 0 | 
|---|
| 50 | #endif | 
|---|
| 51 |  | 
|---|
| 52 | #endif  // ABSL_BASE_INTERNAL_PER_THREAD_TLS_H_ | 
|---|
| 53 |  | 
|---|