[M3devel] what to do about file sizes being 32bits?

Mika Nystrom mika at async.async.caltech.edu
Fri Jan 8 01:31:10 CET 2010


Tony Hosking writes:
>
>--Apple-Mail-29--1022292864
>Content-Transfer-Encoding: quoted-printable
>Content-Type: text/plain;
>	charset=iso-8859-1
>
>On 7 Jan 2010, at 15:33, Jay K wrote:
>
>> I agree it isn't pretty but a big mistake was made many years ago, =
>assuming file sizes are no larger than address spaces,
>> and the current system might also not be so great (not allowing =
>comparing a LONGINT to "0" or assigning it from an INTEGER).
>> This seems to be about the best we can do.
>
>I actually think it is *much* cleaner to have Rd/Wr.T sizes no larger =
>than address spaces.  If someone really wants to use an OS-specific file =
>size that is bigger than an address space then they can use the C =
>interfaces, along with LONGINT.  If they are working with Rd/Wr then =
>they don't need to mess with the ugliness.

Just to add my input to this discussion... 

I have programs that like to write huge log files (> 2GB), and with Wr.PutText
this is a problem.

But it's very easy to work around.  Use the RdWrReset interface implemented as
follows (not sure where I originally got this code from, Blair MacIntyre?):

MODULE RdWrReset;
IMPORT Rd AS R, Wr AS W;
IMPORT RdClass, WrClass;
<*NOWARN*>IMPORT UnsafeWr, UnsafeRd;

(* Since we need to use the Mutex properties of Rd.T and Wr.T, we
   should actually import UnsafeWr and UnsafeRd. We need to add the
   following revelations, as the comment in UnsafeRd points out, if we
   want to include both the Unsafe* and *Class interfaces. *)
REVEAL RdClass.Private <: MUTEX;
REVEAL WrClass.Private <: MUTEX;

PROCEDURE Rd (rd: R.T) =
  BEGIN
    LOCK rd DO DEC(rd.cur, rd.lo); DEC(rd.hi, rd.lo); rd.lo := 0; END;
  END Rd;

PROCEDURE Wr (wr: W.T) =
  BEGIN
    LOCK wr DO DEC(wr.cur, wr.lo); DEC(wr.hi, wr.lo); wr.lo := 0; END;
  END Wr;

BEGIN END RdWrReset.

So far this has sufficed for me...
    Mika



More information about the M3devel mailing list