ia64/xen-unstable

changeset 17429:5b25d3264f7e

libxc: Move xg_memalign() into a proper source file, so that it
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>
author Keir Fraser <keir.fraser@citrix.com>
date Wed Apr 09 17:49:25 2008 +0100 (2008-04-09)
parents b3fdc4c38995
children 3105a548e2f5
files tools/libxc/xg_private.c tools/libxc/xg_private.h
line diff
     1.1 --- a/tools/libxc/xg_private.c	Wed Apr 09 16:54:44 2008 +0100
     1.2 +++ b/tools/libxc/xg_private.c	Wed Apr 09 17:49:25 2008 +0100
     1.3 @@ -8,6 +8,8 @@
     1.4  #include <unistd.h>
     1.5  #include <zlib.h>
     1.6  #include <strings.h>
     1.7 +#include <stdlib.h>
     1.8 +#include <malloc.h>
     1.9  
    1.10  #include "xg_private.h"
    1.11  
    1.12 @@ -198,6 +200,22 @@ unsigned long csum_page(void *page)
    1.13      return -1;
    1.14  }
    1.15  
    1.16 +void *xg_memalign(size_t alignment, size_t size)
    1.17 +{
    1.18 +#if defined(_POSIX_C_SOURCE) && !defined(__sun__)
    1.19 +    int ret;
    1.20 +    void *ptr;
    1.21 +    ret = posix_memalign(&ptr, alignment, size);
    1.22 +    if (ret != 0)
    1.23 +        return NULL;
    1.24 +    return ptr;
    1.25 +#elif defined(_BSD)
    1.26 +    return valloc(size);
    1.27 +#else
    1.28 +    return memalign(alignment, size);
    1.29 +#endif
    1.30 +}
    1.31 +
    1.32  /*
    1.33   * Local variables:
    1.34   * mode: C
     2.1 --- a/tools/libxc/xg_private.h	Wed Apr 09 16:54:44 2008 +0100
     2.2 +++ b/tools/libxc/xg_private.h	Wed Apr 09 17:49:25 2008 +0100
     2.3 @@ -7,7 +7,6 @@
     2.4  #include <stdio.h>
     2.5  #include <stdlib.h>
     2.6  #include <string.h>
     2.7 -#include <malloc.h>
     2.8  #include <sys/mman.h>
     2.9  #include <sys/types.h>
    2.10  #include <sys/stat.h>
    2.11 @@ -177,21 +176,6 @@ int xc_copy_to_domain_page(int xc_handle
    2.12  int pin_table(int xc_handle, unsigned int type, unsigned long mfn,
    2.13                domid_t dom);
    2.14  
    2.15 -/* Grrr portability */
    2.16 -static inline void *xg_memalign(size_t alignment, size_t size)
    2.17 -{
    2.18 -#if (_POSIX_C_SOURCE - 0) >= 200112L || (_XOPEN_SOURCE - 0) >= 600
    2.19 -    int ret;
    2.20 -    void *ptr;
    2.21 -    ret = posix_memalign(&ptr, alignment, size);
    2.22 -    if (ret != 0)
    2.23 -        return NULL;
    2.24 -    return ptr;
    2.25 -#elif defined(_BSD)
    2.26 -    return valloc(size);
    2.27 -#else
    2.28 -    return memalign(alignment, size);
    2.29 -#endif
    2.30 -}
    2.31 +void *xg_memalign(size_t alignment, size_t size);
    2.32  
    2.33  #endif /* XG_PRIVATE_H */