diff options
author | cl349@firebug.cl.cam.ac.uk <cl349@firebug.cl.cam.ac.uk> | 2005-06-02 20:27:34 +0000 |
---|---|---|
committer | cl349@firebug.cl.cam.ac.uk <cl349@firebug.cl.cam.ac.uk> | 2005-06-02 20:27:34 +0000 |
commit | 42825bdf1d9d4e1b560e4d37a5a8500b595796eb (patch) | |
tree | 1a92c57122d1af4be602b9f0f366d5e2112db5ab /xen/include/xen/xmalloc.h | |
parent | 4e8fab61b579a23ee89277729f5596417d4bc555 (diff) | |
download | xen-42825bdf1d9d4e1b560e4d37a5a8500b595796eb.tar.gz xen-42825bdf1d9d4e1b560e4d37a5a8500b595796eb.tar.bz2 xen-42825bdf1d9d4e1b560e4d37a5a8500b595796eb.zip |
bitkeeper revision 1.1649 (429f6bb65KQm70mnFwO33ykh9n1qag)
sched.h:
g/c unneeded include.
Many files:
Rename xen/slab.h to xen/xmalloc.h and fix resulting fallout.
xmalloc.h:
Rename: xen/include/xen/slab.h -> xen/include/xen/xmalloc.h
sched.h, multicall.c, dom_mem_ops.c, asm-offsets.c:
cleanup incorrect includes.
Signed-off-by: Christian Limpach <Christian.Limpach@cl.cam.ac.uk>
Diffstat (limited to 'xen/include/xen/xmalloc.h')
-rw-r--r-- | xen/include/xen/xmalloc.h | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/xen/include/xen/xmalloc.h b/xen/include/xen/xmalloc.h new file mode 100644 index 0000000000..893627f04a --- /dev/null +++ b/xen/include/xen/xmalloc.h @@ -0,0 +1,27 @@ + +#ifndef __XMALLOC_H__ +#define __XMALLOC_H__ + +/* Allocate space for typed object. */ +#define xmalloc(_type) ((_type *)_xmalloc(sizeof(_type), __alignof__(_type))) + +/* Allocate space for array of typed objects. */ +#define xmalloc_array(_type, _num) ((_type *)_xmalloc_array(sizeof(_type), __alignof__(_type), _num)) + +/* Allocate untyped storage. */ +#define xmalloc_bytes(_bytes) (_xmalloc(_bytes, SMP_CACHE_BYTES)) + +/* Free any of the above. */ +extern void xfree(const void *); + +/* Underlying functions */ +extern void *_xmalloc(size_t size, size_t align); +static inline void *_xmalloc_array(size_t size, size_t align, size_t num) +{ + /* Check for overflow. */ + if (size && num > UINT_MAX / size) + return NULL; + return _xmalloc(size * num, align); +} + +#endif /* __XMALLOC_H__ */ |