[MLton-commit] r6404

Matthew Fluet fluet at mlton.org
Thu Feb 14 10:13:44 PST 2008


Integrate Wesley Teprstra's pid not int patch:

 The old windows bindings for spawn assumed that it returns an int. However, it is
 actually returning a pid. This causes problems for win64, but was wrong for win32 as
 well.

Only minor changes from the original patch.
The "pid-not-int" actually refers to two aspects:
 * the spawn* functions return a pid, not an int.
 * fix a simple type error when C_PId.t <> C_Int.t


----------------------------------------------------------------------

U   mlton/trunk/basis-library/posix/proc-env.sml
U   mlton/trunk/basis-library/primitive/basis-ffi.sml
U   mlton/trunk/runtime/basis/MLton/Process/spawne.c
U   mlton/trunk/runtime/basis/MLton/Process/spawnp.c
U   mlton/trunk/runtime/basis-ffi.h
U   mlton/trunk/runtime/gen/basis-ffi.def
U   mlton/trunk/runtime/gen/basis-ffi.h
U   mlton/trunk/runtime/gen/basis-ffi.sml

----------------------------------------------------------------------

Modified: mlton/trunk/basis-library/posix/proc-env.sml
===================================================================
--- mlton/trunk/basis-library/posix/proc-env.sml	2008-02-14 17:04:57 UTC (rev 6403)
+++ mlton/trunk/basis-library/posix/proc-env.sml	2008-02-14 18:13:42 UTC (rev 6404)
@@ -33,7 +33,9 @@
          val setuid = fn uid => SysCall.simple (fn () => setuid uid)
       end
 
-      fun setsid () = SysCall.simpleResult (Prim.setsid)
+      fun setsid () = 
+        SysCall.simpleResult' 
+        ({errVal = C_PId.castFromFixedInt ~1}, Prim.setsid)
 
       val uidToWord = C_UId.castToSysWord
       val wordToUid = C_UId.castFromSysWord

Modified: mlton/trunk/basis-library/primitive/basis-ffi.sml
===================================================================
--- mlton/trunk/basis-library/primitive/basis-ffi.sml	2008-02-14 17:04:57 UTC (rev 6403)
+++ mlton/trunk/basis-library/primitive/basis-ffi.sml	2008-02-14 18:13:42 UTC (rev 6404)
@@ -80,8 +80,8 @@
 structure Process = 
 struct
 val cwait = _import "MLton_Process_cwait" : C_PId.t * (C_Status.t) ref -> (C_PId.t) C_Errno.t;
-val spawne = _import "MLton_Process_spawne" : 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;
-val spawnp = _import "MLton_Process_spawnp" : NullString8.t * String8.t * (C_Pointer.t) array * (C_Size.t) vector -> (C_Int.t) C_Errno.t;
+val spawne = _import "MLton_Process_spawne" : NullString8.t * String8.t * (C_Pointer.t) array * (C_Size.t) vector * String8.t * (C_Pointer.t) array * (C_Size.t) vector -> (C_PId.t) C_Errno.t;
+val spawnp = _import "MLton_Process_spawnp" : NullString8.t * String8.t * (C_Pointer.t) array * (C_Size.t) vector -> (C_PId.t) C_Errno.t;
 end
 structure Rlimit = 
 struct

Modified: mlton/trunk/runtime/basis/MLton/Process/spawne.c
===================================================================
--- mlton/trunk/runtime/basis/MLton/Process/spawne.c	2008-02-14 17:04:57 UTC (rev 6403)
+++ mlton/trunk/runtime/basis/MLton/Process/spawne.c	2008-02-14 18:13:42 UTC (rev 6404)
@@ -2,7 +2,7 @@
 
 #if HAS_SPAWN
 
