debuggers.hg
annotate xen/include/xen/slab.h @ 3664:8472fafee3cf
bitkeeper revision 1.1159.212.74 (42015ef3sPQp8pjeJAck1wBtTAYL9g)
Interface to typed allocator is now just xmalloc/xmalloc_array/xfree.
_xmalloc/_xmalloc_array are dead (or, at least, non-API).
Signed-off-by: keir.fraser@cl.cam.ac.uk
Interface to typed allocator is now just xmalloc/xmalloc_array/xfree.
_xmalloc/_xmalloc_array are dead (or, at least, non-API).
Signed-off-by: keir.fraser@cl.cam.ac.uk
author | kaf24@scramble.cl.cam.ac.uk |
---|---|
date | Wed Feb 02 23:14:59 2005 +0000 (2005-02-02) |
parents | 0ef6e8e6e85d |
children | 07d5c9548534 |
rev | line source |
---|---|
kaf24@1248 | 1 /* |
kaf24@1248 | 2 * Written by Mark Hemment, 1996. |
kaf24@1248 | 3 * (markhe@nextd.demon.co.uk) |
kaf24@1248 | 4 */ |
kaf24@1248 | 5 |
kaf24@1526 | 6 #ifndef __SLAB_H__ |
kaf24@1592 | 7 #define __SLAB_H__ |
kaf24@1248 | 8 |
kaf24@3515 | 9 #include <xen/config.h> |
kaf24@3515 | 10 |
kaf24@3515 | 11 #ifdef __ARCH_HAS_SLAB_ALLOCATOR |
kaf24@3515 | 12 |
kaf24@3515 | 13 #include <asm/slab.h> |
kaf24@3515 | 14 |
kaf24@3515 | 15 #else |
iap10@3654 | 16 |
iap10@3654 | 17 typedef struct xmem_cache_s xmem_cache_t; |
iap10@3654 | 18 |
kaf24@1526 | 19 #include <xen/mm.h> |
kaf24@1526 | 20 #include <xen/cache.h> |
iap10@3650 | 21 #include <xen/types.h> |
kaf24@1248 | 22 |
iap10@3654 | 23 /* Flags to pass to xmem_cache_create(). */ |
iap10@3654 | 24 /* NB. The first 3 are only valid when built with SLAB_DEBUG_SUPPORT. */ |
iap10@3654 | 25 #define SLAB_DEBUG_INITIAL 0x00000200UL /* Call constructor */ |
iap10@3654 | 26 #define SLAB_RED_ZONE 0x00000400UL /* Red zone objs in a cache */ |
iap10@3654 | 27 #define SLAB_POISON 0x00000800UL /* Poison objects */ |
iap10@3654 | 28 #define SLAB_NO_REAP 0x00001000UL /* never reap from the cache */ |
iap10@3654 | 29 #define SLAB_HWCACHE_ALIGN 0x00002000UL /* align obj on a cache line */ |
iap10@3654 | 30 |
iap10@3654 | 31 /* Flags passed to a constructor function. */ |
iap10@3654 | 32 #define SLAB_CTOR_CONSTRUCTOR 0x001UL /* if not set, then deconstructor */ |
iap10@3654 | 33 #define SLAB_CTOR_ATOMIC 0x002UL /* tell cons. it can't sleep */ |
iap10@3654 | 34 #define SLAB_CTOR_VERIFY 0x004UL /* tell cons. it's a verify call */ |
iap10@3654 | 35 |
iap10@3654 | 36 extern void xmem_cache_init(void); |
iap10@3654 | 37 extern void xmem_cache_sizes_init(unsigned long); |
iap10@3654 | 38 |
iap10@3654 | 39 extern xmem_cache_t *xmem_find_general_cachep(size_t); |
iap10@3654 | 40 extern xmem_cache_t *xmem_cache_create( |
iap10@3654 | 41 const char *, size_t, size_t, unsigned long, |
iap10@3654 | 42 void (*)(void *, xmem_cache_t *, unsigned long), |
iap10@3654 | 43 void (*)(void *, xmem_cache_t *, unsigned long)); |
iap10@3654 | 44 extern int xmem_cache_destroy(xmem_cache_t *); |
iap10@3654 | 45 extern int xmem_cache_shrink(xmem_cache_t *); |
iap10@3654 | 46 extern void *xmem_cache_alloc(xmem_cache_t *); |
iap10@3654 | 47 extern void xmem_cache_free(xmem_cache_t *, void *); |
iap10@3654 | 48 |
iap10@3654 | 49 extern void *_xmalloc(size_t); |
iap10@3654 | 50 extern void xfree(const void *); |
iap10@3654 | 51 |
iap10@3654 | 52 extern int xmem_cache_reap(void); |
iap10@3654 | 53 |
iap10@3654 | 54 extern void dump_slabinfo(); |
kaf24@1248 | 55 |
iap10@3650 | 56 /* Nicely typesafe for you. */ |
kaf24@3664 | 57 #define xmalloc(_type) ((typeof(_type) *)_xmalloc(sizeof(_type))) |
kaf24@3664 | 58 #define xmalloc_array(_type, _num) \ |
kaf24@3664 | 59 ((_type *)(((_num) > (UINT_MAX / sizeof(_type))) ? \ |
kaf24@3664 | 60 NULL : _xmalloc((_num) * sizeof(_type)))) |
kaf24@3515 | 61 #endif /* __ARCH_HAS_SLAB_ALLOCATOR */ |
kaf24@3515 | 62 |
kaf24@1592 | 63 #endif /* __SLAB_H__ */ |