debuggers.hg

view xen/include/xen/slab.h @ 3691:32d29625d39b

bitkeeper revision 1.1159.212.88 (4203fbb5CoEmX_fzlXc90dxNw6gqoA)

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.bkX
author iap10@labyrinth.cl.cam.ac.uk
date Fri Feb 04 22:48:21 2005 +0000 (2005-02-04)
parents 07d5c9548534 6e6976c1a545
children 88957a238191
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 #include <xen/mm.h>
18 #include <xen/cache.h>
19 #include <xen/types.h>
21 /* Allocate space for typed object. */
22 #define xmalloc(_type) ((_type *)_xmalloc(sizeof(_type), __alignof__(_type)))
24 /* Allocate space for array of typed objects. */
25 #define xmalloc_array(_type, _num) ((_type *)_xmalloc_array(sizeof(_type), __alignof__(_type), _num))
27 /* Allocate untyped storage. */
28 #define xmalloc_bytes(_bytes) (_xmalloc(_bytes, SMP_CACHE_BYTES))
30 /* Free any of the above. */
31 extern void xfree(const void *);
33 /* Underlying functions */
34 extern void *_xmalloc(size_t size, size_t align);
35 static inline void *_xmalloc_array(size_t size, size_t align, size_t num)
36 {
37 /* Check for overflow. */
38 if (size && num > UINT_MAX / size)
39 return NULL;
40 return _xmalloc(size * num, align);
41 }
43 #endif /* __ARCH_HAS_SLAB_ALLOCATOR */
45 #endif /* __SLAB_H__ */