]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/blob - include/kmem.h
xfs: use per-AG reservations for the finobt
[thirdparty/xfsprogs-dev.git] / include / kmem.h
1 /*
2 * Copyright (c) 2008 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 __KMEM_H__
19 #define __KMEM_H__
20
21 #define KM_SLEEP 0x0001u
22 #define KM_NOSLEEP 0x0002u
23 #define KM_NOFS 0x0004u
24 #define KM_MAYFAIL 0x0008u
25 #define KM_LARGE 0x0010u
26
27 typedef struct kmem_zone {
28 int zone_unitsize; /* Size in bytes of zone unit */
29 char *zone_name; /* tag name */
30 int allocated; /* debug: How many currently allocated */
31 } kmem_zone_t;
32
33 extern kmem_zone_t *kmem_zone_init(int, char *);
34 extern void *kmem_zone_alloc(kmem_zone_t *, int);
35 extern void *kmem_zone_zalloc(kmem_zone_t *, int);
36
37 static inline void
38 kmem_zone_free(kmem_zone_t *zone, void *ptr)
39 {
40 zone->allocated--;
41 free(ptr);
42 }
43
44 extern void *kmem_alloc(size_t, int);
45 extern void *kmem_zalloc(size_t, int);
46
47 static inline void
48 kmem_free(void *ptr) {
49 free(ptr);
50 }
51
52 extern void *kmem_realloc(void *, size_t, int);
53
54 #endif