2 * UCW Library -- Allocation of Large Aligned Buffers
4 * (c) 2006 Martin Mares <mj@ucw.cz>
6 * This software may be freely distributed and used according to the terms
7 * of the GNU Lesser General Public License.
16 big_round(unsigned int len)
18 return ALIGN_TO(len, PAGE_SIZE);
22 big_alloc(unsigned int len)
28 byte *p = mmap(NULL, len, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANON, -1, 0);
29 if (p == (byte*) MAP_FAILED)
30 die("Cannot mmap %d bytes of memory: %m", len);
32 mprotect(p, PAGE_SIZE, PROT_NONE);
33 mprotect(p+len-PAGE_SIZE, PAGE_SIZE, PROT_NONE);
40 big_free(void *start, unsigned int len)
43 ASSERT(!((addr_int_t) p & (PAGE_SIZE-1)));
56 byte *p = big_alloc(123456);