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,94 @@
|
|
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
|
+
// -----------------------------------------------------------------------------
|
18
|
+
// File: cycleclock.h
|
19
|
+
// -----------------------------------------------------------------------------
|
20
|
+
//
|
21
|
+
// This header file defines a `CycleClock`, which yields the value and frequency
|
22
|
+
// of a cycle counter that increments at a rate that is approximately constant.
|
23
|
+
//
|
24
|
+
// NOTE:
|
25
|
+
//
|
26
|
+
// The cycle counter frequency is not necessarily related to the core clock
|
27
|
+
// frequency and should not be treated as such. That is, `CycleClock` cycles are
|
28
|
+
// not necessarily "CPU cycles" and code should not rely on that behavior, even
|
29
|
+
// if experimentally observed.
|
30
|
+
//
|
31
|
+
// An arbitrary offset may have been added to the counter at power on.
|
32
|
+
//
|
33
|
+
// On some platforms, the rate and offset of the counter may differ
|
34
|
+
// slightly when read from different CPUs of a multiprocessor. Usually,
|
35
|
+
// we try to ensure that the operating system adjusts values periodically
|
36
|
+
// so that values agree approximately. If you need stronger guarantees,
|
37
|
+
// consider using alternate interfaces.
|
38
|
+
//
|
39
|
+
// The CPU is not required to maintain the ordering of a cycle counter read
|
40
|
+
// with respect to surrounding instructions.
|
41
|
+
|
42
|
+
#ifndef ABSL_BASE_INTERNAL_CYCLECLOCK_H_
|
43
|
+
#define ABSL_BASE_INTERNAL_CYCLECLOCK_H_
|
44
|
+
|
45
|
+
#include <cstdint>
|
46
|
+
|
47
|
+
#include "absl/base/config.h"
|
48
|
+
|
49
|
+
namespace absl {
|
50
|
+
ABSL_NAMESPACE_BEGIN
|
51
|
+
namespace base_internal {
|
52
|
+
|
53
|
+
// -----------------------------------------------------------------------------
|
54
|
+
// CycleClock
|
55
|
+
// -----------------------------------------------------------------------------
|
56
|
+
class CycleClock {
|
57
|
+
public:
|
58
|
+
// CycleClock::Now()
|
59
|
+
//
|
60
|
+
// Returns the value of a cycle counter that counts at a rate that is
|
61
|
+
// approximately constant.
|
62
|
+
static int64_t Now();
|
63
|
+
|
64
|
+
// CycleClock::Frequency()
|
65
|
+
//
|
66
|
+
// Returns the amount by which `CycleClock::Now()` increases per second. Note
|
67
|
+
// that this value may not necessarily match the core CPU clock frequency.
|
68
|
+
static double Frequency();
|
69
|
+
|
70
|
+
private:
|
71
|
+
CycleClock() = delete; // no instances
|
72
|
+
CycleClock(const CycleClock&) = delete;
|
73
|
+
CycleClock& operator=(const CycleClock&) = delete;
|
74
|
+
};
|
75
|
+
|
76
|
+
using CycleClockSourceFunc = int64_t (*)();
|
77
|
+
|
78
|
+
class CycleClockSource {
|
79
|
+
private:
|
80
|
+
// CycleClockSource::Register()
|
81
|
+
//
|
82
|
+
// Register a function that provides an alternate source for the unscaled CPU
|
83
|
+
// cycle count value. The source function must be async signal safe, must not
|
84
|
+
// call CycleClock::Now(), and must have a frequency that matches that of the
|
85
|
+
// unscaled clock used by CycleClock. A nullptr value resets CycleClock to use
|
86
|
+
// the default source.
|
87
|
+
static void Register(CycleClockSourceFunc source);
|
88
|
+
};
|
89
|
+
|
90
|
+
} // namespace base_internal
|
91
|
+
ABSL_NAMESPACE_END
|
92
|
+
} // namespace absl
|
93
|
+
|
94
|
+
#endif // ABSL_BASE_INTERNAL_CYCLECLOCK_H_
|
@@ -0,0 +1,266 @@
|
|
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
|
+
|
16
|
+
#ifndef ABSL_BASE_INTERNAL_ENDIAN_H_
|
17
|
+
#define ABSL_BASE_INTERNAL_ENDIAN_H_
|
18
|
+
|
19
|
+
// The following guarantees declaration of the byte swap functions
|
20
|
+
#ifdef _MSC_VER
|
21
|
+
#include <stdlib.h> // NOLINT(build/include)
|
22
|
+
#elif defined(__FreeBSD__)
|
23
|
+
#include <sys/endian.h>
|
24
|
+
#elif defined(__GLIBC__)
|
25
|
+
#include <byteswap.h> // IWYU pragma: export
|
26
|
+
#endif
|
27
|
+
|
28
|
+
#include <cstdint>
|
29
|
+
#include "absl/base/config.h"
|
30
|
+
#include "absl/base/internal/unaligned_access.h"
|
31
|
+
#include "absl/base/port.h"
|
32
|
+
|
33
|
+
namespace absl {
|
34
|
+
ABSL_NAMESPACE_BEGIN
|
35
|
+
|
36
|
+
// Use compiler byte-swapping intrinsics if they are available. 32-bit
|
37
|
+
// and 64-bit versions are available in Clang and GCC as of GCC 4.3.0.
|
38
|
+
// The 16-bit version is available in Clang and GCC only as of GCC 4.8.0.
|
39
|
+
// For simplicity, we enable them all only for GCC 4.8.0 or later.
|
40
|
+
#if defined(__clang__) || \
|
41
|
+
(defined(__GNUC__) && \
|
42
|
+
((__GNUC__ == 4 && __GNUC_MINOR__ >= 8) || __GNUC__ >= 5))
|
43
|
+
inline uint64_t gbswap_64(uint64_t host_int) {
|
44
|
+
return __builtin_bswap64(host_int);
|
45
|
+
}
|
46
|
+
inline uint32_t gbswap_32(uint32_t host_int) {
|
47
|
+
return __builtin_bswap32(host_int);
|
48
|
+
}
|
49
|
+
inline uint16_t gbswap_16(uint16_t host_int) {
|
50
|
+
return __builtin_bswap16(host_int);
|
51
|
+
}
|
52
|
+
|
53
|
+
#elif defined(_MSC_VER)
|
54
|
+
inline uint64_t gbswap_64(uint64_t host_int) {
|
55
|
+
return _byteswap_uint64(host_int);
|
56
|
+
}
|
57
|
+
inline uint32_t gbswap_32(uint32_t host_int) {
|
58
|
+
return _byteswap_ulong(host_int);
|
59
|
+
}
|
60
|
+
inline uint16_t gbswap_16(uint16_t host_int) {
|
61
|
+
return _byteswap_ushort(host_int);
|
62
|
+
}
|
63
|
+
|
64
|
+
#else
|
65
|
+
inline uint64_t gbswap_64(uint64_t host_int) {
|
66
|
+
#if defined(__GNUC__) && defined(__x86_64__) && !defined(__APPLE__)
|
67
|
+
// Adapted from /usr/include/byteswap.h. Not available on Mac.
|
68
|
+
if (__builtin_constant_p(host_int)) {
|
69
|
+
return __bswap_constant_64(host_int);
|
70
|
+
} else {
|
71
|
+
uint64_t result;
|
72
|
+
__asm__("bswap %0" : "=r"(result) : "0"(host_int));
|
73
|
+
return result;
|
74
|
+
}
|
75
|
+
#elif defined(__GLIBC__)
|
76
|
+
return bswap_64(host_int);
|
77
|
+
#else
|
78
|
+
return (((host_int & uint64_t{0xFF}) << 56) |
|
79
|
+
((host_int & uint64_t{0xFF00}) << 40) |
|
80
|
+
((host_int & uint64_t{0xFF0000}) << 24) |
|
81
|
+
((host_int & uint64_t{0xFF000000}) << 8) |
|
82
|
+
((host_int & uint64_t{0xFF00000000}) >> 8) |
|
83
|
+
((host_int & uint64_t{0xFF0000000000}) >> 24) |
|
84
|
+
((host_int & uint64_t{0xFF000000000000}) >> 40) |
|
85
|
+
((host_int & uint64_t{0xFF00000000000000}) >> 56));
|
86
|
+
#endif // bswap_64
|
87
|
+
}
|
88
|
+
|
89
|
+
inline uint32_t gbswap_32(uint32_t host_int) {
|
90
|
+
#if defined(__GLIBC__)
|
91
|
+
return bswap_32(host_int);
|
92
|
+
#else
|
93
|
+
return (((host_int & uint32_t{0xFF}) << 24) |
|
94
|
+
((host_int & uint32_t{0xFF00}) << 8) |
|
95
|
+
((host_int & uint32_t{0xFF0000}) >> 8) |
|
96
|
+
((host_int & uint32_t{0xFF000000}) >> 24));
|
97
|
+
#endif
|
98
|
+
}
|
99
|
+
|
100
|
+
inline uint16_t gbswap_16(uint16_t host_int) {
|
101
|
+
#if defined(__GLIBC__)
|
102
|
+
return bswap_16(host_int);
|
103
|
+
#else
|
104
|
+
return (((host_int & uint16_t{0xFF}) << 8) |
|
105
|
+
((host_int & uint16_t{0xFF00}) >> 8));
|
106
|
+
#endif
|
107
|
+
}
|
108
|
+
|
109
|
+
#endif // intrinsics available
|
110
|
+
|
111
|
+
#ifdef ABSL_IS_LITTLE_ENDIAN
|
112
|
+
|
113
|
+
// Definitions for ntohl etc. that don't require us to include
|
114
|
+
// netinet/in.h. We wrap gbswap_32 and gbswap_16 in functions rather
|
115
|
+
// than just #defining them because in debug mode, gcc doesn't
|
116
|
+
// correctly handle the (rather involved) definitions of bswap_32.
|
117
|
+
// gcc guarantees that inline functions are as fast as macros, so
|
118
|
+
// this isn't a performance hit.
|
119
|
+
inline uint16_t ghtons(uint16_t x) { return gbswap_16(x); }
|
120
|
+
inline uint32_t ghtonl(uint32_t x) { return gbswap_32(x); }
|
121
|
+
inline uint64_t ghtonll(uint64_t x) { return gbswap_64(x); }
|
122
|
+
|
123
|
+
#elif defined ABSL_IS_BIG_ENDIAN
|
124
|
+
|
125
|
+
// These definitions are simpler on big-endian machines
|
126
|
+
// These are functions instead of macros to avoid self-assignment warnings
|
127
|
+
// on calls such as "i = ghtnol(i);". This also provides type checking.
|
128
|
+
inline uint16_t ghtons(uint16_t x) { return x; }
|
129
|
+
inline uint32_t ghtonl(uint32_t x) { return x; }
|
130
|
+
inline uint64_t ghtonll(uint64_t x) { return x; }
|
131
|
+
|
132
|
+
#else
|
133
|
+
#error \
|
134
|
+
"Unsupported byte order: Either ABSL_IS_BIG_ENDIAN or " \
|
135
|
+
"ABSL_IS_LITTLE_ENDIAN must be defined"
|
136
|
+
#endif // byte order
|
137
|
+
|
138
|
+
inline uint16_t gntohs(uint16_t x) { return ghtons(x); }
|
139
|
+
inline uint32_t gntohl(uint32_t x) { return ghtonl(x); }
|
140
|
+
inline uint64_t gntohll(uint64_t x) { return ghtonll(x); }
|
141
|
+
|
142
|
+
// Utilities to convert numbers between the current hosts's native byte
|
143
|
+
// order and little-endian byte order
|
144
|
+
//
|
145
|
+
// Load/Store methods are alignment safe
|
146
|
+
namespace little_endian {
|
147
|
+
// Conversion functions.
|
148
|
+
#ifdef ABSL_IS_LITTLE_ENDIAN
|
149
|
+
|
150
|
+
inline uint16_t FromHost16(uint16_t x) { return x; }
|
151
|
+
inline uint16_t ToHost16(uint16_t x) { return x; }
|
152
|
+
|
153
|
+
inline uint32_t FromHost32(uint32_t x) { return x; }
|
154
|
+
inline uint32_t ToHost32(uint32_t x) { return x; }
|
155
|
+
|
156
|
+
inline uint64_t FromHost64(uint64_t x) { return x; }
|
157
|
+
inline uint64_t ToHost64(uint64_t x) { return x; }
|
158
|
+
|
159
|
+
inline constexpr bool IsLittleEndian() { return true; }
|
160
|
+
|
161
|
+
#elif defined ABSL_IS_BIG_ENDIAN
|
162
|
+
|
163
|
+
inline uint16_t FromHost16(uint16_t x) { return gbswap_16(x); }
|
164
|
+
inline uint16_t ToHost16(uint16_t x) { return gbswap_16(x); }
|
165
|
+
|
166
|
+
inline uint32_t FromHost32(uint32_t x) { return gbswap_32(x); }
|
167
|
+
inline uint32_t ToHost32(uint32_t x) { return gbswap_32(x); }
|
168
|
+
|
169
|
+
inline uint64_t FromHost64(uint64_t x) { return gbswap_64(x); }
|
170
|
+
inline uint64_t ToHost64(uint64_t x) { return gbswap_64(x); }
|
171
|
+
|
172
|
+
inline constexpr bool IsLittleEndian() { return false; }
|
173
|
+
|
174
|
+
#endif /* ENDIAN */
|
175
|
+
|
176
|
+
// Functions to do unaligned loads and stores in little-endian order.
|
177
|
+
inline uint16_t Load16(const void *p) {
|
178
|
+
return ToHost16(ABSL_INTERNAL_UNALIGNED_LOAD16(p));
|
179
|
+
}
|
180
|
+
|
181
|
+
inline void Store16(void *p, uint16_t v) {
|
182
|
+
ABSL_INTERNAL_UNALIGNED_STORE16(p, FromHost16(v));
|
183
|
+
}
|
184
|
+
|
185
|
+
inline uint32_t Load32(const void *p) {
|
186
|
+
return ToHost32(ABSL_INTERNAL_UNALIGNED_LOAD32(p));
|
187
|
+
}
|
188
|
+
|
189
|
+
inline void Store32(void *p, uint32_t v) {
|
190
|
+
ABSL_INTERNAL_UNALIGNED_STORE32(p, FromHost32(v));
|
191
|
+
}
|
192
|
+
|
193
|
+
inline uint64_t Load64(const void *p) {
|
194
|
+
return ToHost64(ABSL_INTERNAL_UNALIGNED_LOAD64(p));
|
195
|
+
}
|
196
|
+
|
197
|
+
inline void Store64(void *p, uint64_t v) {
|
198
|
+
ABSL_INTERNAL_UNALIGNED_STORE64(p, FromHost64(v));
|
199
|
+
}
|
200
|
+
|
201
|
+
} // namespace little_endian
|
202
|
+
|
203
|
+
// Utilities to convert numbers between the current hosts's native byte
|
204
|
+
// order and big-endian byte order (same as network byte order)
|
205
|
+
//
|
206
|
+
// Load/Store methods are alignment safe
|
207
|
+
namespace big_endian {
|
208
|
+
#ifdef ABSL_IS_LITTLE_ENDIAN
|
209
|
+
|
210
|
+
inline uint16_t FromHost16(uint16_t x) { return gbswap_16(x); }
|
211
|
+
inline uint16_t ToHost16(uint16_t x) { return gbswap_16(x); }
|
212
|
+
|
213
|
+
inline uint32_t FromHost32(uint32_t x) { return gbswap_32(x); }
|
214
|
+
inline uint32_t ToHost32(uint32_t x) { return gbswap_32(x); }
|
215
|
+
|
216
|
+
inline uint64_t FromHost64(uint64_t x) { return gbswap_64(x); }
|
217
|
+
inline uint64_t ToHost64(uint64_t x) { return gbswap_64(x); }
|
218
|
+
|
219
|
+
inline constexpr bool IsLittleEndian() { return true; }
|
220
|
+
|
221
|
+
#elif defined ABSL_IS_BIG_ENDIAN
|
222
|
+
|
223
|
+
inline uint16_t FromHost16(uint16_t x) { return x; }
|
224
|
+
inline uint16_t ToHost16(uint16_t x) { return x; }
|
225
|
+
|
226
|
+
inline uint32_t FromHost32(uint32_t x) { return x; }
|
227
|
+
inline uint32_t ToHost32(uint32_t x) { return x; }
|
228
|
+
|
229
|
+
inline uint64_t FromHost64(uint64_t x) { return x; }
|
230
|
+
inline uint64_t ToHost64(uint64_t x) { return x; }
|
231
|
+
|
232
|
+
inline constexpr bool IsLittleEndian() { return false; }
|
233
|
+
|
234
|
+
#endif /* ENDIAN */
|
235
|
+
|
236
|
+
// Functions to do unaligned loads and stores in big-endian order.
|
237
|
+
inline uint16_t Load16(const void *p) {
|
238
|
+
return ToHost16(ABSL_INTERNAL_UNALIGNED_LOAD16(p));
|
239
|
+
}
|
240
|
+
|
241
|
+
inline void Store16(void *p, uint16_t v) {
|
242
|
+
ABSL_INTERNAL_UNALIGNED_STORE16(p, FromHost16(v));
|
243
|
+
}
|
244
|
+
|
245
|
+
inline uint32_t Load32(const void *p) {
|
246
|
+
return ToHost32(ABSL_INTERNAL_UNALIGNED_LOAD32(p));
|
247
|
+
}
|
248
|
+
|
249
|
+
inline void Store32(void *p, uint32_t v) {
|
250
|
+
ABSL_INTERNAL_UNALIGNED_STORE32(p, FromHost32(v));
|
251
|
+
}
|
252
|
+
|
253
|
+
inline uint64_t Load64(const void *p) {
|
254
|
+
return ToHost64(ABSL_INTERNAL_UNALIGNED_LOAD64(p));
|
255
|
+
}
|
256
|
+
|
257
|
+
inline void Store64(void *p, uint64_t v) {
|
258
|
+
ABSL_INTERNAL_UNALIGNED_STORE64(p, FromHost64(v));
|
259
|
+
}
|
260
|
+
|
261
|
+
} // namespace big_endian
|
262
|
+
|
263
|
+
ABSL_NAMESPACE_END
|
264
|
+
} // namespace absl
|
265
|
+
|
266
|
+
#endif // ABSL_BASE_INTERNAL_ENDIAN_H_
|
@@ -0,0 +1,51 @@
|
|
1
|
+
// Copyright 2018 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_HIDE_PTR_H_
|
16
|
+
#define ABSL_BASE_INTERNAL_HIDE_PTR_H_
|
17
|
+
|
18
|
+
#include <cstdint>
|
19
|
+
|
20
|
+
#include "absl/base/config.h"
|
21
|
+
|
22
|
+
namespace absl {
|
23
|
+
ABSL_NAMESPACE_BEGIN
|
24
|
+
namespace base_internal {
|
25
|
+
|
26
|
+
// Arbitrary value with high bits set. Xor'ing with it is unlikely
|
27
|
+
// to map one valid pointer to another valid pointer.
|
28
|
+
constexpr uintptr_t HideMask() {
|
29
|
+
return (uintptr_t{0xF03A5F7BU} << (sizeof(uintptr_t) - 4) * 8) | 0xF03A5F7BU;
|
30
|
+
}
|
31
|
+
|
32
|
+
// Hide a pointer from the leak checker. For internal use only.
|
33
|
+
// Differs from absl::IgnoreLeak(ptr) in that absl::IgnoreLeak(ptr) causes ptr
|
34
|
+
// and all objects reachable from ptr to be ignored by the leak checker.
|
35
|
+
template <class T>
|
36
|
+
inline uintptr_t HidePtr(T* ptr) {
|
37
|
+
return reinterpret_cast<uintptr_t>(ptr) ^ HideMask();
|
38
|
+
}
|
39
|
+
|
40
|
+
// Return a pointer that has been hidden from the leak checker.
|
41
|
+
// For internal use only.
|
42
|
+
template <class T>
|
43
|
+
inline T* UnhidePtr(uintptr_t hidden) {
|
44
|
+
return reinterpret_cast<T*>(hidden ^ HideMask());
|
45
|
+
}
|
46
|
+
|
47
|
+
} // namespace base_internal
|
48
|
+
ABSL_NAMESPACE_END
|
49
|
+
} // namespace absl
|
50
|
+
|
51
|
+
#endif // ABSL_BASE_INTERNAL_HIDE_PTR_H_
|
@@ -0,0 +1,37 @@
|
|
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
|
+
|
16
|
+
#ifndef ABSL_BASE_INTERNAL_IDENTITY_H_
|
17
|
+
#define ABSL_BASE_INTERNAL_IDENTITY_H_
|
18
|
+
|
19
|
+
#include "absl/base/config.h"
|
20
|
+
|
21
|
+
namespace absl {
|
22
|
+
ABSL_NAMESPACE_BEGIN
|
23
|
+
namespace internal {
|
24
|
+
|
25
|
+
template <typename T>
|
26
|
+
struct identity {
|
27
|
+
typedef T type;
|
28
|
+
};
|
29
|
+
|
30
|
+
template <typename T>
|
31
|
+
using identity_t = typename identity<T>::type;
|
32
|
+
|
33
|
+
} // namespace internal
|
34
|
+
ABSL_NAMESPACE_END
|
35
|
+
} // namespace absl
|
36
|
+
|
37
|
+
#endif // ABSL_BASE_INTERNAL_IDENTITY_H_
|