[MLton-user] Posix.Process.exece on MinGW
Dave Herman
dherman at ccs.neu.edu
Wed May 30 05:37:17 PDT 2007
The MLton.World.load call uses Posix.Process.exece to restart the
program with the special @MLton commands to load a world file, but in
MinGW this isn't implemented.
I started trying to hack it in myself but ran up against my limited
understanding of the MLton internals and the difficulty of hacking and
recompiling the whole compiler (which takes a long time on my laptop).
I thought I'd report on my progress, and maybe Vesa or someone else can
pick up where I left off.
I was trying to use the Win32 API functions documented here:
http://msdn2.microsoft.com/en-us/library/20y988d2(VS.71).aspx
In basis-library/platform/mingw.sml, I added:
val exece = PrimitiveFFI.MinGW.exece
and in runtime/gen/basis-ffi.def I added:
MinGW.exece = _import : NullString8.t * String8.t * C_Pointer.t array *
C_Size.t vector * String8.t * C_Pointer.t array * C_Size.t vector ->
C_Int.t C_Errno.t
and then in basis-library/posix/stub-mingw.sml I changed
PrimitiveFFI.Process.exece to:
val exece = if let open Primitive.MLton.Platform.OS in MinGW = host end
then MinGW.exece
else exece
Then in runtime/platform/mingw.c I added a new function:
C_Errno_t(C_Int_t) MinGW_exece (NullString8_t pNStr,
String8_t aStr,
Array(C_Pointer_t) aPtr,
Vector(C_Size_t) aOff,
String8_t eStr,
Array(C_Pointer_t) ePtr,
Vector(C_Size_t) eOff) {
...
}
I originally tried to implement this function as a shim for _execve in
the Win32 API, and I tried copying the logic from
runtime/basis/Posix/Process/exece.c, but there were issues with spaces
in arguments.
At this point I'm so lost in the many layers of abstraction that I
really don't know how all this fits together. :) Hopefully this is of use,
Thanks,
Dave
More information about the MLton-user
mailing list