From cae7f8650a1ef8810a11daba24d5340d059cfa6f Mon Sep 17 00:00:00 2001 From: Sascha Wildner Date: Thu, 9 Aug 2012 21:15:53 +0200 Subject: [PATCH] posix_memalign.3: Document aligned_alloc(). --- lib/libc/stdlib/Makefile.inc | 1 + lib/libc/stdlib/posix_memalign.3 | 32 +++++++++++++++++++++++++++++--- 2 files changed, 30 insertions(+), 3 deletions(-) diff --git a/lib/libc/stdlib/Makefile.inc b/lib/libc/stdlib/Makefile.inc index a014174a8d..3752d238c7 100644 --- a/lib/libc/stdlib/Makefile.inc +++ b/lib/libc/stdlib/Makefile.inc @@ -47,6 +47,7 @@ MLINKS+=hcreate.3 hdestroy.3 hcreate.3 hsearch.3 MLINKS+=insque.3 remque.3 MLINKS+=lsearch.3 lfind.3 MLINKS+=malloc.3 calloc.3 malloc.3 free.3 malloc.3 realloc.3 malloc.3 reallocf.3 +MLINKS+=posix_memalign.3 aligned_alloc.3 MLINKS+=ptsname.3 grantpt.3 ptsname.3 unlockpt.3 MLINKS+=qsort.3 heapsort.3 qsort.3 mergesort.3 qsort.3 qsort_r.3 MLINKS+=radixsort.3 sradixsort.3 diff --git a/lib/libc/stdlib/posix_memalign.3 b/lib/libc/stdlib/posix_memalign.3 index 5fff120689..050e35857a 100644 --- a/lib/libc/stdlib/posix_memalign.3 +++ b/lib/libc/stdlib/posix_memalign.3 @@ -25,11 +25,12 @@ .\" OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, .\" EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd May 2, 2009 +.Dd August 9, 2012 .Dt POSIX_MEMALIGN 3 .Os .Sh NAME -.Nm posix_memalign +.Nm posix_memalign , +.Nm aligned_alloc .Nd aligned memory allocation .Sh LIBRARY .Lb libc @@ -37,6 +38,8 @@ .In stdlib.h .Ft int .Fn posix_memalign "void **ptr" "size_t alignment" "size_t size" +.Ft void * +.Fn aligned_alloc "size_t alignment" "size_t size" .Sh DESCRIPTION The .Fn posix_memalign @@ -59,6 +62,16 @@ can be used as an argument in subsequent calls to .Xr reallocf 3 , and .Xr free 3 . +.Pp +The +.Fn aligned_alloc +function is the same as +.Fn posix_memalign , +but it takes just +.Fa alignment +and +.Fa size +and the allocation pointer is returned. .Sh IMPLEMENTATION NOTES The .Fn posix_memalign @@ -77,10 +90,19 @@ well-fitted results when the requests are reasonable. The .Fn posix_memalign function returns the value 0 if successful; otherwise it returns an error value. +The +.Fn aligned_alloc +returns a pointer to the allocated memory if successful; otherwise a +.Dv NULL +pointer is returned and +.Va errno +is set. .Sh ERRORS The .Fn posix_memalign -function will fail if: +and +.Fn aligned_alloc +functions will fail if: .Bl -tag -width Er .It Bq Er EINVAL The @@ -101,3 +123,7 @@ The .Fn posix_memalign function conforms to .St -p1003.1-2008 . +.\"The +.\".Fn aligned_alloc +.\"function conforms to +.\".St -isoC-2011 . -- 2.41.0