[M3devel] Getting IsLittleEndian as a Modula-3 CONST
Rodney M. Bates
rodney_bates at lcwb.coop
Fri May 31 04:37:07 CEST 2013
On 05/28/2013 01:17 AM, Jay K wrote:
> > >> I know this can be done using m3makefiles and the build system, but I
> > >> am hoping someone can point to a place where it already exists. I need
>
>
> We already do expose this, TARGET_ENDIAN, via m3makefile as you allude.
> See here:
> http://modula3.elegosoft.com/cgi-bin/cvsweb.cgi/cm3/m3-libs/m3core/src/float/m3makefile?rev=1.38;content-type=text%2Fplain
>
>
> Also a good place to expose this would be here:
> http://modula3.elegosoft.com/cgi-bin/cvsweb.cgi/cm3/m3-libs/m3core/src/runtime/common/m3makefile?rev=1.34;content-type=text%2Fplain
> => http://modula3.elegosoft.com/cgi-bin/cvsweb.cgi/cm3/m3-libs/m3core/src/runtime/common/Compiler.tmpl
> => Compiler.ThisEndian or such.
>
>
> Why do you need it?
> Very little code cares about this sort of thing, and you can usually figure it out easily enough portably at runtime.
>
Yeah, I can do it at runtime, but that means it has to be stored in variables.
For a given compile, this will never change, and I have some potentially high-
frequency paths that I want to squeeze out as much execution time as possible,
especially array subscripts derived from endianness. I want to get it and
things derived from it in constants.
>
> - Jay
>
>
>
>
>
> > Date: Sun, 26 May 2013 21:02:21 -0500
> > From: rodney_bates at lcwb.coop
> > To: m3devel at elegosoft.com
> > Subject: Re: [M3devel] Getting IsLittleEndian as a Modula-3 CONST
> >
> > Yes. And so says Modula-3, 2.6.15, Constant Expressions.
> > ADR isn't legal in constant expressions either.
> >
> > On 05/26/2013 02:54 PM, Dragiša Durić wrote:
> > > My first idea (very fast&dirty) was
> > >
> > > CONST
> > > BigEndian = LOOPHOLE(1, ARRAY[0..7] OF BITS 8 FOR [0..255])[0] = 0;
> > >
> > > But this is not constant expression, so says cm3 :).
> > >
> > > --
> > > Dragiša Durić
> > > dragisha at m3w.org <mailto:dragisha at m3w.org>
> > >
> > >
> > >
> > > On May 26, 2013, at 8:47 PM, Rodney M. Bates wrote:
> > >
> > >> I know this can be done using m3makefiles and the build system, but I
> > >> am hoping someone can point to a place where it already exists. I need
> > >> a Module-3 CONST that tells endianness of the machine we are running
> > >> on, that is available to code in m3core.
> > >
> >
More information about the M3devel
mailing list