This is the mail archive of the mailing list for the GCC project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: GNU Coding Standards -- updated

On 15-Aug-2001, Joe Buck <jbuck@synopsys.COM> wrote:
> On Solaris, for gcc 2.95.2, code from both branches appears, but the
> branch is unconditional (no if-test).  That is, the call to a appears
> in the assembly language code but it is unreachable.
> For gcc 3.0, only the call to b is generated; there is no branch.

When using this technique, some care will be required when writing code with
gcc 3.0 to make sure that it remains portable to gcc 2.95.2 and other C
compilers.  In particular, it's important to ensure that all symbols referenced
in the branches which get optimized out are defined.  So for example
you should continue to use conditional compilation for cases where you call
a function that will be defined on one system but not on other systems.

For example, here's one from read_include_file() in cppfiles.c:

	      if (pagesize == -1)
		pagesize = getpagesize ();

	      if (size / pagesize >= MMAP_THRESHOLD)
		  buf = (U_CHAR *) mmap (0, size, PROT_READ, MAP_PRIVATE, inc->fd, 0);
		  if (buf == (U_CHAR *)-1)
		    goto perror_fail;
		  inc->mapped = 1;

That needs to stay as an `#if' rather than an `if' because some systems don't
define mmap().

Fergus Henderson <>  |  "I have always known that the pursuit
The University of Melbourne         |  of excellence is a lethal habit"
WWW: <>  |     -- the last words of T. S. Garp.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]