config.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  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. #ifndef ABSL_FLAGS_CONFIG_H_
  16. #define ABSL_FLAGS_CONFIG_H_
  17. // Determine if we should strip string literals from the Flag objects.
  18. // By default we strip string literals on mobile platforms.
  19. #if !defined(ABSL_FLAGS_STRIP_NAMES)
  20. #if defined(__ANDROID__)
  21. #define ABSL_FLAGS_STRIP_NAMES 1
  22. #elif defined(__APPLE__)
  23. #include <TargetConditionals.h>
  24. #if defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE
  25. #define ABSL_FLAGS_STRIP_NAMES 1
  26. #elif defined(TARGET_OS_EMBEDDED) && TARGET_OS_EMBEDDED
  27. #define ABSL_FLAGS_STRIP_NAMES 1
  28. #endif // TARGET_OS_*
  29. #endif
  30. #endif // !defined(ABSL_FLAGS_STRIP_NAMES)
  31. #if !defined(ABSL_FLAGS_STRIP_NAMES)
  32. // If ABSL_FLAGS_STRIP_NAMES wasn't set on the command line or above,
  33. // the default is not to strip.
  34. #define ABSL_FLAGS_STRIP_NAMES 0
  35. #endif
  36. #if !defined(ABSL_FLAGS_STRIP_HELP)
  37. // By default, if we strip names, we also strip help.
  38. #define ABSL_FLAGS_STRIP_HELP ABSL_FLAGS_STRIP_NAMES
  39. #endif
  40. // ABSL_FLAGS_INTERNAL_ATOMIC_DOUBLE_WORD macro is used for using atomics with
  41. // double words, e.g. absl::Duration.
  42. // For reasons in bug https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80878, modern
  43. // versions of GCC do not support cmpxchg16b instruction in standard atomics.
  44. #ifdef ABSL_FLAGS_INTERNAL_ATOMIC_DOUBLE_WORD
  45. #error "ABSL_FLAGS_INTERNAL_ATOMIC_DOUBLE_WORD should not be defined."
  46. #elif defined(__clang__) && defined(__x86_64__) && \
  47. defined(__GCC_HAVE_SYNC_COMPARE_AND_SWAP_16)
  48. #define ABSL_FLAGS_INTERNAL_ATOMIC_DOUBLE_WORD 1
  49. #endif
  50. // ABSL_FLAGS_INTERNAL_HAS_RTTI macro is used for selecting if we can use RTTI
  51. // for flag type identification.
  52. #ifdef ABSL_FLAGS_INTERNAL_HAS_RTTI
  53. #error ABSL_FLAGS_INTERNAL_HAS_RTTI cannot be directly set
  54. #elif !defined(__GNUC__) || defined(__GXX_RTTI)
  55. #define ABSL_FLAGS_INTERNAL_HAS_RTTI 1
  56. #endif // !defined(__GNUC__) || defined(__GXX_RTTI)
  57. // These macros represent the "source of truth" for the list of supported
  58. // built-in types.
  59. #define ABSL_FLAGS_INTERNAL_BUILTIN_TYPES(A) \
  60. A(bool, bool) \
  61. A(short, short) \
  62. A(unsigned short, unsigned_short) \
  63. A(int, int) \
  64. A(unsigned int, unsigned_int) \
  65. A(long, long) \
  66. A(unsigned long, unsigned_long) \
  67. A(long long, long_long) \
  68. A(unsigned long long, unsigned_long_long) \
  69. A(double, double) \
  70. A(float, float)
  71. #define ABSL_FLAGS_INTERNAL_SUPPORTED_TYPES(A) \
  72. ABSL_FLAGS_INTERNAL_BUILTIN_TYPES(A) \
  73. A(std::string, std_string) \
  74. A(std::vector<std::string>, std_vector_of_string)
  75. #endif // ABSL_FLAGS_CONFIG_H_