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.
- checksums.yaml +4 -4
- data/Makefile +1654 -1519
- data/etc/roots.pem +44 -0
- data/include/grpc/grpc_security.h +37 -15
- data/include/grpc/grpc_security_constants.h +27 -0
- data/include/grpc/impl/codegen/grpc_types.h +14 -0
- data/include/grpc/impl/codegen/port_platform.h +1 -1
- data/src/core/ext/filters/client_channel/client_channel.cc +0 -20
- data/src/core/ext/filters/client_channel/http_proxy.cc +4 -4
- data/src/core/ext/filters/client_channel/lb_policy.cc +4 -3
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc +191 -201
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_balancer_addresses.cc +89 -0
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_balancer_addresses.h +40 -0
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel_secure.cc +3 -2
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.cc +88 -121
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.h +28 -57
- data/src/core/ext/filters/client_channel/lb_policy/subchannel_list.h +0 -7
- data/src/core/ext/filters/client_channel/lb_policy/xds/cds.cc +8 -9
- data/src/core/ext/filters/client_channel/lb_policy/xds/xds.cc +53 -34
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc +18 -5
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc +24 -19
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h +2 -1
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_fallback.cc +4 -2
- data/src/core/ext/filters/client_channel/server_address.cc +6 -9
- data/src/core/ext/filters/client_channel/server_address.h +3 -10
- data/src/core/ext/filters/client_channel/xds/xds_api.cc +394 -150
- data/src/core/ext/filters/client_channel/xds/xds_api.h +75 -35
- data/src/core/ext/filters/client_channel/xds/xds_bootstrap.cc +59 -22
- data/src/core/ext/filters/client_channel/xds/xds_bootstrap.h +13 -9
- data/src/core/ext/filters/client_channel/xds/xds_channel_secure.cc +8 -6
- data/src/core/ext/filters/client_channel/xds/xds_client.cc +456 -175
- data/src/core/ext/filters/client_channel/xds/xds_client.h +33 -21
- data/src/core/ext/filters/client_channel/xds/xds_client_stats.cc +5 -8
- data/src/core/ext/filters/client_channel/xds/xds_client_stats.h +18 -24
- data/src/core/ext/transport/chttp2/transport/chttp2_transport.cc +2 -2
- data/src/core/ext/upb-generated/src/proto/grpc/lb/v1/load_balancer.upb.c +13 -5
- data/src/core/ext/upb-generated/src/proto/grpc/lb/v1/load_balancer.upb.h +34 -0
- data/src/core/lib/channel/channelz.h +11 -1
- data/src/core/lib/gpr/time_precise.cc +1 -1
- data/src/core/lib/gprpp/optional.h +26 -0
- data/src/core/lib/gprpp/string_view.h +14 -10
- data/src/core/lib/iomgr/executor.cc +1 -1
- data/src/core/lib/iomgr/fork_posix.cc +4 -0
- data/src/core/lib/iomgr/poller/eventmanager_libuv.cc +87 -0
- data/src/core/lib/iomgr/poller/eventmanager_libuv.h +88 -0
- data/src/core/lib/iomgr/socket_utils_common_posix.cc +14 -0
- data/src/core/lib/iomgr/socket_utils_posix.h +12 -0
- data/src/core/lib/iomgr/tcp_custom.h +3 -0
- data/src/core/lib/iomgr/tcp_posix.cc +607 -56
- data/src/core/lib/iomgr/tcp_server_custom.cc +15 -2
- data/src/core/lib/iomgr/tcp_server_utils_posix_common.cc +8 -0
- data/src/core/lib/json/json.h +11 -1
- data/src/core/lib/json/json_reader.cc +206 -28
- data/src/core/lib/json/json_writer.cc +111 -24
- data/src/core/lib/security/credentials/composite/composite_credentials.cc +7 -0
- data/src/core/lib/security/credentials/composite/composite_credentials.h +5 -1
- data/src/core/lib/security/credentials/credentials.h +10 -1
- data/src/core/lib/security/credentials/fake/fake_credentials.h +2 -1
- data/src/core/lib/security/credentials/oauth2/oauth2_credentials.cc +1 -1
- data/src/core/lib/security/credentials/plugin/plugin_credentials.cc +6 -4
- data/src/core/lib/security/credentials/plugin/plugin_credentials.h +2 -1
- data/src/core/lib/security/credentials/tls/grpc_tls_credentials_options.cc +20 -0
- data/src/core/lib/security/credentials/tls/grpc_tls_credentials_options.h +8 -0
- data/src/core/lib/security/credentials/tls/{spiffe_credentials.cc → tls_credentials.cc} +23 -24
- data/src/core/lib/security/credentials/tls/{spiffe_credentials.h → tls_credentials.h} +9 -9
- data/src/core/lib/security/security_connector/alts/alts_security_connector.cc +13 -0
- data/src/core/lib/security/security_connector/fake/fake_security_connector.cc +22 -2
- data/src/core/lib/security/security_connector/load_system_roots_fallback.cc +2 -2
- data/src/core/lib/security/security_connector/load_system_roots_linux.cc +2 -2
- data/src/core/lib/security/security_connector/local/local_security_connector.cc +30 -3
- data/src/core/lib/security/security_connector/ssl_utils.cc +45 -3
- data/src/core/lib/security/security_connector/ssl_utils.h +12 -0
- data/src/core/lib/security/security_connector/tls/{spiffe_security_connector.cc → tls_security_connector.cc} +82 -69
- data/src/core/lib/security/security_connector/tls/{spiffe_security_connector.h → tls_security_connector.h} +17 -18
- data/src/core/lib/security/transport/client_auth_filter.cc +33 -0
- data/src/core/lib/surface/completion_queue.cc +22 -1
- data/src/core/lib/surface/version.cc +1 -1
- data/src/core/tsi/alts/handshaker/alts_tsi_handshaker.cc +11 -1
- data/src/core/tsi/alts/handshaker/alts_tsi_handshaker.h +1 -1
- data/src/core/tsi/alts/zero_copy_frame_protector/alts_zero_copy_grpc_protector.cc +3 -3
- data/src/core/tsi/fake_transport_security.cc +7 -3
- data/src/core/tsi/fake_transport_security.h +2 -0
- data/src/core/tsi/ssl_transport_security.cc +144 -8
- data/src/core/tsi/ssl_transport_security.h +15 -1
- data/src/core/tsi/transport_security.cc +13 -0
- data/src/core/tsi/transport_security_grpc.cc +2 -2
- data/src/core/tsi/transport_security_grpc.h +2 -2
- data/src/core/tsi/transport_security_interface.h +12 -0
- data/src/ruby/bin/math_pb.rb +5 -5
- data/src/ruby/ext/grpc/rb_call_credentials.c +4 -1
- data/src/ruby/ext/grpc/rb_grpc_imports.generated.c +2 -0
- data/src/ruby/ext/grpc/rb_grpc_imports.generated.h +4 -1
- data/src/ruby/lib/grpc/version.rb +1 -1
- data/src/ruby/pb/grpc/health/v1/health_pb.rb +3 -3
- data/src/ruby/pb/src/proto/grpc/testing/empty_pb.rb +1 -1
- data/src/ruby/pb/src/proto/grpc/testing/messages_pb.rb +23 -13
- data/third_party/abseil-cpp/absl/algorithm/algorithm.h +159 -0
- data/third_party/abseil-cpp/absl/base/attributes.h +609 -0
- data/third_party/abseil-cpp/absl/base/call_once.h +226 -0
- data/third_party/abseil-cpp/absl/base/casts.h +184 -0
- data/third_party/abseil-cpp/absl/base/config.h +622 -0
- data/third_party/abseil-cpp/absl/base/const_init.h +76 -0
- data/third_party/abseil-cpp/absl/base/dynamic_annotations.cc +129 -0
- data/third_party/abseil-cpp/absl/base/dynamic_annotations.h +389 -0
- data/third_party/abseil-cpp/absl/base/internal/atomic_hook.h +179 -0
- data/third_party/abseil-cpp/absl/base/internal/bits.h +218 -0
- data/third_party/abseil-cpp/absl/base/internal/cycleclock.cc +107 -0
- data/third_party/abseil-cpp/absl/base/internal/cycleclock.h +94 -0
- data/third_party/abseil-cpp/absl/base/internal/endian.h +266 -0
- data/third_party/abseil-cpp/absl/base/internal/hide_ptr.h +51 -0
- data/third_party/abseil-cpp/absl/base/internal/identity.h +37 -0
- data/third_party/abseil-cpp/absl/base/internal/inline_variable.h +107 -0
- data/third_party/abseil-cpp/absl/base/internal/invoke.h +187 -0
- data/third_party/abseil-cpp/absl/base/internal/low_level_scheduling.h +107 -0
- data/third_party/abseil-cpp/absl/base/internal/per_thread_tls.h +52 -0
- data/third_party/abseil-cpp/absl/base/internal/raw_logging.cc +237 -0
- data/third_party/abseil-cpp/absl/base/internal/raw_logging.h +179 -0
- data/third_party/abseil-cpp/absl/base/internal/scheduling_mode.h +58 -0
- data/third_party/abseil-cpp/absl/base/internal/spinlock.cc +233 -0
- data/third_party/abseil-cpp/absl/base/internal/spinlock.h +243 -0
- data/third_party/abseil-cpp/absl/base/internal/spinlock_akaros.inc +35 -0
- data/third_party/abseil-cpp/absl/base/internal/spinlock_linux.inc +67 -0
- data/third_party/abseil-cpp/absl/base/internal/spinlock_posix.inc +46 -0
- data/third_party/abseil-cpp/absl/base/internal/spinlock_wait.cc +81 -0
- data/third_party/abseil-cpp/absl/base/internal/spinlock_wait.h +93 -0
- data/third_party/abseil-cpp/absl/base/internal/spinlock_win32.inc +37 -0
- data/third_party/abseil-cpp/absl/base/internal/sysinfo.cc +414 -0
- data/third_party/abseil-cpp/absl/base/internal/sysinfo.h +66 -0
- data/third_party/abseil-cpp/absl/base/internal/thread_annotations.h +271 -0
- data/third_party/abseil-cpp/absl/base/internal/thread_identity.cc +140 -0
- data/third_party/abseil-cpp/absl/base/internal/thread_identity.h +250 -0
- data/third_party/abseil-cpp/absl/base/internal/throw_delegate.cc +108 -0
- data/third_party/abseil-cpp/absl/base/internal/throw_delegate.h +75 -0
- data/third_party/abseil-cpp/absl/base/internal/tsan_mutex_interface.h +66 -0
- data/third_party/abseil-cpp/absl/base/internal/unaligned_access.h +158 -0
- data/third_party/abseil-cpp/absl/base/internal/unscaledcycleclock.cc +103 -0
- data/third_party/abseil-cpp/absl/base/internal/unscaledcycleclock.h +124 -0
- data/third_party/abseil-cpp/absl/base/log_severity.cc +27 -0
- data/third_party/abseil-cpp/absl/base/log_severity.h +121 -0
- data/third_party/abseil-cpp/absl/base/macros.h +220 -0
- data/third_party/abseil-cpp/absl/base/optimization.h +181 -0
- data/third_party/abseil-cpp/absl/base/options.h +214 -0
- data/third_party/abseil-cpp/absl/base/policy_checks.h +111 -0
- data/third_party/abseil-cpp/absl/base/port.h +26 -0
- data/third_party/abseil-cpp/absl/base/thread_annotations.h +280 -0
- data/third_party/abseil-cpp/absl/container/inlined_vector.h +848 -0
- data/third_party/abseil-cpp/absl/container/internal/compressed_tuple.h +265 -0
- data/third_party/abseil-cpp/absl/container/internal/inlined_vector.h +892 -0
- data/third_party/abseil-cpp/absl/memory/memory.h +695 -0
- data/third_party/abseil-cpp/absl/meta/type_traits.h +759 -0
- data/third_party/abseil-cpp/absl/numeric/int128.cc +404 -0
- data/third_party/abseil-cpp/absl/numeric/int128.h +1091 -0
- data/third_party/abseil-cpp/absl/numeric/int128_have_intrinsic.inc +302 -0
- data/third_party/abseil-cpp/absl/numeric/int128_no_intrinsic.inc +308 -0
- data/third_party/abseil-cpp/absl/strings/ascii.cc +200 -0
- data/third_party/abseil-cpp/absl/strings/ascii.h +241 -0
- data/third_party/abseil-cpp/absl/strings/charconv.cc +985 -0
- data/third_party/abseil-cpp/absl/strings/charconv.h +119 -0
- data/third_party/abseil-cpp/absl/strings/escaping.cc +949 -0
- data/third_party/abseil-cpp/absl/strings/escaping.h +164 -0
- data/third_party/abseil-cpp/absl/strings/internal/char_map.h +156 -0
- data/third_party/abseil-cpp/absl/strings/internal/charconv_bigint.cc +359 -0
- data/third_party/abseil-cpp/absl/strings/internal/charconv_bigint.h +421 -0
- data/third_party/abseil-cpp/absl/strings/internal/charconv_parse.cc +504 -0
- data/third_party/abseil-cpp/absl/strings/internal/charconv_parse.h +99 -0
- data/third_party/abseil-cpp/absl/strings/internal/escaping.cc +180 -0
- data/third_party/abseil-cpp/absl/strings/internal/escaping.h +58 -0
- data/third_party/abseil-cpp/absl/strings/internal/memutil.cc +112 -0
- data/third_party/abseil-cpp/absl/strings/internal/memutil.h +148 -0
- data/third_party/abseil-cpp/absl/strings/internal/ostringstream.cc +36 -0
- data/third_party/abseil-cpp/absl/strings/internal/ostringstream.h +89 -0
- data/third_party/abseil-cpp/absl/strings/internal/resize_uninitialized.h +73 -0
- data/third_party/abseil-cpp/absl/strings/internal/stl_type_traits.h +248 -0
- data/third_party/abseil-cpp/absl/strings/internal/str_join_internal.h +314 -0
- data/third_party/abseil-cpp/absl/strings/internal/str_split_internal.h +455 -0
- data/third_party/abseil-cpp/absl/strings/internal/utf8.cc +53 -0
- data/third_party/abseil-cpp/absl/strings/internal/utf8.h +50 -0
- data/third_party/abseil-cpp/absl/strings/match.cc +40 -0
- data/third_party/abseil-cpp/absl/strings/match.h +90 -0
- data/third_party/abseil-cpp/absl/strings/numbers.cc +916 -0
- data/third_party/abseil-cpp/absl/strings/numbers.h +263 -0
- data/third_party/abseil-cpp/absl/strings/str_cat.cc +246 -0
- data/third_party/abseil-cpp/absl/strings/str_cat.h +408 -0
- data/third_party/abseil-cpp/absl/strings/str_join.h +293 -0
- data/third_party/abseil-cpp/absl/strings/str_replace.cc +82 -0
- data/third_party/abseil-cpp/absl/strings/str_replace.h +219 -0
- data/third_party/abseil-cpp/absl/strings/str_split.cc +139 -0
- data/third_party/abseil-cpp/absl/strings/str_split.h +513 -0
- data/third_party/abseil-cpp/absl/strings/string_view.cc +235 -0
- data/third_party/abseil-cpp/absl/strings/string_view.h +615 -0
- data/third_party/abseil-cpp/absl/strings/strip.h +91 -0
- data/third_party/abseil-cpp/absl/strings/substitute.cc +171 -0
- data/third_party/abseil-cpp/absl/strings/substitute.h +693 -0
- data/third_party/abseil-cpp/absl/types/bad_optional_access.cc +48 -0
- data/third_party/abseil-cpp/absl/types/bad_optional_access.h +78 -0
- data/third_party/abseil-cpp/absl/types/internal/optional.h +396 -0
- data/third_party/abseil-cpp/absl/types/internal/span.h +128 -0
- data/third_party/abseil-cpp/absl/types/optional.h +776 -0
- data/third_party/abseil-cpp/absl/types/span.h +713 -0
- data/third_party/abseil-cpp/absl/utility/utility.h +350 -0
- data/third_party/upb/upb/decode.c +4 -0
- data/third_party/upb/upb/port.c +0 -1
- data/third_party/upb/upb/port_def.inc +1 -3
- data/third_party/upb/upb/table.c +2 -1
- metadata +147 -43
- data/src/core/lib/json/json_common.h +0 -34
- data/src/core/lib/json/json_reader.h +0 -146
- data/src/core/lib/json/json_string.cc +0 -367
- data/src/core/lib/json/json_writer.h +0 -84
@@ -0,0 +1,158 @@
|
|
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
|
+
#ifndef ABSL_BASE_INTERNAL_UNALIGNED_ACCESS_H_
|
18
|
+
#define ABSL_BASE_INTERNAL_UNALIGNED_ACCESS_H_
|
19
|
+
|
20
|
+
#include <string.h>
|
21
|
+
|
22
|
+
#include <cstdint>
|
23
|
+
|
24
|
+
#include "absl/base/attributes.h"
|
25
|
+
#include "absl/base/config.h"
|
26
|
+
|
27
|
+
// unaligned APIs
|
28
|
+
|
29
|
+
// Portable handling of unaligned loads, stores, and copies.
|
30
|
+
|
31
|
+
// The unaligned API is C++ only. The declarations use C++ features
|
32
|
+
// (namespaces, inline) which are absent or incompatible in C.
|
33
|
+
#if defined(__cplusplus)
|
34
|
+
|
35
|
+
#if defined(ADDRESS_SANITIZER) || defined(THREAD_SANITIZER) ||\
|
36
|
+
defined(MEMORY_SANITIZER)
|
37
|
+
// Consider we have an unaligned load/store of 4 bytes from address 0x...05.
|
38
|
+
// AddressSanitizer will treat it as a 3-byte access to the range 05:07 and
|
39
|
+
// will miss a bug if 08 is the first unaddressable byte.
|
40
|
+
// ThreadSanitizer will also treat this as a 3-byte access to 05:07 and will
|
41
|
+
// miss a race between this access and some other accesses to 08.
|
42
|
+
// MemorySanitizer will correctly propagate the shadow on unaligned stores
|
43
|
+
// and correctly report bugs on unaligned loads, but it may not properly
|
44
|
+
// update and report the origin of the uninitialized memory.
|
45
|
+
// For all three tools, replacing an unaligned access with a tool-specific
|
46
|
+
// callback solves the problem.
|
47
|
+
|
48
|
+
// Make sure uint16_t/uint32_t/uint64_t are defined.
|
49
|
+
#include <stdint.h>
|
50
|
+
|
51
|
+
extern "C" {
|
52
|
+
uint16_t __sanitizer_unaligned_load16(const void *p);
|
53
|
+
uint32_t __sanitizer_unaligned_load32(const void *p);
|
54
|
+
uint64_t __sanitizer_unaligned_load64(const void *p);
|
55
|
+
void __sanitizer_unaligned_store16(void *p, uint16_t v);
|
56
|
+
void __sanitizer_unaligned_store32(void *p, uint32_t v);
|
57
|
+
void __sanitizer_unaligned_store64(void *p, uint64_t v);
|
58
|
+
} // extern "C"
|
59
|
+
|
60
|
+
namespace absl {
|
61
|
+
ABSL_NAMESPACE_BEGIN
|
62
|
+
namespace base_internal {
|
63
|
+
|
64
|
+
inline uint16_t UnalignedLoad16(const void *p) {
|
65
|
+
return __sanitizer_unaligned_load16(p);
|
66
|
+
}
|
67
|
+
|
68
|
+
inline uint32_t UnalignedLoad32(const void *p) {
|
69
|
+
return __sanitizer_unaligned_load32(p);
|
70
|
+
}
|
71
|
+
|
72
|
+
inline uint64_t UnalignedLoad64(const void *p) {
|
73
|
+
return __sanitizer_unaligned_load64(p);
|
74
|
+
}
|
75
|
+
|
76
|
+
inline void UnalignedStore16(void *p, uint16_t v) {
|
77
|
+
__sanitizer_unaligned_store16(p, v);
|
78
|
+
}
|
79
|
+
|
80
|
+
inline void UnalignedStore32(void *p, uint32_t v) {
|
81
|
+
__sanitizer_unaligned_store32(p, v);
|
82
|
+
}
|
83
|
+
|
84
|
+
inline void UnalignedStore64(void *p, uint64_t v) {
|
85
|
+
__sanitizer_unaligned_store64(p, v);
|
86
|
+
}
|
87
|
+
|
88
|
+
} // namespace base_internal
|
89
|
+
ABSL_NAMESPACE_END
|
90
|
+
} // namespace absl
|
91
|
+
|
92
|
+
#define ABSL_INTERNAL_UNALIGNED_LOAD16(_p) \
|
93
|
+
(absl::base_internal::UnalignedLoad16(_p))
|
94
|
+
#define ABSL_INTERNAL_UNALIGNED_LOAD32(_p) \
|
95
|
+
(absl::base_internal::UnalignedLoad32(_p))
|
96
|
+
#define ABSL_INTERNAL_UNALIGNED_LOAD64(_p) \
|
97
|
+
(absl::base_internal::UnalignedLoad64(_p))
|
98
|
+
|
99
|
+
#define ABSL_INTERNAL_UNALIGNED_STORE16(_p, _val) \
|
100
|
+
(absl::base_internal::UnalignedStore16(_p, _val))
|
101
|
+
#define ABSL_INTERNAL_UNALIGNED_STORE32(_p, _val) \
|
102
|
+
(absl::base_internal::UnalignedStore32(_p, _val))
|
103
|
+
#define ABSL_INTERNAL_UNALIGNED_STORE64(_p, _val) \
|
104
|
+
(absl::base_internal::UnalignedStore64(_p, _val))
|
105
|
+
|
106
|
+
#else
|
107
|
+
|
108
|
+
namespace absl {
|
109
|
+
ABSL_NAMESPACE_BEGIN
|
110
|
+
namespace base_internal {
|
111
|
+
|
112
|
+
inline uint16_t UnalignedLoad16(const void *p) {
|
113
|
+
uint16_t t;
|
114
|
+
memcpy(&t, p, sizeof t);
|
115
|
+
return t;
|
116
|
+
}
|
117
|
+
|
118
|
+
inline uint32_t UnalignedLoad32(const void *p) {
|
119
|
+
uint32_t t;
|
120
|
+
memcpy(&t, p, sizeof t);
|
121
|
+
return t;
|
122
|
+
}
|
123
|
+
|
124
|
+
inline uint64_t UnalignedLoad64(const void *p) {
|
125
|
+
uint64_t t;
|
126
|
+
memcpy(&t, p, sizeof t);
|
127
|
+
return t;
|
128
|
+
}
|
129
|
+
|
130
|
+
inline void UnalignedStore16(void *p, uint16_t v) { memcpy(p, &v, sizeof v); }
|
131
|
+
|
132
|
+
inline void UnalignedStore32(void *p, uint32_t v) { memcpy(p, &v, sizeof v); }
|
133
|
+
|
134
|
+
inline void UnalignedStore64(void *p, uint64_t v) { memcpy(p, &v, sizeof v); }
|
135
|
+
|
136
|
+
} // namespace base_internal
|
137
|
+
ABSL_NAMESPACE_END
|
138
|
+
} // namespace absl
|
139
|
+
|
140
|
+
#define ABSL_INTERNAL_UNALIGNED_LOAD16(_p) \
|
141
|
+
(absl::base_internal::UnalignedLoad16(_p))
|
142
|
+
#define ABSL_INTERNAL_UNALIGNED_LOAD32(_p) \
|
143
|
+
(absl::base_internal::UnalignedLoad32(_p))
|
144
|
+
#define ABSL_INTERNAL_UNALIGNED_LOAD64(_p) \
|
145
|
+
(absl::base_internal::UnalignedLoad64(_p))
|
146
|
+
|
147
|
+
#define ABSL_INTERNAL_UNALIGNED_STORE16(_p, _val) \
|
148
|
+
(absl::base_internal::UnalignedStore16(_p, _val))
|
149
|
+
#define ABSL_INTERNAL_UNALIGNED_STORE32(_p, _val) \
|
150
|
+
(absl::base_internal::UnalignedStore32(_p, _val))
|
151
|
+
#define ABSL_INTERNAL_UNALIGNED_STORE64(_p, _val) \
|
152
|
+
(absl::base_internal::UnalignedStore64(_p, _val))
|
153
|
+
|
154
|
+
#endif
|
155
|
+
|
156
|
+
#endif // defined(__cplusplus), end of unaligned API
|
157
|
+
|
158
|
+
#endif // ABSL_BASE_INTERNAL_UNALIGNED_ACCESS_H_
|
@@ -0,0 +1,103 @@
|
|
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
|
+
#include "absl/base/internal/unscaledcycleclock.h"
|
16
|
+
|
17
|
+
#if ABSL_USE_UNSCALED_CYCLECLOCK
|
18
|
+
|
19
|
+
#if defined(_WIN32)
|
20
|
+
#include <intrin.h>
|
21
|
+
#endif
|
22
|
+
|
23
|
+
#if defined(__powerpc__) || defined(__ppc__)
|
24
|
+
#include <sys/platform/ppc.h>
|
25
|
+
#endif
|
26
|
+
|
27
|
+
#include "absl/base/internal/sysinfo.h"
|
28
|
+
|
29
|
+
namespace absl {
|
30
|
+
ABSL_NAMESPACE_BEGIN
|
31
|
+
namespace base_internal {
|
32
|
+
|
33
|
+
#if defined(__i386__)
|
34
|
+
|
35
|
+
int64_t UnscaledCycleClock::Now() {
|
36
|
+
int64_t ret;
|
37
|
+
__asm__ volatile("rdtsc" : "=A"(ret));
|
38
|
+
return ret;
|
39
|
+
}
|
40
|
+
|
41
|
+
double UnscaledCycleClock::Frequency() {
|
42
|
+
return base_internal::NominalCPUFrequency();
|
43
|
+
}
|
44
|
+
|
45
|
+
#elif defined(__x86_64__)
|
46
|
+
|
47
|
+
int64_t UnscaledCycleClock::Now() {
|
48
|
+
uint64_t low, high;
|
49
|
+
__asm__ volatile("rdtsc" : "=a"(low), "=d"(high));
|
50
|
+
return (high << 32) | low;
|
51
|
+
}
|
52
|
+
|
53
|
+
double UnscaledCycleClock::Frequency() {
|
54
|
+
return base_internal::NominalCPUFrequency();
|
55
|
+
}
|
56
|
+
|
57
|
+
#elif defined(__powerpc__) || defined(__ppc__)
|
58
|
+
|
59
|
+
int64_t UnscaledCycleClock::Now() {
|
60
|
+
return __ppc_get_timebase();
|
61
|
+
}
|
62
|
+
|
63
|
+
double UnscaledCycleClock::Frequency() {
|
64
|
+
return __ppc_get_timebase_freq();
|
65
|
+
}
|
66
|
+
|
67
|
+
#elif defined(__aarch64__)
|
68
|
+
|
69
|
+
// System timer of ARMv8 runs at a different frequency than the CPU's.
|
70
|
+
// The frequency is fixed, typically in the range 1-50MHz. It can be
|
71
|
+
// read at CNTFRQ special register. We assume the OS has set up
|
72
|
+
// the virtual timer properly.
|
73
|
+
int64_t UnscaledCycleClock::Now() {
|
74
|
+
int64_t virtual_timer_value;
|
75
|
+
asm volatile("mrs %0, cntvct_el0" : "=r"(virtual_timer_value));
|
76
|
+
return virtual_timer_value;
|
77
|
+
}
|
78
|
+
|
79
|
+
double UnscaledCycleClock::Frequency() {
|
80
|
+
uint64_t aarch64_timer_frequency;
|
81
|
+
asm volatile("mrs %0, cntfrq_el0" : "=r"(aarch64_timer_frequency));
|
82
|
+
return aarch64_timer_frequency;
|
83
|
+
}
|
84
|
+
|
85
|
+
#elif defined(_M_IX86) || defined(_M_X64)
|
86
|
+
|
87
|
+
#pragma intrinsic(__rdtsc)
|
88
|
+
|
89
|
+
int64_t UnscaledCycleClock::Now() {
|
90
|
+
return __rdtsc();
|
91
|
+
}
|
92
|
+
|
93
|
+
double UnscaledCycleClock::Frequency() {
|
94
|
+
return base_internal::NominalCPUFrequency();
|
95
|
+
}
|
96
|
+
|
97
|
+
#endif
|
98
|
+
|
99
|
+
} // namespace base_internal
|
100
|
+
ABSL_NAMESPACE_END
|
101
|
+
} // namespace absl
|
102
|
+
|
103
|
+
#endif // ABSL_USE_UNSCALED_CYCLECLOCK
|
@@ -0,0 +1,124 @@
|
|
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
|
+
// UnscaledCycleClock
|
16
|
+
// An UnscaledCycleClock yields the value and frequency of a cycle counter
|
17
|
+
// that increments at a rate that is approximately constant.
|
18
|
+
// This class is for internal / whitelisted use only, you should consider
|
19
|
+
// using CycleClock instead.
|
20
|
+
//
|
21
|
+
// Notes:
|
22
|
+
// The cycle counter frequency is not necessarily the core clock frequency.
|
23
|
+
// That is, CycleCounter cycles are not necessarily "CPU cycles".
|
24
|
+
//
|
25
|
+
// An arbitrary offset may have been added to the counter at power on.
|
26
|
+
//
|
27
|
+
// On some platforms, the rate and offset of the counter may differ
|
28
|
+
// slightly when read from different CPUs of a multiprocessor. Usually,
|
29
|
+
// we try to ensure that the operating system adjusts values periodically
|
30
|
+
// so that values agree approximately. If you need stronger guarantees,
|
31
|
+
// consider using alternate interfaces.
|
32
|
+
//
|
33
|
+
// The CPU is not required to maintain the ordering of a cycle counter read
|
34
|
+
// with respect to surrounding instructions.
|
35
|
+
|
36
|
+
#ifndef ABSL_BASE_INTERNAL_UNSCALEDCYCLECLOCK_H_
|
37
|
+
#define ABSL_BASE_INTERNAL_UNSCALEDCYCLECLOCK_H_
|
38
|
+
|
39
|
+
#include <cstdint>
|
40
|
+
|
41
|
+
#if defined(__APPLE__)
|
42
|
+
#include <TargetConditionals.h>
|
43
|
+
#endif
|
44
|
+
|
45
|
+
#include "absl/base/port.h"
|
46
|
+
|
47
|
+
// The following platforms have an implementation of a hardware counter.
|
48
|
+
#if defined(__i386__) || defined(__x86_64__) || defined(__aarch64__) || \
|
49
|
+
defined(__powerpc__) || defined(__ppc__) || \
|
50
|
+
defined(_M_IX86) || defined(_M_X64)
|
51
|
+
#define ABSL_HAVE_UNSCALED_CYCLECLOCK_IMPLEMENTATION 1
|
52
|
+
#else
|
53
|
+
#define ABSL_HAVE_UNSCALED_CYCLECLOCK_IMPLEMENTATION 0
|
54
|
+
#endif
|
55
|
+
|
56
|
+
// The following platforms often disable access to the hardware
|
57
|
+
// counter (through a sandbox) even if the underlying hardware has a
|
58
|
+
// usable counter. The CycleTimer interface also requires a *scaled*
|
59
|
+
// CycleClock that runs at atleast 1 MHz. We've found some Android
|
60
|
+
// ARM64 devices where this is not the case, so we disable it by
|
61
|
+
// default on Android ARM64.
|
62
|
+
#if defined(__native_client__) || \
|
63
|
+
(defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE) || \
|
64
|
+
(defined(__ANDROID__) && defined(__aarch64__))
|
65
|
+
#define ABSL_USE_UNSCALED_CYCLECLOCK_DEFAULT 0
|
66
|
+
#else
|
67
|
+
#define ABSL_USE_UNSCALED_CYCLECLOCK_DEFAULT 1
|
68
|
+
#endif
|
69
|
+
|
70
|
+
// UnscaledCycleClock is an optional internal feature.
|
71
|
+
// Use "#if ABSL_USE_UNSCALED_CYCLECLOCK" to test for its presence.
|
72
|
+
// Can be overridden at compile-time via -DABSL_USE_UNSCALED_CYCLECLOCK=0|1
|
73
|
+
#if !defined(ABSL_USE_UNSCALED_CYCLECLOCK)
|
74
|
+
#define ABSL_USE_UNSCALED_CYCLECLOCK \
|
75
|
+
(ABSL_HAVE_UNSCALED_CYCLECLOCK_IMPLEMENTATION && \
|
76
|
+
ABSL_USE_UNSCALED_CYCLECLOCK_DEFAULT)
|
77
|
+
#endif
|
78
|
+
|
79
|
+
#if ABSL_USE_UNSCALED_CYCLECLOCK
|
80
|
+
|
81
|
+
// This macro can be used to test if UnscaledCycleClock::Frequency()
|
82
|
+
// is NominalCPUFrequency() on a particular platform.
|
83
|
+
#if (defined(__i386__) || defined(__x86_64__) || \
|
84
|
+
defined(_M_IX86) || defined(_M_X64))
|
85
|
+
#define ABSL_INTERNAL_UNSCALED_CYCLECLOCK_FREQUENCY_IS_CPU_FREQUENCY
|
86
|
+
#endif
|
87
|
+
|
88
|
+
namespace absl {
|
89
|
+
ABSL_NAMESPACE_BEGIN
|
90
|
+
namespace time_internal {
|
91
|
+
class UnscaledCycleClockWrapperForGetCurrentTime;
|
92
|
+
} // namespace time_internal
|
93
|
+
|
94
|
+
namespace base_internal {
|
95
|
+
class CycleClock;
|
96
|
+
class UnscaledCycleClockWrapperForInitializeFrequency;
|
97
|
+
|
98
|
+
class UnscaledCycleClock {
|
99
|
+
private:
|
100
|
+
UnscaledCycleClock() = delete;
|
101
|
+
|
102
|
+
// Return the value of a cycle counter that counts at a rate that is
|
103
|
+
// approximately constant.
|
104
|
+
static int64_t Now();
|
105
|
+
|
106
|
+
// Return the how much UnscaledCycleClock::Now() increases per second.
|
107
|
+
// This is not necessarily the core CPU clock frequency.
|
108
|
+
// It may be the nominal value report by the kernel, rather than a measured
|
109
|
+
// value.
|
110
|
+
static double Frequency();
|
111
|
+
|
112
|
+
// Whitelisted friends.
|
113
|
+
friend class base_internal::CycleClock;
|
114
|
+
friend class time_internal::UnscaledCycleClockWrapperForGetCurrentTime;
|
115
|
+
friend class base_internal::UnscaledCycleClockWrapperForInitializeFrequency;
|
116
|
+
};
|
117
|
+
|
118
|
+
} // namespace base_internal
|
119
|
+
ABSL_NAMESPACE_END
|
120
|
+
} // namespace absl
|
121
|
+
|
122
|
+
#endif // ABSL_USE_UNSCALED_CYCLECLOCK
|
123
|
+
|
124
|
+
#endif // ABSL_BASE_INTERNAL_UNSCALEDCYCLECLOCK_H_
|
@@ -0,0 +1,27 @@
|
|
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
|
+
#include "absl/base/log_severity.h"
|
16
|
+
|
17
|
+
#include <ostream>
|
18
|
+
|
19
|
+
namespace absl {
|
20
|
+
ABSL_NAMESPACE_BEGIN
|
21
|
+
|
22
|
+
std::ostream& operator<<(std::ostream& os, absl::LogSeverity s) {
|
23
|
+
if (s == absl::NormalizeLogSeverity(s)) return os << absl::LogSeverityName(s);
|
24
|
+
return os << "absl::LogSeverity(" << static_cast<int>(s) << ")";
|
25
|
+
}
|
26
|
+
ABSL_NAMESPACE_END
|
27
|
+
} // namespace absl
|
@@ -0,0 +1,121 @@
|
|
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_LOG_SEVERITY_H_
|
16
|
+
#define ABSL_BASE_INTERNAL_LOG_SEVERITY_H_
|
17
|
+
|
18
|
+
#include <array>
|
19
|
+
#include <ostream>
|
20
|
+
|
21
|
+
#include "absl/base/attributes.h"
|
22
|
+
#include "absl/base/config.h"
|
23
|
+
|
24
|
+
namespace absl {
|
25
|
+
ABSL_NAMESPACE_BEGIN
|
26
|
+
|
27
|
+
// absl::LogSeverity
|
28
|
+
//
|
29
|
+
// Four severity levels are defined. Logging APIs should terminate the program
|
30
|
+
// when a message is logged at severity `kFatal`; the other levels have no
|
31
|
+
// special semantics.
|
32
|
+
//
|
33
|
+
// Values other than the four defined levels (e.g. produced by `static_cast`)
|
34
|
+
// are valid, but their semantics when passed to a function, macro, or flag
|
35
|
+
// depend on the function, macro, or flag. The usual behavior is to normalize
|
36
|
+
// such values to a defined severity level, however in some cases values other
|
37
|
+
// than the defined levels are useful for comparison.
|
38
|
+
//
|
39
|
+
// Exmaple:
|
40
|
+
//
|
41
|
+
// // Effectively disables all logging:
|
42
|
+
// SetMinLogLevel(static_cast<absl::LogSeverity>(100));
|
43
|
+
//
|
44
|
+
// Abseil flags may be defined with type `LogSeverity`. Dependency layering
|
45
|
+
// constraints require that the `AbslParseFlag()` overload be declared and
|
46
|
+
// defined in the flags library itself rather than here. The `AbslUnparseFlag()`
|
47
|
+
// overload is defined there as well for consistency.
|
48
|
+
//
|
49
|
+
// absl::LogSeverity Flag String Representation
|
50
|
+
//
|
51
|
+
// An `absl::LogSeverity` has a string representation used for parsing
|
52
|
+
// command-line flags based on the enumerator name (e.g. `kFatal`) or
|
53
|
+
// its unprefixed name (without the `k`) in any case-insensitive form. (E.g.
|
54
|
+
// "FATAL", "fatal" or "Fatal" are all valid.) Unparsing such flags produces an
|
55
|
+
// unprefixed string representation in all caps (e.g. "FATAL") or an integer.
|
56
|
+
//
|
57
|
+
// Additionally, the parser accepts arbitrary integers (as if the type were
|
58
|
+
// `int`).
|
59
|
+
//
|
60
|
+
// Examples:
|
61
|
+
//
|
62
|
+
// --my_log_level=kInfo
|
63
|
+
// --my_log_level=INFO
|
64
|
+
// --my_log_level=info
|
65
|
+
// --my_log_level=0
|
66
|
+
//
|
67
|
+
// Unparsing a flag produces the same result as `absl::LogSeverityName()` for
|
68
|
+
// the standard levels and a base-ten integer otherwise.
|
69
|
+
enum class LogSeverity : int {
|
70
|
+
kInfo = 0,
|
71
|
+
kWarning = 1,
|
72
|
+
kError = 2,
|
73
|
+
kFatal = 3,
|
74
|
+
};
|
75
|
+
|
76
|
+
// LogSeverities()
|
77
|
+
//
|
78
|
+
// Returns an iterable of all standard `absl::LogSeverity` values, ordered from
|
79
|
+
// least to most severe.
|
80
|
+
constexpr std::array<absl::LogSeverity, 4> LogSeverities() {
|
81
|
+
return {{absl::LogSeverity::kInfo, absl::LogSeverity::kWarning,
|
82
|
+
absl::LogSeverity::kError, absl::LogSeverity::kFatal}};
|
83
|
+
}
|
84
|
+
|
85
|
+
// LogSeverityName()
|
86
|
+
//
|
87
|
+
// Returns the all-caps string representation (e.g. "INFO") of the specified
|
88
|
+
// severity level if it is one of the standard levels and "UNKNOWN" otherwise.
|
89
|
+
constexpr const char* LogSeverityName(absl::LogSeverity s) {
|
90
|
+
return s == absl::LogSeverity::kInfo
|
91
|
+
? "INFO"
|
92
|
+
: s == absl::LogSeverity::kWarning
|
93
|
+
? "WARNING"
|
94
|
+
: s == absl::LogSeverity::kError
|
95
|
+
? "ERROR"
|
96
|
+
: s == absl::LogSeverity::kFatal ? "FATAL" : "UNKNOWN";
|
97
|
+
}
|
98
|
+
|
99
|
+
// NormalizeLogSeverity()
|
100
|
+
//
|
101
|
+
// Values less than `kInfo` normalize to `kInfo`; values greater than `kFatal`
|
102
|
+
// normalize to `kError` (**NOT** `kFatal`).
|
103
|
+
constexpr absl::LogSeverity NormalizeLogSeverity(absl::LogSeverity s) {
|
104
|
+
return s < absl::LogSeverity::kInfo
|
105
|
+
? absl::LogSeverity::kInfo
|
106
|
+
: s > absl::LogSeverity::kFatal ? absl::LogSeverity::kError : s;
|
107
|
+
}
|
108
|
+
constexpr absl::LogSeverity NormalizeLogSeverity(int s) {
|
109
|
+
return absl::NormalizeLogSeverity(static_cast<absl::LogSeverity>(s));
|
110
|
+
}
|
111
|
+
|
112
|
+
// operator<<
|
113
|
+
//
|
114
|
+
// The exact representation of a streamed `absl::LogSeverity` is deliberately
|
115
|
+
// unspecified; do not rely on it.
|
116
|
+
std::ostream& operator<<(std::ostream& os, absl::LogSeverity s);
|
117
|
+
|
118
|
+
ABSL_NAMESPACE_END
|
119
|
+
} // namespace absl
|
120
|
+
|
121
|
+
#endif // ABSL_BASE_INTERNAL_LOG_SEVERITY_H_
|