delorie.com/archives/browse.cgi | search |
From: | "Tim Van Holder" <tim DOT van DOT holder AT pandora DOT be> |
To: | <djgpp-workers AT delorie DOT com> |
Subject: | Re: memalign hooks (was: LIBM patch for GCC 3.3 - math changes) |
Date: | Wed, 25 Jun 2003 09:05:04 +0200 |
MIME-Version: | 1.0 |
X-Mailer: | Microsoft Outlook, Build 11.0.4920 |
In-reply-to: | <3EF8A24D.9BCD6C6F@phekda.freeserve.co.uk> |
X-MimeOLE: | Produced By Microsoft MimeOLE V6.00.3718.0 |
Thread-Index: | AcM6i5myj3mjrRoJTli+sGEefO7lPgAWvUaA |
Message-Id: | <20030625070545.B47E533DBA7@iceage.anubex.com> |
Reply-To: | djgpp-workers AT delorie DOT com |
Errors-To: | nobody AT delorie DOT com |
X-Mailing-List: | djgpp-workers AT delorie DOT com |
X-Unsubscribes-To: | listserv AT delorie DOT com |
I checked the glibc 2.3.2 code and it has this comment before the memalign prototype: /* memalign(size_t alignment, size_t n); Returns a pointer to a newly allocated chunk of n bytes, aligned in accord with the alignment argument. The alignment argument should be a power of two. If the argument is not a power of two, the nearest greater power is used. 8-byte alignment is guaranteed by normal malloc calls, so don't bother calling memalign with an argument of 8 or less. Overreliance on memalign is a sure way to fragment space. */ The code agrees with this - if the requested alignment is less than that provided by malloc(), the call is forwarded to malloc(). If it is smaller than the minimum size, the minimum size is used instead (this seems an implementation detail of the malloc package used by glibc). Then the alignment size is brought up to a power of two, and normal memalign operation proceeds. memalign also has its own hook function (__memalign_hook) that is called before anything else is done. posix_memalign checks alignment and returns EINVAL instead of increasing alignment and proceeding.
webmaster | delorie software privacy |
Copyright © 2019 by DJ Delorie | Updated Jul 2019 |