Home My Page Projects Code Snippets Project Openings SML/NJ
Summary Activity Forums Tracker Lists Tasks Docs Surveys News SCM Files

SCM Repository

[smlnj] View of /sml/trunk/src/eXene/lib/protocol/xtime.sml
ViewVC logotype

View of /sml/trunk/src/eXene/lib/protocol/xtime.sml

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1188 - (download) (annotate)
Wed Apr 17 15:17:31 2002 UTC (17 years, 2 months ago) by jhr
File size: 1101 byte(s)
  XTime bug fix and new scrollbar implementation from Allen Stoughton.
(* xtime.sml
 *
 * COPYRIGHT (c) 1995 AT&T Bell Laboratories.
 *
 * An abstract interface to server time values.
 *)

structure XTime : sig

    datatype time = XT of Word32.word

    val toReal : time -> real

    val + : (time * time) -> time
    val - : (time * time) -> time

    val <  : (time * time) -> bool
    val <= : (time * time) -> bool
    val >  : (time * time) -> bool
    val >= : (time * time) -> bool

  end = struct

  (* X time values are 32-bit values in milliseconds since the server was booted
   * and they wrap around every 49.7 days.
   *)
    datatype time = XT of Word32.word

    fun binOp rator (XT t1, XT t2) = XT(rator(t1, t2))
    fun cmpOp rator (XT t1, XT t2) = rator(t1, t2)

    fun toReal (XT w) = let
	  fun cvt w = if (w >= 0wx40000000)
		then cvt(w - 0wx40000000) + 1073741824.0
		else Real.fromInt(Word32.toInt w)
	  in
	    cvt w
	  end

    val (op +) = binOp Word32.+
    val (op -) = binOp Word32.-

    val (op <)  = cmpOp Word32.<
    val (op <=) = cmpOp Word32.<=
    val (op >)  = cmpOp Word32.>
    val (op >=) = cmpOp Word32.>=

  end (* XTime *)


root@smlnj-gforge.cs.uchicago.edu
ViewVC Help
Powered by ViewVC 1.0.0