ia64/xen-unstable

view extras/mini-os/include/xmalloc.h @ 8284:7557f0b4098c

Merge in the newer Xenbus implementation from Linux to the Mini-OS. The new
version compiles and starts up, but I'm not really sure how to test the new
xenbus implementation.

* Added unbind_evtchn
* Copied parts of the Linux spinlock implementation to make the changes to
xenbus compared to Linux smaller. Also added a dummy rwsem implementation.
* Updated the xenbus-files

Signed-off-by: Simon Kagstrom <simon.kagstrom@bth.se>
author kaf24@firebug.cl.cam.ac.uk
date Thu Dec 08 15:24:02 2005 +0100 (2005-12-08)
parents 06d84bf87159
children 8984cc0a1d80
line source
1 #ifndef __XMALLOC_H__
2 #define __XMALLOC_H__
4 /* Allocate space for typed object. */
5 #define xmalloc(_type) ((_type *)_xmalloc(sizeof(_type), __alignof__(_type)))
7 /* Allocate space for array of typed objects. */
8 #define xmalloc_array(_type, _num) ((_type *)_xmalloc_array(sizeof(_type), __alignof__(_type), _num))
10 #define malloc(size) _xmalloc(size, 4)
11 #define free(ptr) xfree(ptr)
13 /* Free any of the above. */
14 extern void xfree(const void *);
16 /* Underlying functions */
17 extern void *_xmalloc(size_t size, size_t align);
18 static inline void *_xmalloc_array(size_t size, size_t align, size_t num)
19 {
20 /* Check for overflow. */
21 if (size && num > UINT_MAX / size)
22 return NULL;
23 return _xmalloc(size * num, align);
24 }
26 #endif /* __XMALLOC_H__ */