Fix ODR violtions in quic/core See https://abseil.io/tips/140 PiperOrigin-RevId: 600884321
diff --git a/quiche/quic/core/congestion_control/tcp_cubic_sender_bytes.h b/quiche/quic/core/congestion_control/tcp_cubic_sender_bytes.h index 0a945db..9162f62 100644 --- a/quiche/quic/core/congestion_control/tcp_cubic_sender_bytes.h +++ b/quiche/quic/core/congestion_control/tcp_cubic_sender_bytes.h
@@ -25,7 +25,7 @@ class RttStats; // Maximum window to allow when doing bandwidth resumption. -const QuicPacketCount kMaxResumptionCongestionWindow = 200; +inline constexpr QuicPacketCount kMaxResumptionCongestionWindow = 200; namespace test { class TcpCubicSenderBytesPeer;
diff --git a/quiche/quic/core/http/http_frames.h b/quiche/quic/core/http/http_frames.h index 874dc10..5b72bb0 100644 --- a/quiche/quic/core/http/http_frames.h +++ b/quiche/quic/core/http/http_frames.h
@@ -108,7 +108,7 @@ // incoming 0xf0701 frames are treated as frames of unknown type. // Length of a priority frame's first byte. -const QuicByteCount kPriorityFirstByteLength = 1; +inline constexpr QuicByteCount kPriorityFirstByteLength = 1; struct QUICHE_EXPORT PriorityUpdateFrame { uint64_t prioritized_element_id = 0;
diff --git a/quiche/quic/core/quic_connection_id.h b/quiche/quic/core/quic_connection_id.h index 6bf5cc4..b7f8b48 100644 --- a/quiche/quic/core/quic_connection_id.h +++ b/quiche/quic/core/quic_connection_id.h
@@ -23,19 +23,19 @@ // Maximum connection ID length supported by versions that use the encoding from // draft-ietf-quic-invariants-06. -const uint8_t kQuicMaxConnectionIdWithLengthPrefixLength = 20; +inline constexpr uint8_t kQuicMaxConnectionIdWithLengthPrefixLength = 20; // Maximum connection ID length supported by versions that use the encoding from // draft-ietf-quic-invariants-05. -const uint8_t kQuicMaxConnectionId4BitLength = 18; +inline constexpr uint8_t kQuicMaxConnectionId4BitLength = 18; // kQuicDefaultConnectionIdLength is the only supported length for QUIC // versions < v99, and is the default picked for all versions. -const uint8_t kQuicDefaultConnectionIdLength = 8; +inline constexpr uint8_t kQuicDefaultConnectionIdLength = 8; // According to the IETF spec, the initial server connection ID generated by // the client must be at least this long. -const uint8_t kQuicMinimumInitialConnectionIdLength = 8; +inline constexpr uint8_t kQuicMinimumInitialConnectionIdLength = 8; class QUICHE_EXPORT QuicConnectionId { public:
diff --git a/quiche/quic/core/quic_flow_controller.h b/quiche/quic/core/quic_flow_controller.h index 8bd43c2..6091f59 100644 --- a/quiche/quic/core/quic_flow_controller.h +++ b/quiche/quic/core/quic_flow_controller.h
@@ -19,7 +19,7 @@ // How much larger the session flow control window needs to be relative to any // stream's flow control window. -const float kSessionFlowControlMultiplier = 1.5; +inline constexpr float kSessionFlowControlMultiplier = 1.5; class QUICHE_EXPORT QuicFlowControllerInterface { public:
diff --git a/quiche/quic/core/quic_framer.h b/quiche/quic/core/quic_framer.h index 62c4ce8..432d052 100644 --- a/quiche/quic/core/quic_framer.h +++ b/quiche/quic/core/quic_framer.h
@@ -32,37 +32,38 @@ class QuicStreamFrameDataProducer; // Number of bytes reserved for the frame type preceding each frame. -const size_t kQuicFrameTypeSize = 1; +inline constexpr size_t kQuicFrameTypeSize = 1; // Number of bytes reserved for error code. -const size_t kQuicErrorCodeSize = 4; +inline constexpr size_t kQuicErrorCodeSize = 4; // Number of bytes reserved to denote the length of error details field. -const size_t kQuicErrorDetailsLengthSize = 2; +inline constexpr size_t kQuicErrorDetailsLengthSize = 2; // Maximum number of bytes reserved for stream id. -const size_t kQuicMaxStreamIdSize = 4; +inline constexpr size_t kQuicMaxStreamIdSize = 4; // Maximum number of bytes reserved for byte offset in stream frame. -const size_t kQuicMaxStreamOffsetSize = 8; +inline constexpr size_t kQuicMaxStreamOffsetSize = 8; // Number of bytes reserved to store payload length in stream frame. -const size_t kQuicStreamPayloadLengthSize = 2; +inline constexpr size_t kQuicStreamPayloadLengthSize = 2; // Number of bytes to reserve for IQ Error codes (for the Connection Close, // Application Close, and Reset Stream frames). -const size_t kQuicIetfQuicErrorCodeSize = 2; +inline constexpr size_t kQuicIetfQuicErrorCodeSize = 2; // Minimum size of the IETF QUIC Error Phrase's length field -const size_t kIetfQuicMinErrorPhraseLengthSize = 1; +inline constexpr size_t kIetfQuicMinErrorPhraseLengthSize = 1; // Size in bytes reserved for the delta time of the largest observed // packet number in ack frames. -const size_t kQuicDeltaTimeLargestObservedSize = 2; +inline constexpr size_t kQuicDeltaTimeLargestObservedSize = 2; // Size in bytes reserved for the number of received packets with timestamps. -const size_t kQuicNumTimestampsSize = 1; +inline constexpr size_t kQuicNumTimestampsSize = 1; // Size in bytes reserved for the number of missing packets in ack frames. -const size_t kNumberOfNackRangesSize = 1; +inline constexpr size_t kNumberOfNackRangesSize = 1; // Size in bytes reserved for the number of ack blocks in ack frames. -const size_t kNumberOfAckBlocksSize = 1; +inline constexpr size_t kNumberOfAckBlocksSize = 1; // Maximum number of missing packet ranges that can fit within an ack frame. -const size_t kMaxNackRanges = (1 << (kNumberOfNackRangesSize * 8)) - 1; +inline constexpr size_t kMaxNackRanges = + (1 << (kNumberOfNackRangesSize * 8)) - 1; // Maximum number of ack blocks that can fit within an ack frame. -const size_t kMaxAckBlocks = (1 << (kNumberOfAckBlocksSize * 8)) - 1; +inline constexpr size_t kMaxAckBlocks = (1 << (kNumberOfAckBlocksSize * 8)) - 1; // This class receives callbacks from the framer when packets // are processed.
diff --git a/quiche/quic/core/quic_linux_socket_utils.h b/quiche/quic/core/quic_linux_socket_utils.h index a1e725b..a0e338d 100644 --- a/quiche/quic/core/quic_linux_socket_utils.h +++ b/quiche/quic/core/quic_linux_socket_utils.h
@@ -44,20 +44,20 @@ namespace quic { -const int kCmsgSpaceForIpv4 = CMSG_SPACE(sizeof(in_pktinfo)); -const int kCmsgSpaceForIpv6 = CMSG_SPACE(sizeof(in6_pktinfo)); +inline constexpr int kCmsgSpaceForIpv4 = CMSG_SPACE(sizeof(in_pktinfo)); +inline constexpr int kCmsgSpaceForIpv6 = CMSG_SPACE(sizeof(in6_pktinfo)); // kCmsgSpaceForIp should be big enough to hold both IPv4 and IPv6 packet info. -const int kCmsgSpaceForIp = (kCmsgSpaceForIpv4 < kCmsgSpaceForIpv6) - ? kCmsgSpaceForIpv6 - : kCmsgSpaceForIpv4; +inline constexpr int kCmsgSpaceForIp = (kCmsgSpaceForIpv4 < kCmsgSpaceForIpv6) + ? kCmsgSpaceForIpv6 + : kCmsgSpaceForIpv4; -const int kCmsgSpaceForSegmentSize = CMSG_SPACE(sizeof(uint16_t)); +inline constexpr int kCmsgSpaceForSegmentSize = CMSG_SPACE(sizeof(uint16_t)); -const int kCmsgSpaceForTxTime = CMSG_SPACE(sizeof(uint64_t)); +inline constexpr int kCmsgSpaceForTxTime = CMSG_SPACE(sizeof(uint64_t)); -const int kCmsgSpaceForTTL = CMSG_SPACE(sizeof(int)); +inline constexpr int kCmsgSpaceForTTL = CMSG_SPACE(sizeof(int)); -const int kCmsgSpaceForTOS = CMSG_SPACE(sizeof(int)); +inline constexpr int kCmsgSpaceForTOS = CMSG_SPACE(sizeof(int)); // QuicMsgHdr is used to build msghdr objects that can be used send packets via // ::sendmsg.
diff --git a/quiche/quic/core/quic_mtu_discovery.h b/quiche/quic/core/quic_mtu_discovery.h index 68fbc6d..fe61640 100644 --- a/quiche/quic/core/quic_mtu_discovery.h +++ b/quiche/quic/core/quic_mtu_discovery.h
@@ -14,10 +14,10 @@ // The initial number of packets between MTU probes. After each attempt the // number is doubled. -const QuicPacketCount kPacketsBetweenMtuProbesBase = 100; +inline constexpr QuicPacketCount kPacketsBetweenMtuProbesBase = 100; // The number of MTU probes that get sent before giving up. -const size_t kMtuDiscoveryAttempts = 3; +inline constexpr size_t kMtuDiscoveryAttempts = 3; // Ensure that exponential back-off does not result in an integer overflow. // The number of packets can be potentially capped, but that is not useful at @@ -28,8 +28,8 @@ "The initial number of packets between MTU probes is too high"); // The increased packet size targeted when doing path MTU discovery. -const QuicByteCount kMtuDiscoveryTargetPacketSizeHigh = 1400; -const QuicByteCount kMtuDiscoveryTargetPacketSizeLow = 1380; +inline constexpr QuicByteCount kMtuDiscoveryTargetPacketSizeHigh = 1400; +inline constexpr QuicByteCount kMtuDiscoveryTargetPacketSizeLow = 1380; static_assert(kMtuDiscoveryTargetPacketSizeLow <= kMaxOutgoingPacketSize, "MTU discovery target is too large");
diff --git a/quiche/quic/core/quic_packet_reader.h b/quiche/quic/core/quic_packet_reader.h index c994557..3b417f2 100644 --- a/quiche/quic/core/quic_packet_reader.h +++ b/quiche/quic/core/quic_packet_reader.h
@@ -18,7 +18,7 @@ namespace quic { // Read in larger batches to minimize recvmmsg overhead. -const int kNumPacketsPerReadMmsgCall = 16; +inline constexpr int kNumPacketsPerReadMmsgCall = 16; class QUICHE_EXPORT QuicPacketReader { public: