varint.cc
Go to the documentation of this file.
1 /*
2  *
3  * Copyright 2015 gRPC authors.
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  */
18 
20 
22 
23 #include "absl/base/attributes.h"
24 
25 namespace grpc_core {
26 
28  if (tail_value < (1 << 7)) {
29  return 2;
30  } else if (tail_value < (1 << 14)) {
31  return 3;
32  } else if (tail_value < (1 << 21)) {
33  return 4;
34  } else if (tail_value < (1 << 28)) {
35  return 5;
36  } else {
37  return 6;
38  }
39 }
40 
42  uint32_t tail_length) {
43  switch (tail_length) {
44  case 5:
45  target[4] = static_cast<uint8_t>((tail_value >> 28) | 0x80);
47  case 4:
48  target[3] = static_cast<uint8_t>((tail_value >> 21) | 0x80);
50  case 3:
51  target[2] = static_cast<uint8_t>((tail_value >> 14) | 0x80);
53  case 2:
54  target[1] = static_cast<uint8_t>((tail_value >> 7) | 0x80);
56  case 1:
57  target[0] = static_cast<uint8_t>((tail_value) | 0x80);
58  }
59  target[tail_length - 1] &= 0x7f;
60 }
61 
62 } // namespace grpc_core
grpc_core::VarintWriteTail
void VarintWriteTail(uint32_t tail_value, uint8_t *target, uint32_t tail_length)
Definition: varint.cc:41
varint.h
grpc_core
Definition: call_metric_recorder.h:31
uint8_t
unsigned char uint8_t
Definition: stdint-msvc2008.h:78
uint32_t
unsigned int uint32_t
Definition: stdint-msvc2008.h:80
grpc_core::VarintLength
uint32_t VarintLength(uint32_t tail_value)
Definition: varint.cc:27
ABSL_FALLTHROUGH_INTENDED
#define ABSL_FALLTHROUGH_INTENDED
Definition: abseil-cpp/absl/base/attributes.h:641
setup.target
target
Definition: third_party/bloaty/third_party/protobuf/python/setup.py:179
port_platform.h


grpc
Author(s):
autogenerated on Fri May 16 2025 03:00:52