186d7f5d3SJohn Marino /* Memory allocation aligned to system page boundaries. 286d7f5d3SJohn Marino 386d7f5d3SJohn Marino Copyright (C) 2005 Free Software Foundation, Inc. 486d7f5d3SJohn Marino 586d7f5d3SJohn Marino This program is free software; you can redistribute it and/or modify it 686d7f5d3SJohn Marino under the terms of the GNU General Public License as published 786d7f5d3SJohn Marino by the Free Software Foundation; either version 2, or (at your option) 886d7f5d3SJohn Marino any later version. 986d7f5d3SJohn Marino 1086d7f5d3SJohn Marino This program is distributed in the hope that it will be useful, 1186d7f5d3SJohn Marino but WITHOUT ANY WARRANTY; without even the implied warranty of 1286d7f5d3SJohn Marino MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 1386d7f5d3SJohn Marino General Public License for more details. 1486d7f5d3SJohn Marino 1586d7f5d3SJohn Marino You should have received a copy of the GNU General Public 1686d7f5d3SJohn Marino License along with this program; if not, write to the Free Software 1786d7f5d3SJohn Marino Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 1886d7f5d3SJohn Marino USA. */ 1986d7f5d3SJohn Marino 2086d7f5d3SJohn Marino #ifndef _PAGEALIGN_ALLOC_H 2186d7f5d3SJohn Marino # define _PAGEALIGN_ALLOC_H 2286d7f5d3SJohn Marino 2386d7f5d3SJohn Marino # include <stddef.h> 2486d7f5d3SJohn Marino 2586d7f5d3SJohn Marino /* Allocate a block of memory of SIZE bytes, aligned on a system page 2686d7f5d3SJohn Marino boundary. 2786d7f5d3SJohn Marino If SIZE is not a multiple of the system page size, it will be rounded up 2886d7f5d3SJohn Marino to the next multiple. 2986d7f5d3SJohn Marino Return a pointer to the start of the memory block. Upon allocation failure, 3086d7f5d3SJohn Marino return NULL and set errno. */ 3186d7f5d3SJohn Marino extern void *pagealign_alloc (size_t size); 3286d7f5d3SJohn Marino 3386d7f5d3SJohn Marino /* Like pagealign_alloc, except it exits the program if the allocation 3486d7f5d3SJohn Marino fails. */ 3586d7f5d3SJohn Marino extern void *pagealign_xalloc (size_t size); 3686d7f5d3SJohn Marino 3786d7f5d3SJohn Marino /* Free a memory block. 3886d7f5d3SJohn Marino PTR must be a non-NULL pointer returned by pagealign_alloc or 3986d7f5d3SJohn Marino pagealign_xalloc. */ 4086d7f5d3SJohn Marino extern void pagealign_free (void *ptr); 4186d7f5d3SJohn Marino 4286d7f5d3SJohn Marino #endif /* _PAGEALIGN_ALLOC_H */ 43