[MLton] Type cleanup for 64bit port (was: sparc works)

Wesley W. Terpstra terpstra@gkec.tu-darmstadt.de
Thu, 23 Dec 2004 21:57:00 +0100

On Thu, Dec 23, 2004 at 12:25:42PM -0800, Stephen Weeks wrote:
> > If we take this approach we should be very disciplined in the runtime to
> > immediately cast the parameter to the correct C type. Otherwise, macros
> > and variable-argument functions may run amock. 
> This makes perfect sense.
> It might be good to put asserts somewhere in the runtime that verify
> our assumptions about the relationships between SML types and C types.
> For example, right now we would write
> 	assert (sizeof (pid_t) == sizeof (Pid));

So, how will this preamble generator work?

It needs to generate typedefs for C (and those asserts) and the type
aliases/wrappers for SML. To do it's job it will need to know the list
of all the types the SML compiler knows and also all the C types the
runtime needs. It also needs to be able to use sizeof() on types.

This has to happen before the first build of MLton, right?
In fact, before even the compile of the runtime.

Aside from just the POSIX types (pid_t, uid_t, etc), I think we should 
also do the same for the types needed in gc.c. Things like counters,
array sizes, etc should have some distinct types we pick. ullong is not
a meaningful type! grrr :-)

> and once we sanitize the runtime code as you did for waitpid we would
> change that to
> 	assert (sizeof (pid_t) <= sizeof (Pid));

Yeah... I just like to avoid programming styles which require the developer
to remember to look after something. That's why I like SML so much. =)

Wesley W. Terpstra