grpc 1.26.0 → 1.27.0.pre1

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of grpc might be problematic. Click here for more details.

Files changed (209) hide show
  1. checksums.yaml +4 -4
  2. data/Makefile +1654 -1519
  3. data/etc/roots.pem +44 -0
  4. data/include/grpc/grpc_security.h +37 -15
  5. data/include/grpc/grpc_security_constants.h +27 -0
  6. data/include/grpc/impl/codegen/grpc_types.h +14 -0
  7. data/include/grpc/impl/codegen/port_platform.h +1 -1
  8. data/src/core/ext/filters/client_channel/client_channel.cc +0 -20
  9. data/src/core/ext/filters/client_channel/http_proxy.cc +4 -4
  10. data/src/core/ext/filters/client_channel/lb_policy.cc +4 -3
  11. data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc +191 -201
  12. data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_balancer_addresses.cc +89 -0
  13. data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_balancer_addresses.h +40 -0
  14. data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel_secure.cc +3 -2
  15. data/src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.cc +88 -121
  16. data/src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.h +28 -57
  17. data/src/core/ext/filters/client_channel/lb_policy/subchannel_list.h +0 -7
  18. data/src/core/ext/filters/client_channel/lb_policy/xds/cds.cc +8 -9
  19. data/src/core/ext/filters/client_channel/lb_policy/xds/xds.cc +53 -34
  20. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc +18 -5
  21. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc +24 -19
  22. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h +2 -1
  23. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_fallback.cc +4 -2
  24. data/src/core/ext/filters/client_channel/server_address.cc +6 -9
  25. data/src/core/ext/filters/client_channel/server_address.h +3 -10
  26. data/src/core/ext/filters/client_channel/xds/xds_api.cc +394 -150
  27. data/src/core/ext/filters/client_channel/xds/xds_api.h +75 -35
  28. data/src/core/ext/filters/client_channel/xds/xds_bootstrap.cc +59 -22
  29. data/src/core/ext/filters/client_channel/xds/xds_bootstrap.h +13 -9
  30. data/src/core/ext/filters/client_channel/xds/xds_channel_secure.cc +8 -6
  31. data/src/core/ext/filters/client_channel/xds/xds_client.cc +456 -175
  32. data/src/core/ext/filters/client_channel/xds/xds_client.h +33 -21
  33. data/src/core/ext/filters/client_channel/xds/xds_client_stats.cc +5 -8
  34. data/src/core/ext/filters/client_channel/xds/xds_client_stats.h +18 -24
  35. data/src/core/ext/transport/chttp2/transport/chttp2_transport.cc +2 -2
  36. data/src/core/ext/upb-generated/src/proto/grpc/lb/v1/load_balancer.upb.c +13 -5
  37. data/src/core/ext/upb-generated/src/proto/grpc/lb/v1/load_balancer.upb.h +34 -0
  38. data/src/core/lib/channel/channelz.h +11 -1
  39. data/src/core/lib/gpr/time_precise.cc +1 -1
  40. data/src/core/lib/gprpp/optional.h +26 -0
  41. data/src/core/lib/gprpp/string_view.h +14 -10
  42. data/src/core/lib/iomgr/executor.cc +1 -1
  43. data/src/core/lib/iomgr/fork_posix.cc +4 -0
  44. data/src/core/lib/iomgr/poller/eventmanager_libuv.cc +87 -0
  45. data/src/core/lib/iomgr/poller/eventmanager_libuv.h +88 -0
  46. data/src/core/lib/iomgr/socket_utils_common_posix.cc +14 -0
  47. data/src/core/lib/iomgr/socket_utils_posix.h +12 -0
  48. data/src/core/lib/iomgr/tcp_custom.h +3 -0
  49. data/src/core/lib/iomgr/tcp_posix.cc +607 -56
  50. data/src/core/lib/iomgr/tcp_server_custom.cc +15 -2
  51. data/src/core/lib/iomgr/tcp_server_utils_posix_common.cc +8 -0
  52. data/src/core/lib/json/json.h +11 -1
  53. data/src/core/lib/json/json_reader.cc +206 -28
  54. data/src/core/lib/json/json_writer.cc +111 -24
  55. data/src/core/lib/security/credentials/composite/composite_credentials.cc +7 -0
  56. data/src/core/lib/security/credentials/composite/composite_credentials.h +5 -1
  57. data/src/core/lib/security/credentials/credentials.h +10 -1
  58. data/src/core/lib/security/credentials/fake/fake_credentials.h +2 -1
  59. data/src/core/lib/security/credentials/oauth2/oauth2_credentials.cc +1 -1
  60. data/src/core/lib/security/credentials/plugin/plugin_credentials.cc +6 -4
  61. data/src/core/lib/security/credentials/plugin/plugin_credentials.h +2 -1
  62. data/src/core/lib/security/credentials/tls/grpc_tls_credentials_options.cc +20 -0
  63. data/src/core/lib/security/credentials/tls/grpc_tls_credentials_options.h +8 -0
  64. data/src/core/lib/security/credentials/tls/{spiffe_credentials.cc → tls_credentials.cc} +23 -24
  65. data/src/core/lib/security/credentials/tls/{spiffe_credentials.h → tls_credentials.h} +9 -9
  66. data/src/core/lib/security/security_connector/alts/alts_security_connector.cc +13 -0
  67. data/src/core/lib/security/security_connector/fake/fake_security_connector.cc +22 -2
  68. data/src/core/lib/security/security_connector/load_system_roots_fallback.cc +2 -2
  69. data/src/core/lib/security/security_connector/load_system_roots_linux.cc +2 -2
  70. data/src/core/lib/security/security_connector/local/local_security_connector.cc +30 -3
  71. data/src/core/lib/security/security_connector/ssl_utils.cc +45 -3
  72. data/src/core/lib/security/security_connector/ssl_utils.h +12 -0
  73. data/src/core/lib/security/security_connector/tls/{spiffe_security_connector.cc → tls_security_connector.cc} +82 -69
  74. data/src/core/lib/security/security_connector/tls/{spiffe_security_connector.h → tls_security_connector.h} +17 -18
  75. data/src/core/lib/security/transport/client_auth_filter.cc +33 -0
  76. data/src/core/lib/surface/completion_queue.cc +22 -1
  77. data/src/core/lib/surface/version.cc +1 -1
  78. data/src/core/tsi/alts/handshaker/alts_tsi_handshaker.cc +11 -1
  79. data/src/core/tsi/alts/handshaker/alts_tsi_handshaker.h +1 -1
  80. data/src/core/tsi/alts/zero_copy_frame_protector/alts_zero_copy_grpc_protector.cc +3 -3
  81. data/src/core/tsi/fake_transport_security.cc +7 -3
  82. data/src/core/tsi/fake_transport_security.h +2 -0
  83. data/src/core/tsi/ssl_transport_security.cc +144 -8
  84. data/src/core/tsi/ssl_transport_security.h +15 -1
  85. data/src/core/tsi/transport_security.cc +13 -0
  86. data/src/core/tsi/transport_security_grpc.cc +2 -2
  87. data/src/core/tsi/transport_security_grpc.h +2 -2
  88. data/src/core/tsi/transport_security_interface.h +12 -0
  89. data/src/ruby/bin/math_pb.rb +5 -5
  90. data/src/ruby/ext/grpc/rb_call_credentials.c +4 -1
  91. data/src/ruby/ext/grpc/rb_grpc_imports.generated.c +2 -0
  92. data/src/ruby/ext/grpc/rb_grpc_imports.generated.h +4 -1
  93. data/src/ruby/lib/grpc/version.rb +1 -1
  94. data/src/ruby/pb/grpc/health/v1/health_pb.rb +3 -3
  95. data/src/ruby/pb/src/proto/grpc/testing/empty_pb.rb +1 -1
  96. data/src/ruby/pb/src/proto/grpc/testing/messages_pb.rb +23 -13
  97. data/third_party/abseil-cpp/absl/algorithm/algorithm.h +159 -0
  98. data/third_party/abseil-cpp/absl/base/attributes.h +609 -0
  99. data/third_party/abseil-cpp/absl/base/call_once.h +226 -0
  100. data/third_party/abseil-cpp/absl/base/casts.h +184 -0
  101. data/third_party/abseil-cpp/absl/base/config.h +622 -0
  102. data/third_party/abseil-cpp/absl/base/const_init.h +76 -0
  103. data/third_party/abseil-cpp/absl/base/dynamic_annotations.cc +129 -0
  104. data/third_party/abseil-cpp/absl/base/dynamic_annotations.h +389 -0
  105. data/third_party/abseil-cpp/absl/base/internal/atomic_hook.h +179 -0
  106. data/third_party/abseil-cpp/absl/base/internal/bits.h +218 -0
  107. data/third_party/abseil-cpp/absl/base/internal/cycleclock.cc +107 -0
  108. data/third_party/abseil-cpp/absl/base/internal/cycleclock.h +94 -0
  109. data/third_party/abseil-cpp/absl/base/internal/endian.h +266 -0
  110. data/third_party/abseil-cpp/absl/base/internal/hide_ptr.h +51 -0
  111. data/third_party/abseil-cpp/absl/base/internal/identity.h +37 -0
  112. data/third_party/abseil-cpp/absl/base/internal/inline_variable.h +107 -0
  113. data/third_party/abseil-cpp/absl/base/internal/invoke.h +187 -0
  114. data/third_party/abseil-cpp/absl/base/internal/low_level_scheduling.h +107 -0
  115. data/third_party/abseil-cpp/absl/base/internal/per_thread_tls.h +52 -0
  116. data/third_party/abseil-cpp/absl/base/internal/raw_logging.cc +237 -0
  117. data/third_party/abseil-cpp/absl/base/internal/raw_logging.h +179 -0
  118. data/third_party/abseil-cpp/absl/base/internal/scheduling_mode.h +58 -0
  119. data/third_party/abseil-cpp/absl/base/internal/spinlock.cc +233 -0
  120. data/third_party/abseil-cpp/absl/base/internal/spinlock.h +243 -0
  121. data/third_party/abseil-cpp/absl/base/internal/spinlock_akaros.inc +35 -0
  122. data/third_party/abseil-cpp/absl/base/internal/spinlock_linux.inc +67 -0
  123. data/third_party/abseil-cpp/absl/base/internal/spinlock_posix.inc +46 -0
  124. data/third_party/abseil-cpp/absl/base/internal/spinlock_wait.cc +81 -0
  125. data/third_party/abseil-cpp/absl/base/internal/spinlock_wait.h +93 -0
  126. data/third_party/abseil-cpp/absl/base/internal/spinlock_win32.inc +37 -0
  127. data/third_party/abseil-cpp/absl/base/internal/sysinfo.cc +414 -0
  128. data/third_party/abseil-cpp/absl/base/internal/sysinfo.h +66 -0
  129. data/third_party/abseil-cpp/absl/base/internal/thread_annotations.h +271 -0
  130. data/third_party/abseil-cpp/absl/base/internal/thread_identity.cc +140 -0
  131. data/third_party/abseil-cpp/absl/base/internal/thread_identity.h +250 -0
  132. data/third_party/abseil-cpp/absl/base/internal/throw_delegate.cc +108 -0
  133. data/third_party/abseil-cpp/absl/base/internal/throw_delegate.h +75 -0
  134. data/third_party/abseil-cpp/absl/base/internal/tsan_mutex_interface.h +66 -0
  135. data/third_party/abseil-cpp/absl/base/internal/unaligned_access.h +158 -0
  136. data/third_party/abseil-cpp/absl/base/internal/unscaledcycleclock.cc +103 -0
  137. data/third_party/abseil-cpp/absl/base/internal/unscaledcycleclock.h +124 -0
  138. data/third_party/abseil-cpp/absl/base/log_severity.cc +27 -0
  139. data/third_party/abseil-cpp/absl/base/log_severity.h +121 -0
  140. data/third_party/abseil-cpp/absl/base/macros.h +220 -0
  141. data/third_party/abseil-cpp/absl/base/optimization.h +181 -0
  142. data/third_party/abseil-cpp/absl/base/options.h +214 -0
  143. data/third_party/abseil-cpp/absl/base/policy_checks.h +111 -0
  144. data/third_party/abseil-cpp/absl/base/port.h +26 -0
  145. data/third_party/abseil-cpp/absl/base/thread_annotations.h +280 -0
  146. data/third_party/abseil-cpp/absl/container/inlined_vector.h +848 -0
  147. data/third_party/abseil-cpp/absl/container/internal/compressed_tuple.h +265 -0
  148. data/third_party/abseil-cpp/absl/container/internal/inlined_vector.h +892 -0
  149. data/third_party/abseil-cpp/absl/memory/memory.h +695 -0
  150. data/third_party/abseil-cpp/absl/meta/type_traits.h +759 -0
  151. data/third_party/abseil-cpp/absl/numeric/int128.cc +404 -0
  152. data/third_party/abseil-cpp/absl/numeric/int128.h +1091 -0
  153. data/third_party/abseil-cpp/absl/numeric/int128_have_intrinsic.inc +302 -0
  154. data/third_party/abseil-cpp/absl/numeric/int128_no_intrinsic.inc +308 -0
  155. data/third_party/abseil-cpp/absl/strings/ascii.cc +200 -0
  156. data/third_party/abseil-cpp/absl/strings/ascii.h +241 -0
  157. data/third_party/abseil-cpp/absl/strings/charconv.cc +985 -0
  158. data/third_party/abseil-cpp/absl/strings/charconv.h +119 -0
  159. data/third_party/abseil-cpp/absl/strings/escaping.cc +949 -0
  160. data/third_party/abseil-cpp/absl/strings/escaping.h +164 -0
  161. data/third_party/abseil-cpp/absl/strings/internal/char_map.h +156 -0
  162. data/third_party/abseil-cpp/absl/strings/internal/charconv_bigint.cc +359 -0
  163. data/third_party/abseil-cpp/absl/strings/internal/charconv_bigint.h +421 -0
  164. data/third_party/abseil-cpp/absl/strings/internal/charconv_parse.cc +504 -0
  165. data/third_party/abseil-cpp/absl/strings/internal/charconv_parse.h +99 -0
  166. data/third_party/abseil-cpp/absl/strings/internal/escaping.cc +180 -0
  167. data/third_party/abseil-cpp/absl/strings/internal/escaping.h +58 -0
  168. data/third_party/abseil-cpp/absl/strings/internal/memutil.cc +112 -0
  169. data/third_party/abseil-cpp/absl/strings/internal/memutil.h +148 -0
  170. data/third_party/abseil-cpp/absl/strings/internal/ostringstream.cc +36 -0
  171. data/third_party/abseil-cpp/absl/strings/internal/ostringstream.h +89 -0
  172. data/third_party/abseil-cpp/absl/strings/internal/resize_uninitialized.h +73 -0
  173. data/third_party/abseil-cpp/absl/strings/internal/stl_type_traits.h +248 -0
  174. data/third_party/abseil-cpp/absl/strings/internal/str_join_internal.h +314 -0
  175. data/third_party/abseil-cpp/absl/strings/internal/str_split_internal.h +455 -0
  176. data/third_party/abseil-cpp/absl/strings/internal/utf8.cc +53 -0
  177. data/third_party/abseil-cpp/absl/strings/internal/utf8.h +50 -0
  178. data/third_party/abseil-cpp/absl/strings/match.cc +40 -0
  179. data/third_party/abseil-cpp/absl/strings/match.h +90 -0
  180. data/third_party/abseil-cpp/absl/strings/numbers.cc +916 -0
  181. data/third_party/abseil-cpp/absl/strings/numbers.h +263 -0
  182. data/third_party/abseil-cpp/absl/strings/str_cat.cc +246 -0
  183. data/third_party/abseil-cpp/absl/strings/str_cat.h +408 -0
  184. data/third_party/abseil-cpp/absl/strings/str_join.h +293 -0
  185. data/third_party/abseil-cpp/absl/strings/str_replace.cc +82 -0
  186. data/third_party/abseil-cpp/absl/strings/str_replace.h +219 -0
  187. data/third_party/abseil-cpp/absl/strings/str_split.cc +139 -0
  188. data/third_party/abseil-cpp/absl/strings/str_split.h +513 -0
  189. data/third_party/abseil-cpp/absl/strings/string_view.cc +235 -0
  190. data/third_party/abseil-cpp/absl/strings/string_view.h +615 -0
  191. data/third_party/abseil-cpp/absl/strings/strip.h +91 -0
  192. data/third_party/abseil-cpp/absl/strings/substitute.cc +171 -0
  193. data/third_party/abseil-cpp/absl/strings/substitute.h +693 -0
  194. data/third_party/abseil-cpp/absl/types/bad_optional_access.cc +48 -0
  195. data/third_party/abseil-cpp/absl/types/bad_optional_access.h +78 -0
  196. data/third_party/abseil-cpp/absl/types/internal/optional.h +396 -0
  197. data/third_party/abseil-cpp/absl/types/internal/span.h +128 -0
  198. data/third_party/abseil-cpp/absl/types/optional.h +776 -0
  199. data/third_party/abseil-cpp/absl/types/span.h +713 -0
  200. data/third_party/abseil-cpp/absl/utility/utility.h +350 -0
  201. data/third_party/upb/upb/decode.c +4 -0
  202. data/third_party/upb/upb/port.c +0 -1
  203. data/third_party/upb/upb/port_def.inc +1 -3
  204. data/third_party/upb/upb/table.c +2 -1
  205. metadata +147 -43
  206. data/src/core/lib/json/json_common.h +0 -34
  207. data/src/core/lib/json/json_reader.h +0 -146
  208. data/src/core/lib/json/json_string.cc +0 -367
  209. data/src/core/lib/json/json_writer.h +0 -84
