Go to the documentation of this file.
30 #ifndef GOOGLE_PROTOBUF_STUBS_INT128_H_
31 #define GOOGLE_PROTOBUF_STUBS_INT128_H_
33 #include <google/protobuf/stubs/common.h>
37 #include <google/protobuf/port_def.inc>
46 #ifdef GOOGLE_PROTOBUF_HAS_CONSTEXPR
47 # define UINT128_CONSTEXPR constexpr
49 # define UINT128_CONSTEXPR
53 class PROTOBUF_EXPORT uint128 {
76 uint128 operator--(
int);
77 uint128& operator<<=(
int);
78 uint128& operator>>=(
int);
83 uint128& operator--();
89 PROTOBUF_EXPORT
friend std::ostream&
operator<<(std::ostream&
o,
93 static void DivModImpl(uint128 dividend, uint128 divisor,
94 uint128* quotient_ret, uint128* remainder_ret);
121 PROTOBUF_EXPORT
extern const uint128_pod
kuint128max;
124 PROTOBUF_EXPORT
extern std::ostream&
operator<<(std::ostream& o,
138 inline bool operator==(
const uint128& lhs,
const uint128& rhs) {
142 inline bool operator!=(
const uint128& lhs,
const uint128& rhs) {
143 return !(lhs == rhs);
148 : lo_(bottom), hi_(
top) {}
150 : lo_(
v.lo), hi_(
v.hi) {}
152 : lo_(bottom), hi_(0) {}
155 : lo_(bottom), hi_(0) {}
157 : lo_(bottom), hi_(static_cast<
int64>((bottom < 0) ? -1 : 0)) {}
160 #undef UINT128_CONSTEXPR
170 inline bool operator op(const uint128& lhs, const uint128& rhs) { \
171 return (Uint128High64(lhs) == Uint128High64(rhs)) ? \
172 (Uint128Low64(lhs) op Uint128Low64(rhs)) : \
173 (Uint128High64(lhs) op Uint128High64(rhs)); \
185 inline uint128
operator-(
const uint128& val) {
188 const uint64 lo_add = lo_flip + 1;
189 if (lo_add < lo_flip) {
190 return uint128(hi_flip + 1, lo_add);
192 return uint128(hi_flip, lo_add);
195 inline bool operator!(
const uint128& val) {
201 inline uint128
operator~(
const uint128& val) {
205 #define LOGIC128(op) \
206 inline uint128 operator op(const uint128& lhs, const uint128& rhs) { \
207 return uint128(Uint128High64(lhs) op Uint128High64(rhs), \
208 Uint128Low64(lhs) op Uint128Low64(rhs)); \
217 #define LOGICASSIGN128(op) \
218 inline uint128& uint128::operator op(const uint128& other) { \
228 #undef LOGICASSIGN128
232 inline uint128
operator<<(
const uint128& val,
int amount) {
241 return uint128(new_hi, new_lo);
242 }
else if (amount < 128) {
245 return uint128(0, 0);
249 inline uint128
operator>>(
const uint128& val,
int amount) {
258 return uint128(new_hi, new_lo);
259 }
else if (amount < 128) {
262 return uint128(0, 0);
266 inline uint128& uint128::operator<<=(
int amount) {
270 hi_ = (hi_ << amount) | (lo_ >> (64 - amount));
273 }
else if (amount < 128) {
274 hi_ = lo_ << (amount - 64);
283 inline uint128& uint128::operator>>=(
int amount) {
287 lo_ = (lo_ >> amount) | (hi_ << (64 - amount));
290 }
else if (amount < 128) {
291 lo_ = hi_ >> (amount - 64);
300 inline uint128
operator+(
const uint128& lhs,
const uint128& rhs) {
301 return uint128(lhs) += rhs;
304 inline uint128
operator-(
const uint128& lhs,
const uint128& rhs) {
305 return uint128(lhs) -= rhs;
308 inline uint128
operator*(
const uint128& lhs,
const uint128& rhs) {
309 return uint128(lhs) *= rhs;
312 inline uint128
operator/(
const uint128& lhs,
const uint128& rhs) {
313 return uint128(lhs) /= rhs;
316 inline uint128
operator%(
const uint128& lhs,
const uint128& rhs) {
317 return uint128(lhs) %= rhs;
339 uint64 a64 = hi_ & 0xffffffff
u;
341 uint64 a00 = lo_ & 0xffffffff
u;
349 uint64 c96 = a96 * b00 + a64 * b32 + a32 * b64 + a00 * b96;
350 uint64 c64 = a64 * b00 + a32 * b32 + a00 * b64;
351 this->hi_ = (c96 << 32) + c64;
354 *
this += uint128(a32 * b00) << 32;
355 *
this += uint128(a00 * b32) << 32;
366 inline uint128 uint128::operator--(
int) {
377 inline uint128& uint128::operator--() {
385 #include <google/protobuf/port_undef.inc>
387 #endif // GOOGLE_PROTOBUF_STUBS_INT128_H_
constexpr uint128 operator~(uint128 val)
uint64 Uint128Low64(const uint128 &v)
StatusToStringMode & operator^=(StatusToStringMode &lhs, StatusToStringMode rhs)
Duration & operator%=(Duration &d1, const Duration &d2)
Duration operator+(Duration lhs, Duration rhs)
Duration & operator+=(Duration &d1, const Duration &d2)
OPENSSL_EXPORT pem_password_cb void * u
uint64 Uint128High64(const uint128 &v)
uint128 operator%(uint128 lhs, uint128 rhs)
Duration operator-(Duration lhs, Duration rhs)
constexpr uint64_t Uint128High64(uint128 v)
constexpr uint64_t Uint128Low64(uint128 v)
constexpr bool operator!(uint128 val)
UINT128_CONSTEXPR uint128()
void Initialize(int *argc, char **argv)
StatusToStringMode & operator&=(StatusToStringMode &lhs, StatusToStringMode rhs)
std::ostream & operator<<(std::ostream &o, const uint128 &b)
static void operator++(Engine &e, int unused)
#define UINT128_CONSTEXPR
Duration & operator/=(Duration &d, int64 r)
constexpr uint128 operator>>(uint128 lhs, int amount)
Duration operator*(Duration lhs, double rhs)
#define LOGICASSIGN128(op)
bool operator==(const uint128 &lhs, const uint128 &rhs)
bool operator!=(const uint128 &lhs, const uint128 &rhs)
Duration & operator*=(Duration &d, int64 r)
const uint128_pod kuint128max
std::ostream & operator<<(std::ostream &out, const string_ref &string)
StatusToStringMode & operator|=(StatusToStringMode &lhs, StatusToStringMode rhs)
static upb_pb_encoder_segment * top(upb_pb_encoder *e)
Duration & operator-=(Duration &d1, const Duration &d2)
Duration operator/(Duration lhs, int64_t rhs)
grpc
Author(s):
autogenerated on Fri May 16 2025 02:59:06