X-Authentication-Warning: delorie.com: mailnull set sender to djgpp-bounces using -f Message-ID: <0BA32251E589D2118EA60008C70DDCAB025F91A5@JNJFRISEXS1.eu.jnj.com> From: "Baribaud, Christophe [JNJFR]" To: "'djgpp AT delorie DOT com'" Subject: RE: Alignment problem Date: Fri, 8 Feb 2002 10:50:33 +0100 MIME-Version: 1.0 X-Mailer: Internet Mail Service (5.5.2653.19) Content-Type: multipart/alternative; boundary="----_=_NextPart_001_01C1B086.0CD69420" Reply-To: djgpp AT delorie DOT com This message is in MIME format. Since your mail reader does not understand this format, some or all of this message may not be legible. ------_=_NextPart_001_01C1B086.0CD69420 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable >> If gcc's library permits this (and I don't believe so) it is not the = =3D >> case for other C compilers. >This has nothing to do with the compiler: malloc is implemented in >the library. Yes, of course, but what I wanted to explain is that it is generally dangerous to assume that malloc returns aligned memory when writing = portable code. I haven't heard about a standard, libc is one of the possible libraries implementing malloc. -----Message d'origine----- De : Eli Zaretskii [mailto:eliz AT is DOT elta DOT co DOT il] Envoy=E9 : vendredi 8 f=E9vrier 2002 09:06 =C0 : djgpp AT delorie DOT com Objet : Re: Alignment problem > From: "Baribaud, Christophe [JNJFR]" > Date: Fri, 8 Feb 2002 07:23:47 +0100=20 >=20 > It seems that you consider that malloc should return an aligned =3D > pointer. It has never been the case... Of course, it was. malloc should return a buffer aligned on 8-byte boundary for any allocation whose size is greater than 8. Even if some other impementations of malloc don't guarantee that (I think most if not all do), the DJGPP implementation should, since the x86 processors impose a significant penalty on unaligned accesses. > If gcc's library permits this (and I don't believe so) it is not the = =3D > case for other C compilers. This has nothing to do with the compiler: malloc is implemented in the library. ------_=_NextPart_001_01C1B086.0CD69420 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable RE: Alignment problem

>> If gcc's library permits this (and I don't = believe so) it is not the =3D
>> case for other C compilers.

>This has nothing to do with the compiler: malloc = is implemented in
>the library.

Yes, of course, but what I wanted to explain is that = it is generally dangerous to assume that malloc returns aligned memory = when writing portable code. I haven't heard about a standard, libc is = one of the possible libraries implementing malloc.

-----Message d'origine-----
De : Eli Zaretskii [mailto:eliz AT is DOT elta DOT co DOT il]=
Envoy=E9 : vendredi 8 f=E9vrier 2002 09:06
=C0 : djgpp AT delorie DOT com
Objet : Re: Alignment problem


> From: "Baribaud, Christophe [JNJFR]" = <CBARIBAU AT jnjfr DOT JNJ DOT com>
> Date: Fri, 8 Feb 2002 07:23:47 +0100
>
> It seems that you consider that malloc should = return an aligned =3D
> pointer. It has never been the case...

Of course, it was.  malloc should return a = buffer aligned on 8-byte
boundary for any allocation whose size is greater = than 8.  Even if
some other impementations of malloc don't guarantee = that (I think
most if not all do), the DJGPP implementation = should, since the x86
processors impose a significant penalty on unaligned = accesses.

> If gcc's library permits this (and I don't = believe so) it is not the =3D
> case for other C compilers.

This has nothing to do with the compiler: malloc is = implemented in
the library.

------_=_NextPart_001_01C1B086.0CD69420--