Path: utzoo!utgpu!news-server.csri.toronto.edu!bonnie.concordia.ca!uunet!mcsun!hp4nl!phigate!philica!adrie From: adrie@philica.ica.philips.nl (Adrie Koolen) Newsgroups: comp.os.minix Subject: Re: #! in MM -- take 2 Message-ID: <819@philica.ica.philips.nl> Date: 28 May 91 09:04:23 GMT References: <10033@star.cs.vu.nl> <10055@star.cs.vu.nl> <1991May24.164952.22295@Arco.COM> Reply-To: adrie@beitel.ica.philips.nl (Adrie Koolen) Organization: Philips TDS, Innovation Centre Aachen Lines: 51 In article <1991May24.164952.22295@Arco.COM> dprrhb@inetg1.ARCO.COM (Reginald H. Beardsley) writes: > It is not the alignment of the characters that matters, it is the >alignment of the adjacent full word values that matters. This means that >in addition to starting the string on a word boundary, to needs to be >padded to a multiple of the word length. For SPARC this will need to be >4 bytes. Even on systems that will tolerate the misalignment, there are >very significant performance penalties for breaking the alignment. I compiled a program containing: char s1[] = ""; char s2[] = "a"; char s3[] = "ab"; char s4[] = "abc"; char s5[] = "abcd"; char s6[] = "abcde"; ... printf("%08x, %08x, %08x, %08x, %08x, %08x.\n", s1, s2, s3, s4, s5, s6); on a SparcStation. The Sun C compiler aligned all strings to word addresses: 000040a8, 000040ac, 000040b0, 000040b4, 000040b8, 000040c0. while the GNU C compiler put all strings one after the other without aligning anything: 000040a8, 000040a9, 000040ab, 000040ae, 000040b2, 000040b7. It looks like string alignment is not necessary in ANSI C. But then again, maybe I missed your point. Anyway, Minix-Sparc generates with the following program: main(int argc, char *argv[]) { int i; for (i=0; i