f2de26a7b0f1b81fbcce6ad6165c1fbe3f8f34aa
5 * Userspace RCU - Reference counting
7 * Copyright (C) 2009 Novell Inc.
8 * Copyright (C) 2010 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
10 * Author: Jan Blunck <jblunck@suse.de>
12 * This program is free software; you can redistribute it and/or modify it
13 * under the terms of the GNU Lesser General Public License version 2.1 as
14 * published by the Free Software Foundation.
20 #include <urcu/uatomic.h>
23 long refcount
; /* ATOMIC */
26 static inline void urcu_ref_set(struct urcu_ref
*ref
, long val
)
28 uatomic_set(&ref
->refcount
, val
);
31 static inline void urcu_ref_init(struct urcu_ref
*ref
)
36 static inline void urcu_ref_get(struct urcu_ref
*ref
)
40 old
= uatomic_read(&ref
->refcount
);
42 if (old
== LONG_MAX
) {
46 res
= uatomic_cmpxchg(&ref
->refcount
, old
, _new
);
54 static inline void urcu_ref_put(struct urcu_ref
*ref
,
55 void (*release
)(struct urcu_ref
*))
57 long res
= uatomic_sub_return(&ref
->refcount
, 1);
63 #endif /* _URCU_REF_H */
This page took 0.0317 seconds and 3 git commands to generate.