grpc 1.57.0 → 1.58.0.pre1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Makefile +534 -284
- data/include/grpc/event_engine/event_engine.h +0 -1
- data/include/grpc/event_engine/memory_allocator.h +2 -2
- data/include/grpc/impl/channel_arg_names.h +371 -0
- data/include/grpc/impl/grpc_types.h +1 -353
- data/include/grpc/module.modulemap +1 -0
- data/src/core/ext/filters/backend_metrics/backend_metric_filter.cc +1 -1
- data/src/core/ext/filters/channel_idle/channel_idle_filter.cc +2 -1
- data/src/core/ext/filters/client_channel/client_channel.cc +7 -3
- data/src/core/ext/filters/client_channel/http_proxy.cc +1 -1
- data/src/core/ext/filters/client_channel/lb_policy/address_filtering.cc +10 -5
- data/src/core/ext/filters/client_channel/lb_policy/address_filtering.h +7 -5
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc +1 -0
- data/src/core/ext/filters/client_channel/lb_policy/health_check_client.cc +5 -3
- data/src/core/ext/filters/client_channel/lb_policy/oob_backend_metric.cc +4 -2
- data/src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc +115 -109
- data/src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.h +0 -5
- data/src/core/ext/filters/client_channel/lb_policy/priority/priority.cc +7 -2
- data/src/core/ext/filters/client_channel/lb_policy/ring_hash/ring_hash.cc +2 -1
- data/src/core/ext/filters/client_channel/lb_policy/rls/rls.cc +1 -0
- data/src/core/ext/filters/client_channel/lb_policy/subchannel_list.h +1 -1
- data/src/core/ext/filters/client_channel/lb_policy/weighted_round_robin/weighted_round_robin.cc +11 -3
- data/src/core/ext/filters/client_channel/lb_policy/weighted_target/weighted_target.cc +6 -1
- data/src/core/ext/filters/client_channel/lb_policy/xds/xds_cluster_resolver.cc +8 -5
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc +1 -1
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_posix.cc +102 -11
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc +9 -4
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h +4 -1
- data/src/core/ext/filters/client_channel/resolver/dns/dns_resolver_plugin.cc +6 -0
- data/src/core/ext/filters/client_channel/resolver/dns/event_engine/event_engine_client_channel_resolver.cc +41 -14
- data/src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc +1 -1
- data/src/core/ext/filters/client_channel/resolver/polling_resolver.cc +3 -2
- data/src/core/ext/filters/client_channel/resolver/xds/xds_resolver.cc +1 -1
- data/src/core/ext/filters/client_channel/retry_filter.h +1 -0
- data/src/core/ext/filters/client_channel/retry_service_config.cc +1 -1
- data/src/core/ext/filters/client_channel/service_config_channel_arg_filter.cc +1 -1
- data/src/core/ext/filters/client_channel/subchannel.cc +9 -5
- data/src/core/ext/filters/client_channel/subchannel.h +8 -2
- data/src/core/ext/filters/deadline/deadline_filter.cc +1 -1
- data/src/core/ext/filters/http/client/http_client_filter.cc +1 -0
- data/src/core/ext/filters/http/client_authority_filter.cc +1 -1
- data/src/core/ext/filters/http/message_compress/compression_filter.cc +1 -0
- data/src/core/ext/filters/http/server/http_server_filter.cc +1 -1
- data/src/core/ext/filters/message_size/message_size_filter.cc +1 -0
- data/src/core/ext/filters/rbac/rbac_service_config_parser.cc +4 -7
- data/src/core/ext/transport/chttp2/client/chttp2_connector.cc +1 -0
- data/src/core/ext/transport/chttp2/server/chttp2_server.cc +8 -12
- data/src/core/ext/transport/chttp2/transport/chttp2_transport.cc +357 -358
- data/src/core/ext/transport/chttp2/transport/frame_ping.cc +5 -18
- data/src/core/ext/transport/chttp2/transport/hpack_parser.cc +63 -4
- data/src/core/ext/transport/chttp2/transport/hpack_parser.h +7 -2
- data/src/core/ext/transport/chttp2/transport/internal.h +30 -57
- data/src/core/ext/transport/chttp2/transport/parsing.cc +16 -7
- data/src/core/ext/transport/chttp2/transport/ping_abuse_policy.cc +80 -0
- data/src/core/ext/transport/chttp2/transport/ping_abuse_policy.h +55 -0
- data/src/core/ext/transport/chttp2/transport/ping_rate_policy.cc +98 -0
- data/src/core/ext/transport/chttp2/transport/ping_rate_policy.h +73 -0
- data/src/core/ext/transport/chttp2/transport/writing.cc +81 -89
- data/src/core/ext/transport/inproc/inproc_transport.cc +1 -0
- data/src/core/ext/xds/xds_client_grpc.cc +1 -0
- data/src/core/ext/xds/xds_http_fault_filter.cc +1 -2
- data/src/core/ext/xds/xds_http_fault_filter.h +1 -2
- data/src/core/ext/xds/xds_http_filters.h +2 -4
- data/src/core/ext/xds/xds_http_rbac_filter.cc +3 -8
- data/src/core/ext/xds/xds_http_rbac_filter.h +1 -2
- data/src/core/ext/xds/xds_http_stateful_session_filter.cc +1 -2
- data/src/core/ext/xds/xds_http_stateful_session_filter.h +1 -2
- data/src/core/ext/xds/xds_lb_policy_registry.cc +3 -6
- data/src/core/ext/xds/xds_routing.cc +2 -2
- data/src/core/ext/xds/xds_transport_grpc.cc +1 -0
- data/src/core/lib/avl/avl.h +10 -173
- data/src/core/lib/channel/call_tracer.cc +289 -0
- data/src/core/lib/channel/call_tracer.h +35 -0
- data/src/core/lib/channel/channel_args.cc +84 -79
- data/src/core/lib/channel/channel_args.h +29 -17
- data/src/core/lib/channel/connected_channel.cc +0 -1
- data/src/core/lib/channel/promise_based_filter.cc +4 -1
- data/src/core/lib/compression/compression_internal.cc +8 -4
- data/src/core/lib/debug/stats_data.cc +93 -21
- data/src/core/lib/debug/stats_data.h +41 -0
- data/src/core/lib/event_engine/ares_resolver.cc +712 -0
- data/src/core/lib/event_engine/ares_resolver.h +150 -0
- data/src/core/lib/event_engine/cf_engine/cf_engine.cc +9 -3
- data/src/core/lib/event_engine/cf_engine/cfstream_endpoint.cc +2 -2
- data/src/core/lib/event_engine/cf_engine/dns_service_resolver.cc +229 -0
- data/src/core/lib/event_engine/cf_engine/dns_service_resolver.h +117 -0
- data/src/core/lib/event_engine/forkable.cc +15 -1
- data/src/core/lib/event_engine/forkable.h +15 -0
- data/src/core/lib/event_engine/grpc_polled_fd.h +73 -0
- data/src/core/lib/event_engine/posix_engine/ev_poll_posix.cc +25 -3
- data/src/core/lib/event_engine/posix_engine/ev_poll_posix.h +10 -1
- data/src/core/lib/event_engine/posix_engine/grpc_polled_fd_posix.h +197 -0
- data/src/core/lib/event_engine/posix_engine/posix_endpoint.cc +3 -3
- data/src/core/lib/event_engine/posix_engine/posix_engine.cc +47 -1
- data/src/core/lib/event_engine/posix_engine/posix_engine.h +12 -1
- data/src/core/lib/event_engine/posix_engine/tcp_socket_utils.cc +1 -0
- data/src/core/lib/event_engine/posix_engine/traced_buffer_list.cc +2 -0
- data/src/core/lib/event_engine/thread_pool/thread_count.cc +58 -0
- data/src/core/lib/event_engine/thread_pool/thread_count.h +161 -0
- data/src/core/lib/event_engine/thread_pool/thread_pool_factory.cc +7 -0
- data/src/core/lib/event_engine/thread_pool/work_stealing_thread_pool.cc +86 -111
- data/src/core/lib/event_engine/thread_pool/work_stealing_thread_pool.h +15 -61
- data/src/core/lib/event_engine/windows/windows_endpoint.cc +3 -4
- data/src/core/lib/experiments/config.cc +14 -0
- data/src/core/lib/experiments/experiments.cc +141 -304
- data/src/core/lib/experiments/experiments.h +16 -17
- data/src/core/lib/gprpp/ref_counted.h +3 -1
- data/src/core/lib/gprpp/ref_counted_string.cc +44 -0
- data/src/core/lib/gprpp/ref_counted_string.h +146 -0
- data/src/core/lib/gprpp/time.h +2 -2
- data/src/core/lib/gprpp/work_serializer.cc +36 -0
- data/src/core/lib/gprpp/work_serializer.h +5 -0
- data/src/core/lib/http/httpcli_security_connector.cc +1 -0
- data/src/core/lib/iomgr/buffer_list.cc +2 -0
- data/src/core/lib/iomgr/event_engine_shims/endpoint.cc +7 -22
- data/src/core/lib/iomgr/tcp_posix.cc +3 -3
- data/src/core/lib/promise/detail/basic_seq.h +1 -372
- data/src/core/lib/promise/detail/seq_state.h +2076 -0
- data/src/core/lib/promise/seq.h +19 -2
- data/src/core/lib/promise/sleep.h +5 -10
- data/src/core/lib/promise/try_seq.h +34 -2
- data/src/core/lib/resource_quota/api.cc +1 -0
- data/src/core/lib/resource_quota/arena.cc +2 -0
- data/src/core/lib/resource_quota/arena.h +42 -8
- data/src/core/lib/resource_quota/memory_quota.cc +0 -1
- data/src/core/lib/resource_quota/resource_quota.h +1 -0
- data/src/core/lib/security/authorization/authorization_policy_provider.h +1 -1
- data/src/core/lib/security/authorization/rbac_policy.h +1 -1
- data/src/core/lib/security/credentials/external/aws_request_signer.cc +8 -0
- data/src/core/lib/security/credentials/google_default/google_default_credentials.cc +1 -0
- data/src/core/lib/security/credentials/jwt/json_token.cc +17 -0
- data/src/core/lib/security/credentials/jwt/json_token.h +4 -0
- data/src/core/lib/security/credentials/jwt/jwt_verifier.cc +42 -0
- data/src/core/lib/security/credentials/ssl/ssl_credentials.cc +1 -0
- data/src/core/lib/security/credentials/tls/grpc_tls_certificate_provider.cc +4 -0
- data/src/core/lib/security/credentials/tls/tls_credentials.cc +1 -0
- data/src/core/lib/security/credentials/xds/xds_credentials.cc +1 -0
- data/src/core/lib/security/security_connector/alts/alts_security_connector.cc +1 -0
- data/src/core/lib/security/security_connector/fake/fake_security_connector.cc +1 -0
- data/src/core/lib/security/security_connector/ssl_utils.cc +1 -0
- data/src/core/lib/security/transport/client_auth_filter.cc +8 -5
- data/src/core/lib/security/transport/security_handshaker.cc +1 -0
- data/src/core/lib/security/transport/server_auth_filter.cc +2 -0
- data/src/core/lib/surface/call.cc +32 -8
- data/src/core/lib/surface/channel.cc +1 -0
- data/src/core/lib/surface/completion_queue.cc +10 -0
- data/src/core/lib/surface/init.cc +1 -0
- data/src/core/lib/surface/server.cc +67 -64
- data/src/core/lib/surface/server.h +1 -15
- data/src/core/lib/surface/version.cc +2 -2
- data/src/core/tsi/alts/crypt/aes_gcm.cc +27 -2
- data/src/core/tsi/ssl_transport_security.cc +11 -0
- data/src/ruby/lib/grpc/generic/active_call.rb +9 -14
- data/src/ruby/lib/grpc/version.rb +1 -1
- data/src/ruby/pb/test/client.rb +16 -0
- data/src/ruby/spec/generic/rpc_server_spec.rb +3 -3
- data/third_party/abseil-cpp/absl/algorithm/container.h +3 -2
- data/third_party/abseil-cpp/absl/base/attributes.h +58 -5
- data/third_party/abseil-cpp/absl/base/call_once.h +1 -1
- data/third_party/abseil-cpp/absl/base/casts.h +8 -8
- data/third_party/abseil-cpp/absl/base/config.h +89 -106
- data/third_party/abseil-cpp/absl/base/dynamic_annotations.h +26 -1
- data/third_party/abseil-cpp/absl/base/internal/direct_mmap.h +2 -2
- data/third_party/abseil-cpp/absl/base/internal/low_level_alloc.cc +50 -39
- data/third_party/abseil-cpp/absl/base/internal/low_level_alloc.h +2 -1
- data/third_party/abseil-cpp/absl/base/internal/prefetch.h +17 -18
- data/third_party/abseil-cpp/absl/base/internal/raw_logging.cc +32 -3
- data/third_party/abseil-cpp/absl/base/internal/raw_logging.h +24 -4
- data/third_party/abseil-cpp/absl/base/internal/sysinfo.cc +31 -73
- data/third_party/abseil-cpp/absl/base/internal/thread_identity.cc +9 -8
- data/third_party/abseil-cpp/absl/base/internal/thread_identity.h +11 -11
- data/third_party/abseil-cpp/absl/base/internal/throw_delegate.cc +23 -32
- data/third_party/abseil-cpp/absl/base/internal/unscaledcycleclock.cc +2 -3
- data/third_party/abseil-cpp/absl/base/options.h +1 -1
- data/third_party/abseil-cpp/absl/base/policy_checks.h +3 -3
- data/third_party/abseil-cpp/absl/base/prefetch.h +198 -0
- data/third_party/abseil-cpp/absl/container/fixed_array.h +54 -29
- data/third_party/abseil-cpp/absl/container/flat_hash_map.h +5 -1
- data/third_party/abseil-cpp/absl/container/flat_hash_set.h +6 -2
- data/third_party/abseil-cpp/absl/container/inlined_vector.h +167 -79
- data/third_party/abseil-cpp/absl/container/internal/common_policy_traits.h +1 -1
- data/third_party/abseil-cpp/absl/container/internal/compressed_tuple.h +3 -21
- data/third_party/abseil-cpp/absl/container/internal/container_memory.h +1 -1
- data/third_party/abseil-cpp/absl/container/internal/hash_function_defaults.h +46 -0
- data/third_party/abseil-cpp/absl/container/internal/hashtablez_sampler.cc +2 -0
- data/third_party/abseil-cpp/absl/container/internal/inlined_vector.h +85 -26
- data/third_party/abseil-cpp/absl/container/internal/raw_hash_map.h +35 -18
- data/third_party/abseil-cpp/absl/container/internal/raw_hash_set.cc +70 -29
- data/third_party/abseil-cpp/absl/container/internal/raw_hash_set.h +437 -236
- data/third_party/abseil-cpp/absl/crc/crc32c.h +8 -1
- data/third_party/abseil-cpp/absl/crc/internal/cpu_detect.cc +14 -8
- data/third_party/abseil-cpp/absl/crc/internal/crc.cc +4 -35
- data/third_party/abseil-cpp/absl/crc/internal/crc.h +2 -10
- data/third_party/abseil-cpp/absl/crc/internal/crc32_x86_arm_combined_simd.h +1 -1
- data/third_party/abseil-cpp/absl/crc/internal/crc_cord_state.cc +1 -1
- data/third_party/abseil-cpp/absl/crc/internal/crc_cord_state.h +4 -4
- data/third_party/abseil-cpp/absl/crc/internal/crc_internal.h +8 -10
- data/third_party/abseil-cpp/absl/crc/internal/crc_memcpy_x86_64.cc +17 -19
- data/third_party/abseil-cpp/absl/crc/internal/crc_x86_arm_combined.cc +8 -8
- data/third_party/abseil-cpp/absl/debugging/internal/elf_mem_image.h +2 -1
- data/third_party/abseil-cpp/absl/debugging/internal/stacktrace_aarch64-inl.inc +59 -23
- data/third_party/abseil-cpp/absl/debugging/internal/stacktrace_powerpc-inl.inc +1 -1
- data/third_party/abseil-cpp/absl/debugging/internal/stacktrace_x86-inl.inc +1 -1
- data/third_party/abseil-cpp/absl/debugging/internal/symbolize.h +1 -1
- data/third_party/abseil-cpp/absl/debugging/symbolize_elf.inc +43 -19
- data/third_party/abseil-cpp/absl/debugging/symbolize_emscripten.inc +3 -0
- data/third_party/abseil-cpp/absl/flags/commandlineflag.h +1 -1
- data/third_party/abseil-cpp/absl/flags/internal/commandlineflag.cc +1 -1
- data/third_party/abseil-cpp/absl/flags/internal/flag.cc +2 -2
- data/third_party/abseil-cpp/absl/flags/internal/flag.h +16 -15
- data/third_party/abseil-cpp/absl/flags/internal/flag_msvc.inc +1 -1
- data/third_party/abseil-cpp/absl/flags/marshalling.cc +43 -2
- data/third_party/abseil-cpp/absl/flags/marshalling.h +5 -0
- data/third_party/abseil-cpp/absl/functional/any_invocable.h +9 -1
- data/third_party/abseil-cpp/absl/functional/bind_front.h +1 -1
- data/third_party/abseil-cpp/absl/functional/function_ref.h +3 -3
- data/third_party/abseil-cpp/absl/functional/internal/any_invocable.h +37 -24
- data/third_party/abseil-cpp/absl/functional/internal/function_ref.h +19 -9
- data/third_party/abseil-cpp/absl/hash/hash.h +7 -4
- data/third_party/abseil-cpp/absl/hash/internal/hash.h +38 -15
- data/third_party/abseil-cpp/absl/hash/internal/low_level_hash.cc +6 -0
- data/third_party/abseil-cpp/absl/meta/type_traits.h +48 -373
- data/third_party/abseil-cpp/absl/numeric/bits.h +4 -4
- data/third_party/abseil-cpp/absl/numeric/int128.cc +20 -8
- data/third_party/abseil-cpp/absl/numeric/int128.h +36 -39
- data/third_party/abseil-cpp/absl/numeric/int128_have_intrinsic.inc +0 -3
- data/third_party/abseil-cpp/absl/numeric/int128_no_intrinsic.inc +47 -30
- data/third_party/abseil-cpp/absl/random/internal/fast_uniform_bits.h +4 -3
- data/third_party/abseil-cpp/absl/random/internal/generate_real.h +1 -1
- data/third_party/abseil-cpp/absl/random/internal/platform.h +1 -1
- data/third_party/abseil-cpp/absl/random/internal/randen_detect.cc +4 -0
- data/third_party/abseil-cpp/absl/random/internal/randen_engine.h +1 -1
- data/third_party/abseil-cpp/absl/random/internal/randen_hwaes.cc +1 -1
- data/third_party/abseil-cpp/absl/random/internal/uniform_helper.h +1 -1
- data/third_party/abseil-cpp/absl/status/internal/status_internal.h +4 -0
- data/third_party/abseil-cpp/absl/status/internal/statusor_internal.h +12 -24
- data/third_party/abseil-cpp/absl/status/status.cc +11 -7
- data/third_party/abseil-cpp/absl/status/status.h +11 -2
- data/third_party/abseil-cpp/absl/status/statusor.h +22 -8
- data/third_party/abseil-cpp/absl/strings/ascii.cc +54 -6
- data/third_party/abseil-cpp/absl/strings/charconv.cc +21 -4
- data/third_party/abseil-cpp/absl/strings/charconv.h +2 -2
- data/third_party/abseil-cpp/absl/strings/cord.cc +1 -2
- data/third_party/abseil-cpp/absl/strings/cord.h +32 -5
- data/third_party/abseil-cpp/absl/strings/cord_analysis.cc +23 -1
- data/third_party/abseil-cpp/absl/strings/cord_analysis.h +18 -0
- data/third_party/abseil-cpp/absl/strings/cord_buffer.h +2 -5
- data/third_party/abseil-cpp/absl/strings/escaping.cc +10 -32
- data/third_party/abseil-cpp/absl/strings/escaping.h +1 -1
- data/third_party/abseil-cpp/absl/strings/internal/charconv_bigint.cc +2 -4
- data/third_party/abseil-cpp/absl/strings/internal/charconv_bigint.h +3 -3
- data/third_party/abseil-cpp/absl/strings/internal/cord_internal.cc +0 -1
- data/third_party/abseil-cpp/absl/strings/internal/cord_internal.h +15 -13
- data/third_party/abseil-cpp/absl/strings/internal/cord_rep_btree.cc +13 -4
- data/third_party/abseil-cpp/absl/strings/internal/cord_rep_btree.h +8 -0
- data/third_party/abseil-cpp/absl/strings/internal/cord_rep_consume.cc +5 -3
- data/third_party/abseil-cpp/absl/strings/internal/cord_rep_consume.h +4 -7
- data/third_party/abseil-cpp/absl/strings/internal/cord_rep_flat.h +8 -0
- data/third_party/abseil-cpp/absl/strings/internal/cord_rep_ring.h +2 -2
- data/third_party/abseil-cpp/absl/strings/internal/cordz_handle.cc +46 -20
- data/third_party/abseil-cpp/absl/strings/internal/cordz_handle.h +1 -34
- data/third_party/abseil-cpp/absl/strings/internal/cordz_info.cc +2 -1
- data/third_party/abseil-cpp/absl/strings/internal/escaping.cc +23 -0
- data/third_party/abseil-cpp/absl/strings/internal/escaping.h +1 -0
- data/third_party/abseil-cpp/absl/strings/internal/memutil.cc +2 -77
- data/third_party/abseil-cpp/absl/strings/internal/memutil.h +4 -112
- data/third_party/abseil-cpp/absl/strings/internal/stl_type_traits.h +1 -1
- data/third_party/abseil-cpp/absl/strings/internal/str_format/arg.cc +10 -31
- data/third_party/abseil-cpp/absl/strings/internal/str_format/arg.h +8 -8
- data/third_party/abseil-cpp/absl/strings/internal/str_format/bind.h +5 -20
- data/third_party/abseil-cpp/absl/strings/internal/str_format/constexpr_parser.h +1 -0
- data/third_party/abseil-cpp/absl/strings/internal/str_format/extension.h +1 -1
- data/third_party/abseil-cpp/absl/strings/internal/str_format/float_conversion.cc +9 -9
- data/third_party/abseil-cpp/absl/strings/internal/str_split_internal.h +56 -6
- data/third_party/abseil-cpp/absl/strings/match.cc +87 -0
- data/third_party/abseil-cpp/absl/strings/match.h +19 -0
- data/third_party/abseil-cpp/absl/strings/numbers.cc +154 -122
- data/third_party/abseil-cpp/absl/strings/numbers.h +1 -6
- data/third_party/abseil-cpp/absl/strings/str_cat.cc +7 -50
- data/third_party/abseil-cpp/absl/strings/str_cat.h +83 -15
- data/third_party/abseil-cpp/absl/strings/str_format.h +6 -3
- data/third_party/abseil-cpp/absl/strings/str_split.cc +9 -6
- data/third_party/abseil-cpp/absl/strings/string_view.cc +26 -4
- data/third_party/abseil-cpp/absl/synchronization/internal/create_thread_identity.cc +5 -0
- data/third_party/abseil-cpp/absl/synchronization/internal/futex.h +63 -43
- data/third_party/abseil-cpp/absl/synchronization/internal/futex_waiter.cc +111 -0
- data/third_party/abseil-cpp/absl/synchronization/internal/futex_waiter.h +63 -0
- data/third_party/abseil-cpp/absl/synchronization/internal/graphcycles.cc +11 -7
- data/third_party/abseil-cpp/absl/synchronization/internal/kernel_timeout.cc +225 -0
- data/third_party/abseil-cpp/absl/synchronization/internal/kernel_timeout.h +122 -114
- data/third_party/abseil-cpp/absl/synchronization/internal/per_thread_sem.cc +12 -8
- data/third_party/abseil-cpp/absl/synchronization/internal/per_thread_sem.h +10 -1
- data/third_party/abseil-cpp/absl/synchronization/internal/pthread_waiter.cc +167 -0
- data/third_party/abseil-cpp/absl/synchronization/internal/pthread_waiter.h +60 -0
- data/third_party/abseil-cpp/absl/synchronization/internal/sem_waiter.cc +122 -0
- data/third_party/abseil-cpp/absl/synchronization/internal/sem_waiter.h +65 -0
- data/third_party/abseil-cpp/absl/synchronization/internal/stdcpp_waiter.cc +91 -0
- data/third_party/abseil-cpp/absl/synchronization/internal/stdcpp_waiter.h +56 -0
- data/third_party/abseil-cpp/absl/synchronization/internal/waiter.h +19 -113
- data/third_party/abseil-cpp/absl/synchronization/internal/waiter_base.cc +42 -0
- data/third_party/abseil-cpp/absl/synchronization/internal/waiter_base.h +90 -0
- data/third_party/abseil-cpp/absl/synchronization/internal/win32_waiter.cc +151 -0
- data/third_party/abseil-cpp/absl/synchronization/internal/win32_waiter.h +70 -0
- data/third_party/abseil-cpp/absl/synchronization/mutex.cc +407 -411
- data/third_party/abseil-cpp/absl/synchronization/mutex.h +152 -118
- data/third_party/abseil-cpp/absl/time/clock.cc +6 -7
- data/third_party/abseil-cpp/absl/time/duration.cc +24 -26
- data/third_party/abseil-cpp/absl/time/internal/cctz/include/cctz/time_zone.h +1 -0
- data/third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_fixed.cc +1 -1
- data/third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_format.cc +3 -3
- data/third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_if.cc +8 -6
- data/third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_if.h +6 -3
- data/third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_impl.cc +4 -2
- data/third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_impl.h +4 -0
- data/third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_info.cc +322 -295
- data/third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_info.h +8 -17
- data/third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_libc.cc +51 -33
- data/third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_libc.h +7 -2
- data/third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_lookup.cc +128 -2
- data/third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_posix.h +1 -1
- data/third_party/abseil-cpp/absl/time/internal/cctz/src/tzfile.h +5 -1
- data/third_party/abseil-cpp/absl/time/internal/cctz/src/zone_info_source.cc +34 -34
- data/third_party/abseil-cpp/absl/time/time.cc +9 -2
- data/third_party/abseil-cpp/absl/time/time.h +115 -15
- data/third_party/abseil-cpp/absl/types/internal/optional.h +0 -52
- data/third_party/abseil-cpp/absl/types/internal/span.h +2 -2
- data/third_party/abseil-cpp/absl/types/internal/variant.h +2 -2
- data/third_party/abseil-cpp/absl/types/optional.h +15 -13
- data/third_party/abseil-cpp/absl/types/span.h +1 -2
- data/third_party/boringssl-with-bazel/err_data.c +15 -14
- data/third_party/boringssl-with-bazel/src/crypto/asn1/a_gentm.c +7 -3
- data/third_party/boringssl-with-bazel/src/crypto/asn1/a_strex.c +7 -7
- data/third_party/boringssl-with-bazel/src/crypto/asn1/a_utctm.c +7 -3
- data/third_party/boringssl-with-bazel/src/crypto/bio/connect.c +5 -5
- data/third_party/boringssl-with-bazel/src/crypto/bio/errno.c +92 -0
- data/third_party/boringssl-with-bazel/src/crypto/bio/fd.c +4 -48
- data/third_party/boringssl-with-bazel/src/crypto/bio/file.c +11 -6
- data/third_party/boringssl-with-bazel/src/crypto/bio/internal.h +16 -6
- data/third_party/boringssl-with-bazel/src/crypto/bio/socket.c +2 -2
- data/third_party/boringssl-with-bazel/src/crypto/bio/socket_helper.c +9 -0
- data/third_party/boringssl-with-bazel/src/crypto/bytestring/cbs.c +1 -1
- data/third_party/boringssl-with-bazel/src/crypto/conf/conf.c +3 -7
- data/third_party/boringssl-with-bazel/src/crypto/cpu_aarch64_apple.c +0 -2
- data/third_party/boringssl-with-bazel/src/crypto/cpu_aarch64_fuchsia.c +0 -1
- data/third_party/boringssl-with-bazel/src/crypto/cpu_aarch64_linux.c +0 -2
- data/third_party/boringssl-with-bazel/src/crypto/cpu_aarch64_openbsd.c +0 -1
- data/third_party/boringssl-with-bazel/src/crypto/cpu_aarch64_sysreg.c +93 -0
- data/third_party/boringssl-with-bazel/src/crypto/cpu_aarch64_win.c +1 -1
- data/third_party/boringssl-with-bazel/src/crypto/cpu_arm_freebsd.c +0 -1
- data/third_party/boringssl-with-bazel/src/crypto/cpu_arm_linux.c +0 -2
- data/third_party/boringssl-with-bazel/src/crypto/dh_extra/dh_asn1.c +4 -0
- data/third_party/boringssl-with-bazel/src/crypto/dh_extra/params.c +5 -0
- data/third_party/boringssl-with-bazel/src/crypto/ec_extra/hash_to_curve.c +9 -14
- data/third_party/boringssl-with-bazel/src/crypto/ec_extra/internal.h +4 -6
- data/third_party/boringssl-with-bazel/src/crypto/err/err.c +10 -11
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/dh/check.c +37 -8
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/dh/dh.c +38 -19
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/dh/internal.h +7 -0
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/self_check/self_check.c +39 -16
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/service_indicator/service_indicator.c +4 -7
- data/third_party/boringssl-with-bazel/src/crypto/hpke/hpke.c +7 -0
- data/third_party/boringssl-with-bazel/src/crypto/internal.h +13 -21
- data/third_party/boringssl-with-bazel/src/crypto/obj/obj.c +6 -23
- data/third_party/boringssl-with-bazel/src/crypto/rand_extra/getentropy.c +4 -0
- data/third_party/boringssl-with-bazel/src/crypto/stack/stack.c +5 -0
- data/third_party/boringssl-with-bazel/src/crypto/x509/by_dir.c +1 -6
- data/third_party/boringssl-with-bazel/src/crypto/x509/by_file.c +0 -3
- data/third_party/boringssl-with-bazel/src/crypto/x509/x509_d2.c +1 -3
- data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_alt.c +2 -3
- data/third_party/boringssl-with-bazel/src/include/openssl/base.h +9 -1
- data/third_party/boringssl-with-bazel/src/include/openssl/bio.h +11 -1
- data/third_party/boringssl-with-bazel/src/include/openssl/dh.h +4 -1
- data/third_party/boringssl-with-bazel/src/include/openssl/ec.h +7 -9
- data/third_party/boringssl-with-bazel/src/include/openssl/hpke.h +6 -2
- data/third_party/boringssl-with-bazel/src/include/openssl/span.h +22 -20
- data/third_party/boringssl-with-bazel/src/include/openssl/ssl.h +4 -0
- data/third_party/boringssl-with-bazel/src/include/openssl/stack.h +20 -12
- data/third_party/boringssl-with-bazel/src/include/openssl/target.h +50 -3
- data/third_party/boringssl-with-bazel/src/include/openssl/x509.h +0 -4
- data/third_party/boringssl-with-bazel/src/ssl/ssl_cipher.cc +2 -2
- data/third_party/boringssl-with-bazel/src/ssl/ssl_file.cc +4 -4
- data/third_party/boringssl-with-bazel/src/ssl/ssl_lib.cc +2 -0
- metadata +41 -33
- data/src/core/lib/promise/detail/basic_join.h +0 -197
- data/src/core/lib/promise/detail/switch.h +0 -1455
- data/src/core/lib/promise/try_join.h +0 -82
- data/third_party/abseil-cpp/absl/synchronization/internal/waiter.cc +0 -403
- data/third_party/boringssl-with-bazel/src/crypto/cpu_aarch64_freebsd.c +0 -62
- data/third_party/boringssl-with-bazel/src/crypto/cpu_arm.c +0 -38
- data/third_party/boringssl-with-bazel/src/crypto/cpu_arm_openbsd.c +0 -31
- data/third_party/re2/util/benchmark.h +0 -156
- data/third_party/re2/util/flags.h +0 -26
- data/third_party/re2/util/malloc_counter.h +0 -19
- data/third_party/re2/util/pcre.cc +0 -1025
- data/third_party/re2/util/pcre.h +0 -681
- data/third_party/re2/util/test.h +0 -50
- data/third_party/upb/upb/mini_table.h +0 -36
- data/third_party/zlib/gzclose.c +0 -25
- data/third_party/zlib/gzlib.c +0 -639
- data/third_party/zlib/gzread.c +0 -650
- data/third_party/zlib/gzwrite.c +0 -677
@@ -21,12 +21,35 @@
|
|
21
21
|
#include <cstring>
|
22
22
|
#include <ostream>
|
23
23
|
|
24
|
-
#include "absl/strings/internal/memutil.h"
|
25
|
-
|
26
24
|
namespace absl {
|
27
25
|
ABSL_NAMESPACE_BEGIN
|
28
26
|
|
29
27
|
namespace {
|
28
|
+
|
29
|
+
// This is significantly faster for case-sensitive matches with very
|
30
|
+
// few possible matches.
|
31
|
+
const char* memmatch(const char* phaystack, size_t haylen, const char* pneedle,
|
32
|
+
size_t neelen) {
|
33
|
+
if (0 == neelen) {
|
34
|
+
return phaystack; // even if haylen is 0
|
35
|
+
}
|
36
|
+
if (haylen < neelen) return nullptr;
|
37
|
+
|
38
|
+
const char* match;
|
39
|
+
const char* hayend = phaystack + haylen - neelen + 1;
|
40
|
+
// A static cast is used here to work around the fact that memchr returns
|
41
|
+
// a void* on Posix-compliant systems and const void* on Windows.
|
42
|
+
while (
|
43
|
+
(match = static_cast<const char*>(memchr(
|
44
|
+
phaystack, pneedle[0], static_cast<size_t>(hayend - phaystack))))) {
|
45
|
+
if (memcmp(match, pneedle, neelen) == 0)
|
46
|
+
return match;
|
47
|
+
else
|
48
|
+
phaystack = match + 1;
|
49
|
+
}
|
50
|
+
return nullptr;
|
51
|
+
}
|
52
|
+
|
30
53
|
void WritePadding(std::ostream& o, size_t pad) {
|
31
54
|
char fill_buf[32];
|
32
55
|
memset(fill_buf, o.fill(), sizeof(fill_buf));
|
@@ -84,8 +107,7 @@ string_view::size_type string_view::find(string_view s,
|
|
84
107
|
if (empty() && pos == 0 && s.empty()) return 0;
|
85
108
|
return npos;
|
86
109
|
}
|
87
|
-
const char* result =
|
88
|
-
strings_internal::memmatch(ptr_ + pos, length_ - pos, s.ptr_, s.length_);
|
110
|
+
const char* result = memmatch(ptr_ + pos, length_ - pos, s.ptr_, s.length_);
|
89
111
|
return result ? static_cast<size_type>(result - ptr_) : npos;
|
90
112
|
}
|
91
113
|
|
@@ -13,10 +13,12 @@
|
|
13
13
|
// limitations under the License.
|
14
14
|
|
15
15
|
#include <stdint.h>
|
16
|
+
|
16
17
|
#include <new>
|
17
18
|
|
18
19
|
// This file is a no-op if the required LowLevelAlloc support is missing.
|
19
20
|
#include "absl/base/internal/low_level_alloc.h"
|
21
|
+
#include "absl/synchronization/internal/waiter.h"
|
20
22
|
#ifndef ABSL_LOW_LEVEL_ALLOC_MISSING
|
21
23
|
|
22
24
|
#include <string.h>
|
@@ -71,6 +73,9 @@ static intptr_t RoundUp(intptr_t addr, intptr_t align) {
|
|
71
73
|
|
72
74
|
void OneTimeInitThreadIdentity(base_internal::ThreadIdentity* identity) {
|
73
75
|
PerThreadSem::Init(identity);
|
76
|
+
identity->ticker.store(0, std::memory_order_relaxed);
|
77
|
+
identity->wait_start.store(0, std::memory_order_relaxed);
|
78
|
+
identity->is_idle.store(false, std::memory_order_relaxed);
|
74
79
|
}
|
75
80
|
|
76
81
|
static void ResetThreadIdentityBetweenReuse(
|
@@ -16,9 +16,7 @@
|
|
16
16
|
|
17
17
|
#include "absl/base/config.h"
|
18
18
|
|
19
|
-
#
|
20
|
-
#include <windows.h>
|
21
|
-
#else
|
19
|
+
#ifndef _WIN32
|
22
20
|
#include <sys/time.h>
|
23
21
|
#include <unistd.h>
|
24
22
|
#endif
|
@@ -34,6 +32,7 @@
|
|
34
32
|
|
35
33
|
#include <atomic>
|
36
34
|
#include <cstdint>
|
35
|
+
#include <limits>
|
37
36
|
|
38
37
|
#include "absl/base/optimization.h"
|
39
38
|
#include "absl/synchronization/internal/kernel_timeout.h"
|
@@ -81,51 +80,64 @@ namespace synchronization_internal {
|
|
81
80
|
|
82
81
|
#if defined(SYS_futex_time64) && !defined(SYS_futex)
|
83
82
|
#define SYS_futex SYS_futex_time64
|
83
|
+
using FutexTimespec = struct timespec;
|
84
|
+
#else
|
85
|
+
// Some libc implementations have switched to an unconditional 64-bit `time_t`
|
86
|
+
// definition. This means that `struct timespec` may not match the layout
|
87
|
+
// expected by the kernel ABI on 32-bit platforms. So we define the
|
88
|
+
// FutexTimespec that matches the kernel timespec definition. It should be safe
|
89
|
+
// to use this struct for 64-bit userspace builds too, since it will use another
|
90
|
+
// SYS_futex kernel call with 64-bit tv_sec inside timespec.
|
91
|
+
struct FutexTimespec {
|
92
|
+
long tv_sec; // NOLINT
|
93
|
+
long tv_nsec; // NOLINT
|
94
|
+
};
|
84
95
|
#endif
|
85
96
|
|
86
97
|
class FutexImpl {
|
87
98
|
public:
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
}
|
107
|
-
if (ABSL_PREDICT_FALSE(err != 0)) {
|
99
|
+
// Atomically check that `*v == val`, and if it is, then sleep until the until
|
100
|
+
// woken by `Wake()`.
|
101
|
+
static int Wait(std::atomic<int32_t>* v, int32_t val) {
|
102
|
+
return WaitAbsoluteTimeout(v, val, nullptr);
|
103
|
+
}
|
104
|
+
|
105
|
+
// Atomically check that `*v == val`, and if it is, then sleep until
|
106
|
+
// CLOCK_REALTIME reaches `*abs_timeout`, or until woken by `Wake()`.
|
107
|
+
static int WaitAbsoluteTimeout(std::atomic<int32_t>* v, int32_t val,
|
108
|
+
const struct timespec* abs_timeout) {
|
109
|
+
FutexTimespec ts;
|
110
|
+
// https://locklessinc.com/articles/futex_cheat_sheet/
|
111
|
+
// Unlike FUTEX_WAIT, FUTEX_WAIT_BITSET uses absolute time.
|
112
|
+
auto err = syscall(
|
113
|
+
SYS_futex, reinterpret_cast<int32_t*>(v),
|
114
|
+
FUTEX_WAIT_BITSET | FUTEX_PRIVATE_FLAG | FUTEX_CLOCK_REALTIME, val,
|
115
|
+
ToFutexTimespec(abs_timeout, &ts), nullptr, FUTEX_BITSET_MATCH_ANY);
|
116
|
+
if (err != 0) {
|
108
117
|
return -errno;
|
109
118
|
}
|
110
119
|
return 0;
|
111
120
|
}
|
112
121
|
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
122
|
+
// Atomically check that `*v == val`, and if it is, then sleep until
|
123
|
+
// `*rel_timeout` has elapsed, or until woken by `Wake()`.
|
124
|
+
static int WaitRelativeTimeout(std::atomic<int32_t>* v, int32_t val,
|
125
|
+
const struct timespec* rel_timeout) {
|
126
|
+
FutexTimespec ts;
|
127
|
+
// Atomically check that the futex value is still 0, and if it
|
128
|
+
// is, sleep until abs_timeout or until woken by FUTEX_WAKE.
|
129
|
+
auto err =
|
130
|
+
syscall(SYS_futex, reinterpret_cast<int32_t*>(v), FUTEX_PRIVATE_FLAG,
|
131
|
+
val, ToFutexTimespec(rel_timeout, &ts));
|
132
|
+
if (err != 0) {
|
121
133
|
return -errno;
|
122
134
|
}
|
123
135
|
return 0;
|
124
136
|
}
|
125
137
|
|
126
|
-
|
127
|
-
|
128
|
-
|
138
|
+
// Wakes at most `count` waiters that have entered the sleep state on `v`.
|
139
|
+
static int Wake(std::atomic<int32_t>* v, int32_t count) {
|
140
|
+
auto err = syscall(SYS_futex, reinterpret_cast<int32_t*>(v),
|
129
141
|
FUTEX_WAKE | FUTEX_PRIVATE_FLAG, count);
|
130
142
|
if (ABSL_PREDICT_FALSE(err < 0)) {
|
131
143
|
return -errno;
|
@@ -133,16 +145,24 @@ class FutexImpl {
|
|
133
145
|
return 0;
|
134
146
|
}
|
135
147
|
|
136
|
-
|
137
|
-
static
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
nullptr, bits);
|
142
|
-
if (ABSL_PREDICT_FALSE(err < 0)) {
|
143
|
-
return -errno;
|
148
|
+
private:
|
149
|
+
static FutexTimespec* ToFutexTimespec(const struct timespec* userspace_ts,
|
150
|
+
FutexTimespec* futex_ts) {
|
151
|
+
if (userspace_ts == nullptr) {
|
152
|
+
return nullptr;
|
144
153
|
}
|
145
|
-
|
154
|
+
|
155
|
+
using FutexSeconds = decltype(futex_ts->tv_sec);
|
156
|
+
using FutexNanoseconds = decltype(futex_ts->tv_nsec);
|
157
|
+
|
158
|
+
constexpr auto kMaxSeconds{(std::numeric_limits<FutexSeconds>::max)()};
|
159
|
+
if (userspace_ts->tv_sec > kMaxSeconds) {
|
160
|
+
futex_ts->tv_sec = kMaxSeconds;
|
161
|
+
} else {
|
162
|
+
futex_ts->tv_sec = static_cast<FutexSeconds>(userspace_ts->tv_sec);
|
163
|
+
}
|
164
|
+
futex_ts->tv_nsec = static_cast<FutexNanoseconds>(userspace_ts->tv_nsec);
|
165
|
+
return futex_ts;
|
146
166
|
}
|
147
167
|
};
|
148
168
|
|
@@ -0,0 +1,111 @@
|
|
1
|
+
// Copyright 2023 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/synchronization/internal/futex_waiter.h"
|
16
|
+
|
17
|
+
#ifdef ABSL_INTERNAL_HAVE_FUTEX_WAITER
|
18
|
+
|
19
|
+
#include <atomic>
|
20
|
+
#include <cstdint>
|
21
|
+
#include <cerrno>
|
22
|
+
|
23
|
+
#include "absl/base/config.h"
|
24
|
+
#include "absl/base/internal/raw_logging.h"
|
25
|
+
#include "absl/base/internal/thread_identity.h"
|
26
|
+
#include "absl/base/optimization.h"
|
27
|
+
#include "absl/synchronization/internal/kernel_timeout.h"
|
28
|
+
#include "absl/synchronization/internal/futex.h"
|
29
|
+
|
30
|
+
namespace absl {
|
31
|
+
ABSL_NAMESPACE_BEGIN
|
32
|
+
namespace synchronization_internal {
|
33
|
+
|
34
|
+
#ifdef ABSL_INTERNAL_NEED_REDUNDANT_CONSTEXPR_DECL
|
35
|
+
constexpr char FutexWaiter::kName[];
|
36
|
+
#endif
|
37
|
+
|
38
|
+
int FutexWaiter::WaitUntil(std::atomic<int32_t>* v, int32_t val,
|
39
|
+
KernelTimeout t) {
|
40
|
+
#ifdef CLOCK_MONOTONIC
|
41
|
+
constexpr bool kHasClockMonotonic = true;
|
42
|
+
#else
|
43
|
+
constexpr bool kHasClockMonotonic = false;
|
44
|
+
#endif
|
45
|
+
|
46
|
+
// We can't call Futex::WaitUntil() here because the prodkernel implementation
|
47
|
+
// does not know about KernelTimeout::SupportsSteadyClock().
|
48
|
+
if (!t.has_timeout()) {
|
49
|
+
return Futex::Wait(v, val);
|
50
|
+
} else if (kHasClockMonotonic && KernelTimeout::SupportsSteadyClock() &&
|
51
|
+
t.is_relative_timeout()) {
|
52
|
+
auto rel_timespec = t.MakeRelativeTimespec();
|
53
|
+
return Futex::WaitRelativeTimeout(v, val, &rel_timespec);
|
54
|
+
} else {
|
55
|
+
auto abs_timespec = t.MakeAbsTimespec();
|
56
|
+
return Futex::WaitAbsoluteTimeout(v, val, &abs_timespec);
|
57
|
+
}
|
58
|
+
}
|
59
|
+
|
60
|
+
bool FutexWaiter::Wait(KernelTimeout t) {
|
61
|
+
// Loop until we can atomically decrement futex from a positive
|
62
|
+
// value, waiting on a futex while we believe it is zero.
|
63
|
+
// Note that, since the thread ticker is just reset, we don't need to check
|
64
|
+
// whether the thread is idle on the very first pass of the loop.
|
65
|
+
bool first_pass = true;
|
66
|
+
while (true) {
|
67
|
+
int32_t x = futex_.load(std::memory_order_relaxed);
|
68
|
+
while (x != 0) {
|
69
|
+
if (!futex_.compare_exchange_weak(x, x - 1,
|
70
|
+
std::memory_order_acquire,
|
71
|
+
std::memory_order_relaxed)) {
|
72
|
+
continue; // Raced with someone, retry.
|
73
|
+
}
|
74
|
+
return true; // Consumed a wakeup, we are done.
|
75
|
+
}
|
76
|
+
|
77
|
+
if (!first_pass) MaybeBecomeIdle();
|
78
|
+
const int err = WaitUntil(&futex_, 0, t);
|
79
|
+
if (err != 0) {
|
80
|
+
if (err == -EINTR || err == -EWOULDBLOCK) {
|
81
|
+
// Do nothing, the loop will retry.
|
82
|
+
} else if (err == -ETIMEDOUT) {
|
83
|
+
return false;
|
84
|
+
} else {
|
85
|
+
ABSL_RAW_LOG(FATAL, "Futex operation failed with error %d\n", err);
|
86
|
+
}
|
87
|
+
}
|
88
|
+
first_pass = false;
|
89
|
+
}
|
90
|
+
}
|
91
|
+
|
92
|
+
void FutexWaiter::Post() {
|
93
|
+
if (futex_.fetch_add(1, std::memory_order_release) == 0) {
|
94
|
+
// We incremented from 0, need to wake a potential waiter.
|
95
|
+
Poke();
|
96
|
+
}
|
97
|
+
}
|
98
|
+
|
99
|
+
void FutexWaiter::Poke() {
|
100
|
+
// Wake one thread waiting on the futex.
|
101
|
+
const int err = Futex::Wake(&futex_, 1);
|
102
|
+
if (ABSL_PREDICT_FALSE(err < 0)) {
|
103
|
+
ABSL_RAW_LOG(FATAL, "Futex operation failed with error %d\n", err);
|
104
|
+
}
|
105
|
+
}
|
106
|
+
|
107
|
+
} // namespace synchronization_internal
|
108
|
+
ABSL_NAMESPACE_END
|
109
|
+
} // namespace absl
|
110
|
+
|
111
|
+
#endif // ABSL_INTERNAL_HAVE_FUTEX_WAITER
|
@@ -0,0 +1,63 @@
|
|
1
|
+
// Copyright 2023 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_SYNCHRONIZATION_INTERNAL_FUTEX_WAITER_H_
|
17
|
+
#define ABSL_SYNCHRONIZATION_INTERNAL_FUTEX_WAITER_H_
|
18
|
+
|
19
|
+
#include <atomic>
|
20
|
+
#include <cstdint>
|
21
|
+
|
22
|
+
#include "absl/base/config.h"
|
23
|
+
#include "absl/synchronization/internal/kernel_timeout.h"
|
24
|
+
#include "absl/synchronization/internal/futex.h"
|
25
|
+
#include "absl/synchronization/internal/waiter_base.h"
|
26
|
+
|
27
|
+
#ifdef ABSL_INTERNAL_HAVE_FUTEX
|
28
|
+
|
29
|
+
namespace absl {
|
30
|
+
ABSL_NAMESPACE_BEGIN
|
31
|
+
namespace synchronization_internal {
|
32
|
+
|
33
|
+
#define ABSL_INTERNAL_HAVE_FUTEX_WAITER 1
|
34
|
+
|
35
|
+
class FutexWaiter : public WaiterCrtp<FutexWaiter> {
|
36
|
+
public:
|
37
|
+
FutexWaiter() : futex_(0) {}
|
38
|
+
|
39
|
+
bool Wait(KernelTimeout t);
|
40
|
+
void Post();
|
41
|
+
void Poke();
|
42
|
+
|
43
|
+
static constexpr char kName[] = "FutexWaiter";
|
44
|
+
|
45
|
+
private:
|
46
|
+
// Atomically check that `*v == val`, and if it is, then sleep until the
|
47
|
+
// timeout `t` has been reached, or until woken by `Wake()`.
|
48
|
+
static int WaitUntil(std::atomic<int32_t>* v, int32_t val,
|
49
|
+
KernelTimeout t);
|
50
|
+
|
51
|
+
// Futexes are defined by specification to be 32-bits.
|
52
|
+
// Thus std::atomic<int32_t> must be just an int32_t with lockfree methods.
|
53
|
+
std::atomic<int32_t> futex_;
|
54
|
+
static_assert(sizeof(int32_t) == sizeof(futex_), "Wrong size for futex");
|
55
|
+
};
|
56
|
+
|
57
|
+
} // namespace synchronization_internal
|
58
|
+
ABSL_NAMESPACE_END
|
59
|
+
} // namespace absl
|
60
|
+
|
61
|
+
#endif // ABSL_INTERNAL_HAVE_FUTEX
|
62
|
+
|
63
|
+
#endif // ABSL_SYNCHRONIZATION_INTERNAL_FUTEX_WAITER_H_
|
@@ -37,6 +37,7 @@
|
|
37
37
|
|
38
38
|
#include <algorithm>
|
39
39
|
#include <array>
|
40
|
+
#include <cinttypes>
|
40
41
|
#include <limits>
|
41
42
|
#include "absl/base/internal/hide_ptr.h"
|
42
43
|
#include "absl/base/internal/raw_logging.h"
|
@@ -114,7 +115,7 @@ class Vec {
|
|
114
115
|
if (src->ptr_ == src->space_) {
|
115
116
|
// Need to actually copy
|
116
117
|
resize(src->size_);
|
117
|
-
std::
|
118
|
+
std::copy_n(src->ptr_, src->size_, ptr_);
|
118
119
|
src->size_ = 0;
|
119
120
|
} else {
|
120
121
|
Discard();
|
@@ -148,7 +149,7 @@ class Vec {
|
|
148
149
|
size_t request = static_cast<size_t>(capacity_) * sizeof(T);
|
149
150
|
T* copy = static_cast<T*>(
|
150
151
|
base_internal::LowLevelAlloc::AllocWithArena(request, arena));
|
151
|
-
std::
|
152
|
+
std::copy_n(ptr_, size_, copy);
|
152
153
|
Discard();
|
153
154
|
ptr_ = copy;
|
154
155
|
}
|
@@ -386,19 +387,22 @@ bool GraphCycles::CheckInvariants() const {
|
|
386
387
|
Node* nx = r->nodes_[x];
|
387
388
|
void* ptr = base_internal::UnhidePtr<void>(nx->masked_ptr);
|
388
389
|
if (ptr != nullptr && static_cast<uint32_t>(r->ptrmap_.Find(ptr)) != x) {
|
389
|
-
ABSL_RAW_LOG(FATAL, "Did not find live node in hash table %
|
390
|
+
ABSL_RAW_LOG(FATAL, "Did not find live node in hash table %" PRIu32 " %p",
|
391
|
+
x, ptr);
|
390
392
|
}
|
391
393
|
if (nx->visited) {
|
392
|
-
ABSL_RAW_LOG(FATAL, "Did not clear visited marker on node %
|
394
|
+
ABSL_RAW_LOG(FATAL, "Did not clear visited marker on node %" PRIu32, x);
|
393
395
|
}
|
394
396
|
if (!ranks.insert(nx->rank)) {
|
395
|
-
ABSL_RAW_LOG(FATAL, "Duplicate occurrence of rank %
|
397
|
+
ABSL_RAW_LOG(FATAL, "Duplicate occurrence of rank %" PRId32, nx->rank);
|
396
398
|
}
|
397
399
|
HASH_FOR_EACH(y, nx->out) {
|
398
400
|
Node* ny = r->nodes_[static_cast<uint32_t>(y)];
|
399
401
|
if (nx->rank >= ny->rank) {
|
400
|
-
ABSL_RAW_LOG(FATAL,
|
401
|
-
|
402
|
+
ABSL_RAW_LOG(FATAL,
|
403
|
+
"Edge %" PRIu32 " ->%" PRId32
|
404
|
+
" has bad rank assignment %" PRId32 "->%" PRId32,
|
405
|
+
x, y, nx->rank, ny->rank);
|
402
406
|
}
|
403
407
|
}
|
404
408
|
}
|
@@ -0,0 +1,225 @@
|
|
1
|
+
// Copyright 2023 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/synchronization/internal/kernel_timeout.h"
|
16
|
+
|
17
|
+
#ifndef _WIN32
|
18
|
+
#include <sys/types.h>
|
19
|
+
#endif
|
20
|
+
|
21
|
+
#include <algorithm>
|
22
|
+
#include <chrono> // NOLINT(build/c++11)
|
23
|
+
#include <cstdint>
|
24
|
+
#include <cstdlib>
|
25
|
+
#include <cstring>
|
26
|
+
#include <ctime>
|
27
|
+
#include <limits>
|
28
|
+
|
29
|
+
#include "absl/base/attributes.h"
|
30
|
+
#include "absl/base/call_once.h"
|
31
|
+
#include "absl/base/config.h"
|
32
|
+
#include "absl/time/time.h"
|
33
|
+
|
34
|
+
namespace absl {
|
35
|
+
ABSL_NAMESPACE_BEGIN
|
36
|
+
namespace synchronization_internal {
|
37
|
+
|
38
|
+
#ifdef ABSL_INTERNAL_NEED_REDUNDANT_CONSTEXPR_DECL
|
39
|
+
constexpr uint64_t KernelTimeout::kNoTimeout;
|
40
|
+
constexpr int64_t KernelTimeout::kMaxNanos;
|
41
|
+
#endif
|
42
|
+
|
43
|
+
int64_t KernelTimeout::SteadyClockNow() {
|
44
|
+
if (!SupportsSteadyClock()) {
|
45
|
+
return absl::GetCurrentTimeNanos();
|
46
|
+
}
|
47
|
+
return std::chrono::duration_cast<std::chrono::nanoseconds>(
|
48
|
+
std::chrono::steady_clock::now().time_since_epoch())
|
49
|
+
.count();
|
50
|
+
}
|
51
|
+
|
52
|
+
KernelTimeout::KernelTimeout(absl::Time t) {
|
53
|
+
// `absl::InfiniteFuture()` is a common "no timeout" value and cheaper to
|
54
|
+
// compare than convert.
|
55
|
+
if (t == absl::InfiniteFuture()) {
|
56
|
+
rep_ = kNoTimeout;
|
57
|
+
return;
|
58
|
+
}
|
59
|
+
|
60
|
+
int64_t unix_nanos = absl::ToUnixNanos(t);
|
61
|
+
|
62
|
+
// A timeout that lands before the unix epoch is converted to 0.
|
63
|
+
// In theory implementations should expire these timeouts immediately.
|
64
|
+
if (unix_nanos < 0) {
|
65
|
+
unix_nanos = 0;
|
66
|
+
}
|
67
|
+
|
68
|
+
// Values greater than or equal to kMaxNanos are converted to infinite.
|
69
|
+
if (unix_nanos >= kMaxNanos) {
|
70
|
+
rep_ = kNoTimeout;
|
71
|
+
return;
|
72
|
+
}
|
73
|
+
|
74
|
+
rep_ = static_cast<uint64_t>(unix_nanos) << 1;
|
75
|
+
}
|
76
|
+
|
77
|
+
KernelTimeout::KernelTimeout(absl::Duration d) {
|
78
|
+
// `absl::InfiniteDuration()` is a common "no timeout" value and cheaper to
|
79
|
+
// compare than convert.
|
80
|
+
if (d == absl::InfiniteDuration()) {
|
81
|
+
rep_ = kNoTimeout;
|
82
|
+
return;
|
83
|
+
}
|
84
|
+
|
85
|
+
int64_t nanos = absl::ToInt64Nanoseconds(d);
|
86
|
+
|
87
|
+
// Negative durations are normalized to 0.
|
88
|
+
// In theory implementations should expire these timeouts immediately.
|
89
|
+
if (nanos < 0) {
|
90
|
+
nanos = 0;
|
91
|
+
}
|
92
|
+
|
93
|
+
int64_t now = SteadyClockNow();
|
94
|
+
if (nanos > kMaxNanos - now) {
|
95
|
+
// Durations that would be greater than kMaxNanos are converted to infinite.
|
96
|
+
rep_ = kNoTimeout;
|
97
|
+
return;
|
98
|
+
}
|
99
|
+
|
100
|
+
nanos += now;
|
101
|
+
rep_ = (static_cast<uint64_t>(nanos) << 1) | uint64_t{1};
|
102
|
+
}
|
103
|
+
|
104
|
+
int64_t KernelTimeout::MakeAbsNanos() const {
|
105
|
+
if (!has_timeout()) {
|
106
|
+
return kMaxNanos;
|
107
|
+
}
|
108
|
+
|
109
|
+
int64_t nanos = RawAbsNanos();
|
110
|
+
|
111
|
+
if (is_relative_timeout()) {
|
112
|
+
// We need to change epochs, because the relative timeout might be
|
113
|
+
// represented by an absolute timestamp from another clock.
|
114
|
+
nanos = std::max<int64_t>(nanos - SteadyClockNow(), 0);
|
115
|
+
int64_t now = absl::GetCurrentTimeNanos();
|
116
|
+
if (nanos > kMaxNanos - now) {
|
117
|
+
// Overflow.
|
118
|
+
nanos = kMaxNanos;
|
119
|
+
} else {
|
120
|
+
nanos += now;
|
121
|
+
}
|
122
|
+
} else if (nanos == 0) {
|
123
|
+
// Some callers have assumed that 0 means no timeout, so instead we return a
|
124
|
+
// time of 1 nanosecond after the epoch.
|
125
|
+
nanos = 1;
|
126
|
+
}
|
127
|
+
|
128
|
+
return nanos;
|
129
|
+
}
|
130
|
+
|
131
|
+
int64_t KernelTimeout::InNanosecondsFromNow() const {
|
132
|
+
if (!has_timeout()) {
|
133
|
+
return kMaxNanos;
|
134
|
+
}
|
135
|
+
|
136
|
+
int64_t nanos = RawAbsNanos();
|
137
|
+
if (is_absolute_timeout()) {
|
138
|
+
return std::max<int64_t>(nanos - absl::GetCurrentTimeNanos(), 0);
|
139
|
+
}
|
140
|
+
return std::max<int64_t>(nanos - SteadyClockNow(), 0);
|
141
|
+
}
|
142
|
+
|
143
|
+
struct timespec KernelTimeout::MakeAbsTimespec() const {
|
144
|
+
return absl::ToTimespec(absl::Nanoseconds(MakeAbsNanos()));
|
145
|
+
}
|
146
|
+
|
147
|
+
struct timespec KernelTimeout::MakeRelativeTimespec() const {
|
148
|
+
return absl::ToTimespec(absl::Nanoseconds(InNanosecondsFromNow()));
|
149
|
+
}
|
150
|
+
|
151
|
+
#ifndef _WIN32
|
152
|
+
struct timespec KernelTimeout::MakeClockAbsoluteTimespec(clockid_t c) const {
|
153
|
+
if (!has_timeout()) {
|
154
|
+
return absl::ToTimespec(absl::Nanoseconds(kMaxNanos));
|
155
|
+
}
|
156
|
+
|
157
|
+
int64_t nanos = RawAbsNanos();
|
158
|
+
if (is_absolute_timeout()) {
|
159
|
+
nanos -= absl::GetCurrentTimeNanos();
|
160
|
+
} else {
|
161
|
+
nanos -= SteadyClockNow();
|
162
|
+
}
|
163
|
+
|
164
|
+
struct timespec now;
|
165
|
+
ABSL_RAW_CHECK(clock_gettime(c, &now) == 0, "clock_gettime() failed");
|
166
|
+
absl::Duration from_clock_epoch =
|
167
|
+
absl::DurationFromTimespec(now) + absl::Nanoseconds(nanos);
|
168
|
+
if (from_clock_epoch <= absl::ZeroDuration()) {
|
169
|
+
// Some callers have assumed that 0 means no timeout, so instead we return a
|
170
|
+
// time of 1 nanosecond after the epoch. For safety we also do not return
|
171
|
+
// negative values.
|
172
|
+
return absl::ToTimespec(absl::Nanoseconds(1));
|
173
|
+
}
|
174
|
+
return absl::ToTimespec(from_clock_epoch);
|
175
|
+
}
|
176
|
+
#endif
|
177
|
+
|
178
|
+
KernelTimeout::DWord KernelTimeout::InMillisecondsFromNow() const {
|
179
|
+
constexpr DWord kInfinite = std::numeric_limits<DWord>::max();
|
180
|
+
|
181
|
+
if (!has_timeout()) {
|
182
|
+
return kInfinite;
|
183
|
+
}
|
184
|
+
|
185
|
+
constexpr uint64_t kNanosInMillis = uint64_t{1'000'000};
|
186
|
+
constexpr uint64_t kMaxValueNanos =
|
187
|
+
std::numeric_limits<int64_t>::max() - kNanosInMillis + 1;
|
188
|
+
|
189
|
+
uint64_t ns_from_now = static_cast<uint64_t>(InNanosecondsFromNow());
|
190
|
+
if (ns_from_now >= kMaxValueNanos) {
|
191
|
+
// Rounding up would overflow.
|
192
|
+
return kInfinite;
|
193
|
+
}
|
194
|
+
// Convert to milliseconds, always rounding up.
|
195
|
+
uint64_t ms_from_now = (ns_from_now + kNanosInMillis - 1) / kNanosInMillis;
|
196
|
+
if (ms_from_now > kInfinite) {
|
197
|
+
return kInfinite;
|
198
|
+
}
|
199
|
+
return static_cast<DWord>(ms_from_now);
|
200
|
+
}
|
201
|
+
|
202
|
+
std::chrono::time_point<std::chrono::system_clock>
|
203
|
+
KernelTimeout::ToChronoTimePoint() const {
|
204
|
+
if (!has_timeout()) {
|
205
|
+
return std::chrono::time_point<std::chrono::system_clock>::max();
|
206
|
+
}
|
207
|
+
|
208
|
+
// The cast to std::microseconds is because (on some platforms) the
|
209
|
+
// std::ratio used by std::chrono::steady_clock doesn't convert to
|
210
|
+
// std::nanoseconds, so it doesn't compile.
|
211
|
+
auto micros = std::chrono::duration_cast<std::chrono::microseconds>(
|
212
|
+
std::chrono::nanoseconds(MakeAbsNanos()));
|
213
|
+
return std::chrono::system_clock::from_time_t(0) + micros;
|
214
|
+
}
|
215
|
+
|
216
|
+
std::chrono::nanoseconds KernelTimeout::ToChronoDuration() const {
|
217
|
+
if (!has_timeout()) {
|
218
|
+
return std::chrono::nanoseconds::max();
|
219
|
+
}
|
220
|
+
return std::chrono::nanoseconds(InNanosecondsFromNow());
|
221
|
+
}
|
222
|
+
|
223
|
+
} // namespace synchronization_internal
|
224
|
+
ABSL_NAMESPACE_END
|
225
|
+
} // namespace absl
|