struct vm_map *map;
vm_map_t map;
sys_munmap(p, v, retval)	struct proc *p;	void *v;	register_t *retval;{	struct sys_munmap_args /* {		syscallarg(caddr_t) addr;		syscallarg(size_t) len;	} */ *uap = v;	vaddr_t addr;	vsize_t size, pageoff;	struct vm_map *map;	vaddr_t vm_min_address = VM_MIN_ADDRESS;	struct vm_map_entry *dead_entries;	/*	 * get syscall args.	 */	addr = (vaddr_t)SCARG(uap, addr);	size = (vsize_t)SCARG(uap, len);	/*	 * align the address to a page boundary and adjust the size accordingly.	 */	pageoff = (addr & PAGE_MASK);	addr -= pageoff;	size += pageoff;	size = (vsize_t)round_page(size);	if ((int)size < 0)		return (EINVAL);	if (size == 0)		return (0);	/*	 * Check for illegal addresses.  Watch out for address wrap...	 * Note that VM_*_ADDRESS are not constants due to casts (argh).	 */	if (VM_MAXUSER_ADDRESS > 0 && addr + size > VM_MAXUSER_ADDRESS)		return (EINVAL);	if (vm_min_address > 0 && addr < vm_min_address)		return (EINVAL);	if (addr > addr + size)		return (EINVAL);	map = &p->p_vmspace->vm_map;	/*	 * interesting system call semantic: make sure entire range is	 * allocated before allowing an unmap.	 */	vm_map_lock(map);	if (!uvm_map_checkprot(map, addr, addr + size, VM_PROT_NONE)) {		vm_map_unlock(map);		return (EINVAL);	}	uvm_unmap_remove(map, addr, addr + size, &dead_entries);	vm_map_unlock(map);	if (dead_entries != NULL)		uvm_unmap_detach(dead_entries, 0);	return (0);}