[M3devel] INTEGER

Tony Hosking hosking at cs.purdue.edu
Sun Apr 18 04:40:20 CEST 2010


On 17 Apr 2010, at 22:35, Mika Nystrom wrote:

> Ok, sorry if I am beating a dead horse here.
> 
> What is INTEGER on a 64-bit machine? 

The language spec doesn't say, but CM3 pretty strongly assumes BITSIZE(INTEGER)=BITSIZE(ADDRESS).
So, that means 64 bits.

> Modula-3 doesn't specify it to be one or the other does it?
> But normally, 64 bits?
> 
> I am asking because I was looking through some stub generator code,
> and I'm really wondering about the LONGINT.  Now there are "longcard"
> things showing up, which means another set of changes to a lot of code.
> 
> The rationale for LONGINT is, again?

Yes, LONGINT is to permit longer than "efficient" INTEGER.  Mainly for 32 bit machines where we'd like to have a C "long long" equivalent.

> We need it to match 64-bit integers on 32-bit machines?  That seems like
> a very weak rationale indeed, if the same functionality could be provided
> through some other mechanism (e.g., ARRAY [0..1] OF INTEGER---even with
> a pragma e.g. <*CLONGLONG*>.. if it is necessary to tell the compiler that
> a special linkage convention is needed).

There's no special linkage convention.  Not sure what you mean here.

> On a 64-bit machine INTEGER and CARDINAL are 64/63 bits (right?), so
> there is really no need for LONGINT there.

True.  The only expectation is BITSIZE(LONGINT) >= BITSIZE(INTEGER).

> And having an array with a LONGINT index seems silly since you can't
> address more memory than you can fit in an INTEGER anyhow...

We don't allow arrays with LONGINT indexes in the current implementation.

> 
>    Mika
> 
>> ________________________________
>> From: hosking at cs.purdue.edu
>> Date: Thu, 15 Apr 2010 12:55:52 -0400
>> To: jay.krell at cornell.edu
>> CC: m3devel at elegosoft.com
>> Subject: Re: [M3devel] Modula-3/C interop in Date/Time?
>> Excepting that INTEGER is not the same as int on 64-bit platforms.
>> 
>> Antony Hosking | Associate Professor | Computer Science | Purdue University
>> 305 N. University Street | West Lafayette | IN 47907 | USA
>> Office +1 765 494 6001 | Mobile +1 765 427 5484
>> 
>> 
>> 
>> 
>> On 15 Apr 2010, at 02:45, Jay K wrote:
>> 
>> Is this legal/correct?
>> 
>> 
>> Date.i3:
>> TYPE TimeZone <: REFANY;
>> VAR Local, UTC: TimeZone; (* granted, will maybe change these to extern *)
>> 
>> 
>> Date.m3:=1B$B!!=1B(B
>> REVEAL TimeZone =3D BRANDED "Date.TimeZone" REF INTEGER;
>> =1B$B!!=1B(B
>> 
>> DatePosixC.c:
>> static const int Local =3D 0;
>> static const int UTC =3D 1;
>> extern const int const * const Date__Local =3D &Local;
>> extern const int const * const Date__UTC =3D &UTC;
>> =1B$B!!=1B(B
>> 
>> - Jay

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://m3lists.elegosoft.com/pipermail/m3devel/attachments/20100417/5566ddf3/attachment-0002.html>


More information about the M3devel mailing list