]> CyberLeo.Net >> Repos - FreeBSD/releng/9.2.git/blob - sys/gnu/fs/xfs/FreeBSD/support/kmem.h
- Copy stable/9 to releng/9.2 as part of the 9.2-RELEASE cycle.
[FreeBSD/releng/9.2.git] / sys / gnu / fs / xfs / FreeBSD / support / kmem.h
1 #ifndef __XFS_SUPPORT_KMEM_H__
2 #define __XFS_SUPPORT_KMEM_H__
3
4 #include <sys/param.h>
5 #include <sys/systm.h>
6 #include <sys/malloc.h>
7 #include <sys/kernel.h>
8 #include <sys/lock.h>
9 #include <sys/mutex.h>
10 #include <vm/uma.h>
11
12 typedef unsigned long xfs_pflags_t;
13
14 #define PFLAGS_TEST_NOIO()              0
15 #define PFLAGS_TEST_FSTRANS()           0
16
17 #define PFLAGS_SET_NOIO(STATEP) do {    \
18 } while (0)
19
20 #define PFLAGS_SET_FSTRANS(STATEP) do { \
21 } while (0)
22
23 #define PFLAGS_RESTORE(STATEP) do {     \
24 } while (0)
25
26 #define PFLAGS_DUP(OSTATEP, NSTATEP) do { \
27 } while (0)
28
29 /* Restore the PF_FSTRANS state to what was saved in STATEP */
30 #define PFLAGS_RESTORE_FSTRANS(STATEP) do {                     \
31 } while (0)
32
33 /*
34  * memory management routines
35  */
36 #define KM_SLEEP        M_WAITOK
37 #define KM_NOSLEEP      M_NOWAIT
38 #define KM_NOFS         M_WAITOK
39 #define KM_MAYFAIL      0
40
41 #define kmem_zone       uma_zone
42
43 typedef struct uma_zone kmem_zone_t;
44 typedef struct uma_zone xfs_zone_t;
45
46
47 #define KM_ZONE_HWALIGN 0
48 #define KM_ZONE_RECLAIM 0
49 #define KM_ZONE_SPREAD  0
50
51 #define kmem_zone_init(len, name)               \
52         uma_zcreate(name, len, NULL, NULL, NULL, NULL, 0, 0)
53
54 static inline kmem_zone_t *
55 kmem_zone_init_flags(int size, char *zone_name, unsigned long flags,
56                      void (*construct)(void *, kmem_zone_t *, unsigned long))
57 {
58         return uma_zcreate(zone_name, size, NULL, NULL, NULL, NULL, 0, 0);
59 }
60
61 #define kmem_zone_free(zone, ptr)               \
62         uma_zfree(zone, ptr)
63
64 static inline void
65 kmem_zone_destroy(kmem_zone_t *zone)
66 {
67         uma_zdestroy(zone);
68 }
69
70 #define kmem_zone_alloc(zone, flg)              \
71         uma_zalloc(zone, flg)
72 #define kmem_zone_zalloc(zone, flg)             \
73         uma_zalloc(zone, (flg) | M_ZERO)
74
75 #define kmem_alloc(len, flg)                    \
76         malloc(len, M_XFS, flg)
77 #define kmem_zalloc(len, flg)                   \
78         malloc(len, M_XFS, (flg) | M_ZERO)
79 #define kmem_free(ptr, size)                    \
80         free(ptr, M_XFS)
81 #define kmem_realloc(ptr, nsize, osize, flg)    \
82         realloc(ptr, nsize, M_XFS, flg)
83
84 MALLOC_DECLARE(M_XFS);
85
86 #endif /* __XFS_SUPPORT_KMEM_H__ */