From 777d6a9d4f38aca932efc91643c90bbd86b86c29 Mon Sep 17 00:00:00 2001 From: Protobuf Team Bot Date: Fri, 6 Oct 2023 23:52:49 +0000 Subject: [PATCH] Auto-generate files after cl/571462941 --- php/ext/google/protobuf/php-upb.c | 20 ++++++++++++++++++++ php/ext/google/protobuf/php-upb.h | 3 +++ ruby/ext/google/protobuf_c/ruby-upb.c | 20 ++++++++++++++++++++ ruby/ext/google/protobuf_c/ruby-upb.h | 3 +++ 4 files changed, 46 insertions(+) diff --git a/php/ext/google/protobuf/php-upb.c b/php/ext/google/protobuf/php-upb.c index 7237ddaff1..30f4fae6ce 100644 --- a/php/ext/google/protobuf/php-upb.c +++ b/php/ext/google/protobuf/php-upb.c @@ -5804,6 +5804,26 @@ bool upb_Arena_Fuse(upb_Arena* a1, upb_Arena* a2) { } } +void upb_Arena_IncRefFor(upb_Arena* arena, const void* owner) { + _upb_ArenaRoot r; +retry: + r = _upb_Arena_FindRoot(arena); + if (upb_Atomic_CompareExchangeWeak( + &r.root->parent_or_count, &r.tagged_count, + _upb_Arena_TaggedFromRefcount( + _upb_Arena_RefCountFromTagged(r.tagged_count) + 1), + memory_order_release, memory_order_acquire)) { + // We incremented it successfully, so we are done. + return; + } + // We failed update due to parent switching on the arena. + goto retry; +} + +void upb_Arena_DecRefFor(upb_Arena* arena, const void* owner) { + upb_Arena_Free(arena); +} + // Must be last. diff --git a/php/ext/google/protobuf/php-upb.h b/php/ext/google/protobuf/php-upb.h index 601e75fd34..d5e8c4c07a 100644 --- a/php/ext/google/protobuf/php-upb.h +++ b/php/ext/google/protobuf/php-upb.h @@ -561,6 +561,9 @@ UPB_API upb_Arena* upb_Arena_Init(void* mem, size_t n, upb_alloc* alloc); UPB_API void upb_Arena_Free(upb_Arena* a); UPB_API bool upb_Arena_Fuse(upb_Arena* a, upb_Arena* b); +void upb_Arena_IncRefFor(upb_Arena* arena, const void* owner); +void upb_Arena_DecRefFor(upb_Arena* arena, const void* owner); + void* _upb_Arena_SlowMalloc(upb_Arena* a, size_t size); size_t upb_Arena_SpaceAllocated(upb_Arena* arena); uint32_t upb_Arena_DebugRefCount(upb_Arena* arena); diff --git a/ruby/ext/google/protobuf_c/ruby-upb.c b/ruby/ext/google/protobuf_c/ruby-upb.c index fe878c14ac..730e58de54 100644 --- a/ruby/ext/google/protobuf_c/ruby-upb.c +++ b/ruby/ext/google/protobuf_c/ruby-upb.c @@ -5318,6 +5318,26 @@ bool upb_Arena_Fuse(upb_Arena* a1, upb_Arena* a2) { } } +void upb_Arena_IncRefFor(upb_Arena* arena, const void* owner) { + _upb_ArenaRoot r; +retry: + r = _upb_Arena_FindRoot(arena); + if (upb_Atomic_CompareExchangeWeak( + &r.root->parent_or_count, &r.tagged_count, + _upb_Arena_TaggedFromRefcount( + _upb_Arena_RefCountFromTagged(r.tagged_count) + 1), + memory_order_release, memory_order_acquire)) { + // We incremented it successfully, so we are done. + return; + } + // We failed update due to parent switching on the arena. + goto retry; +} + +void upb_Arena_DecRefFor(upb_Arena* arena, const void* owner) { + upb_Arena_Free(arena); +} + // Must be last. diff --git a/ruby/ext/google/protobuf_c/ruby-upb.h b/ruby/ext/google/protobuf_c/ruby-upb.h index 2e5dcec896..c2b5f65e5c 100755 --- a/ruby/ext/google/protobuf_c/ruby-upb.h +++ b/ruby/ext/google/protobuf_c/ruby-upb.h @@ -563,6 +563,9 @@ UPB_API upb_Arena* upb_Arena_Init(void* mem, size_t n, upb_alloc* alloc); UPB_API void upb_Arena_Free(upb_Arena* a); UPB_API bool upb_Arena_Fuse(upb_Arena* a, upb_Arena* b); +void upb_Arena_IncRefFor(upb_Arena* arena, const void* owner); +void upb_Arena_DecRefFor(upb_Arena* arena, const void* owner); + void* _upb_Arena_SlowMalloc(upb_Arena* a, size_t size); size_t upb_Arena_SpaceAllocated(upb_Arena* arena); uint32_t upb_Arena_DebugRefCount(upb_Arena* arena);