debuggers.hg

diff 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
author iap10@labyrinth.cl.cam.ac.uk
date Wed Feb 02 15:24:31 2005 +0000 (2005-02-02)
parents 610068179f96 552dd1f1c64c
children 8472fafee3cf
line diff
     1.1 --- a/xen/include/xen/slab.h	Wed Feb 02 09:38:32 2005 +0000
     1.2 +++ b/xen/include/xen/slab.h	Wed Feb 02 15:24:31 2005 +0000
     1.3 @@ -18,6 +18,7 @@ typedef struct xmem_cache_s xmem_cache_t
     1.4  
     1.5  #include <xen/mm.h>
     1.6  #include <xen/cache.h>
     1.7 +#include <xen/types.h>
     1.8  
     1.9  /* Flags to pass to xmem_cache_create(). */
    1.10  /* NB. The first 3 are only valid when built with SLAB_DEBUG_SUPPORT. */
    1.11 @@ -45,13 +46,24 @@ extern int xmem_cache_shrink(xmem_cache_
    1.12  extern void *xmem_cache_alloc(xmem_cache_t *);
    1.13  extern void xmem_cache_free(xmem_cache_t *, void *);
    1.14  
    1.15 -extern void *xmalloc(size_t);
    1.16 +extern void *_xmalloc(size_t);
    1.17  extern void xfree(const void *);
    1.18  
    1.19  extern int xmem_cache_reap(void);
    1.20  
    1.21  extern void dump_slabinfo();
    1.22  
    1.23 +/* Nicely typesafe for you. */
    1.24 +#define xmalloc(type) ((type *)_xmalloc(sizeof(type)))
    1.25 +#define xmalloc_array(type, num) ((type *)_xmalloc_array(sizeof(type), (num)))
    1.26 +
    1.27 +static inline void *_xmalloc_array(size_t size, size_t num)
    1.28 +{
    1.29 +	/* Check for overflow. */
    1.30 +	if (size && num > UINT_MAX / size)
    1.31 +		return NULL;
    1.32 +	return _xmalloc(size * num);
    1.33 +}
    1.34  #endif /* __ARCH_HAS_SLAB_ALLOCATOR */
    1.35  
    1.36  #endif /* __SLAB_H__ */