(***************************************************************************

     $RCSfile: TimerUtil.mod $
  Description: Support for clients of timer.device

   Created by: fjc (Frank Copeland)
    $Revision: 3.2 $
      $Author: fjc $
        $Date: 1994/08/08 16:09:29 $

  Copyright © 1994, Frank Copeland.
  This file is part of the Oberon-A Library.
  See Oberon-A.doc for conditions of use and distribution.

***************************************************************************)

MODULE TimerUtil;

(*
** $C- CaseChk       $I- IndexChk  $L+ LongAdr   $N- NilChk
** $P- PortableCode  $R- RangeChk  $S- StackChk  $T- TypeChk
** $V- OvflChk       $Z- ZeroVars
*)

IMPORT E := Exec, EU := ExecUtil, Ti := Timer;

(*------------------------------------*)
(*
 * An AmigaDOS 1.3 implementation of the AmigaDOS 2.0+ function.  Based on
 * an example in the 2nd edition RKM:Libraries and Devices.
 *)
PROCEDURE GetSysTime *
  ( req : Ti.TimeRequestPtr; VAR dest : Ti.TimeVal );

  VAR port : E.MsgPortPtr; result : SHORTINT;

BEGIN (* GetSysTime *)
  dest.secs := 0; dest.micro := 0; port := NIL;
  IF req.replyPort = NIL THEN
    port := EU.CreatePort ("", 0);
    IF port # NIL THEN req.replyPort := port
    ELSE RETURN
    END
  END;
  req.type := E.ntMessage;
  req.pri := 0;
  req.name := NIL;
  req.command := Ti.getSysTime;
  result := E.base.DoIO (req);
  dest := req.time;
  IF port # NIL THEN EU.DeletePort (port) END
END GetSysTime;

END TimerUtil.
