Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:13:17

0001 // Protocol Buffers - Google's data interchange format
0002 // Copyright 2023 Google LLC.  All rights reserved.
0003 //
0004 // Use of this source code is governed by a BSD-style
0005 // license that can be found in the LICENSE file or at
0006 // https://developers.google.com/open-source/licenses/bsd
0007 
0008 #ifndef UPB_MINI_TABLE_INTERNAL_TAGGED_PTR_H_
0009 #define UPB_MINI_TABLE_INTERNAL_TAGGED_PTR_H_
0010 
0011 #include <stdint.h>
0012 
0013 #include "upb/message/internal/message.h"
0014 
0015 // Must be last.
0016 #include "upb/port/def.inc"
0017 
0018 #ifdef __cplusplus
0019 extern "C" {
0020 #endif
0021 
0022 // Internal-only because empty messages cannot be created by the user.
0023 UPB_INLINE uintptr_t
0024 UPB_PRIVATE(_upb_TaggedMessagePtr_Pack)(struct upb_Message* ptr, bool empty) {
0025   UPB_ASSERT(((uintptr_t)ptr & 1) == 0);
0026   return (uintptr_t)ptr | (empty ? 1 : 0);
0027 }
0028 
0029 UPB_API_INLINE bool upb_TaggedMessagePtr_IsEmpty(uintptr_t ptr) {
0030   return ptr & 1;
0031 }
0032 
0033 UPB_INLINE struct upb_Message* UPB_PRIVATE(_upb_TaggedMessagePtr_GetMessage)(
0034     uintptr_t ptr) {
0035   return (struct upb_Message*)(ptr & ~(uintptr_t)1);
0036 }
0037 
0038 UPB_API_INLINE struct upb_Message* upb_TaggedMessagePtr_GetNonEmptyMessage(
0039     uintptr_t ptr) {
0040   UPB_ASSERT(!upb_TaggedMessagePtr_IsEmpty(ptr));
0041   return UPB_PRIVATE(_upb_TaggedMessagePtr_GetMessage)(ptr);
0042 }
0043 
0044 UPB_INLINE struct upb_Message* UPB_PRIVATE(
0045     _upb_TaggedMessagePtr_GetEmptyMessage)(uintptr_t ptr) {
0046   UPB_ASSERT(upb_TaggedMessagePtr_IsEmpty(ptr));
0047   return UPB_PRIVATE(_upb_TaggedMessagePtr_GetMessage)(ptr);
0048 }
0049 
0050 #ifdef __cplusplus
0051 } /* extern "C" */
0052 #endif
0053 
0054 #include "upb/port/undef.inc"
0055 
0056 #endif /* UPB_MINI_TABLE_INTERNAL_TAGGED_PTR_H_ */