-C_Errno_t(C_Int_t) MLton_Process_spawne (NullString8_t pNStr,
+C_Errno_t(C_PId_t) MLton_Process_spawne (NullString8_t pNStr,
                                          String8_t aStr, 
                                          Array(C_Pointer_t) aPtr,
                                          Vector(C_Size_t) aOff,
@@ -14,7 +14,7 @@
   char            **env;
   int             aLen;
   int             eLen;
-  int             res;
+  C_PId_t         res;
 
   path = (const char *) pNStr;
   args = (char **) aPtr;
@@ -32,13 +32,13 @@
   res = spawnve (SPAWN_MODE, path, 
                  (const char * const *)args,
                  (const char * const *)env);
-  return res;
+  return (C_Errno_t(C_PId_t))res;
 }
 
 #else
 
 __attribute__ ((noreturn))
-C_Errno_t(C_Int_t) MLton_Process_spawne (__attribute__ ((unused))NullString8_t pNStr,
+C_Errno_t(C_PId_t) MLton_Process_spawne (__attribute__ ((unused))NullString8_t pNStr,
                                          __attribute__ ((unused))String8_t aStr, 
                                          __attribute__ ((unused))Array(C_Pointer_t) aPtr,
                                          __attribute__ ((unused))Vector(C_Size_t) aOff,

Modified: mlton/trunk/runtime/basis/MLton/Process/spawnp.c
===================================================================
--- mlton/trunk/runtime/basis/MLton/Process/spawnp.c	2008-02-14 17:04:57 UTC (rev 6403)
+++ mlton/trunk/runtime/basis/MLton/Process/spawnp.c	2008-02-14 18:13:42 UTC (rev 6404)
@@ -2,14 +2,14 @@
 
 #if HAS_SPAWN
 
-C_Errno_t(C_Int_t) MLton_Process_spawnp (NullString8_t pNStr, 
+C_Errno_t(C_PId_t) MLton_Process_spawnp (NullString8_t pNStr, 
                                          String8_t aStr,
                                          Array(C_Pointer_t) aPtr,
                                          Vector(C_Size_t) aOff) {
   const char      *path;
   char            **args;
   int             aLen;
-  int             res;
+  C_PId_t         res;
 
   path = (const char *) pNStr;
   args = (char **) aPtr;
@@ -20,13 +20,13 @@
   args[aLen - 1] = NULL;
   res = spawnvp (SPAWN_MODE, path, 
                  (const char * const *)args);
-  return (C_Errno_t(C_Int_t))res;
+  return (C_Errno_t(C_PId_t))res;
 }
 
 #else
 
 __attribute__ ((noreturn))
-C_Errno_t(C_Int_t) MLton_Process_spawnp (__attribute__ ((unused)) NullString8_t pNStr, 
+C_Errno_t(C_PId_t) MLton_Process_spawnp (__attribute__ ((unused)) NullString8_t pNStr, 
                                          __attribute__ ((unused)) String8_t aStr,
                                          __attribute__ ((unused)) Array(C_Pointer_t) aPtr,
                                          __attribute__ ((unused)) Vector(C_Size_t) aOff) {

Modified: mlton/trunk/runtime/basis-ffi.h
===================================================================
--- mlton/trunk/runtime/basis-ffi.h	2008-02-14 17:04:57 UTC (rev 6403)
+++ mlton/trunk/runtime/basis-ffi.h	2008-02-14 18:13:42 UTC (rev 6404)
@@ -51,8 +51,8 @@
 C_Errno_t(C_Int_t) MLton_Itimer_set(C_Int_t,C_Time_t,C_SUSeconds_t,C_Time_t,C_SUSeconds_t);
 extern const C_Int_t MLton_Itimer_VIRTUAL;
 C_Errno_t(C_PId_t) MLton_Process_cwait(C_PId_t,Ref(C_Status_t));
-C_Errno_t(C_Int_t) MLton_Process_spawne(NullString8_t,String8_t,Array(C_Pointer_t),Vector(C_Size_t),String8_t,Array(C_Pointer_t),Vector(C_Size_t));
-C_Errno_t(C_Int_t) MLton_Process_spawnp(NullString8_t,String8_t,Array(C_Pointer_t),Vector(C_Size_t));
+C_Errno_t(C_PId_t) MLton_Process_spawne(NullString8_t,String8_t,Array(C_Pointer_t),Vector(C_Size_t),String8_t,Array(C_Pointer_t),Vector(C_Size_t));
+C_Errno_t(C_PId_t) MLton_Process_spawnp(NullString8_t,String8_t,Array(C_Pointer_t),Vector(C_Size_t));
 extern const C_Int_t MLton_Rlimit_AS;
 extern const C_Int_t MLton_Rlimit_CORE;
 extern const C_Int_t MLton_Rlimit_CPU;

Modified: mlton/trunk/runtime/gen/basis-ffi.def
===================================================================
--- mlton/trunk/runtime/gen/basis-ffi.def	2008-02-14 17:04:57 UTC (rev 6403)
+++ mlton/trunk/runtime/gen/basis-ffi.def	2008-02-14 18:13:42 UTC (rev 6404)
@@ -43,8 +43,8 @@
 MLton.Itimer.VIRTUAL = _const : C_Int.t
 MLton.Itimer.set = _import : C_Int.t * C_Time.t * C_SUSeconds.t * C_Time.t * C_SUSeconds.t -> C_Int.t C_Errno.t
 MLton.Process.cwait = _import : C_PId.t * C_Status.t ref -> C_PId.t C_Errno.t
-MLton.Process.spawne = _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
-MLton.Process.spawnp = _import : NullString8.t * String8.t * C_Pointer.t array * C_Size.t vector -> C_Int.t C_Errno.t
+MLton.Process.spawne = _import : NullString8.t * String8.t * C_Pointer.t array * C_Size.t vector * String8.t * C_Pointer.t array * C_Size.t vector -> C_PId.t C_Errno.t
+MLton.Process.spawnp = _import : NullString8.t * String8.t * C_Pointer.t array * C_Size.t vector -> C_PId.t C_Errno.t
 MLton.Rlimit.AS = _const : C_Int.t
 MLton.Rlimit.CORE = _const : C_Int.t
 MLton.Rlimit.CPU = _const : C_Int.t

Modified: mlton/trunk/runtime/gen/basis-ffi.h
===================================================================
--- mlton/trunk/runtime/gen/basis-ffi.h	2008-02-14 17:04:57 UTC (rev 6403)
+++ mlton/trunk/runtime/gen/basis-ffi.h	2008-02-14 18:13:42 UTC (rev 6404)
@@ -51,8 +51,8 @@
 C_Errno_t(C_Int_t) MLton_Itimer_set(C_Int_t,C_Time_t,C_SUSeconds_t,C_Time_t,C_SUSeconds_t);
 extern const C_Int_t MLton_Itimer_VIRTUAL;
 C_Errno_t(C_PId_t) MLton_Process_cwait(C_PId_t,Ref(C_Status_t));
-C_Errno_t(C_Int_t) MLton_Process_spawne(NullString8_t,String8_t,Array(C_Pointer_t),Vector(C_Size_t),String8_t,Array(C_Pointer_t),Vector(C_Size_t));
-C_Errno_t(C_Int_t) MLton_Process_spawnp(NullString8_t,String8_t,Array(C_Pointer_t),Vector(C_Size_t));
+C_Errno_t(C_PId_t) MLton_Process_spawne(NullString8_t,String8_t,Array(C_Pointer_t),Vector(C_Size_t),String8_t,Array(C_Pointer_t),Vector(C_Size_t));
+C_Errno_t(C_PId_t) MLton_Process_spawnp(NullString8_t,String8_t,Array(C_Pointer_t),Vector(C_Size_t));
 extern const C_Int_t MLton_Rlimit_AS;
 extern const C_Int_t MLton_Rlimit_CORE;
 extern const C_Int_t MLton_Rlimit_CPU;

Modified: mlton/trunk/runtime/gen/basis-ffi.sml
===================================================================
--- mlton/trunk/runtime/gen/basis-ffi.sml	2008-02-14 17:04:57 UTC (rev 6403)
+++ mlton/trunk/runtime/gen/basis-ffi.sml	2008-02-14 18:13:42 UTC (rev 6404)
@@ -80,8 +80,8 @@
 structure Process = 
 struct
 val cwait = _import "MLton_Process_cwait" : C_PId.t * (C_Status.t) ref -> (C_PId.t) C_Errno.t;
-val spawne = _import "MLton_Process_spawne" : 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;
-val spawnp = _import "MLton_Process_spawnp" : NullString8.t * String8.t * (C_Pointer.t) array * (C_Size.t) vector -> (C_Int.t) C_Errno.t;
+val spawne = _import "MLton_Process_spawne" : NullString8.t * String8.t * (C_Pointer.t) array * (C_Size.t) vector * String8.t * (C_Pointer.t) array * (C_Size.t) vector -> (C_PId.t) C_Errno.t;
+val spawnp = _import "MLton_Process_spawnp" : NullString8.t * String8.t * (C_Pointer.t) array * (C_Size.t) vector -> (C_PId.t) C_Errno.t;
 end
 structure Rlimit = 
 struct




More information about the MLton-commit mailing list