[MLton-commit] r5488

Matthew Fluet fluet at mlton.org
Thu Mar 29 11:44:15 PST 2007


Patch from Nicolas Bertolotti (PolySpace).

- bug-fix-times-mingw.patch

This patch is designed to avoid raising an exception during the
initialization of the basis library on MinGW when the code contains calls to
the "times" function which are not detected as dead code during compilation.
Then, if the "times" function is called, the exception will be raised from
the location of the call which is easier to understand from a user's point
of view.


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

U   mlton/trunk/basis-library/posix/proc-env.sml

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

Modified: mlton/trunk/basis-library/posix/proc-env.sml
===================================================================
--- mlton/trunk/basis-library/posix/proc-env.sml	2007-03-29 19:37:47 UTC (rev 5487)
+++ mlton/trunk/basis-library/posix/proc-env.sml	2007-03-29 19:44:14 UTC (rev 5488)
@@ -224,13 +224,19 @@
       local
          structure Times = Prim.Times
 
-         val ticksPerSec = SysWord.toLargeIntX (sysconf "CLK_TCK")
+         val clocksPerSec = 
+            (* syconf is not implemented on MinGW; 
+             * we don't want a SysErr during Basis Library initialization. 
+             *)
+            if (let open Primitive.MLton.Platform.OS in host = MinGW end)
+               then LargeInt.fromInt 0
+            else SysWord.toLargeIntX (sysconf "CLK_TCK")
 
-         fun cvt (ticks: C_Clock.t) =
+         fun cvt (clocks: C_Clock.t) =
             Time.fromTicks (LargeInt.quot
-                            (LargeInt.* (C_Clock.toLargeInt ticks,
+                            (LargeInt.* (C_Clock.toLargeInt clocks,
                                          Time.ticksPerSecond),
-                             ticksPerSec))
+                             clocksPerSec))
       in
          fun times () =
             SysCall.syscall'




More information about the MLton-commit mailing list