int advice, error;
int advice, rv;;
sys_madvise(p, v, retval)	struct proc *p;	void *v;	register_t *retval;{	struct sys_madvise_args /* {		syscallarg(caddr_t) addr;		syscallarg(size_t) len;		syscallarg(int) behav;	} */ *uap = v;	vaddr_t addr;	vsize_t size, pageoff;	int advice, error;	addr = (vaddr_t)SCARG(uap, addr);	size = (vsize_t)SCARG(uap, len);	advice = SCARG(uap, behav);	/*	 * 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 ((ssize_t)size <= 0)		return (EINVAL);	switch (advice) {	case MADV_NORMAL:	case MADV_RANDOM:	case MADV_SEQUENTIAL:		error = uvm_map_advice(&p->p_vmspace->vm_map, addr, addr + size,		    advice);		break;	case MADV_WILLNEED:		/*		 * Activate all these pages, pre-faulting them in if		 * necessary.		 */		/*		 * XXX IMPLEMENT ME.		 * Should invent a "weak" mode for uvm_fault()		 * which would only do the PGO_LOCKED pgo_get().		 */		return (0);	case MADV_DONTNEED:		/*		 * Deactivate all these pages.  We don't need them		 * any more.  We don't, however, toss the data in		 * the pages.		 */		error = uvm_map_clean(&p->p_vmspace->vm_map, addr, addr + size,		    PGO_DEACTIVATE);		break;	case MADV_FREE:		/*		 * These pages contain no valid data, and may be		 * garbage-collected.  Toss all resources, including		 * any swap space in use.		 */		error = uvm_map_clean(&p->p_vmspace->vm_map, addr, addr + size,		    PGO_FREE);		break;	case MADV_SPACEAVAIL:		/*		 * XXXMRG What is this?  I think it's:		 *		 *	Ensure that we have allocated backing-store		 *	for these pages.		 *		 * This is going to require changes to the page daemon,		 * as it will free swap space allocated to pages in core.		 * There's also what to do for device/file/anonymous memory.		 */		return (EINVAL);	default:		return (EINVAL);	}	return error;}