void xen_map_cache_init(phys_offset_to_gaddr_t f, void *opaque)

{

    unsigned long size;

    struct rlimit rlimit_as;



    mapcache = g_malloc0(sizeof (MapCache));



    mapcache->phys_offset_to_gaddr = f;

    mapcache->opaque = opaque;

    qemu_mutex_init(&mapcache->lock);



    QTAILQ_INIT(&mapcache->locked_entries);



    if (geteuid() == 0) {

        rlimit_as.rlim_cur = RLIM_INFINITY;

        rlimit_as.rlim_max = RLIM_INFINITY;

        mapcache->max_mcache_size = MCACHE_MAX_SIZE;

    } else {

        getrlimit(RLIMIT_AS, &rlimit_as);

        rlimit_as.rlim_cur = rlimit_as.rlim_max;



        if (rlimit_as.rlim_max != RLIM_INFINITY) {

            fprintf(stderr, "Warning: QEMU's maximum size of virtual"

                    " memory is not infinity.\n");

        }

        if (rlimit_as.rlim_max < MCACHE_MAX_SIZE + NON_MCACHE_MEMORY_SIZE) {

            mapcache->max_mcache_size = rlimit_as.rlim_max -

                NON_MCACHE_MEMORY_SIZE;

        } else {

            mapcache->max_mcache_size = MCACHE_MAX_SIZE;

        }

    }



    setrlimit(RLIMIT_AS, &rlimit_as);



    mapcache->nr_buckets =

        (((mapcache->max_mcache_size >> XC_PAGE_SHIFT) +

          (1UL << (MCACHE_BUCKET_SHIFT - XC_PAGE_SHIFT)) - 1) >>

         (MCACHE_BUCKET_SHIFT - XC_PAGE_SHIFT));



    size = mapcache->nr_buckets * sizeof (MapCacheEntry);

    size = (size + XC_PAGE_SIZE - 1) & ~(XC_PAGE_SIZE - 1);

    DPRINTF("%s, nr_buckets = %lx size %lu\n", __func__,

            mapcache->nr_buckets, size);

    mapcache->entry = g_malloc0(size);

}

void xen_map_cache_init(phys_offset_to_gaddr_t f, void *opaque)

{

    unsigned long size;

    struct rlimit rlimit_as;



    mapcache = g_malloc0(sizeof (MapCache));



    mapcache->phys_offset_to_gaddr = f;

    mapcache->opaque = opaque;

    qemu_mutex_init(&mapcache->lock);



    QTAILQ_INIT(&mapcache->locked_entries);



    if (geteuid() == 0) {

        rlimit_as.rlim_cur = RLIM_INFINITY;

        rlimit_as.rlim_max = RLIM_INFINITY;

        mapcache->max_mcache_size = MCACHE_MAX_SIZE;

    } else {

        getrlimit(RLIMIT_AS, &rlimit_as);

        rlimit_as.rlim_cur = rlimit_as.rlim_max;



        if (rlimit_as.rlim_max != RLIM_INFINITY) {

            fprintf(stderr, "Warning: QEMU's maximum size of virtual"

                    " memory is not infinity.\n");

        }

        if (rlimit_as.rlim_max < MCACHE_MAX_SIZE + NON_MCACHE_MEMORY_SIZE) {

            mapcache->max_mcache_size = rlimit_as.rlim_max -

                NON_MCACHE_MEMORY_SIZE;

        } else {

            mapcache->max_mcache_size = MCACHE_MAX_SIZE;

        }

    }



    setrlimit(RLIMIT_AS, &rlimit_as);



    mapcache->nr_buckets =

        (((mapcache->max_mcache_size >> XC_PAGE_SHIFT) +

          (1UL << (MCACHE_BUCKET_SHIFT - XC_PAGE_SHIFT)) - 1) >>

         (MCACHE_BUCKET_SHIFT - XC_PAGE_SHIFT));



    size = mapcache->nr_buckets * sizeof (MapCacheEntry);

    size = (size + XC_PAGE_SIZE - 1) & ~(XC_PAGE_SIZE - 1);

    DPRINTF("%s, nr_buckets = %lx size %lu\n", __func__,

            mapcache->nr_buckets, size);

    mapcache->entry = g_malloc0(size);

}

