debuggers.hg
annotate xen/include/xen/slab.h @ 3658:0ef6e8e6e85d
bitkeeper revision 1.1159.212.71 (4200f0afX_JumfbEHQex6TdFENULMQ)
Merge labyrinth.cl.cam.ac.uk:/auto/groups/xeno-xenod/BK/xen-unstable.bk
into labyrinth.cl.cam.ac.uk:/auto/groups/xeno/users/iap10/xeno-clone/xen-unstable.bk
Merge labyrinth.cl.cam.ac.uk:/auto/groups/xeno-xenod/BK/xen-unstable.bk
into labyrinth.cl.cam.ac.uk:/auto/groups/xeno/users/iap10/xeno-clone/xen-unstable.bk
author | iap10@labyrinth.cl.cam.ac.uk |
---|---|
date | Wed Feb 02 15:24:31 2005 +0000 (2005-02-02) |
parents | 610068179f96 552dd1f1c64c |
children | 8472fafee3cf |
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. */ |
iap10@3652 | 57 #define xmalloc(type) ((type *)_xmalloc(sizeof(type))) |
iap10@3652 | 58 #define xmalloc_array(type, num) ((type *)_xmalloc_array(sizeof(type), (num))) |
iap10@3650 | 59 |
iap10@3652 | 60 static inline void *_xmalloc_array(size_t size, size_t num) |
iap10@3650 | 61 { |
iap10@3650 | 62 /* Check for overflow. */ |
iap10@3650 | 63 if (size && num > UINT_MAX / size) |
iap10@3650 | 64 return NULL; |
iap10@3652 | 65 return _xmalloc(size * num); |
iap10@3650 | 66 } |
kaf24@3515 | 67 #endif /* __ARCH_HAS_SLAB_ALLOCATOR */ |
kaf24@3515 | 68 |
kaf24@1592 | 69 #endif /* __SLAB_H__ */ |