Real.maxFinite bug

Matthew Fluet fluet@CS.Cornell.EDU
Wed, 3 Oct 2001 18:09:44 -0400 (EDT)


> Wouldn't it be easier to just have some assembler file (with the .o in
> libmlton.a) which has the real maxFinite in it?  I'm worried that the way
> you describe PackReal.fromBytes is always going to be in the final executable.

Only if it's not culled by the unused basis removal.

But, I agree with you about the .o file.  I was originally trying to do it
in real.c.

Now, it's trivial to do the following in real.c:

long long const maxPos = 0xF..F;

Then do, in the Real structure of primitives.sml,
	val maxPos = _ffi "Real_maxPos": real;

And then in the Real structure of real.sml
	val maxPos = Primitive.maxPos

(I think the second assignment will allow the value to be fetched once as
a global during initGlobals, rather than each time.)

If it is fetched once, then I guess we will be fine.  My previous
hesitation was that maxPos in real.c doesn't get aligned mod 8.  Nate (my
officemate) and I spent some quality time with Kernighan and Ritchie
trying to figure out how to initalize a union, in the vain hope that:

typedef union {long long l; double d;} ldd;
lld const maxPos = {0xF..F};

would get the right alignment; but gcc doesn't do it right.