]> xenbits.xensource.com Git - people/vhanquez/xen.git/commitdiff
libxc: Move xg_memalign() into a proper source file, so that it
authorKeir Fraser <keir.fraser@citrix.com>
Wed, 9 Apr 2008 16:50:15 +0000 (17:50 +0100)
committerKeir Fraser <keir.fraser@citrix.com>
Wed, 9 Apr 2008 16:50:15 +0000 (17:50 +0100)
definitely does not leak out of tools/libxc. Return to the
ioemu/osdep.c way of checking for posix_memalign() as this works on
Solaris.

Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
xen-unstable changeset:   17427:5b25d3264f7e3ca1d9e958be8a8543fcf1fc5958
xen-unstable date:        Wed Apr 09 17:49:25 2008 +0100

tools/libxc/xg_private.c
tools/libxc/xg_private.h

index 37bc587477e071148b312293112f30eda656ab78..02c0ff70a6c5eca65ddaf7a41c14b6c466c2c81b 100644 (file)
@@ -8,6 +8,8 @@
 #include <unistd.h>
 #include <zlib.h>
 #include <strings.h>
+#include <stdlib.h>
+#include <malloc.h>
 
 #include "xg_private.h"
 
@@ -198,6 +200,22 @@ __attribute__((weak))
     return -1;
 }
 
+void *xg_memalign(size_t alignment, size_t size)
+{
+#if defined(_POSIX_C_SOURCE) && !defined(__sun__)
+    int ret;
+    void *ptr;
+    ret = posix_memalign(&ptr, alignment, size);
+    if (ret != 0)
+        return NULL;
+    return ptr;
+#elif defined(_BSD)
+    return valloc(size);
+#else
+    return memalign(alignment, size);
+#endif
+}
+
 /*
  * Local variables:
  * mode: C
index 563585793a3bee427f9024f3ce428002f660f40d..e4dedede6d70c752cc07853e295f7eb1a9fcaa63 100644 (file)
@@ -7,7 +7,6 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
-#include <malloc.h>
 #include <sys/mman.h>
 #include <sys/types.h>
 #include <sys/stat.h>
@@ -177,21 +176,6 @@ int xc_copy_to_domain_page(int xc_handle, uint32_t domid,
 int pin_table(int xc_handle, unsigned int type, unsigned long mfn,
               domid_t dom);
 
-/* Grrr portability */
-static inline void *xg_memalign(size_t alignment, size_t size)
-{
-#if (_POSIX_C_SOURCE - 0) >= 200112L || (_XOPEN_SOURCE - 0) >= 600
-    int ret;
-    void *ptr;
-    ret = posix_memalign(&ptr, alignment, size);
-    if (ret != 0)
-        return NULL;
-    return ptr;
-#elif defined(_BSD)
-    return valloc(size);
-#else
-    return memalign(alignment, size);
-#endif
-}
+void *xg_memalign(size_t alignment, size_t size);
 
 #endif /* XG_PRIVATE_H */