(* --- Patch to the time of day function in Design/CPN Created 13/01/2003 Description: The Design/CPN state space tool relies on the tod () function in the SML base to implement the stop criteria for time. The tod() function returns a 31 bit signed integer representing the number of seconds since January 1, 1970. This will result in an overflow after 1073741823 seconds which is in the beginning of January 2004. The user of the Design/CPN state space tool will see this as the state space generation stopping immediately after the generation has been started. This piece of SML code provides a patch for this problem by redefining the tod () function but preserving its type. The patch is not _the_ proper way of solving the problem, but it is the solution that requires the fewest changes to the SML code. In particular users should note that 1) The patch will not work if you set back the clock of your machine past January 1, 1970 + 1073741823 seconds. 2) It will only fix the tod() function until the early morning of Jannuary 19, 2034 (by then we hope that you have all swicthed to CPN Tools++ 64 bit architectures). 3) You can no longer use the tod () function to compute the absolute time using January 1, 1970 as a base. The base is now January 1, 1970 + 1073741823 seconds. The proper way of fixing the problem would be to have the tod() return a 32bit integer, but that would require changes to a number of files in the state space tool since then the return type of the function changes. The patch can be applied in two ways: 1) Store this file (tod.sml) somewhere on your file system, and insert the following line in the beginning of your global declaration box: use ("/tod.sml"); where is the directory on your file system where you saved the tod.sml file. 2) If you have the access rights required to modify your local Design/CPN installation you can store the file tod.sml in the OGMLfiles directory and modify the OGswitch.sml file by inserting the line: use (ogpath^"tod.sml"); after the line: DSUI_SetStatusBarMessage("Entering Occ Graph..."); --- *) val gettimeofday : unit -> (Int32.int * int) = Unsafe.CInterface.c_function "SMLNJ-Time" "timeofday" fun tod() = let (* max int in SML on 32 bit machines (see Int.maxInt) *); val maxint31 = Int32.fromInt 1073741823 val (secs, _) = gettimeofday() (* convert back into "small integers" to preserve type *) val secs31bit = Int.fromLarge(Int32.-(secs,maxint31)) in secs31bit end