From 7c455adeee7e1af615a1035a87a918ef24a8e72b Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Sat, 26 Nov 2011 00:24:43 +0100 Subject: [PATCH] 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. --- ChangeLog | 7 +++++++ doc/posix-functions/posix_memalign.texi | 3 +++ lib/pagealign_alloc.c | 3 +++ 3 files changed, 13 insertions(+) diff --git a/ChangeLog b/ChangeLog index 9623f177a4..056a5001f7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2011-11-25 Bruno Haible + + 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 test-update-copyright.sh: avoid false-positive failure diff --git a/doc/posix-functions/posix_memalign.texi b/doc/posix-functions/posix_memalign.texi index 2ffb334545..82455aaff1 100644 --- a/doc/posix-functions/posix_memalign.texi +++ b/doc/posix-functions/posix_memalign.texi @@ -17,3 +17,6 @@ This function is missing on some platforms: 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. diff --git a/lib/pagealign_alloc.c b/lib/pagealign_alloc.c index b40d960df9..cfd301a986 100644 --- a/lib/pagealign_alloc.c +++ b/lib/pagealign_alloc.c @@ -123,6 +123,9 @@ void * 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; -- 2.39.5