Sha256: 3d3e376a3c7e1d2943a006bc5c8c43a26b50c5aac93deda46182f04f389317e9

Contents?: true

Size: 1.59 KB

Versions: 8

Compression:

Stored size: 1.59 KB

Contents

// Protocol Buffers - Google's data interchange format
// Copyright 2023 Google LLC.  All rights reserved.
//
// 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_MINI_TABLE_INTERNAL_TAGGED_PTR_H_
#define UPB_MINI_TABLE_INTERNAL_TAGGED_PTR_H_

#include <stdint.h>

#include "upb/message/internal/message.h"

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

#ifdef __cplusplus
extern "C" {
#endif

// Internal-only because empty messages cannot be created by the user.
UPB_INLINE uintptr_t
UPB_PRIVATE(_upb_TaggedMessagePtr_Pack)(struct upb_Message* ptr, bool empty) {
  UPB_ASSERT(((uintptr_t)ptr & 1) == 0);
  return (uintptr_t)ptr | (empty ? 1 : 0);
}

UPB_INLINE bool UPB_PRIVATE(_upb_TaggedMessagePtr_IsEmpty)(uintptr_t ptr) {
  return ptr & 1;
}

UPB_INLINE struct upb_Message* UPB_PRIVATE(_upb_TaggedMessagePtr_GetMessage)(
    uintptr_t ptr) {
  return (struct upb_Message*)(ptr & ~(uintptr_t)1);
}

UPB_INLINE struct upb_Message* UPB_PRIVATE(
    _upb_TaggedMessagePtr_GetNonEmptyMessage)(uintptr_t ptr) {
  UPB_ASSERT(!UPB_PRIVATE(_upb_TaggedMessagePtr_IsEmpty)(ptr));
  return UPB_PRIVATE(_upb_TaggedMessagePtr_GetMessage)(ptr);
}

UPB_INLINE struct upb_Message* UPB_PRIVATE(
    _upb_TaggedMessagePtr_GetEmptyMessage)(uintptr_t ptr) {
  UPB_ASSERT(UPB_PRIVATE(_upb_TaggedMessagePtr_IsEmpty)(ptr));
  return UPB_PRIVATE(_upb_TaggedMessagePtr_GetMessage)(ptr);
}

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

#include "upb/port/undef.inc"

#endif /* UPB_MINI_TABLE_INTERNAL_TAGGED_PTR_H_ */

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
grpc-1.63.2 third_party/upb/upb/message/internal/tagged_ptr.h
grpc-1.64.3 third_party/upb/upb/message/internal/tagged_ptr.h
grpc-1.65.2 third_party/upb/upb/message/internal/tagged_ptr.h
grpc-1.65.1 third_party/upb/upb/message/internal/tagged_ptr.h
grpc-1.65.0 third_party/upb/upb/message/internal/tagged_ptr.h
grpc-1.65.0.pre2 third_party/upb/upb/message/internal/tagged_ptr.h
grpc-1.65.0.pre1 third_party/upb/upb/message/internal/tagged_ptr.h
grpc-1.63.0 third_party/upb/upb/message/internal/tagged_ptr.h