ia64/xen-unstable

changeset 3626:8472fafee3cf

bitkeeper revision 1.1159.212.74 (42015ef3sPQp8pjeJAck1wBtTAYL9g)

Interface to typed allocator is now just xmalloc/xmalloc_array/xfree.
_xmalloc/_xmalloc_array are dead (or, at least, non-API).
Signed-off-by: keir.fraser@cl.cam.ac.uk
author kaf24@scramble.cl.cam.ac.uk
date Wed Feb 02 23:14:59 2005 +0000 (2005-02-02)
parents 060c1ea52343
children e922aa58971a
files xen/arch/x86/microcode.c xen/arch/x86/pci-pc.c xen/arch/x86/shadow.c xen/include/asm-x86/shadow.h xen/include/xen/slab.h
line diff
     1.1 --- a/xen/arch/x86/microcode.c	Wed Feb 02 22:31:42 2005 +0000
     1.2 +++ b/xen/arch/x86/microcode.c	Wed Feb 02 23:14:59 2005 +0000
     1.3 @@ -84,7 +84,7 @@
     1.4  #define DECLARE_MUTEX(_m) spinlock_t _m = SPIN_LOCK_UNLOCKED
     1.5  #define down(_m) spin_lock(_m)
     1.6  #define up(_m) spin_unlock(_m)
     1.7 -#define vmalloc(_s) _xmalloc(_s)
     1.8 +#define vmalloc(_s) ((void *)xmalloc(u8[_s]))
     1.9  #define vfree(_p) xfree(_p)
    1.10  #define num_online_cpus() smp_num_cpus
    1.11  static inline int on_each_cpu(
     2.1 --- a/xen/arch/x86/pci-pc.c	Wed Feb 02 22:31:42 2005 +0000
     2.2 +++ b/xen/arch/x86/pci-pc.c	Wed Feb 02 23:14:59 2005 +0000
     2.3 @@ -1036,7 +1036,7 @@ struct irq_routing_table * __devinit pci
     2.4  	if (ret & 0xff00)
     2.5  		printk(KERN_ERR "PCI: Error %02x when fetching IRQ routing table.\n", (ret >> 8) & 0xff);
     2.6  	else if (opt.size) {
     2.7 -		rt = _xmalloc(sizeof(struct irq_routing_table) + opt.size);
     2.8 +		rt = (struct irq_routing_table *)xmalloc(u8[sizeof(struct irq_routing_table) + opt.size]);
     2.9  		if (rt) {
    2.10  			memset(rt, 0, sizeof(struct irq_routing_table));
    2.11  			rt->size = opt.size + sizeof(struct irq_routing_table);
     3.1 --- a/xen/arch/x86/shadow.c	Wed Feb 02 22:31:42 2005 +0000
     3.2 +++ b/xen/arch/x86/shadow.c	Wed Feb 02 23:14:59 2005 +0000
     3.3 @@ -185,7 +185,8 @@ int shadow_mode_enable(struct domain *p,
     3.4      {
     3.5          m->shadow_dirty_bitmap_size = (p->max_pages + 63) & ~63;
     3.6          m->shadow_dirty_bitmap = 
     3.7 -            _xmalloc(m->shadow_dirty_bitmap_size/8);
     3.8 +            xmalloc_array(unsigned long, m->shadow_dirty_bitmap_size /
     3.9 +                                         (8 * sizeof(unsigned long)));
    3.10          if ( m->shadow_dirty_bitmap == NULL )
    3.11          {
    3.12              m->shadow_dirty_bitmap_size = 0;
     4.1 --- a/xen/include/asm-x86/shadow.h	Wed Feb 02 22:31:42 2005 +0000
     4.2 +++ b/xen/include/asm-x86/shadow.h	Wed Feb 02 23:14:59 2005 +0000
     4.3 @@ -616,8 +616,8 @@ static inline void set_shadow_status(
     4.4      {
     4.5          SH_LOG("Allocate more shadow hashtable blocks.");
     4.6  
     4.7 -        extra = _xmalloc(
     4.8 -            sizeof(void *) + (shadow_ht_extra_size * sizeof(*x)));
     4.9 +        extra = (struct shadow_status *)xmalloc(
    4.10 +            u8[sizeof(void *) + (shadow_ht_extra_size * sizeof(*x))]);
    4.11  
    4.12          /* XXX Should be more graceful here. */
    4.13          if ( extra == NULL )
     5.1 --- a/xen/include/xen/slab.h	Wed Feb 02 22:31:42 2005 +0000
     5.2 +++ b/xen/include/xen/slab.h	Wed Feb 02 23:14:59 2005 +0000
     5.3 @@ -54,16 +54,10 @@ extern int xmem_cache_reap(void);
     5.4  extern void dump_slabinfo();
     5.5  
     5.6  /* Nicely typesafe for you. */
     5.7 -#define xmalloc(type) ((type *)_xmalloc(sizeof(type)))
     5.8 -#define xmalloc_array(type, num) ((type *)_xmalloc_array(sizeof(type), (num)))
     5.9 -
    5.10 -static inline void *_xmalloc_array(size_t size, size_t num)
    5.11 -{
    5.12 -	/* Check for overflow. */
    5.13 -	if (size && num > UINT_MAX / size)
    5.14 -		return NULL;
    5.15 -	return _xmalloc(size * num);
    5.16 -}
    5.17 +#define xmalloc(_type) ((typeof(_type) *)_xmalloc(sizeof(_type)))
    5.18 +#define xmalloc_array(_type, _num)                 \
    5.19 +((_type *)(((_num) > (UINT_MAX / sizeof(_type))) ? \
    5.20 +           NULL : _xmalloc((_num) * sizeof(_type))))
    5.21  #endif /* __ARCH_HAS_SLAB_ALLOCATOR */
    5.22  
    5.23  #endif /* __SLAB_H__ */