aboutsummaryrefslogtreecommitdiffstats
path: root/extras/mini-os/include/xmalloc.h
diff options
context:
space:
mode:
authorKeir Fraser <keir.fraser@citrix.com>2008-01-22 14:20:22 +0000
committerKeir Fraser <keir.fraser@citrix.com>2008-01-22 14:20:22 +0000
commite8c1abd6e75d35e747611bcad82d0d4a6564beca (patch)
tree932aa4b778d3c4871b21f89eaa4db484c34e1d21 /extras/mini-os/include/xmalloc.h
parentdfba81d2fcc227ffc2ce546d9884580f682e68b5 (diff)
downloadxen-e8c1abd6e75d35e747611bcad82d0d4a6564beca.tar.gz
xen-e8c1abd6e75d35e747611bcad82d0d4a6564beca.tar.bz2
xen-e8c1abd6e75d35e747611bcad82d0d4a6564beca.zip
minios: POSIX fixes
Fixes some functions which are POSIX. Also make them ifndef HAVE_LIBC. Signed-off-by: Samuel Thibault <samuel.thibault@eu.citrix.com>
Diffstat (limited to 'extras/mini-os/include/xmalloc.h')
-rw-r--r--extras/mini-os/include/xmalloc.h18
1 files changed, 15 insertions, 3 deletions
diff --git a/extras/mini-os/include/xmalloc.h b/extras/mini-os/include/xmalloc.h
index 26ae9dd012..e168a84f88 100644
--- a/extras/mini-os/include/xmalloc.h
+++ b/extras/mini-os/include/xmalloc.h
@@ -1,11 +1,15 @@
#ifndef __XMALLOC_H__
#define __XMALLOC_H__
+#ifdef HAVE_LIBC
+
+#include <stdlib.h>
+#include <malloc.h>
/* Allocate space for typed object. */
-#define xmalloc(_type) ((_type *)_xmalloc(sizeof(_type), __alignof__(_type)))
+#define _xmalloc(size, align) memalign(align, size)
+#define xfree(ptr) free(ptr)
-/* Allocate space for array of typed objects. */
-#define xmalloc_array(_type, _num) ((_type *)_xmalloc_array(sizeof(_type), __alignof__(_type), _num))
+#else
#define DEFAULT_ALIGN (sizeof(unsigned long))
#define malloc(size) _xmalloc(size, DEFAULT_ALIGN)
@@ -19,6 +23,8 @@ extern void xfree(const void *);
extern void *_xmalloc(size_t size, size_t align);
extern void *_realloc(void *ptr, size_t size);
+#endif
+
static inline void *_xmalloc_array(size_t size, size_t align, size_t num)
{
/* Check for overflow. */
@@ -27,4 +33,10 @@ static inline void *_xmalloc_array(size_t size, size_t align, size_t num)
return _xmalloc(size * num, align);
}
+/* 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))
+
#endif /* __XMALLOC_H__ */