delorie.com/archives/browse.cgi | search |
X-Authentication-Warning: | delorie.com: mailnull set sender to djgpp-workers-bounces using -f |
Date: | Fri, 08 Feb 2002 10:10:42 +0200 |
From: | "Eli Zaretskii" <eliz AT is DOT elta DOT co DOT il> |
Sender: | halo1 AT zahav DOT net DOT il |
To: | Eric Rudd <rudd AT cyberoptics DOT com> |
Message-Id: | <379-Fri08Feb2002101042+0200-eliz@is.elta.co.il> |
X-Mailer: | emacs 21.2.50 (via feedmail 8 I) and Blat ver 1.8.9 |
CC: | djgpp-workers AT delorie DOT com |
In-reply-to: | <3C629769.AEAFB611@cyberoptics.com> (message from Eric Rudd on |
Thu, 07 Feb 2002 09:04:09 -0600) | |
Subject: | Re: Alignment problem |
References: | <3C629769 DOT AEAFB611 AT cyberoptics DOT 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 |
> Date: Thu, 07 Feb 2002 09:04:09 -0600 > From: Eric Rudd <rudd AT cyberoptics DOT com> > Newsgroups: comp.os.msdos.djgpp [Note that I redirected this to djgopp-workers.] > int main(void) { > void *ptr; > > ptr = malloc(1024); > if (((int) ptr) & 7) { > printf(" ptr %p not 8-byte aligned.\n", ptr); > } else { > printf(" ptr %p 8-byte aligned.\n", ptr); > } > free(ptr); > return 0; > } > > I get output like > > ptr 8f4e4 not 8-byte aligned. > > about half the time. I cannot reproduce this on Windows, but I do get 4-byte aligned pointers on MS-DOS. > I thought that this alignment problem had been solved in gcc 2.95 and > binutils 2.9.1. This has nothing to do with the compiler or Binutils, I think: malloc gets memory from the DPMI server, and then subdivides them into chunks. The alignment of data that's on the heap should be malloc's job. It sounds like malloc doesn't do that, though. Can someone tell where in malloc is the code that should have produced aligned pointers? Am I missing something? Or are you saying that the whole data segment is unaligned?
webmaster | delorie software privacy |
Copyright © 2019 by DJ Delorie | Updated Jul 2019 |