00001 /* 00002 * Operating system kernel abstraction -- reference counting. 00003 * 00004 * Copyright (C) 2010 Cambridge Silicon Radio Ltd. 00005 * 00006 * Refer to LICENSE.txt included with this source code for details on 00007 * the license terms. 00008 */ 00009 #ifndef __OSKA_REFCOUNT_H 00010 #define __OSKA_REFCOUNT_H 00011 00012 #include <oska/spinlock.h> 00013 00025 typedef void (*os_refcount_callback_f)(void *arg); 00026 00027 struct __os_refcount_impl { 00028 unsigned count; 00029 os_spinlock_t lock; 00030 os_refcount_callback_f func; 00031 void *arg; 00032 }; 00033 00039 typedef struct __os_refcount_impl os_refcount_t; 00040 00054 void os_refcount_init(os_refcount_t *refcount, os_refcount_callback_f func, void *arg); 00055 00063 void os_refcount_destroy(os_refcount_t *refcount); 00064 00072 void os_refcount_get(os_refcount_t *refcount); 00073 00084 void os_refcount_put(os_refcount_t *refcount); 00085 00086 #endif /* #ifndef __OSKA_REFCOUNT_H */