debuggers.hg

view xen/include/xen/slab.h @ 3667:07d5c9548534

bitkeeper revision 1.1159.212.76 (4201eac5AlEp4jSQYKA8-oSf0N15pQ)

Add xmalloc_bytes() to the allocator API.
Signed-off-by: keir.fraser@cl.cam.ac.uk
author kaf24@scramble.cl.cam.ac.uk
date Thu Feb 03 09:11:33 2005 +0000 (2005-02-03)
parents 8472fafee3cf
children bbe8541361dd 6e6976c1a545 32d29625d39b
line source
1 /*
2 * Written by Mark Hemment, 1996.
3 * (markhe@nextd.demon.co.uk)
4 */
6 #ifndef __SLAB_H__
7 #define __SLAB_H__
9 #include <xen/config.h>
11 #ifdef __ARCH_HAS_SLAB_ALLOCATOR
13 #include <asm/slab.h>
15 #else
17 typedef struct xmem_cache_s xmem_cache_t;
19 #include <xen/mm.h>
20 #include <xen/cache.h>
21 #include <xen/types.h>
23 /* Flags to pass to xmem_cache_create(). */
24 /* NB. The first 3 are only valid when built with SLAB_DEBUG_SUPPORT. */
25 #define SLAB_DEBUG_INITIAL 0x00000200UL /* Call constructor */
26 #define SLAB_RED_ZONE 0x00000400UL /* Red zone objs in a cache */
27 #define SLAB_POISON 0x00000800UL /* Poison objects */
28 #define SLAB_NO_REAP 0x00001000UL /* never reap from the cache */
29 #define SLAB_HWCACHE_ALIGN 0x00002000UL /* align obj on a cache line */
31 /* Flags passed to a constructor function. */
32 #define SLAB_CTOR_CONSTRUCTOR 0x001UL /* if not set, then deconstructor */
33 #define SLAB_CTOR_ATOMIC 0x002UL /* tell cons. it can't sleep */
34 #define SLAB_CTOR_VERIFY 0x004UL /* tell cons. it's a verify call */
36 extern void xmem_cache_init(void);
37 extern void xmem_cache_sizes_init(unsigned long);
39 extern xmem_cache_t *xmem_find_general_cachep(size_t);
40 extern xmem_cache_t *xmem_cache_create(
41 const char *, size_t, size_t, unsigned long,
42 void (*)(void *, xmem_cache_t *, unsigned long),
43 void (*)(void *, xmem_cache_t *, unsigned long));
44 extern int xmem_cache_destroy(xmem_cache_t *);
45 extern int xmem_cache_shrink(xmem_cache_t *);
46 extern void *xmem_cache_alloc(xmem_cache_t *);
47 extern void xmem_cache_free(xmem_cache_t *, void *);
49 extern void *_xmalloc(size_t);
50 extern void xfree(const void *);
52 extern int xmem_cache_reap(void);
54 extern void dump_slabinfo();
56 /* Allocate space for typed object. */
57 #define xmalloc(_type) ((_type *)_xmalloc(sizeof(_type)))
59 /* Allocate space for array of typed objects. */
60 #define xmalloc_array(_type, _num) \
61 ((_type *)(((_num) > (UINT_MAX / sizeof(_type))) ? \
62 NULL : _xmalloc((_num) * sizeof(_type))))
64 /* Allocate untyped storage. */
65 #define xmalloc_bytes(_bytes) (_xmalloc(_bytes))
67 #endif /* __ARCH_HAS_SLAB_ALLOCATOR */
69 #endif /* __SLAB_H__ */