From ee65919c607b92da9f896a2dbd3626f3cc9b3360 Mon Sep 17 00:00:00 2001 From: Richard Fuchs Date: Mon, 20 Oct 2025 07:37:05 -0400 Subject: [PATCH] MT#55283 replace g_atomic with atomic_* Change-Id: Ib792e9fbc051ca808f82426d2cb1f0c3243b01b5 --- lib/obj.h | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/lib/obj.h b/lib/obj.h index 9c510d4e2..477fbb912 100644 --- a/lib/obj.h +++ b/lib/obj.h @@ -10,6 +10,7 @@ #include #include #include "compat.h" +#include "auxlib.h" @@ -38,7 +39,7 @@ struct obj { uint32_t magic; char *type; #endif - volatile gint ref; + unsigned int ref; void (*free_func)(void *); size_t size; }; @@ -188,7 +189,7 @@ INLINE struct obj *__obj_hold(struct obj *o #if OBJ_DEBUG assert(o->magic == OBJ_MAGIC); write_log(LOG_DEBUG, "obj_hold(%p, \"%s\"), refcnt inc %u -> %u [%s:%s:%u]", - o, o->type, g_atomic_int_get(&o->ref), g_atomic_int_get(&o->ref) + 1, file, func, line); + o, o->type, atomic_get_na(&o->ref), atomic_get_na(&o->ref) + 1, file, func, line); #if OBJ_BACKTRACE void *bt[4]; int addrs = backtrace(bt, 4); @@ -200,7 +201,7 @@ INLINE struct obj *__obj_hold(struct obj *o free(syms); #endif #endif - g_atomic_int_inc(&o->ref); + atomic_inc(&o->ref); return o; } @@ -224,7 +225,7 @@ INLINE void __obj_put(struct obj *o #if OBJ_DEBUG assert(o->magic == OBJ_MAGIC); write_log(LOG_DEBUG, "obj_put(%p, \"%s\"), refcnt dec %u -> %u [%s:%s:%u]", - o, o->type, g_atomic_int_get(&o->ref), g_atomic_int_get(&o->ref) - 1, file, func, line); + o, o->type, atomic_get_na(&o->ref), atomic_get_na(&o->ref) - 1, file, func, line); #if OBJ_BACKTRACE void *bt[4]; int addrs = backtrace(bt, 4); @@ -236,7 +237,7 @@ INLINE void __obj_put(struct obj *o free(syms); #endif #endif - if (!g_atomic_int_dec_and_test(&o->ref)) + if (atomic_dec(&o->ref) != 1) return; if (o->free_func) o->free_func(o);