File indexing completed on 2025-01-18 10:13:17
0001
0002
0003
0004
0005
0006
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
0016 #include "upb/port/def.inc"
0017
0018 #ifdef __cplusplus
0019 extern "C" {
0020 #endif
0021
0022
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 }
0052 #endif
0053
0054 #include "upb/port/undef.inc"
0055
0056 #endif