From: Simon Marlow (simonm@dcs.glasgow.ac.uk)
Date: 06/07/92


From: simonm@dcs.glasgow.ac.uk (Simon Marlow)
Subject: Re: gcc2 woes
Date: 7 Jun 1992 12:24:47 GMT

gt7080a@prism.gatech.EDU (Nathan Laredo) writes:

>Stripped a.out filesize: Sequent S81: 8192 bytes
> Linux on my 486DX-33mhz: 9220 bytes

The file size in Linux consists of two 4K pages (one for code, one for
data) most of which will be empty in a short program. Plus a short
a.out file header. I don't know about the sequent's a.out format. You
can make the file a great deal smaller by using -N to link, although
this turns off demand loading on the program (hardly worth it for a
2-page executable anyway :-)

>I suppose that's understandable given that Dynix is an established
>OS with probably better support, but the following is what I found
>most disturbing:

>For those who are not familiar with the Sequent S81, it's a multi-
>processor 386 16Mhz machine. We as lowly students would never be
>allowed however to compile things to work with multiple processors
>or else we'd bring the system to it's knees with a 100+ user load.
>The following is the source followed by the assembler output, which
>I had originally expected to be identical. It was not.

>/* This is a test */

>#include <stdio.h>

>main()
>{
> int i;

> puts("start");
> for (i=0;i<10000000;i++);
> puts("done");
>}

[assembler listings deleted...]

hmmm, seems like puts is defined as a macro in Linux. If we look at
stdio.h we see

#ifdef __OPTIMIZE__
...
#define puts(s) ((fputs((s), stdout) == EOF || \
                                putc('\n', stdout) == EOF) ? EOF : 0)
...
#endif

so puts gets inlined when optimization is turned on, and I think you
will find that the assembler output from Linux is faster than the
Sequent version. The reason that the Sequent version works in Linux is
that puts is also in the library (this version gets used when
optimization is turned off, and is required for POSIX I think):

int puts(const char *s)
{
  return(fputs(s, stdout) == EOF || putchar('\n') == EOF ? EOF : 0);
}

So in fact the Linux setup is more flexible than the Sequent. If you
don't like this inlining you can always '#undef puts', which should
give you the same output as the Sequent.

>-Nathan Laredo
>-- >Nathan Laredo |begin 600 mean.msg.Z >Georgia
Institute of Technology |@'YV06V)T`;$"!`@B;]R4,<BPH<.'<MJ`:"''#`@3"@``
>Box 37080 |` >Atlanta, Georgia, 30332 |end

Cheers,
        Simon