File indexing completed on 2025-01-18 10:13:17
0001
0002
0003
0004
0005
0006
0007
0008 #ifndef UPB_MESSAGE_INTERNAL_TYPES_H_
0009 #define UPB_MESSAGE_INTERNAL_TYPES_H_
0010
0011 #include <stdint.h>
0012
0013
0014 #include "upb/port/def.inc"
0015
0016 #define UPB_OPAQUE(x) x##_opaque
0017
0018 struct upb_Message {
0019 union {
0020 uintptr_t UPB_OPAQUE(internal);
0021 double d;
0022 };
0023 };
0024
0025 #ifdef __cplusplus
0026 extern "C" {
0027 #endif
0028
0029 UPB_INLINE void UPB_PRIVATE(_upb_Message_ShallowFreeze)(
0030 struct upb_Message* msg) {
0031 msg->UPB_OPAQUE(internal) |= 1ULL;
0032 }
0033
0034 UPB_API_INLINE bool upb_Message_IsFrozen(const struct upb_Message* msg) {
0035 return (msg->UPB_OPAQUE(internal) & 1ULL) != 0;
0036 }
0037
0038 UPB_INLINE struct upb_Message_Internal* UPB_PRIVATE(_upb_Message_GetInternal)(
0039 const struct upb_Message* msg) {
0040 const uintptr_t tmp = msg->UPB_OPAQUE(internal) & ~1ULL;
0041 return (struct upb_Message_Internal*)tmp;
0042 }
0043
0044 UPB_INLINE void UPB_PRIVATE(_upb_Message_SetInternal)(
0045 struct upb_Message* msg, struct upb_Message_Internal* internal) {
0046 UPB_ASSERT(!upb_Message_IsFrozen(msg));
0047 msg->UPB_OPAQUE(internal) = (uintptr_t)internal;
0048 }
0049
0050 #ifdef __cplusplus
0051 }
0052 #endif
0053
0054 #undef UPB_OPAQUE
0055
0056 #include "upb/port/undef.inc"
0057
0058 #endif