annotate lib/pagealign_alloc.h @ 6912:314715e0260d

Merge from coreutils.
author Paul Eggert <eggert@cs.ucla.edu>
date Mon, 03 Jul 2006 08:32:46 +0000
parents a48fb0e98c8c
children bbbbbf4cd1c5
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
5673
dbfd56933568 New module 'pagealign_alloc'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
1 /* Memory allocation aligned to system page boundaries.
dbfd56933568 New module 'pagealign_alloc'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
2
dbfd56933568 New module 'pagealign_alloc'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
3 Copyright (C) 2005 Free Software Foundation, Inc.
dbfd56933568 New module 'pagealign_alloc'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
4
dbfd56933568 New module 'pagealign_alloc'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
5 This program is free software; you can redistribute it and/or modify it
dbfd56933568 New module 'pagealign_alloc'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
6 under the terms of the GNU General Public License as published
dbfd56933568 New module 'pagealign_alloc'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
7 by the Free Software Foundation; either version 2, or (at your option)
dbfd56933568 New module 'pagealign_alloc'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
8 any later version.
dbfd56933568 New module 'pagealign_alloc'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
9
dbfd56933568 New module 'pagealign_alloc'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
10 This program is distributed in the hope that it will be useful,
dbfd56933568 New module 'pagealign_alloc'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
dbfd56933568 New module 'pagealign_alloc'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
dbfd56933568 New module 'pagealign_alloc'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
13 General Public License for more details.
dbfd56933568 New module 'pagealign_alloc'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
14
dbfd56933568 New module 'pagealign_alloc'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
15 You should have received a copy of the GNU General Public
dbfd56933568 New module 'pagealign_alloc'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
16 License along with this program; if not, write to the Free Software
5848
a48fb0e98c8c *** empty log message ***
Paul Eggert <eggert@cs.ucla.edu>
parents: 5678
diff changeset
17 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
5673
dbfd56933568 New module 'pagealign_alloc'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
18 USA. */
dbfd56933568 New module 'pagealign_alloc'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
19
dbfd56933568 New module 'pagealign_alloc'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
20 #ifndef _PAGEALIGN_ALLOC_H
dbfd56933568 New module 'pagealign_alloc'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
21 # define _PAGEALIGN_ALLOC_H
dbfd56933568 New module 'pagealign_alloc'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
22
dbfd56933568 New module 'pagealign_alloc'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
23 # include <stddef.h>
dbfd56933568 New module 'pagealign_alloc'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
24
dbfd56933568 New module 'pagealign_alloc'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
25 /* Allocate a block of memory of SIZE bytes, aligned on a system page
dbfd56933568 New module 'pagealign_alloc'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
26 boundary.
dbfd56933568 New module 'pagealign_alloc'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
27 If SIZE is not a multiple of the system page size, it will be rounded up
dbfd56933568 New module 'pagealign_alloc'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
28 to the next multiple.
5678
6868adf039ec Note pagealign_alloc() sets errno on failure.
Bruno Haible <bruno@clisp.org>
parents: 5675
diff changeset
29 Return a pointer to the start of the memory block. Upon allocation failure,
6868adf039ec Note pagealign_alloc() sets errno on failure.
Bruno Haible <bruno@clisp.org>
parents: 5675
diff changeset
30 return NULL and set errno. */
5673
dbfd56933568 New module 'pagealign_alloc'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
31 extern void *pagealign_alloc (size_t size);
dbfd56933568 New module 'pagealign_alloc'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
32
5675
9fb0004d9fa6 Check or don't check for allocation failure? Provide both alternatives.
Bruno Haible <bruno@clisp.org>
parents: 5673
diff changeset
33 /* Like pagealign_alloc, except it exits the program if the allocation
9fb0004d9fa6 Check or don't check for allocation failure? Provide both alternatives.
Bruno Haible <bruno@clisp.org>
parents: 5673
diff changeset
34 fails. */
9fb0004d9fa6 Check or don't check for allocation failure? Provide both alternatives.
Bruno Haible <bruno@clisp.org>
parents: 5673
diff changeset
35 extern void *pagealign_xalloc (size_t size);
9fb0004d9fa6 Check or don't check for allocation failure? Provide both alternatives.
Bruno Haible <bruno@clisp.org>
parents: 5673
diff changeset
36
5673
dbfd56933568 New module 'pagealign_alloc'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
37 /* Free a memory block.
5675
9fb0004d9fa6 Check or don't check for allocation failure? Provide both alternatives.
Bruno Haible <bruno@clisp.org>
parents: 5673
diff changeset
38 PTR must be a non-NULL pointer returned by pagealign_alloc or
9fb0004d9fa6 Check or don't check for allocation failure? Provide both alternatives.
Bruno Haible <bruno@clisp.org>
parents: 5673
diff changeset
39 pagealign_xalloc. */
5673
dbfd56933568 New module 'pagealign_alloc'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
40 extern void pagealign_free (void *ptr);
dbfd56933568 New module 'pagealign_alloc'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
41
dbfd56933568 New module 'pagealign_alloc'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
42 #endif /* _PAGEALIGN_ALLOC_H */