pty: Activate the signature wrapper of forkpty.
[gnulib.git] / lib / pagealign_alloc.h
1 /* Memory allocation aligned to system page boundaries.
2
3    Copyright (C) 2005, 2008, 2010-2013 Free Software Foundation, Inc.
4
5    This program is free software: you can redistribute it and/or modify
6    it under the terms of the GNU General Public License as published by
7    the Free Software Foundation; either version 3 of the License, or
8    (at your option) any later version.
9
10    This program is distributed in the hope that it will be useful,
11    but WITHOUT ANY WARRANTY; without even the implied warranty of
12    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13    GNU General Public License for more details.
14
15    You should have received a copy of the GNU General Public License
16    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
17
18 #ifndef _PAGEALIGN_ALLOC_H
19 # define _PAGEALIGN_ALLOC_H
20
21 # include <stddef.h>
22
23 /* Allocate a block of memory of SIZE bytes, aligned on a system page
24    boundary.
25    If SIZE is not a multiple of the system page size, it will be rounded up
26    to the next multiple.
27    Return a pointer to the start of the memory block. Upon allocation failure,
28    return NULL and set errno.  */
29 extern void *pagealign_alloc (size_t size)
30 # if __GNUC__ >= 3
31      __attribute__ ((__malloc__))
32 #  if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
33      __attribute__ ((__alloc_size__ (1)))
34 #  endif
35 # endif
36      ;
37
38 /* Like pagealign_alloc, except it exits the program if the allocation
39    fails.  */
40 extern void *pagealign_xalloc (size_t size)
41 # if __GNUC__ >= 3
42      __attribute__ ((__malloc__))
43 #  if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
44      __attribute__ ((__alloc_size__ (1)))
45 #  endif
46 # endif
47      ;
48
49 /* Free a memory block.
50    PTR must be a non-NULL pointer returned by pagealign_alloc or
51    pagealign_xalloc.  */
52 extern void pagealign_free (void *ptr);
53
54 #endif /* _PAGEALIGN_ALLOC_H */