ia64/xen-unstable

view extras/mini-os/include/xmalloc.h @ 19848:5839491bbf20

[IA64] replace MAX_VCPUS with d->max_vcpus where necessary.

don't use MAX_VCPUS, and use vcpu::max_vcpus.
The changeset of 2f9e1348aa98 introduced max_vcpus to allow more vcpus
per guest. This patch is ia64 counter part.

Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
author Isaku Yamahata <yamahata@valinux.co.jp>
date Mon Jun 29 11:26:05 2009 +0900 (2009-06-29)
parents 433d1b26fd51
children
line source
1 #ifndef __XMALLOC_H__
2 #define __XMALLOC_H__
4 #ifdef HAVE_LIBC
6 #include <stdlib.h>
7 #include <malloc.h>
8 /* Allocate space for typed object. */
9 #define _xmalloc(size, align) memalign(align, size)
10 #define xfree(ptr) free(ptr)
12 #else
14 #include <limits.h>
16 #define DEFAULT_ALIGN (sizeof(unsigned long))
17 #define malloc(size) _xmalloc(size, DEFAULT_ALIGN)
18 #define free(ptr) xfree(ptr)
19 #define realloc(ptr, size) _realloc(ptr, size)
21 /* Free any of the above. */
22 extern void xfree(const void *);
24 /* Underlying functions */
25 extern void *_xmalloc(size_t size, size_t align);
26 extern void *_realloc(void *ptr, size_t size);
28 #endif
30 static inline void *_xmalloc_array(size_t size, size_t align, size_t num)
31 {
32 /* Check for overflow. */
33 if (size && num > UINT_MAX / size)
34 return NULL;
35 return _xmalloc(size * num, align);
36 }
38 /* Allocate space for typed object. */
39 #define xmalloc(_type) ((_type *)_xmalloc(sizeof(_type), __alignof__(_type)))
41 /* Allocate space for array of typed objects. */
42 #define xmalloc_array(_type, _num) ((_type *)_xmalloc_array(sizeof(_type), __alignof__(_type), _num))
44 #endif /* __XMALLOC_H__ */