changeset 16121:d2f39a0d2549

pagealign_alloc: Doc and comments. * doc/posix-functions/posix_memalign.texi: Refer to the pagealign_alloc module. * lib/pagealign_alloc.c (pagealign_alloc): Add comment.
author Bruno Haible <bruno@clisp.org>
date Sat, 26 Nov 2011 00:24:43 +0100
parents ff91f9a60967
children e3e8e2fc21a9
files ChangeLog doc/posix-functions/posix_memalign.texi lib/pagealign_alloc.c
diffstat 3 files changed, 13 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2011-11-25  Bruno Haible  <bruno@clisp.org>
+
+	pagealign_alloc: Doc and comments.
+	* doc/posix-functions/posix_memalign.texi: Refer to the pagealign_alloc
+	module.
+	* lib/pagealign_alloc.c (pagealign_alloc): Add comment.
+
 2011-11-25  Jim Meyering  <meyering@redhat.com>
 
 	test-update-copyright.sh: avoid false-positive failure
--- a/doc/posix-functions/posix_memalign.texi
+++ b/doc/posix-functions/posix_memalign.texi
@@ -17,3 +17,6 @@
 MacOS X 10.5, FreeBSD 6.0, NetBSD 3.0, OpenBSD 3.8, Minix 3.1.8, AIX 5.1, HP-UX 11,
 IRIX 6.5, OSF/1 5.1, Solaris 10, Cygwin 1.5.x, mingw, MSVC 9, Interix 3.5, BeOS.
 @end itemize
+
+The Gnulib module @code{pagealign_alloc} provides a similar API
+that returns memory aligned on a system page boundary.
--- a/lib/pagealign_alloc.c
+++ b/lib/pagealign_alloc.c
@@ -123,6 +123,9 @@
 pagealign_alloc (size_t size)
 {
   void *ret;
+  /* We prefer the mmap() approach over the posix_memalign() or malloc()
+     based approaches, since the latter often waste an entire memory page
+     per call.  */
 #if HAVE_MMAP
 # ifdef HAVE_MAP_ANONYMOUS
   const int fd = -1;