diff options
author | Christoph Egger <Christoph.Egger@amd.com> | 2011-01-27 19:03:42 +0000 |
---|---|---|
committer | Christoph Egger <Christoph.Egger@amd.com> | 2011-01-27 19:03:42 +0000 |
commit | e46432026803ad6f750db3b448d962dc20c656e9 (patch) | |
tree | 2610b0faf51f482de46c85cb623076ff65bee2d7 /tools/libxc/xc_dom_bzimageloader.c | |
parent | 921fb156d4bd70020211e377207f52e06cb12e16 (diff) | |
download | xen-e46432026803ad6f750db3b448d962dc20c656e9.tar.gz xen-e46432026803ad6f750db3b448d962dc20c656e9.tar.bz2 xen-e46432026803ad6f750db3b448d962dc20c656e9.zip |
libxc: break xc_get_physmem out into os-dependent files
NetBSD doesn't have sysconf(_SC_PHYS_PAGES).
Factor physmem() out into os-dependent files and rename it to
xc_get_physmem() so as not to pollute the namespace.
Signed-off-by: Christoph Egger <Christoph.Egger@amd.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
Diffstat (limited to 'tools/libxc/xc_dom_bzimageloader.c')
-rw-r--r-- | tools/libxc/xc_dom_bzimageloader.c | 23 |
1 files changed, 1 insertions, 22 deletions
diff --git a/tools/libxc/xc_dom_bzimageloader.c b/tools/libxc/xc_dom_bzimageloader.c index e3ea39f59a..5d949985e0 100644 --- a/tools/libxc/xc_dom_bzimageloader.c +++ b/tools/libxc/xc_dom_bzimageloader.c @@ -140,27 +140,6 @@ static int xc_try_bzip2_decode( #include <lzma.h> -static uint64_t physmem(void) -{ - uint64_t ret = 0; - const long pagesize = sysconf(_SC_PAGESIZE); - const long pages = sysconf(_SC_PHYS_PAGES); - - if ( (pagesize != -1) || (pages != -1) ) - { - /* - * According to docs, pagesize * pages can overflow. - * Simple case is 32-bit box with 4 GiB or more RAM, - * which may report exactly 4 GiB of RAM, and "long" - * being 32-bit will overflow. Casting to uint64_t - * hopefully avoids overflows in the near future. - */ - ret = (uint64_t)(pagesize) * (uint64_t)(pages); - } - - return ret; -} - static int xc_try_lzma_decode( struct xc_dom_image *dom, void **blob, size_t *size) { @@ -173,7 +152,7 @@ static int xc_try_lzma_decode( int outsize; const char *msg; - ret = lzma_alone_decoder(&stream, physmem() / 3); + ret = lzma_alone_decoder(&stream, xc_get_physmem() / 3); if ( ret != LZMA_OK ) { DOMPRINTF("LZMA: Failed to init stream decoder"); |