Esempio n. 1
0
int
main(int ac, char *av[])
{
	fd = open("/dev/urandom", O_RDONLY);
	uintptr_t times = 1;
	uint64_t range_sz = 5;

	if (ac > 1) {
		times = (uintptr_t) atoi(av[1]);
	}
	if (ac > 3) {
		range_sz = (uint64_t)atoi(av[3]);
	}

	int intsrt = 0;
	int intord = 0;
	int strsrt = 0;
	int strord = 0;
	int aci = 2;
	while (aci < ac) {
		if (strcmp("intsrt", av[aci]) == 0) {
			intsrt++;
		}
		if (strcmp("strsrt", av[aci]) == 0) {
			strsrt++;
		}
		aci++;
	}
	uint64_t maxops = times;
	slablist_t *sl_str_s = NULL;
	slablist_t *sl_int_s = NULL;

	if (strsrt) {
		sl_str_s = slablist_create("strlistsrt", STRMAXSZ, cmpfun_str,
					bndfun_str, SL_SORTED);
		do_ops(sl_str_s, maxops, STR, SRT);
		do_free_remaining(sl_str_s, range_sz, STR, SRT);
	}
	if (intsrt) {
		sl_int_s = slablist_create("intlistsrt", 8, cmpfun, bndfun,
					SL_SORTED);
		do_ops(sl_int_s, maxops, INT, SRT);
		do_free_remaining(sl_int_s, range_sz, INT, SRT);
	}
	end();
	close(fd);
	return (0);
}
Esempio n. 2
0
static int add_mmap(unsigned long virt, unsigned long phys, unsigned long len,
		    unsigned int prot, struct host_vm_change *hvc)
{
	__u64 offset;
	struct host_vm_op *last;
	int fd, ret = 0;

	fd = phys_mapping(phys, &offset);
	if (hvc->index != 0) {
		last = &hvc->ops[hvc->index - 1];
		if ((last->type == MMAP) &&
		   (last->u.mmap.addr + last->u.mmap.len == virt) &&
		   (last->u.mmap.prot == prot) && (last->u.mmap.fd == fd) &&
		   (last->u.mmap.offset + last->u.mmap.len == offset)) {
			last->u.mmap.len += len;
			return 0;
		}
	}

	if (hvc->index == ARRAY_SIZE(hvc->ops)) {
		ret = do_ops(hvc, ARRAY_SIZE(hvc->ops), 0);
		hvc->index = 0;
	}

	hvc->ops[hvc->index++] = ((struct host_vm_op)
				  { .type	= MMAP,
				    .u = { .mmap = { .addr	= virt,
						     .len	= len,
						     .prot	= prot,
						     .fd	= fd,
						     .offset	= offset }
			   } });