Auto-generate files after cl/606262924
diff --git a/php/ext/google/protobuf/php-upb.c b/php/ext/google/protobuf/php-upb.c
index 1aefcee..f1b1ce8 100644
--- a/php/ext/google/protobuf/php-upb.c
+++ b/php/ext/google/protobuf/php-upb.c
@@ -4588,6 +4588,21 @@
return memsize;
}
+bool UPB_PRIVATE(_upb_Arena_Contains)(const upb_Arena* a, void* ptr) {
+ upb_ArenaInternal* ai = upb_Arena_Internal(a);
+ UPB_ASSERT(ai);
+
+ upb_MemBlock* block = upb_Atomic_Load(&ai->blocks, memory_order_relaxed);
+ while (block) {
+ uintptr_t beg = (uintptr_t)block;
+ uintptr_t end = beg + block->size;
+ if ((uintptr_t)ptr >= beg && (uintptr_t)ptr < end) return true;
+ block = upb_Atomic_Load(&block->next, memory_order_relaxed);
+ }
+
+ return false;
+}
+
uint32_t upb_Arena_DebugRefCount(upb_Arena* a) {
upb_ArenaInternal* ai = upb_Arena_Internal(a);
// These loads could probably be relaxed, but given that this is debug-only,
diff --git a/php/ext/google/protobuf/php-upb.h b/php/ext/google/protobuf/php-upb.h
index 9ae89a5..7fdba63 100644
--- a/php/ext/google/protobuf/php-upb.h
+++ b/php/ext/google/protobuf/php-upb.h
@@ -689,6 +689,11 @@
void UPB_PRIVATE(_upb_Arena_SwapOut)(struct upb_Arena* des,
const struct upb_Arena* src);
+// Returns whether |ptr| was allocated directly by |a| (so care must be used
+// with fused arenas).
+UPB_API bool UPB_ONLYBITS(_upb_Arena_Contains)(const struct upb_Arena* a,
+ void* ptr);
+
UPB_INLINE size_t UPB_PRIVATE(_upb_ArenaHas)(const struct upb_Arena* a) {
return (size_t)(a->UPB_ONLYBITS(end) - a->UPB_ONLYBITS(ptr));
}
diff --git a/ruby/ext/google/protobuf_c/ruby-upb.c b/ruby/ext/google/protobuf_c/ruby-upb.c
index 8390da6..e4c7722 100644
--- a/ruby/ext/google/protobuf_c/ruby-upb.c
+++ b/ruby/ext/google/protobuf_c/ruby-upb.c
@@ -4102,6 +4102,21 @@
return memsize;
}
+bool UPB_PRIVATE(_upb_Arena_Contains)(const upb_Arena* a, void* ptr) {
+ upb_ArenaInternal* ai = upb_Arena_Internal(a);
+ UPB_ASSERT(ai);
+
+ upb_MemBlock* block = upb_Atomic_Load(&ai->blocks, memory_order_relaxed);
+ while (block) {
+ uintptr_t beg = (uintptr_t)block;
+ uintptr_t end = beg + block->size;
+ if ((uintptr_t)ptr >= beg && (uintptr_t)ptr < end) return true;
+ block = upb_Atomic_Load(&block->next, memory_order_relaxed);
+ }
+
+ return false;
+}
+
uint32_t upb_Arena_DebugRefCount(upb_Arena* a) {
upb_ArenaInternal* ai = upb_Arena_Internal(a);
// These loads could probably be relaxed, but given that this is debug-only,
diff --git a/ruby/ext/google/protobuf_c/ruby-upb.h b/ruby/ext/google/protobuf_c/ruby-upb.h
index 10f4b2d..1d2ef0a 100755
--- a/ruby/ext/google/protobuf_c/ruby-upb.h
+++ b/ruby/ext/google/protobuf_c/ruby-upb.h
@@ -691,6 +691,11 @@
void UPB_PRIVATE(_upb_Arena_SwapOut)(struct upb_Arena* des,
const struct upb_Arena* src);
+// Returns whether |ptr| was allocated directly by |a| (so care must be used
+// with fused arenas).
+UPB_API bool UPB_ONLYBITS(_upb_Arena_Contains)(const struct upb_Arena* a,
+ void* ptr);
+
UPB_INLINE size_t UPB_PRIVATE(_upb_ArenaHas)(const struct upb_Arena* a) {
return (size_t)(a->UPB_ONLYBITS(end) - a->UPB_ONLYBITS(ptr));
}