ia64/xen-unstable
annotate extras/mini-os/include/xmalloc.h @ 10888:5379548bfc79
[NET] Enable TCPv4 segmentation offload in front/back drivers.
Signed-off-by: Keir Fraser <keir@xensource.com>
Signed-off-by: Keir Fraser <keir@xensource.com>
author | kfraser@localhost.localdomain |
---|---|
date | Tue Aug 01 11:54:45 2006 +0100 (2006-08-01) |
parents | 7557f0b4098c |
children | 8984cc0a1d80 |
rev | line source |
---|---|
kaf24@6446 | 1 #ifndef __XMALLOC_H__ |
kaf24@6446 | 2 #define __XMALLOC_H__ |
kaf24@6446 | 3 |
kaf24@6446 | 4 /* Allocate space for typed object. */ |
kaf24@6446 | 5 #define xmalloc(_type) ((_type *)_xmalloc(sizeof(_type), __alignof__(_type))) |
kaf24@6446 | 6 |
kaf24@6446 | 7 /* Allocate space for array of typed objects. */ |
kaf24@6446 | 8 #define xmalloc_array(_type, _num) ((_type *)_xmalloc_array(sizeof(_type), __alignof__(_type), _num)) |
kaf24@6446 | 9 |
kaf24@8284 | 10 #define malloc(size) _xmalloc(size, 4) |
kaf24@8284 | 11 #define free(ptr) xfree(ptr) |
kaf24@8284 | 12 |
kaf24@6446 | 13 /* Free any of the above. */ |
kaf24@6446 | 14 extern void xfree(const void *); |
kaf24@6446 | 15 |
kaf24@6446 | 16 /* Underlying functions */ |
kaf24@6446 | 17 extern void *_xmalloc(size_t size, size_t align); |
kaf24@6446 | 18 static inline void *_xmalloc_array(size_t size, size_t align, size_t num) |
kaf24@6446 | 19 { |
kaf24@6446 | 20 /* Check for overflow. */ |
kaf24@6446 | 21 if (size && num > UINT_MAX / size) |
kaf24@6446 | 22 return NULL; |
kaf24@6446 | 23 return _xmalloc(size * num, align); |
kaf24@6446 | 24 } |
kaf24@6446 | 25 |
kaf24@6446 | 26 #endif /* __XMALLOC_H__ */ |