2N/A * The contents of this file are subject to the terms of the 2N/A * Common Development and Distribution License (the "License"). 2N/A * You may not use this file except in compliance with the License. 2N/A * See the License for the specific language governing permissions 2N/A * and limitations under the License. 2N/A * When distributing Covered Code, include this CDDL HEADER in each 2N/A * If applicable, add the following below this CDDL HEADER, with the 2N/A * fields enclosed by brackets "[]" replaced with your own identifying 2N/A * information: Portions Copyright [yyyy] [name of copyright owner] 2N/A * Copyright (c) 2002, 2012, Oracle and/or its affiliates. All rights reserved. 2N/A * The structure of the sbrk backend: 2N/A * | (vmem_sbrk_alloc(), vmem_free()) 2N/A * | | ... | (vmem_alloc(), vmem_free()) 2N/A * The sbrk_top arena holds all controlled memory. vmem_sbrk_alloc() handles 2N/A * allocations from it, including growing the heap when we run low. 2N/A * Growing the heap is complicated by the fact that we have to extend the 2N/A * sbrk_top arena (using _vmem_extend_alloc()), and that can fail. Since 2N/A * other threads may be actively allocating, we can't return the memory. 2N/A * Instead, we put it on a doubly-linked list, sbrk_fails, which we search 2N/A * before calling sbrk(). 2N/A * Try to extend src with [pos, pos + size). 2N/A * If it fails, add the block to the sbrk_fails list. 2N/A * Try to add at least size bytes to src, using the sbrk_fails list 2N/A * nothing of the right size on the freelist 2N/A * The allocation failed. We need to grow the heap. 2N/A * First, try to use any buffers which failed earlier. 2N/A * buf_size gets overwritten with the actual allocated size 2N/A * Growing the heap failed. The vmem_alloc() above called umem_reap(). 2N/A /* validate vmem_sbrk_minalloc */