• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //
2 //  Copyright 2019 The Abseil Authors.
3 //
4 // Licensed under the Apache License, Version 2.0 (the "License");
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 //      https://www.apache.org/licenses/LICENSE-2.0
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 
16 #ifndef ABSL_FLAGS_CONFIG_H_
17 #define ABSL_FLAGS_CONFIG_H_
18 
19 // Determine if we should strip string literals from the Flag objects.
20 // By default we strip string literals on mobile platforms.
21 #if !defined(ABSL_FLAGS_STRIP_NAMES)
22 
23 #if defined(__ANDROID__)
24 #define ABSL_FLAGS_STRIP_NAMES 1
25 
26 #elif defined(__APPLE__)
27 #include <TargetConditionals.h>
28 #if defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE
29 #define ABSL_FLAGS_STRIP_NAMES 1
30 #elif defined(TARGET_OS_EMBEDDED) && TARGET_OS_EMBEDDED
31 #define ABSL_FLAGS_STRIP_NAMES 1
32 #endif  // TARGET_OS_*
33 #endif
34 
35 #endif  // !defined(ABSL_FLAGS_STRIP_NAMES)
36 
37 #if !defined(ABSL_FLAGS_STRIP_NAMES)
38 // If ABSL_FLAGS_STRIP_NAMES wasn't set on the command line or above,
39 // the default is not to strip.
40 #define ABSL_FLAGS_STRIP_NAMES 0
41 #endif
42 
43 #if !defined(ABSL_FLAGS_STRIP_HELP)
44 // By default, if we strip names, we also strip help.
45 #define ABSL_FLAGS_STRIP_HELP ABSL_FLAGS_STRIP_NAMES
46 #endif
47 
48 // ABSL_FLAGS_INTERNAL_ATOMIC_DOUBLE_WORD macro is used for using atomics with
49 // double words, e.g. absl::Duration.
50 // For reasons in bug https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80878, modern
51 // versions of GCC do not support cmpxchg16b instruction in standard atomics.
52 #ifdef ABSL_FLAGS_INTERNAL_ATOMIC_DOUBLE_WORD
53 #error "ABSL_FLAGS_INTERNAL_ATOMIC_DOUBLE_WORD should not be defined."
54 #elif defined(__clang__) && defined(__x86_64__) && \
55     defined(__GCC_HAVE_SYNC_COMPARE_AND_SWAP_16)
56 #define ABSL_FLAGS_INTERNAL_ATOMIC_DOUBLE_WORD 1
57 #endif
58 
59 // ABSL_FLAGS_INTERNAL_HAS_RTTI macro is used for selecting if we can use RTTI
60 // for flag type identification.
61 #ifdef ABSL_FLAGS_INTERNAL_HAS_RTTI
62 #error ABSL_FLAGS_INTERNAL_HAS_RTTI cannot be directly set
63 #elif !defined(__GNUC__) || defined(__GXX_RTTI)
64 #define ABSL_FLAGS_INTERNAL_HAS_RTTI 1
65 #endif  // !defined(__GNUC__) || defined(__GXX_RTTI)
66 
67 // These macros represent the "source of truth" for the list of supported
68 // built-in types.
69 #define ABSL_FLAGS_INTERNAL_BUILTIN_TYPES(A) \
70   A(bool, bool)                              \
71   A(short, short)                            \
72   A(unsigned short, unsigned_short)          \
73   A(int, int)                                \
74   A(unsigned int, unsigned_int)              \
75   A(long, long)                              \
76   A(unsigned long, unsigned_long)            \
77   A(long long, long_long)                    \
78   A(unsigned long long, unsigned_long_long)  \
79   A(double, double)                          \
80   A(float, float)
81 
82 #define ABSL_FLAGS_INTERNAL_SUPPORTED_TYPES(A) \
83   ABSL_FLAGS_INTERNAL_BUILTIN_TYPES(A)         \
84   A(std::string, std_string)                   \
85   A(std::vector<std::string>, std_vector_of_string)
86 
87 #endif  // ABSL_FLAGS_CONFIG_H_
88