Go to:
Gentoo Home
Documentation
Forums
Lists
Bugs
Planet
Store
Wiki
Get Gentoo!
Gentoo's Bugzilla – Attachment 97536 Details for
Bug 148351
x11-apps/mesa-progs tries to use not-available posix_memalign
Home
|
New
–
[Ex]
|
Browse
|
Search
|
Privacy Policy
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
posix_memalign.patch
freebsd-lib-6.1-posixmemalign.patch (text/plain), 4.30 KB, created by
Victor Roman Archidona
on 2006-09-20 05:31:43 UTC
(
hide
)
Description:
posix_memalign.patch
Filename:
MIME Type:
Creator:
Victor Roman Archidona
Created:
2006-09-20 05:31:43 UTC
Size:
4.30 KB
patch
obsolete
>diff -uNr include.orig/stdlib.h include/stdlib.h >--- include.orig/stdlib.h 2006-09-20 16:23:32 +0200 >+++ include/stdlib.h 2006-09-20 16:24:01 +0200 >@@ -157,7 +157,7 @@ > * research can be done. > */ > #if __POSIX_VISIBLE /* >= ??? */ >-/* int posix_memalign(void **, size_t, size_t); (ADV) */ >+int posix_memalign(void **, size_t, size_t); /* (ADV) */ > int rand_r(unsigned *); /* (TSF) */ > int setenv(const char *, const char *, int); > void unsetenv(const char *); >diff -uNr lib.orig/libc/stdlib/Makefile.inc lib/libc/stdlib/Makefile.inc >--- lib.orig/libc/stdlib/Makefile.inc 2006-09-20 16:23:44 +0200 >+++ lib/libc/stdlib/Makefile.inc 2006-09-20 16:23:56 +0200 >@@ -44,5 +44,5 @@ > MLINKS+=strtol.3 strtoll.3 strtol.3 strtoq.3 strtol.3 strtoimax.3 > MLINKS+=strtoul.3 strtoull.3 strtoul.3 strtouq.3 strtoul.3 strtoumax.3 > MLINKS+=malloc.3 calloc.3 malloc.3 free.3 malloc.3 malloc.conf.5 \ >- malloc.3 realloc.3 malloc.3 reallocf.3 >+ malloc.3 realloc.3 malloc.3 reallocf.3 malloc.3 posix_memalign.3 > MLINKS+=tsearch.3 tdelete.3 tsearch.3 tfind.3 tsearch.3 twalk.3 >diff -uNr lib.orig/libc/stdlib/malloc.3 lib/libc/stdlib/malloc.3 >--- lib.orig/libc/stdlib/malloc.3 2006-09-20 16:23:44 +0200 >+++ lib/libc/stdlib/malloc.3 2006-09-20 16:23:56 +0200 >@@ -36,11 +36,11 @@ > .\" @(#)malloc.3 8.1 (Berkeley) 6/4/93 > .\" $FreeBSD: src/lib/libc/stdlib/malloc.3,v 1.63 2005/01/20 09:17:04 ru Exp $ > .\" >-.Dd August 19, 2004 >+.Dd October 16, 2005 > .Dt MALLOC 3 > .Os > .Sh NAME >-.Nm malloc , calloc , realloc , free , reallocf >+.Nm malloc , calloc , realloc , free , reallocf , posix_memalign > .Nd general purpose memory allocation functions > .Sh LIBRARY > .Lb libc >@@ -54,6 +54,8 @@ > .Fn realloc "void *ptr" "size_t size" > .Ft void * > .Fn reallocf "void *ptr" "size_t size" >+.Ft int >+.Fn posix_memalign "void **ptr" "size_t alignment" "size_t size" > .Ft void > .Fn free "void *ptr" > .Ft const char * >@@ -148,6 +150,19 @@ > for realloc causing memory leaks in libraries. > .Pp > The >+.Fn posix_memalign >+function allocates >+.Fa size >+bytes aligned on a boundary specified by >+.Fa alignment >+and places the address of the allocated memory in >+.Fa ptr . >+The value of >+.Fa alignment >+must be a power of two and a multiple of >+.Fn sizeof "void *" . >+.Pp >+The > .Fn free > function causes the allocated memory referenced by > .Fa ptr >@@ -276,6 +291,18 @@ > .Er ENOMEM . > .Pp > The >+.Fn posix_memalign >+function returns zero on success, >+.Er EINVAL >+if the >+.Fa alignment >+parameter was not a power of two, or was not a multiple of >+.Fn sizeof "void *" . >+Note that >+.Va errno >+is not set. >+.Pp >+The > .Fn realloc > and > .Fn reallocf >@@ -363,7 +390,8 @@ > If > .Fn malloc , > .Fn calloc , >-.Fn realloc >+.Fn realloc , >+.Fn posix_memalign > or > .Fn free > detect an error or warning condition, >@@ -480,6 +508,11 @@ > .Fn free > functions conform to > .St -isoC . >+.Pp >+The >+.Fn posix_memalign >+function conforms to >+.St -p1003.1-2001 . > .Sh HISTORY > The present allocation implementation started out as a file system for a > drum attached to a 20bit binary challenged computer which was built >@@ -493,8 +526,18 @@ > .Fn reallocf > function first appeared in > .Fx 3.0 . >+.Pp >+The >+.Fn posix_memalign >+function first appeared in >+.Fx 7.0 . > .Sh AUTHORS > .An Poul-Henning Kamp Aq phk@FreeBSD.org >+.Pp >+The >+.Fn posix_memalign >+function was added by >+.An Sergey Matveychuk Aq sem@FreeBSD.org > .Sh BUGS > The messages printed in case of problems provide no detail about the > actual values. >diff -uNr lib.orig/libc/stdlib/malloc.c lib/libc/stdlib/malloc.c >--- lib.orig/libc/stdlib/malloc.c 2006-09-20 16:23:44 +0200 >+++ lib/libc/stdlib/malloc.c 2006-09-20 16:23:56 +0200 >@@ -1164,3 +1164,25 @@ > return (pubrealloc(ptr, size, " in realloc():")); > } > >+#define POWEROF2(x) ((((x)-1)&(x))==0) >+ >+int >+posix_memalign(void **ptr, size_t alignment, size_t size) >+{ >+ void *p1; >+ int err; >+ >+ if (alignment % sizeof(void *) || !POWEROF2(alignment)) >+ return(EINVAL); >+ >+ p1 = pubrealloc(NULL, (size+alignment-1) & ~(alignment-1), >+ " in posix_memalign():"); >+ if(p1) { >+ *ptr = p1; >+ return (0); >+ } else { >+ err = errno; >+ errno = 0; >+ return (err); >+ } >+}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 148351
: 97536