Style(9) changes.
Pointed out by: bde
This commit is contained in:
parent
ce8660e395
commit
f0ea4612ef
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=127008
@ -183,29 +183,19 @@ useracc(addr, len, rw)
|
||||
return (rv == TRUE);
|
||||
}
|
||||
|
||||
/*
|
||||
* MPSAFE
|
||||
*/
|
||||
int
|
||||
vslock(addr, len)
|
||||
void *addr;
|
||||
size_t len;
|
||||
vslock(void *addr, size_t len)
|
||||
{
|
||||
vm_offset_t start, end;
|
||||
vm_offset_t end, start;
|
||||
int error, npages;
|
||||
|
||||
start = trunc_page((vm_offset_t)addr);
|
||||
end = round_page((vm_offset_t)addr + len);
|
||||
|
||||
/* disable wrap around */
|
||||
if (end <= start)
|
||||
return (EINVAL);
|
||||
|
||||
npages = atop(end - start);
|
||||
|
||||
if (npages > vm_page_max_wired)
|
||||
return (ENOMEM);
|
||||
|
||||
PROC_LOCK(curproc);
|
||||
if (npages + pmap_wired_count(vm_map_pmap(&curproc->p_vmspace->vm_map)) >
|
||||
atop(lim_cur(curproc, RLIMIT_MEMLOCK))) {
|
||||
@ -213,7 +203,6 @@ vslock(addr, len)
|
||||
return (ENOMEM);
|
||||
}
|
||||
PROC_UNLOCK(curproc);
|
||||
|
||||
#if 0
|
||||
/*
|
||||
* XXX - not yet
|
||||
@ -227,10 +216,8 @@ vslock(addr, len)
|
||||
if (npages + cnt.v_wire_count > vm_page_max_wired)
|
||||
return (EAGAIN);
|
||||
#endif
|
||||
|
||||
error = vm_map_wire(&curproc->p_vmspace->vm_map, start, end,
|
||||
VM_MAP_WIRE_USER|VM_MAP_WIRE_NOHOLES);
|
||||
|
||||
VM_MAP_WIRE_USER | VM_MAP_WIRE_NOHOLES);
|
||||
/*
|
||||
* Return EFAULT on error to match copy{in,out}() behaviour
|
||||
* rather than returning ENOMEM like mlock() would.
|
||||
@ -238,19 +225,14 @@ vslock(addr, len)
|
||||
return (error == KERN_SUCCESS ? 0 : EFAULT);
|
||||
}
|
||||
|
||||
/*
|
||||
* MPSAFE
|
||||
*/
|
||||
void
|
||||
vsunlock(addr, len)
|
||||
void *addr;
|
||||
size_t len;
|
||||
vsunlock(void *addr, size_t len)
|
||||
{
|
||||
|
||||
/* Rely on the parameter sanity checks performed by vslock(). */
|
||||
(void)vm_map_unwire(&curproc->p_vmspace->vm_map,
|
||||
trunc_page((vm_offset_t)addr), round_page((vm_offset_t)addr + len),
|
||||
VM_MAP_WIRE_SYSTEM|VM_MAP_WIRE_NOHOLES);
|
||||
VM_MAP_WIRE_SYSTEM | VM_MAP_WIRE_NOHOLES);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -893,29 +893,24 @@ mlock(td, uap)
|
||||
struct thread *td;
|
||||
struct mlock_args *uap;
|
||||
{
|
||||
struct proc *proc = td->td_proc;
|
||||
vm_offset_t addr, start, end;
|
||||
struct proc *proc;
|
||||
vm_offset_t addr, end, start;
|
||||
vm_size_t size;
|
||||
int error, npages;
|
||||
|
||||
error = suser(td);
|
||||
if (error)
|
||||
return (error);
|
||||
|
||||
addr = (vm_offset_t)uap->addr;
|
||||
size = uap->len;
|
||||
start = trunc_page(addr);
|
||||
end = round_page(addr + size);
|
||||
|
||||
/* disable wrap around */
|
||||
if (end <= start)
|
||||
return (EINVAL);
|
||||
|
||||
npages = atop(end - start);
|
||||
|
||||
if (npages > vm_page_max_wired)
|
||||
return (ENOMEM);
|
||||
|
||||
proc = td->td_proc;
|
||||
PROC_LOCK(proc);
|
||||
if (npages + pmap_wired_count(vm_map_pmap(&proc->p_vmspace->vm_map)) >
|
||||
atop(lim_cur(proc, RLIMIT_MEMLOCK))) {
|
||||
@ -923,12 +918,10 @@ mlock(td, uap)
|
||||
return (ENOMEM);
|
||||
}
|
||||
PROC_UNLOCK(proc);
|
||||
|
||||
if (npages + cnt.v_wire_count > vm_page_max_wired)
|
||||
return (EAGAIN);
|
||||
|
||||
error = vm_map_wire(&proc->p_vmspace->vm_map, start, end,
|
||||
VM_MAP_WIRE_USER|VM_MAP_WIRE_NOHOLES);
|
||||
VM_MAP_WIRE_USER | VM_MAP_WIRE_NOHOLES);
|
||||
return (error == KERN_SUCCESS ? 0 : ENOMEM);
|
||||
}
|
||||
|
||||
@ -1043,25 +1036,21 @@ munlock(td, uap)
|
||||
struct thread *td;
|
||||
struct munlock_args *uap;
|
||||
{
|
||||
vm_offset_t addr, start, end;
|
||||
vm_offset_t addr, end, start;
|
||||
vm_size_t size;
|
||||
int error;
|
||||
|
||||
error = suser(td);
|
||||
if (error)
|
||||
return (error);
|
||||
|
||||
addr = (vm_offset_t)uap->addr;
|
||||
size = uap->len;
|
||||
start = trunc_page(addr);
|
||||
end = round_page(addr + size);
|
||||
|
||||
/* disable wrap around */
|
||||
if (end <= start)
|
||||
return (EINVAL);
|
||||
|
||||
error = vm_map_unwire(&td->td_proc->p_vmspace->vm_map, start, end,
|
||||
VM_MAP_WIRE_USER|VM_MAP_WIRE_NOHOLES);
|
||||
VM_MAP_WIRE_USER | VM_MAP_WIRE_NOHOLES);
|
||||
return (error == KERN_SUCCESS ? 0 : ENOMEM);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user