Fw: Re: [RFC/PATCH] Updated: ppc64: Add mem=X option
Michael Ellerman
michael at ellerman.id.au
Thu Mar 17 17:36:24 EST 2005
On Thu, 17 Mar 2005 16:52, Anton Blanchard wrote:
> > +unsigned long prom_memparse(const char *ptr, const char **retptr)
> > +{
> > + unsigned long ret = prom_strtoul(ptr, retptr);
> > +
> > + switch (**retptr) {
> > + case 'G':
> > + case 'g':
> > + ret <<= 10;
> > + case 'M':
> > + case 'm':
> > + ret <<= 10;
> > + case 'K':
> > + case 'k':
> > + ret <<= 10;
> > + (*retptr)++;
> > + default:
> > + break;
> > + }
> > + return ret;
> > +}
> >
> > I get following exception with the above switch statement in place.
>
> That makes me think gcc is using a particular switch statement
> optimisation. You create a table indexed by the switch values (or part of
> them). This table contains target addresses for the particular switch
> case. You throw it in the count register then do a bctr.
>
> Come to think of it, Im not sure how this optimisation can be safe
> before we copy the kernel down.
Thanks for the bug report Maneesh, you're right about the compiler.
Anton's right, GCC 3.3 uses a switch table whereas 3.4 doesn't.
The bad news is I can't find anyway to turn it off, there doesn't seem to be
an individual option for it, and not even -O0 disables it.
The only other place we use a switch statement in prom_init.c is prom_printf()
but that doesn't generate a switch table (although one day it might?). I
guess I'll just change my code to use a couple of if's.
cheers
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://ozlabs.org/pipermail/linuxppc64-dev/attachments/20050317/e8c1ffa4/attachment.pgp
More information about the Linuxppc64-dev
mailing list