FreeBSD/sys/kern/subr_vmem.c
/*
 * vmem_clip:  Trim the boundary tag edges to the requested start and size.
 */
Trim the boundary tag edges to the requested start and size.
Trim the boundary tag edges to the requested start and size .
static void
vmem_clip(vmem_t *vm, bt_t *bt, vmem_addr_t start, vmem_size_t size)
{
	bt_t *btnew;
	bt_t *btprev;
	VMEM_ASSERT_LOCKED(vm);
	MPASS(bt->bt_type == BT_TYPE_FREE);
	MPASS(bt->bt_size >= size);
	bt_remfree(vm, bt);
	if (bt->bt_start != start) {
		btprev = bt_alloc(vm);
		btprev->bt_type = BT_TYPE_FREE;
		btprev->bt_start = bt->bt_start;
		btprev->bt_size = start - bt->bt_start;
		bt->bt_start = start;
		bt->bt_size -= btprev->bt_size;
		bt_insfree(vm, btprev);
		bt_insseg(vm, btprev,
		    TAILQ_PREV(bt, vmem_seglist, bt_seglist));
	}
	MPASS(bt->bt_start == start);
	if (bt->bt_size != size && bt->bt_size - size > vm->vm_quantum_mask) {
		btnew = bt_alloc(vm);
		btnew->bt_type = BT_TYPE_BUSY;
		btnew->bt_start = bt->bt_start;
		btnew->bt_size = size;
		bt->bt_start = bt->bt_start + size;
		bt->bt_size -= size;
		bt_insfree(vm, bt);
		bt_insseg(vm, btnew,
		    TAILQ_PREV(bt, vmem_seglist, bt_seglist));
		bt_insbusy(vm, btnew);
		bt = btnew;
	} else {
		bt->bt_type = BT_TYPE_BUSY;
		bt_insbusy(vm, bt);
	}
	MPASS(bt->bt_size >= size);
	bt->bt_type = BT_TYPE_BUSY;
}
static void vmem_clip ( vmem_t * vm , bt_t * bt , vmem_addr_t start , vmem_size_t size ) { bt_t * btnew ; bt_t * btprev ; VMEM_ASSERT_LOCKED ( vm ) ; MPASS ( bt -> bt_type == BT_TYPE_FREE ) ; MPASS ( bt -> bt_size >= size ) ; bt_remfree ( vm , bt ) ; if ( bt -> bt_start != start ) { btprev = bt_alloc ( vm ) ; btprev -> bt_type = BT_TYPE_FREE ; btprev -> bt_start = bt -> bt_start ; btprev -> bt_size = start - bt -> bt_start ; bt -> bt_start = start ; bt -> bt_size -= btprev -> bt_size ; bt_insfree ( vm , btprev ) ; bt_insseg ( vm , btprev , TAILQ_PREV ( bt , vmem_seglist , bt_seglist ) ) ; } MPASS ( bt -> bt_start == start ) ; if ( bt -> bt_size != size && bt -> bt_size - size > vm -> vm_quantum_mask ) { btnew = bt_alloc ( vm ) ; btnew -> bt_type = BT_TYPE_BUSY ; btnew -> bt_start = bt -> bt_start ; btnew -> bt_size = size ; bt -> bt_start = bt -> bt_start + size ; bt -> bt_size -= size ; bt_insfree ( vm , bt ) ; bt_insseg ( vm , btnew , TAILQ_PREV ( bt , vmem_seglist , bt_seglist ) ) ; bt_insbusy ( vm , btnew ) ; bt = btnew ; } else { bt -> bt_type = BT_TYPE_BUSY ; bt_insbusy ( vm , bt ) ; } MPASS ( bt -> bt_size >= size ) ; bt -> bt_type = BT_TYPE_BUSY ; }
vmem_clip:  Trim the boundary tag edges to the requested start and size.
vmem_clip : Trim the boundary tag edges to the requested start and size .
/* split */