[MLton] cvs commit: C types now distinguish between signed and unsigned words

Matthew Fluet fluet@cs.cornell.edu
Thu, 13 Jan 2005 15:54:16 -0500 (EST)


> sweeks      04/09/06 17:46:20
>
>   Log:
>   MAIL C types now distinguish between signed and unsigned words
>
>   This distinction is necessary because on some platforms the calling
>   convention for signeds and unsigneds is different.  This can happen
>   when a small word (e.g. 8 bit) is represented in a larger word
>   (e.g. 32 bit), in which case the signed version will be passed sign
>   extended and the unsigned version will be passed zero extended.

I don't believe that this modification had the intended effect.  In
particular, while we correctly distinguish between signed and unsigned
words for primitives, we do not do so for _import-ed functions.  I believe
this is a consequence of aggressively synonym replacement in the
front-end.  As an example, consider:

z.sml:

val my_quot = _import "my_quot": Int8.int * Int8.int -> Int8.int;

val args = CommandLine.arguments ();
val x = valOf (Int8.fromString (List.nth (args, 0)))
val y = valOf (Int8.fromString (List.nth (args, 1)))

val z = Int8.quot (x, y)
val my_z = my_quot (x, y)

val () =
   print (concat ["   z = ", Int8.toString z, "\n",
		  "my_z = ", Int8.toString z, "\n"])

Compiling with -keep g -codegen c, I see:

z.1.c:
...
Int8 WordS8_quot (Int8 x1, Int8 x0);
Word8 my_quot (Word8 x1, Word8 x0);
...