Sha256: e6b3d639b42a80b444ed5207b5d1ac5a5b4836925d8bb660f1b4713a833200f8

Contents?: true

Size: 873 Bytes

Versions: 26

Compression:

Stored size: 873 Bytes

Contents

// Protocol Buffers - Google's data interchange format
// Copyright 2023 Google LLC.  All rights reserved.
// https://developers.google.com/protocol-buffers/
///
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file or at
// https://developers.google.com/open-source/licenses/bsd

#ifndef UPB_BASE_INTERNAL_LOG2_H_
#define UPB_BASE_INTERNAL_LOG2_H_

// Must be last.
#include "upb/port/def.inc"

#ifdef __cplusplus
extern "C" {
#endif

UPB_INLINE int upb_Log2Ceiling(int x) {
  if (x <= 1) return 0;
#ifdef __GNUC__
  return 32 - __builtin_clz(x - 1);
#else
  int lg2 = 0;
  while ((1 << lg2) < x) lg2++;
  return lg2;
#endif
}

UPB_INLINE int upb_Log2CeilingSize(int x) { return 1 << upb_Log2Ceiling(x); }

#ifdef __cplusplus
} /* extern "C" */
#endif

#include "upb/port/undef.inc"

#endif /* UPB_BASE_INTERNAL_LOG2_H_ */

Version data entries

26 entries across 26 versions & 1 rubygems

Version Path
grpc-1.70.1 third_party/upb/upb/base/internal/log2.h
grpc-1.69.0 third_party/upb/upb/base/internal/log2.h
grpc-1.69.0.pre1 third_party/upb/upb/base/internal/log2.h
grpc-1.68.1 third_party/upb/upb/base/internal/log2.h
grpc-1.67.0 third_party/upb/upb/base/internal/log2.h
grpc-1.67.0.pre1 third_party/upb/upb/base/internal/log2.h
grpc-1.66.0 third_party/upb/upb/base/internal/log2.h
grpc-1.66.0.pre5 third_party/upb/upb/base/internal/log2.h
grpc-1.66.0.pre3 third_party/upb/upb/base/internal/log2.h
grpc-1.60.2 third_party/upb/upb/base/internal/log2.h
grpc-1.61.3 third_party/upb/upb/base/internal/log2.h
grpc-1.62.3 third_party/upb/upb/base/internal/log2.h
grpc-1.63.2 third_party/upb/upb/base/internal/log2.h
grpc-1.64.3 third_party/upb/upb/base/internal/log2.h
grpc-1.65.2 third_party/upb/upb/base/internal/log2.h
grpc-1.65.1 third_party/upb/upb/base/internal/log2.h
grpc-1.65.0 third_party/upb/upb/base/internal/log2.h
grpc-1.65.0.pre2 third_party/upb/upb/base/internal/log2.h
grpc-1.65.0.pre1 third_party/upb/upb/base/internal/log2.h
grpc-1.63.0 third_party/upb/upb/base/internal/log2.h