@@ -0,0 +1,220 @@
1
+ //
2
+ // Copyright 2017 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
+ // -----------------------------------------------------------------------------
17
+ // File: macros.h
18
+ // -----------------------------------------------------------------------------
19
+ //
20
+ // This header file defines the set of language macros used within Abseil code.
21
+ // For the set of macros used to determine supported compilers and platforms,
22
+ // see absl/base/config.h instead.
23
+ //
24
+ // This code is compiled directly on many platforms, including client
25
+ // platforms like Windows, Mac, and embedded systems. Before making
26
+ // any changes here, make sure that you're not breaking any platforms.
27
+
28
+ #ifndef ABSL_BASE_MACROS_H_
29
+ #define ABSL_BASE_MACROS_H_
30
+
31
+ #include <cassert>
32
+ #include <cstddef>
33
+
34
+ #include "absl/base/attributes.h"
35
+ #include "absl/base/optimization.h"
36
+ #include "absl/base/port.h"
37
+
38
+ // ABSL_ARRAYSIZE()
39
+ //
40
+ // Returns the number of elements in an array as a compile-time constant, which
41
+ // can be used in defining new arrays. If you use this macro on a pointer by
42
+ // mistake, you will get a compile-time error.
43
+ #define ABSL_ARRAYSIZE(array) \
44
+ (sizeof(::absl::macros_internal::ArraySizeHelper(array)))
45
+
46
+ namespace absl {
47
+ ABSL_NAMESPACE_BEGIN
48
+ namespace macros_internal {
49
+ // Note: this internal template function declaration is used by ABSL_ARRAYSIZE.
50
+ // The function doesn't need a definition, as we only use its type.
51
+ template <typename T, size_t N>
52
+ auto ArraySizeHelper(const T (&array)[N]) -> char (&)[N];
53
+ } // namespace macros_internal
54
+ ABSL_NAMESPACE_END
55
+ } // namespace absl
56
+
57
+ // kLinkerInitialized
58
+ //
59
+ // An enum used only as a constructor argument to indicate that a variable has
60
+ // static storage duration, and that the constructor should do nothing to its
61
+ // state. Use of this macro indicates to the reader that it is legal to
62
+ // declare a static instance of the class, provided the constructor is given
63
+ // the absl::base_internal::kLinkerInitialized argument.
64
+ //
65
+ // Normally, it is unsafe to declare a static variable that has a constructor or
66
+ // a destructor because invocation order is undefined. However, if the type can
67
+ // be zero-initialized (which the loader does for static variables) into a valid
68
+ // state and the type's destructor does not affect storage, then a constructor
69
+ // for static initialization can be declared.
70
+ //
71
+ // Example:
72
+ // // Declaration
73
+ // explicit MyClass(absl::base_internal:LinkerInitialized x) {}
74
+ //
75
+ // // Invocation
76
+ // static MyClass my_global(absl::base_internal::kLinkerInitialized);
77
+ namespace absl {
78
+ ABSL_NAMESPACE_BEGIN
79
+ namespace base_internal {
80
+ enum LinkerInitialized {
81
+ kLinkerInitialized = 0,
82
+ };
83
+ } // namespace base_internal
84
+ ABSL_NAMESPACE_END
85
+ } // namespace absl
86
+
87
+ // ABSL_FALLTHROUGH_INTENDED
88
+ //
89
+ // Annotates implicit fall-through between switch labels, allowing a case to
90
+ // indicate intentional fallthrough and turn off warnings about any lack of a
91
+ // `break` statement. The ABSL_FALLTHROUGH_INTENDED macro should be followed by
92
+ // a semicolon and can be used in most places where `break` can, provided that
93
+ // no statements exist between it and the next switch label.
94
+ //
95
+ // Example:
96
+ //
97
+ // switch (x) {
98
+ // case 40:
99
+ // case 41:
100
+ // if (truth_is_out_there) {
101
+ // ++x;
102
+ // ABSL_FALLTHROUGH_INTENDED; // Use instead of/along with annotations
103
+ // // in comments
104
+ // } else {
105
+ // return x;
106
+ // }
107
+ // case 42:
108
+ // ...
109
+ //
110
+ // Notes: when compiled with clang in C++11 mode, the ABSL_FALLTHROUGH_INTENDED
111
+ // macro is expanded to the [[clang::fallthrough]] attribute, which is analysed
112
+ // when performing switch labels fall-through diagnostic
113
+ // (`-Wimplicit-fallthrough`). See clang documentation on language extensions
114
+ // for details:
115
+ // https://clang.llvm.org/docs/AttributeReference.html#fallthrough-clang-fallthrough
116
+ //
117
+ // When used with unsupported compilers, the ABSL_FALLTHROUGH_INTENDED macro
118
+ // has no effect on diagnostics. In any case this macro has no effect on runtime
119
+ // behavior and performance of code.
120
+ #ifdef ABSL_FALLTHROUGH_INTENDED
121
+ #error "ABSL_FALLTHROUGH_INTENDED should not be defined."
122
+ #endif
123
+
124
+ // TODO(zhangxy): Use c++17 standard [[fallthrough]] macro, when supported.
125
+ #if defined(__clang__) && defined(__has_warning)
126
+ #if __has_feature(cxx_attributes) && __has_warning("-Wimplicit-fallthrough")
127
+ #define ABSL_FALLTHROUGH_INTENDED [[clang::fallthrough]]
128
+ #endif
129
+ #elif defined(__GNUC__) && __GNUC__ >= 7
130
+ #define ABSL_FALLTHROUGH_INTENDED [[gnu::fallthrough]]
131
+ #endif
132
+
133
+ #ifndef ABSL_FALLTHROUGH_INTENDED
134
+ #define ABSL_FALLTHROUGH_INTENDED \
135
+ do { \
136
+ } while (0)
137
+ #endif
138
+
139
+ // ABSL_DEPRECATED()
140
+ //
141
+ // Marks a deprecated class, struct, enum, function, method and variable
142
+ // declarations. The macro argument is used as a custom diagnostic message (e.g.
143
+ // suggestion of a better alternative).
144
+ //
145
+ // Examples:
146
+ //
147
+ // class ABSL_DEPRECATED("Use Bar instead") Foo {...};
148
+ //
149
+ // ABSL_DEPRECATED("Use Baz() instead") void Bar() {...}
150
+ //
151
+ // template <typename T>
152
+ // ABSL_DEPRECATED("Use DoThat() instead")
153
+ // void DoThis();
154
+ //
155
+ // Every usage of a deprecated entity will trigger a warning when compiled with
156
+ // clang's `-Wdeprecated-declarations` option. This option is turned off by
157
+ // default, but the warnings will be reported by clang-tidy.
158
+ #if defined(__clang__) && __cplusplus >= 201103L
159
+ #define ABSL_DEPRECATED(message) __attribute__((deprecated(message)))
160
+ #endif
161
+
162
+ #ifndef ABSL_DEPRECATED
163
+ #define ABSL_DEPRECATED(message)
164
+ #endif
165
+
166
+ // ABSL_BAD_CALL_IF()
167
+ //
168
+ // Used on a function overload to trap bad calls: any call that matches the
169
+ // overload will cause a compile-time error. This macro uses a clang-specific
170
+ // "enable_if" attribute, as described at
171
+ // https://clang.llvm.org/docs/AttributeReference.html#enable-if
172
+ //
173
+ // Overloads which use this macro should be bracketed by
174
+ // `#ifdef ABSL_BAD_CALL_IF`.
175
+ //
176
+ // Example:
177
+ //
178
+ // int isdigit(int c);
179
+ // #ifdef ABSL_BAD_CALL_IF
180
+ // int isdigit(int c)
181
+ // ABSL_BAD_CALL_IF(c <= -1 || c > 255,
182
+ // "'c' must have the value of an unsigned char or EOF");
183
+ // #endif // ABSL_BAD_CALL_IF
184
+ #if ABSL_HAVE_ATTRIBUTE(enable_if)
185
+ #define ABSL_BAD_CALL_IF(expr, msg) \
186
+ __attribute__((enable_if(expr, "Bad call trap"), unavailable(msg)))
187
+ #endif
188
+
189
+ // ABSL_ASSERT()
190
+ //
191
+ // In C++11, `assert` can't be used portably within constexpr functions.
192
+ // ABSL_ASSERT functions as a runtime assert but works in C++11 constexpr
193
+ // functions. Example:
194
+ //
195
+ // constexpr double Divide(double a, double b) {
196
+ // return ABSL_ASSERT(b != 0), a / b;
197
+ // }
198
+ //
199
+ // This macro is inspired by
200
+ // https://akrzemi1.wordpress.com/2017/05/18/asserts-in-constexpr-functions/
201
+ #if defined(NDEBUG)
202
+ #define ABSL_ASSERT(expr) \
203
+ (false ? static_cast<void>(expr) : static_cast<void>(0))
204
+ #else
205
+ #define ABSL_ASSERT(expr) \
206
+ (ABSL_PREDICT_TRUE((expr)) ? static_cast<void>(0) \
207
+ : [] { assert(false && #expr); }()) // NOLINT
208
+ #endif
209
+
210
+ #ifdef ABSL_HAVE_EXCEPTIONS
211
+ #define ABSL_INTERNAL_TRY try
212
+ #define ABSL_INTERNAL_CATCH_ANY catch (...)
213
+ #define ABSL_INTERNAL_RETHROW do { throw; } while (false)
214
+ #else // ABSL_HAVE_EXCEPTIONS
215
+ #define ABSL_INTERNAL_TRY if (true)
216
+ #define ABSL_INTERNAL_CATCH_ANY else if (false)
217
+ #define ABSL_INTERNAL_RETHROW do {} while (false)
218
+ #endif // ABSL_HAVE_EXCEPTIONS
219
+
220
+ #endif // ABSL_BASE_MACROS_H_
@@ -0,0 +1,181 @@
1
+ //
2
+ // Copyright 2017 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
+ // -----------------------------------------------------------------------------
17
+ // File: optimization.h
18
+ // -----------------------------------------------------------------------------
19
+ //
20
+ // This header file defines portable macros for performance optimization.
21
+
22
+ #ifndef ABSL_BASE_OPTIMIZATION_H_
23
+ #define ABSL_BASE_OPTIMIZATION_H_
24
+
25
+ #include "absl/base/config.h"
26
+
27
+ // ABSL_BLOCK_TAIL_CALL_OPTIMIZATION
28
+ //
29
+ // Instructs the compiler to avoid optimizing tail-call recursion. Use of this
30
+ // macro is useful when you wish to preserve the existing function order within
31
+ // a stack trace for logging, debugging, or profiling purposes.
32
+ //
33
+ // Example:
34
+ //
35
+ // int f() {
36
+ // int result = g();
37
+ // ABSL_BLOCK_TAIL_CALL_OPTIMIZATION();
38
+ // return result;
39
+ // }
40
+ #if defined(__pnacl__)
41
+ #define ABSL_BLOCK_TAIL_CALL_OPTIMIZATION() if (volatile int x = 0) { (void)x; }
42
+ #elif defined(__clang__)
43
+ // Clang will not tail call given inline volatile assembly.
44
+ #define ABSL_BLOCK_TAIL_CALL_OPTIMIZATION() __asm__ __volatile__("")
45
+ #elif defined(__GNUC__)
46
+ // GCC will not tail call given inline volatile assembly.
47
+ #define ABSL_BLOCK_TAIL_CALL_OPTIMIZATION() __asm__ __volatile__("")
48
+ #elif defined(_MSC_VER)
49
+ #include <intrin.h>
50
+ // The __nop() intrinsic blocks the optimisation.
51
+ #define ABSL_BLOCK_TAIL_CALL_OPTIMIZATION() __nop()
52
+ #else
53
+ #define ABSL_BLOCK_TAIL_CALL_OPTIMIZATION() if (volatile int x = 0) { (void)x; }
54
+ #endif
55
+
56
+ // ABSL_CACHELINE_SIZE
57
+ //
58
+ // Explicitly defines the size of the L1 cache for purposes of alignment.
59
+ // Setting the cacheline size allows you to specify that certain objects be
60
+ // aligned on a cacheline boundary with `ABSL_CACHELINE_ALIGNED` declarations.
61
+ // (See below.)
62
+ //
63
+ // NOTE: this macro should be replaced with the following C++17 features, when
64
+ // those are generally available:
65
+ //
66
+ // * `std::hardware_constructive_interference_size`
67
+ // * `std::hardware_destructive_interference_size`
68
+ //
69
+ // See http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2016/p0154r1.html
70
+ // for more information.
71
+ #if defined(__GNUC__)
72
+ // Cache line alignment
73
+ #if defined(__i386__) || defined(__x86_64__)
74
+ #define ABSL_CACHELINE_SIZE 64
75
+ #elif defined(__powerpc64__)
76
+ #define ABSL_CACHELINE_SIZE 128
77
+ #elif defined(__aarch64__)
78
+ // We would need to read special register ctr_el0 to find out L1 dcache size.
79
+ // This value is a good estimate based on a real aarch64 machine.
80
+ #define ABSL_CACHELINE_SIZE 64
81
+ #elif defined(__arm__)
82
+ // Cache line sizes for ARM: These values are not strictly correct since
83
+ // cache line sizes depend on implementations, not architectures. There
84
+ // are even implementations with cache line sizes configurable at boot
85
+ // time.
86
+ #if defined(__ARM_ARCH_5T__)
87
+ #define ABSL_CACHELINE_SIZE 32
88
+ #elif defined(__ARM_ARCH_7A__)
89
+ #define ABSL_CACHELINE_SIZE 64
90
+ #endif
91
+ #endif
92
+
93
+ #ifndef ABSL_CACHELINE_SIZE
94
+ // A reasonable default guess. Note that overestimates tend to waste more
95
+ // space, while underestimates tend to waste more time.
96
+ #define ABSL_CACHELINE_SIZE 64
97
+ #endif
98
+
99
+ // ABSL_CACHELINE_ALIGNED
100
+ //
101
+ // Indicates that the declared object be cache aligned using
102
+ // `ABSL_CACHELINE_SIZE` (see above). Cacheline aligning objects allows you to
103
+ // load a set of related objects in the L1 cache for performance improvements.
104
+ // Cacheline aligning objects properly allows constructive memory sharing and
105
+ // prevents destructive (or "false") memory sharing.
106
+ //
107
+ // NOTE: this macro should be replaced with usage of `alignas()` using
108
+ // `std::hardware_constructive_interference_size` and/or
109
+ // `std::hardware_destructive_interference_size` when available within C++17.
110
+ //
111
+ // See http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2016/p0154r1.html
112
+ // for more information.
113
+ //
114
+ // On some compilers, `ABSL_CACHELINE_ALIGNED` expands to an `__attribute__`
115
+ // or `__declspec` attribute. For compilers where this is not known to work,
116
+ // the macro expands to nothing.
117
+ //
118
+ // No further guarantees are made here. The result of applying the macro
119
+ // to variables and types is always implementation-defined.
120
+ //
121
+ // WARNING: It is easy to use this attribute incorrectly, even to the point
122
+ // of causing bugs that are difficult to diagnose, crash, etc. It does not
123
+ // of itself guarantee that objects are aligned to a cache line.
124
+ //
125
+ // NOTE: Some compilers are picky about the locations of annotations such as
126
+ // this attribute, so prefer to put it at the beginning of your declaration.
127
+ // For example,
128
+ //
129
+ // ABSL_CACHELINE_ALIGNED static Foo* foo = ...
130
+ //
131
+ // class ABSL_CACHELINE_ALIGNED Bar { ...
132
+ //
133
+ // Recommendations:
134
+ //
135
+ // 1) Consult compiler documentation; this comment is not kept in sync as
136
+ // toolchains evolve.
137
+ // 2) Verify your use has the intended effect. This often requires inspecting
138
+ // the generated machine code.
139
+ // 3) Prefer applying this attribute to individual variables. Avoid
140
+ // applying it to types. This tends to localize the effect.
141
+ #define ABSL_CACHELINE_ALIGNED __attribute__((aligned(ABSL_CACHELINE_SIZE)))
142
+ #elif defined(_MSC_VER)
143
+ #define ABSL_CACHELINE_SIZE 64
144
+ #define ABSL_CACHELINE_ALIGNED __declspec(align(ABSL_CACHELINE_SIZE))
145
+ #else
146
+ #define ABSL_CACHELINE_SIZE 64
147
+ #define ABSL_CACHELINE_ALIGNED
148
+ #endif
149
+
150
+ // ABSL_PREDICT_TRUE, ABSL_PREDICT_FALSE
151
+ //
152
+ // Enables the compiler to prioritize compilation using static analysis for
153
+ // likely paths within a boolean branch.
154
+ //
155
+ // Example:
156
+ //
157
+ // if (ABSL_PREDICT_TRUE(expression)) {
158
+ // return result; // Faster if more likely
159
+ // } else {
160
+ // return 0;
161
+ // }
162
+ //
163
+ // Compilers can use the information that a certain branch is not likely to be
164
+ // taken (for instance, a CHECK failure) to optimize for the common case in
165
+ // the absence of better information (ie. compiling gcc with `-fprofile-arcs`).
166
+ //
167
+ // Recommendation: Modern CPUs dynamically predict branch execution paths,
168
+ // typically with accuracy greater than 97%. As a result, annotating every
169
+ // branch in a codebase is likely counterproductive; however, annotating
170
+ // specific branches that are both hot and consistently mispredicted is likely
171
+ // to yield performance improvements.
172
+ #if ABSL_HAVE_BUILTIN(__builtin_expect) || \
173
+ (defined(__GNUC__) && !defined(__clang__))
174
+ #define ABSL_PREDICT_FALSE(x) (__builtin_expect(x, 0))
175
+ #define ABSL_PREDICT_TRUE(x) (__builtin_expect(false || (x), true))
176
+ #else
177
+ #define ABSL_PREDICT_FALSE(x) (x)
178
+ #define ABSL_PREDICT_TRUE(x) (x)
179
+ #endif
180
+
181
+ #endif // ABSL_BASE_OPTIMIZATION_H_
@@ -0,0 +1,214 @@
1
+ #ifndef ABSL_BASE_OPTIONS_H_
2
+ #define ABSL_BASE_OPTIONS_H_
3
+
4
+ // Copyright 2019 The Abseil Authors.
5
+ //
6
+ // Licensed under the Apache License, Version 2.0 (the "License");
7
+ // you may not use this file except in compliance with the License.
8
+ // You may obtain a copy of the License at
9
+ //
10
+ // https://www.apache.org/licenses/LICENSE-2.0
11
+ //
12
+ // Unless required by applicable law or agreed to in writing, software
13
+ // distributed under the License is distributed on an "AS IS" BASIS,
14
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ // See the License for the specific language governing permissions and
16
+ // limitations under the License.
17
+ //
18
+ // -----------------------------------------------------------------------------
19
+ // File: options.h
20
+ // -----------------------------------------------------------------------------
21
+ //
22
+ // This file contains Abseil configuration options for setting specific
23
+ // implementations instead of letting Abseil determine which implementation to
24
+ // use at compile-time. Setting these options may be useful for package or build
25
+ // managers who wish to guarantee ABI stability within binary builds (which are
26
+ // otherwise difficult to enforce).
27
+ //
28
+ // *** IMPORTANT NOTICE FOR PACKAGE MANAGERS: It is important that
29
+ // maintainers of package managers who wish to package Abseil read and
30
+ // understand this file! ***
31
+ //
32
+ // Abseil contains a number of possible configuration endpoints, based on
33
+ // parameters such as the detected platform, language version, or command-line
34
+ // flags used to invoke the underlying binary. As is the case with all
35
+ // libraries, binaries which contain Abseil code must ensure that separate
36
+ // packages use the same compiled copy of Abseil to avoid a diamond dependency
37
+ // problem, which can occur if two packages built with different Abseil
38
+ // configuration settings are linked together. Diamond dependency problems in
39
+ // C++ may manifest as violations to the One Definition Rule (ODR) (resulting in
40
+ // linker errors), or undefined behavior (resulting in crashes).
41
+ //
42
+ // Diamond dependency problems can be avoided if all packages utilize the same
43
+ // exact version of Abseil. Building from source code with the same compilation
44
+ // parameters is the easiest way to avoid such dependency problems. However, for
45
+ // package managers who cannot control such compilation parameters, we are
46
+ // providing the file to allow you to inject ABI (Application Binary Interface)
47
+ // stability across builds. Settings options in this file will neither change
48
+ // API nor ABI, providing a stable copy of Abseil between packages.
49
+ //
50
+ // Care must be taken to keep options within these configurations isolated
51
+ // from any other dynamic settings, such as command-line flags which could alter
52
+ // these options. This file is provided specifically to help build and package
53
+ // managers provide a stable copy of Abseil within their libraries and binaries;
54
+ // other developers should not have need to alter the contents of this file.
55
+ //
56
+ // -----------------------------------------------------------------------------
57
+ // Usage
58
+ // -----------------------------------------------------------------------------
59
+ //
60
+ // For any particular package release, set the appropriate definitions within
61
+ // this file to whatever value makes the most sense for your package(s). Note
62
+ // that, by default, most of these options, at the moment, affect the
63
+ // implementation of types; future options may affect other implementation
64
+ // details.
65
+ //
66
+ // NOTE: the defaults within this file all assume that Abseil can select the
67
+ // proper Abseil implementation at compile-time, which will not be sufficient
68
+ // to guarantee ABI stability to package managers.
69
+ //
70
+ // -----------------------------------------------------------------------------
71
+ // Type Compatibility Options
72
+ // -----------------------------------------------------------------------------
73
+ //
74
+ // ABSL_OPTION_USE_STD_ANY
75
+ //
76
+ // This option controls whether absl::any is implemented as an alias to
77
+ // std::any, or as an independent implementation.
78
+ //
79
+ // A value of 0 means to use Abseil's implementation. This requires only C++11
80
+ // support, and is expected to work on every toolchain we support.
81
+ //
82
+ // A value of 1 means to use an alias to std::any. This requires that all code
83
+ // using Abseil is built in C++17 mode or later.
84
+ //
85
+ // A value of 2 means to detect the C++ version being used to compile Abseil,
86
+ // and use an alias only if a working std::any is available. This option is
87
+ // useful when you are building your entire program, including all of its
88
+ // dependencies, from source. It should not be used otherwise -- for example,
89
+ // if you are distributing Abseil in a binary package manager -- since in
90
+ // mode 2, absl::any will name a different type, with a different mangled name
91
+ // and binary layout, depending on the compiler flags passed by the end user.
92
+ // For more info, see https://abseil.io/about/design/dropin-types.
93
+ //
94
+ // User code should not inspect this macro. To check in the preprocessor if
95
+ // absl::any is a typedef of std::any, use the feature macro ABSL_USES_STD_ANY.
96
+
97
+ #define ABSL_OPTION_USE_STD_ANY 2
98
+
99
+
100
+ // ABSL_OPTION_USE_STD_OPTIONAL
101
+ //
102
+ // This option controls whether absl::optional is implemented as an alias to
103
+ // std::optional, or as an independent implementation.
104
+ //
105
+ // A value of 0 means to use Abseil's implementation. This requires only C++11
106
+ // support, and is expected to work on every toolchain we support.
107
+ //
108
+ // A value of 1 means to use an alias to std::optional. This requires that all
109
+ // code using Abseil is built in C++17 mode or later.
110
+ //
111
+ // A value of 2 means to detect the C++ version being used to compile Abseil,
112
+ // and use an alias only if a working std::optional is available. This option
113
+ // is useful when you are building your program from source. It should not be
114
+ // used otherwise -- for example, if you are distributing Abseil in a binary
115
+ // package manager -- since in mode 2, absl::optional will name a different
116
+ // type, with a different mangled name and binary layout, depending on the
117
+ // compiler flags passed by the end user. For more info, see
118
+ // https://abseil.io/about/design/dropin-types.
119
+
120
+ // A value of 2 means to detect the C++ version being used to compile Abseil,
121
+ // and use an alias only if a working std::optional is available. This option
122
+ // should not be used when your program is not built from source -- for example,
123
+ // if you are distributing Abseil in a binary package manager -- since in mode
124
+ // 2, absl::optional will name a different template class, with a different
125
+ // mangled name and binary layout, depending on the compiler flags passed by the
126
+ // end user.
127
+ //
128
+ // User code should not inspect this macro. To check in the preprocessor if
129
+ // absl::optional is a typedef of std::optional, use the feature macro
130
+ // ABSL_USES_STD_OPTIONAL.
131
+
132
+ #define ABSL_OPTION_USE_STD_OPTIONAL 2
133
+
134
+
135
+ // ABSL_OPTION_USE_STD_STRING_VIEW
136
+ //
137
+ // This option controls whether absl::string_view is implemented as an alias to
138
+ // std::string_view, or as an independent implementation.
139
+ //
140
+ // A value of 0 means to use Abseil's implementation. This requires only C++11
141
+ // support, and is expected to work on every toolchain we support.
142
+ //
143
+ // A value of 1 means to use an alias to std::string_view. This requires that
144
+ // all code using Abseil is built in C++17 mode or later.
145
+ //
146
+ // A value of 2 means to detect the C++ version being used to compile Abseil,
147
+ // and use an alias only if a working std::string_view is available. This
148
+ // option is useful when you are building your program from source. It should
149
+ // not be used otherwise -- for example, if you are distributing Abseil in a
150
+ // binary package manager -- since in mode 2, absl::string_view will name a
151
+ // different type, with a different mangled name and binary layout, depending on
152
+ // the compiler flags passed by the end user. For more info, see
153
+ // https://abseil.io/about/design/dropin-types.
154
+ //
155
+ // User code should not inspect this macro. To check in the preprocessor if
156
+ // absl::string_view is a typedef of std::string_view, use the feature macro
157
+ // ABSL_USES_STD_STRING_VIEW.
158
+
159
+ #define ABSL_OPTION_USE_STD_STRING_VIEW 2
160
+
161
+
162
+ // ABSL_OPTION_USE_STD_VARIANT
163
+ //
164
+ // This option controls whether absl::variant is implemented as an alias to
165
+ // std::variant, or as an independent implementation.
166
+ //
167
+ // A value of 0 means to use Abseil's implementation. This requires only C++11
168
+ // support, and is expected to work on every toolchain we support.
169
+ //
170
+ // A value of 1 means to use an alias to std::variant. This requires that all
171
+ // code using Abseil is built in C++17 mode or later.
172
+ //
173
+ // A value of 2 means to detect the C++ version being used to compile Abseil,
174
+ // and use an alias only if a working std::variant is available. This option
175
+ // is useful when you are building your program from source. It should not be
176
+ // used otherwise -- for example, if you are distributing Abseil in a binary
177
+ // package manager -- since in mode 2, absl::variant will name a different
178
+ // type, with a different mangled name and binary layout, depending on the
179
+ // compiler flags passed by the end user. For more info, see
180
+ // https://abseil.io/about/design/dropin-types.
181
+ //
182
+ // User code should not inspect this macro. To check in the preprocessor if
183
+ // absl::variant is a typedef of std::variant, use the feature macro
184
+ // ABSL_USES_STD_VARIANT.
185
+
186
+ #define ABSL_OPTION_USE_STD_VARIANT 2
187
+
188
+
189
+ // ABSL_OPTION_USE_INLINE_NAMESPACE
190
+ // ABSL_OPTION_INLINE_NAMESPACE_NAME
191
+ //
192
+ // These options controls whether all entities in the absl namespace are
193
+ // contained within an inner inline namespace. This does not affect the
194
+ // user-visible API of Abseil, but it changes the mangled names of all symbols.
195
+ //
196
+ // This can be useful as a version tag if you are distributing Abseil in
197
+ // precompiled form. This will prevent a binary library build of Abseil with
198
+ // one inline namespace being used with headers configured with a different
199
+ // inline namespace name. Binary packagers are reminded that Abseil does not
200
+ // guarantee any ABI stability in Abseil, so any update of Abseil or
201
+ // configuration change in such a binary package should be combined with a
202
+ // new, unique value for the inline namespace name.
203
+ //
204
+ // A value of 0 means not to use inline namespaces.
205
+ //
206
+ // A value of 1 means to use an inline namespace with the given name inside
207
+ // namespace absl. If this is set, ABSL_OPTION_INLINE_NAMESPACE_NAME must also
208
+ // be changed to a new, unique identifier name. In particular "head" is not
209
+ // allowed.
210
+
211
+ #define ABSL_OPTION_USE_INLINE_NAMESPACE 0
212
+ #define ABSL_OPTION_INLINE_NAMESPACE_NAME head
213
+
214
+ #endif // ABSL_BASE_OPTIONS_H_