3 * Copyright (C) James R. Leu 2002
6 * This software is covered under the LGPL, for more
7 * info check out http://www.gnu.org/copyleft/lgpl.html
10 #ifndef _MPLS_REFCNT_H_
11 #define _MPLS_REFCNT_H_
13 #include "mpls_assert.h"
15 #define MPLS_REFCNT_FIELD uint32_t _refcnt
17 #define MPLS_REFCNT_VALUE(obj) (obj)?((obj)->_refcnt):(-1)
19 #define MPLS_REFCNT_INIT(obj,count) { \
20 (obj)->_refcnt = count; \
23 #define MPLS_REFCNT_HOLD(obj) { \
29 #define MPLS_REFCNT_RELEASE(obj,dstry) { \
32 if((obj)->_refcnt <= 0) { \
39 #define MPLS_REFCNT_ASSERT(obj,count) { \
41 MPLS_ASSERT((obj)->_refcnt == count); \
45 #define MPLS_REFCNT_PTR_TYPE uint32_t*
46 #define MPLS_REFCNT_PTR(obj) (((obj) != NULL)?(&((obj)->_refcnt)):(NULL))
48 #define MPLS_REFCNT_PTR_HOLD(ptr) { \
53 #define MPLS_REFCNT_PTR_RELEASE(ptr) { \