// Copyright 2024 The Abseil Authors // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // https://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. #ifndef ABSL_DEBUGGING_INTERNAL_BOUNDED_UTF8_LENGTH_SEQUENCE_H_ #define ABSL_DEBUGGING_INTERNAL_BOUNDED_UTF8_LENGTH_SEQUENCE_H_ #include <cstdint> #include "absl/base/config.h" #include "absl/numeric/bits.h" namespace absl { ABSL_NAMESPACE_BEGIN namespace debugging_internal { // A sequence of up to max_elements integers between 1 and 4 inclusive, whose // insertion operation computes the sum of all the elements before the insertion // point. This is useful in decoding Punycode, where one needs to know where in // a UTF-8 byte stream the n-th code point begins. // // BoundedUtf8LengthSequence is async-signal-safe and suitable for use in // symbolizing stack traces in a signal handler, provided max_elements is not // improvidently large. For inputs of lengths accepted by the Rust demangler, // up to a couple hundred code points, InsertAndReturnSumOfPredecessors should // run in a few dozen clock cycles, on par with the other arithmetic required // for Punycode decoding. template <uint32_t max_elements> class BoundedUtf8LengthSequence { … }; } // namespace debugging_internal ABSL_NAMESPACE_END } // namespace absl #endif // ABSL_DEBUGGING_INTERNAL_BOUNDED_UTF8_LENGTH_SEQUENCE_H_