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_MESSAGE_INTERNAL_TYPES_H_
0009 #define UPB_MESSAGE_INTERNAL_TYPES_H_
0010 
0011 #include <stdint.h>
0012 
0013 // Must be last.
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);  // tagged pointer, low bit == frozen
0021     double d;  // Forces same size for 32-bit/64-bit builds
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 } /* extern "C" */
0052 #endif
0053 
0054 #undef UPB_OPAQUE
0055 
0056 #include "upb/port/undef.inc"
0057 
0058 #endif /* UPB_MESSAGE_INTERNAL_TYPES_H_ */