/usr/include/urcu/ref.h is in liburcu-dev 0.7.12-0ubuntu2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 | #ifndef _URCU_REF_H
#define _URCU_REF_H
/*
* Userspace RCU - Reference counting
*
* Copyright (C) 2009 Novell Inc.
* Copyright (C) 2010 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
*
* Author: Jan Blunck <jblunck@suse.de>
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License version 2.1 as
* published by the Free Software Foundation.
*/
#include <assert.h>
#include <urcu/uatomic.h>
struct urcu_ref {
long refcount; /* ATOMIC */
};
static inline void urcu_ref_set(struct urcu_ref *ref, long val)
{
uatomic_set(&ref->refcount, val);
}
static inline void urcu_ref_init(struct urcu_ref *ref)
{
urcu_ref_set(ref, 1);
}
static inline void urcu_ref_get(struct urcu_ref *ref)
{
uatomic_add(&ref->refcount, 1);
}
static inline void urcu_ref_put(struct urcu_ref *ref,
void (*release)(struct urcu_ref *))
{
long res = uatomic_sub_return(&ref->refcount, 1);
assert (res >= 0);
if (res == 0)
release(ref);
}
#endif /* _URCU_REF_H */
|