bo->size = size;
bo->handle = handle;
bo->flags = flags;
- atomic_set(&bo->refcnt, 1);
+ p_atomic_set(&bo->refcnt, 1);
list_inithead(&bo->list);
/* add ourselves to the handle table: */
drmHashInsert(dev->handle_table, handle, bo);
struct etna_bo *etna_bo_ref(struct etna_bo *bo)
{
- atomic_inc(&bo->refcnt);
+ p_atomic_inc(&bo->refcnt);
return bo;
}
if (!bo)
return;
- if (!atomic_dec_and_test(&bo->refcnt))
+ if (!p_atomic_dec_zero(&bo->refcnt))
return;
pthread_mutex_lock(&table_lock);
*size = bucket->size;
bo = find_in_bucket(bucket, flags);
if (bo) {
- atomic_set(&bo->refcnt, 1);
+ p_atomic_set(&bo->refcnt, 1);
etna_device_ref(bo->dev);
return bo;
}
#include <pthread.h>
#include <xf86drm.h>
-#include <xf86atomic.h>
#include "etnaviv_priv.h"
#include "etnaviv_drmif.h"
if (!dev)
return NULL;
- atomic_set(&dev->refcnt, 1);
+ p_atomic_set(&dev->refcnt, 1);
dev->fd = fd;
dev->handle_table = drmHashCreate();
dev->name_table = drmHashCreate();
struct etna_device *etna_device_ref(struct etna_device *dev)
{
- atomic_inc(&dev->refcnt);
+ p_atomic_inc(&dev->refcnt);
return dev;
}
void etna_device_del_locked(struct etna_device *dev)
{
- if (!atomic_dec_and_test(&dev->refcnt))
+ if (!p_atomic_dec_zero(&dev->refcnt))
return;
etna_device_del_impl(dev);
void etna_device_del(struct etna_device *dev)
{
- if (!atomic_dec_and_test(&dev->refcnt))
+ if (!p_atomic_dec_zero(&dev->refcnt))
return;
pthread_mutex_lock(&table_lock);
#include <xf86drm.h>
+#include "util/list.h"
+#include "util/u_atomic.h"
+
#include "etnaviv_drmif.h"
#include "etnaviv_drm.h"
struct etna_device {
int fd;
- atomic_t refcnt;
+ int refcnt;
/* tables to keep track of bo's, to avoid "evil-twin" etna_bo objects:
*
uint32_t flags;
uint32_t name; /* flink global handle (DRI2 name) */
uint64_t offset; /* offset to mmap() */
- atomic_t refcnt;
+ int refcnt;
/* in the common case, a bo won't be referenced by more than a single
* command stream. So to avoid looping over all the bo's in the