aboutsummaryrefslogtreecommitdiffstats
path: root/include/sound/util_mem.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/sound/util_mem.h')
-rw-r--r--include/sound/util_mem.h64
1 files changed, 64 insertions, 0 deletions
diff --git a/include/sound/util_mem.h b/include/sound/util_mem.h
new file mode 100644
index 000000000000..9d2cdfa0c42a
--- /dev/null
+++ b/include/sound/util_mem.h
@@ -0,0 +1,64 @@
1#ifndef __SOUND_UTIL_MEM_H
2#define __SOUND_UTIL_MEM_H
3/*
4 * Copyright (C) 2000 Takashi Iwai <tiwai@suse.de>
5 *
6 * Generic memory management routines for soundcard memory allocation
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 */
22
23typedef struct snd_util_memblk snd_util_memblk_t;
24typedef struct snd_util_memhdr snd_util_memhdr_t;
25typedef unsigned int snd_util_unit_t;
26
27/*
28 * memory block
29 */
30struct snd_util_memblk {
31 snd_util_unit_t size; /* size of this block */
32 snd_util_unit_t offset; /* zero-offset of this block */
33 struct list_head list; /* link */
34};
35
36#define snd_util_memblk_argptr(blk) (void*)((char*)(blk) + sizeof(snd_util_memblk_t))
37
38/*
39 * memory management information
40 */
41struct snd_util_memhdr {
42 snd_util_unit_t size; /* size of whole data */
43 struct list_head block; /* block linked-list header */
44 int nblocks; /* # of allocated blocks */
45 snd_util_unit_t used; /* used memory size */
46 int block_extra_size; /* extra data size of chunk */
47 struct semaphore block_mutex; /* lock */
48};
49
50/*
51 * prototypes
52 */
53snd_util_memhdr_t *snd_util_memhdr_new(int memsize);
54void snd_util_memhdr_free(snd_util_memhdr_t *hdr);
55snd_util_memblk_t *snd_util_mem_alloc(snd_util_memhdr_t *hdr, int size);
56int snd_util_mem_free(snd_util_memhdr_t *hdr, snd_util_memblk_t *blk);
57int snd_util_mem_avail(snd_util_memhdr_t *hdr);
58
59/* functions without mutex */
60snd_util_memblk_t *__snd_util_mem_alloc(snd_util_memhdr_t *hdr, int size);
61void __snd_util_mem_free(snd_util_memhdr_t *hdr, snd_util_memblk_t *blk);
62snd_util_memblk_t *__snd_util_memblk_new(snd_util_memhdr_t *hdr, snd_util_unit_t units, struct list_head *prev);
63
64#endif /* __SOUND_UTIL_MEM_H */