Linux Audio

Check our new training course

Loading...
v3.15
 
 1/*
 2 * Copyright (c) 2006-2007 Silicon Graphics, Inc.
 3 * All Rights Reserved.
 4 *
 5 * This program is free software; you can redistribute it and/or
 6 * modify it under the terms of the GNU General Public License as
 7 * published by the Free Software Foundation.
 8 *
 9 * This program is distributed in the hope that it would be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write the Free Software Foundation,
16 * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
17 */
18#ifndef __XFS_MRU_CACHE_H__
19#define __XFS_MRU_CACHE_H__
20
 
21
22/* Function pointer type for callback to free a client's data pointer. */
23typedef void (*xfs_mru_cache_free_func_t)(unsigned long, void*);
 
 
24
25typedef struct xfs_mru_cache
26{
27	struct radix_tree_root	store;     /* Core storage data structure.  */
28	struct list_head	*lists;    /* Array of lists, one per grp.  */
29	struct list_head	reap_list; /* Elements overdue for reaping. */
30	spinlock_t		lock;      /* Lock to protect this struct.  */
31	unsigned int		grp_count; /* Number of discrete groups.    */
32	unsigned int		grp_time;  /* Time period spanned by grps.  */
33	unsigned int		lru_grp;   /* Group containing time zero.   */
34	unsigned long		time_zero; /* Time first element was added. */
35	xfs_mru_cache_free_func_t free_func; /* Function pointer for freeing. */
36	struct delayed_work	work;      /* Workqueue data for reaping.   */
37	unsigned int		queued;	   /* work has been queued */
38} xfs_mru_cache_t;
39
40int xfs_mru_cache_init(void);
41void xfs_mru_cache_uninit(void);
42int xfs_mru_cache_create(struct xfs_mru_cache **mrup, unsigned int lifetime_ms,
43			     unsigned int grp_count,
44			     xfs_mru_cache_free_func_t free_func);
45void xfs_mru_cache_destroy(struct xfs_mru_cache *mru);
46int xfs_mru_cache_insert(struct xfs_mru_cache *mru, unsigned long key,
47				void *value);
48void * xfs_mru_cache_remove(struct xfs_mru_cache *mru, unsigned long key);
 
49void xfs_mru_cache_delete(struct xfs_mru_cache *mru, unsigned long key);
50void *xfs_mru_cache_lookup(struct xfs_mru_cache *mru, unsigned long key);
 
51void xfs_mru_cache_done(struct xfs_mru_cache *mru);
52
53#endif /* __XFS_MRU_CACHE_H__ */
v6.13.7
 1// SPDX-License-Identifier: GPL-2.0
 2/*
 3 * Copyright (c) 2006-2007 Silicon Graphics, Inc.
 4 * All Rights Reserved.
 
 
 
 
 
 
 
 
 
 
 
 
 
 5 */
 6#ifndef __XFS_MRU_CACHE_H__
 7#define __XFS_MRU_CACHE_H__
 8
 9struct xfs_mru_cache;
10
11struct xfs_mru_cache_elem {
12	struct list_head list_node;
13	unsigned long	key;
14};
15
16/* Function pointer type for callback to free a client's data pointer. */
17typedef void (*xfs_mru_cache_free_func_t)(void *, struct xfs_mru_cache_elem *);
 
 
 
 
 
 
 
 
 
 
 
 
18
19int xfs_mru_cache_init(void);
20void xfs_mru_cache_uninit(void);
21int xfs_mru_cache_create(struct xfs_mru_cache **mrup, void *data,
22		unsigned int lifetime_ms, unsigned int grp_count,
23		xfs_mru_cache_free_func_t free_func);
24void xfs_mru_cache_destroy(struct xfs_mru_cache *mru);
25int xfs_mru_cache_insert(struct xfs_mru_cache *mru, unsigned long key,
26		struct xfs_mru_cache_elem *elem);
27struct xfs_mru_cache_elem *
28xfs_mru_cache_remove(struct xfs_mru_cache *mru, unsigned long key);
29void xfs_mru_cache_delete(struct xfs_mru_cache *mru, unsigned long key);
30struct xfs_mru_cache_elem *
31xfs_mru_cache_lookup(struct xfs_mru_cache *mru, unsigned long key);
32void xfs_mru_cache_done(struct xfs_mru_cache *mru);
33
34#endif /* __XFS_MRU_CACHE_H__ */