From 5540e6a9220c58fffce940b5bc4ae624b9829f61 Mon Sep 17 00:00:00 2001 From: William Kent Date: Sat, 11 Jul 2020 14:02:29 -0400 Subject: [PATCH] Use in vproc.c --- src/libxpc/libvproc.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/libxpc/libvproc.c b/src/libxpc/libvproc.c index cf0ace6..02f64e0 100644 --- a/src/libxpc/libvproc.c +++ b/src/libxpc/libvproc.c @@ -46,6 +46,7 @@ #include #include +#include #include @@ -76,7 +77,7 @@ void _vproc_transaction_end_internal(void *arg __unused); #pragma mark vproc Object struct vproc_s { - int32_t refcount; + atomic_int_fast32_t refcount; mach_port_t j_port; }; @@ -103,7 +104,7 @@ vprocmgr_lookup_vproc(const char *label) vproc_t vproc_retain(vproc_t vp) { - int32_t orig = OSAtomicAdd32(1, &vp->refcount) - 1; + int32_t orig = atomic_fetch_add(&vp->refcount, 1) - 1; if (orig <= 0) { _vproc_set_crash_log_message("Under-retain / over-release of vproc_t."); __builtin_trap(); @@ -115,7 +116,7 @@ vproc_retain(vproc_t vp) void vproc_release(vproc_t vp) { - int32_t newval = OSAtomicAdd32(-1, &vp->refcount); + int32_t newval = atomic_fetch_sub(&vp->refcount, 1) - 1; if (newval < 0) { _vproc_set_crash_log_message("Over-release of vproc_t."); __builtin_trap();