Use OSAtomic

This commit is contained in:
Sergey Bugaev 2017-02-15 15:15:02 +03:00
parent 711cfaa385
commit 48eef895be
2 changed files with 5 additions and 5 deletions

View File

@ -27,11 +27,11 @@
#include <errno.h>
#include <xpc/xpc.h>
#include <machine/atomic.h>
#include <libkern/OSAtomic.h>
#include <Block.h>
#include "xpc_internal.h"
#define XPC_CONNECTION_NEXT_ID(conn) (atomic_fetchadd_long(&conn->xc_last_id, 1))
#define XPC_CONNECTION_NEXT_ID(conn) OSAtomicIncrement64(&conn->xc_last_id)
static void xpc_send(xpc_connection_t xconn, xpc_object_t message, uint64_t id);

View File

@ -28,7 +28,7 @@
#include <sys/types.h>
#include <sys/errno.h>
#include <sys/sbuf.h>
#include <machine/atomic.h>
#include <libkern/OSAtomic.h>
#include <assert.h>
#include <syslog.h>
#include <pthread.h>
@ -160,7 +160,7 @@ xpc_retain(xpc_object_t obj)
struct xpc_object *xo;
xo = obj;
atomic_add_int(&xo->xo_refcnt, 1);
OSAtomicIncrement32(&xo->xo_refcnt);
return (obj);
}
@ -170,7 +170,7 @@ xpc_release(xpc_object_t obj)
struct xpc_object *xo;
xo = obj;
if (atomic_fetchadd_int(&xo->xo_refcnt, -1) > 1)
if (OSAtomicDecrement32(&xo->xo_refcnt) > 1)
return;
xpc_object_destroy(xo);