delorie.com/archives/browse.cgi | search |
X-Authentication-Warning: | delorie.com: mailnull set sender to djgpp-workers-bounces using -f |
Date: | Sat, 9 Feb 2002 07:34:30 -0500 |
Message-Id: | <200202091234.g19CYUV17283@envy.delorie.com> |
From: | DJ Delorie <dj AT delorie DOT com> |
To: | djgpp-workers AT delorie DOT com |
In-reply-to: | <9003-Sat09Feb2002090616+0200-eliz@is.elta.co.il> |
Subject: | Re: Alignment problem |
References: | <3C629769 DOT AEAFB611 AT cyberoptics DOT com> <379-Fri08Feb2002101042+0200-eliz AT is DOT elta DOT co DOT il> <200202081420 DOT g18EKWb06863 AT envy DOT delorie DOT com> <7872-Fri08Feb2002203948+0200-eliz AT is DOT elta DOT co DOT il> <200202081853 DOT g18IrgO08699 AT envy DOT delorie DOT com> <9003-Sat09Feb2002090616+0200-eliz AT is DOT elta DOT co DOT il> |
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'm not sure I understand this: what is the ``required'' alignment > for a buffer that is 8 bytes large or larger? Isn't the required > alignment for these buffers 8-byte alignment? That is, if I malloc a > double, shouldn't I expect to get a double aligned on 8-byte boundary? What it means is that the pointer returned will be sufficiently aligned so that it can be used as a pointer to any possible data type the CPU supports without causing a misalignment exception. For example, on a sparc you must have at least 4-byte alignment or you can't use the pointer to store an "int". I don't know if the x86 has any memory access opcodes that *require* an aligned address. If it does, then the returned pointer must be at least that aligned. Malloc doesn't know the difference between allocating 8 bytes for a double, or for 8 chars. And since you can always realloc a buffer, I don't think we can rely on the size of the allocation to determine what kinds of data types will be used with it.
webmaster | delorie software privacy |
Copyright © 2019 by DJ Delorie | Updated Jul 2019 |