void FUNC_0(phys_offset_to_gaddr_t VAR_0, void *VAR_1)

{

    unsigned long VAR_2;

    struct rlimit VAR_3;



    mapcache = g_malloc0(sizeof (MapCache));



    mapcache->phys_offset_to_gaddr = VAR_0;

    mapcache->VAR_1 = VAR_1;

    qemu_mutex_init(&mapcache->lock);



    QTAILQ_INIT(&mapcache->locked_entries);



    if (geteuid() == 0) {

        VAR_3.rlim_cur = RLIM_INFINITY;

        VAR_3.rlim_max = RLIM_INFINITY;

        mapcache->max_mcache_size = MCACHE_MAX_SIZE;

    } else {

        getrlimit(RLIMIT_AS, &VAR_3);

        VAR_3.rlim_cur = VAR_3.rlim_max;



        if (VAR_3.rlim_max != RLIM_INFINITY) {

            fprintf(stderr, "Warning: QEMU's maximum VAR_2 of virtual"

                    " memory is not infinity.\n");

        }

        if (VAR_3.rlim_max < MCACHE_MAX_SIZE + NON_MCACHE_MEMORY_SIZE) {

            mapcache->max_mcache_size = VAR_3.rlim_max -

                NON_MCACHE_MEMORY_SIZE;

        } else {

            mapcache->max_mcache_size = MCACHE_MAX_SIZE;

        }

    }



    setrlimit(RLIMIT_AS, &VAR_3);



    mapcache->nr_buckets =

        (((mapcache->max_mcache_size >> XC_PAGE_SHIFT) +

          (1UL << (MCACHE_BUCKET_SHIFT - XC_PAGE_SHIFT)) - 1) >>

         (MCACHE_BUCKET_SHIFT - XC_PAGE_SHIFT));



    VAR_2 = mapcache->nr_buckets * sizeof (MapCacheEntry);

    VAR_2 = (VAR_2 + XC_PAGE_SIZE - 1) & ~(XC_PAGE_SIZE - 1);

    DPRINTF("%s, nr_buckets = %lx VAR_2 %lu\n", __func__,

            mapcache->nr_buckets, VAR_2);

    mapcache->entry = g_malloc0(VAR_2);

}

void FUNC_0(phys_offset_to_gaddr_t VAR_0, void *VAR_1)
{ unsigned long VAR_2; struct rlimit VAR_3; mapcache = g_malloc0(sizeof (MapCache)); mapcache->phys_offset_to_gaddr = VAR_0; mapcache->VAR_1 = VAR_1; qemu_mutex_init(&mapcache->lock); QTAILQ_INIT(&mapcache->locked_entries); if (geteuid() == 0) { VAR_3.rlim_cur = RLIM_INFINITY; VAR_3.rlim_max = RLIM_INFINITY; mapcache->max_mcache_size = MCACHE_MAX_SIZE; } else { getrlimit(RLIMIT_AS, &VAR_3); VAR_3.rlim_cur = VAR_3.rlim_max; if (VAR_3.rlim_max != RLIM_INFINITY) { fprintf(stderr, "Warning: QEMU's maximum VAR_2 of virtual"
" memory is not infinity.\n"); } if (VAR_3.rlim_max < MCACHE_MAX_SIZE + NON_MCACHE_MEMORY_SIZE) { mapcache->max_mcache_size = VAR_3.rlim_max -
NON_MCACHE_MEMORY_SIZE; } else { mapcache->max_mcache_size = MCACHE_MAX_SIZE; } } setrlimit(RLIMIT_AS, &VAR_3); mapcache->nr_buckets =
(((mapcache->max_mcache_size >> XC_PAGE_SHIFT) +
(1UL << (MCACHE_BUCKET_SHIFT - XC_PAGE_SHIFT)) - 1) >>
(MCACHE_BUCKET_SHIFT - XC_PAGE_SHIFT)); VAR_2 = mapcache->nr_buckets * sizeof (MapCacheEntry); VAR_2 = (VAR_2 + XC_PAGE_SIZE - 1) & ~(XC_PAGE_SIZE - 1); DPRINTF("%s, nr_buckets = %lx VAR_2 %lu\n", __func__,
mapcache->nr_buckets, VAR_2); mapcache->entry = g_malloc0(VAR_2); }