]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/blame - include/kmem.h
libxfs: Catch non-empty zones on destroy
[thirdparty/xfsprogs-dev.git] / include / kmem.h
CommitLineData
5e656dbb
BN
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
27typedef 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
33extern kmem_zone_t *kmem_zone_init(int, char *);
34extern void *kmem_zone_alloc(kmem_zone_t *, int);
35extern void *kmem_zone_zalloc(kmem_zone_t *, int);
44488491 36extern int kmem_zone_destroy(kmem_zone_t *);
5e656dbb
BN
37
38static inline void
39kmem_zone_free(kmem_zone_t *zone, void *ptr)
40{
41 zone->allocated--;
42 free(ptr);
43}
44
45extern void *kmem_alloc(size_t, int);
46extern void *kmem_zalloc(size_t, int);
47
f8149110 48static inline void
5e656dbb
BN
49kmem_free(void *ptr) {
50 free(ptr);
51}
52
408c66dd 53extern void *kmem_realloc(void *, size_t, int);
5e656dbb
BN
54
55#endif