mirror of
https://github.com/vishapoberon/compiler.git
synced 2026-04-06 15:42:25 +00:00
oocSysClock now don't use C calls, but use Unix.Mod instead.
Unix.Mod modified, Gettimeofday now returns value.
Kernel.Mod modified in order to conform to Unix.Mod new interface
Former-commit-id: 13da72a3ac
This commit is contained in:
parent
8b8f4591be
commit
ad9eb05779
8 changed files with 30 additions and 48 deletions
BIN
ocat
BIN
ocat
Binary file not shown.
|
|
@ -1 +1 @@
|
||||||
af2514a8aa2a2c1b4d24cf77214f36265162340c
|
3c9d1b6124de30d09fec587e5f99eb4b34653feb
|
||||||
|
|
@ -1,25 +1,5 @@
|
||||||
(* $Id: SysClock.Mod,v 1.7 1999/09/02 13:42:24 acken Exp $ *)
|
MODULE oocSysClock;
|
||||||
MODULE oocSysClock(* [FOREIGN "C"; LINK FILE "SysClock.c" END]*);
|
IMPORT Unix;
|
||||||
IMPORT SYSTEM;
|
|
||||||
(* SysClock - facilities for accessing a system clock that records the
|
|
||||||
date and time of day.
|
|
||||||
Copyright (C) 1996-1998 Michael Griebling
|
|
||||||
|
|
||||||
This module is free software; you can redistribute it and/or modify
|
|
||||||
it under the terms of the GNU Lesser General Public License as
|
|
||||||
published by the Free Software Foundation; either version 2 of the
|
|
||||||
License, or (at your option) any later version.
|
|
||||||
|
|
||||||
This module is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU Lesser General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU Lesser General Public
|
|
||||||
License along with this program; if not, write to the Free Software
|
|
||||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
||||||
*)
|
|
||||||
(*<* Warnings := FALSE *>*)
|
|
||||||
|
|
||||||
CONST
|
CONST
|
||||||
maxSecondParts* = 999; (* Most systems have just millisecond accuracy *)
|
maxSecondParts* = 999; (* Most systems have just millisecond accuracy *)
|
||||||
|
|
@ -65,19 +45,15 @@ TYPE
|
||||||
inactive. *)
|
inactive. *)
|
||||||
END;
|
END;
|
||||||
|
|
||||||
PROCEDURE -includeTime()
|
|
||||||
"#include <time.h>";
|
|
||||||
|
|
||||||
PROCEDURE -includeiSysTime()
|
|
||||||
"#include <sys/time.h>";
|
|
||||||
|
|
||||||
|
|
||||||
PROCEDURE -cangetclock() : BOOLEAN
|
|
||||||
"struct timeval t; return (BOOLEAN)(gettimeofday(&t, NULL) == 0);";
|
|
||||||
(*
|
|
||||||
PROCEDURE CanGetClock*(): BOOLEAN;
|
PROCEDURE CanGetClock*(): BOOLEAN;
|
||||||
(* Returns TRUE if a system clock can be read; FALSE otherwise. *)
|
(* Returns TRUE if a system clock can be read; FALSE otherwise. *)
|
||||||
*)
|
VAR timeval: Unix.Timeval; timezone: Unix.Timezone;
|
||||||
|
l : LONGINT;
|
||||||
|
BEGIN
|
||||||
|
l := Unix.Gettimeofday(timeval, timezone);
|
||||||
|
IF l = 0 THEN RETURN TRUE ELSE RETURN FALSE END
|
||||||
|
END CanGetClock;
|
||||||
(*
|
(*
|
||||||
PROCEDURE CanSetClock*(): BOOLEAN;
|
PROCEDURE CanSetClock*(): BOOLEAN;
|
||||||
(* Returns TRUE if a system clock can be set; FALSE otherwise. *)
|
(* Returns TRUE if a system clock can be set; FALSE otherwise. *)
|
||||||
|
|
@ -87,11 +63,8 @@ PROCEDURE IsValidDateTime* (d: DateTime): BOOLEAN;
|
||||||
(* Returns TRUE if the value of `d' represents a valid date and time;
|
(* Returns TRUE if the value of `d' represents a valid date and time;
|
||||||
FALSE otherwise. *)
|
FALSE otherwise. *)
|
||||||
*)
|
*)
|
||||||
(*
|
|
||||||
PROCEDURE GetClock* (VAR userData: DateTime);
|
|
||||||
(* If possible, assigns system date and time of day to `userData' (i.e.,
|
|
||||||
the local time is returned). Error returns 1 Jan 1970. *)
|
|
||||||
*)
|
|
||||||
(*
|
(*
|
||||||
PROCEDURE SetClock* (userData: DateTime);
|
PROCEDURE SetClock* (userData: DateTime);
|
||||||
(* If possible, sets the system clock to the values of `userData'. *)
|
(* If possible, sets the system clock to the values of `userData'. *)
|
||||||
|
|
@ -115,16 +88,23 @@ PROCEDURE MakeLocalTime * (VAR c: DateTime);
|
||||||
whether DST or normal time zone will be chosen. *)
|
whether DST or normal time zone will be chosen. *)
|
||||||
*)
|
*)
|
||||||
|
|
||||||
PROCEDURE -gtod(VAR sec, usec : LONGINT)
|
|
||||||
" struct timeval tval; int res; res = gettimeofday(&tval, NULL); if (!res) { *sec = tval.tv_sec; *usec = tval.tv_usec; return 0; } else {*sec = 0; *usec = 0; return -1; }";
|
|
||||||
|
|
||||||
PROCEDURE GetTimeOfDay* (VAR sec, usec: LONGINT): LONGINT;
|
PROCEDURE GetTimeOfDay* (VAR sec, usec: LONGINT): LONGINT;
|
||||||
(* PRIVAT. Don't use this. Take Time.GetTime instead.
|
(* PRIVAT. Don't use this. Take Time.GetTime instead.
|
||||||
Equivalent to the C function `gettimeofday'. The return value is `0' on
|
Equivalent to the C function `gettimeofday'. The return value is `0' on
|
||||||
success and `-1' on failure; in the latter case `sec' and `usec' are set to
|
success and `-1' on failure; in the latter case `sec' and `usec' are set to
|
||||||
zero. *)
|
zero. *)
|
||||||
|
VAR timeval: Unix.Timeval; timezone: Unix.Timezone;
|
||||||
|
l : LONGINT;
|
||||||
BEGIN
|
BEGIN
|
||||||
gtod (sec, usec);
|
l := Unix.Gettimeofday (timeval, timezone);
|
||||||
|
IF l = 0 THEN
|
||||||
|
sec := timeval.sec;
|
||||||
|
usec := timeval.usec;
|
||||||
|
ELSE
|
||||||
|
sec := 0;
|
||||||
|
usec := 0;
|
||||||
|
END;
|
||||||
|
RETURN l;
|
||||||
END GetTimeOfDay;
|
END GetTimeOfDay;
|
||||||
|
|
||||||
END oocSysClock.
|
END oocSysClock.
|
||||||
|
|
@ -332,7 +332,7 @@ from man gettimeofday
|
||||||
PROCEDURE -Select*(width: LONGINT; VAR readfds, writefds, exceptfds: FdSet; VAR timeout: Timeval): LONGINT
|
PROCEDURE -Select*(width: LONGINT; VAR readfds, writefds, exceptfds: FdSet; VAR timeout: Timeval): LONGINT
|
||||||
"select(width, readfds, writefds, exceptfds, timeout)";
|
"select(width, readfds, writefds, exceptfds, timeout)";
|
||||||
|
|
||||||
PROCEDURE -Gettimeofday* (VAR tv: Timeval; VAR tz: Timezone)
|
PROCEDURE -Gettimeofday* (VAR tv: Timeval; VAR tz: Timezone) : LONGINT
|
||||||
"gettimeofday(tv, tz)";
|
"gettimeofday(tv, tz)";
|
||||||
|
|
||||||
PROCEDURE -Read* (fd, buf, nbyte: LONGINT): LONGINT
|
PROCEDURE -Read* (fd, buf, nbyte: LONGINT): LONGINT
|
||||||
|
|
|
||||||
|
|
@ -84,8 +84,9 @@ MODULE Kernel;
|
||||||
|
|
||||||
PROCEDURE GetClock* (VAR t, d: LONGINT);
|
PROCEDURE GetClock* (VAR t, d: LONGINT);
|
||||||
VAR tv: Unix.Timeval; tz: Unix.Timezone; time: RealTime;
|
VAR tv: Unix.Timeval; tz: Unix.Timezone; time: RealTime;
|
||||||
|
l : LONGINT;
|
||||||
BEGIN
|
BEGIN
|
||||||
Unix.Gettimeofday(tv, tz);
|
l := Unix.Gettimeofday(tv, tz);
|
||||||
time := localtime(tv.sec);
|
time := localtime(tv.sec);
|
||||||
t := time.sec + ASH(time.min, 6) + ASH(time.hour, 12);
|
t := time.sec + ASH(time.min, 6) + ASH(time.hour, 12);
|
||||||
d := time.mday + ASH(time.mon+1, 5) + ASH(time.year MOD 100, 9);
|
d := time.mday + ASH(time.mon+1, 5) + ASH(time.year MOD 100, 9);
|
||||||
|
|
@ -98,8 +99,9 @@ MODULE Kernel;
|
||||||
|
|
||||||
PROCEDURE Time*(): LONGINT;
|
PROCEDURE Time*(): LONGINT;
|
||||||
VAR timeval: Unix.Timeval; timezone: Unix.Timezone;
|
VAR timeval: Unix.Timeval; timezone: Unix.Timezone;
|
||||||
|
l : LONGINT;
|
||||||
BEGIN
|
BEGIN
|
||||||
Unix.Gettimeofday(timeval, timezone);
|
l := Unix.Gettimeofday(timeval, timezone);
|
||||||
RETURN (timeval.usec DIV 1000 + timeval.sec * 1000 - timeStart) MOD 7FFFFFFFH
|
RETURN (timeval.usec DIV 1000 + timeval.sec * 1000 - timeStart) MOD 7FFFFFFFH
|
||||||
END Time;
|
END Time;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1 +1 @@
|
||||||
781786d67da699b419a4f4ae42b31c6cd1506ee8
|
57cd5fe4852aebc3f998f67036da0fcd2f7bf258
|
||||||
|
|
@ -1 +1 @@
|
||||||
5a61e0f70e28eb3c5eb604cf506a2f9a18c3355c
|
57cd5fe4852aebc3f998f67036da0fcd2f7bf258
|
||||||
|
|
@ -1 +1 @@
|
||||||
5a61e0f70e28eb3c5eb604cf506a2f9a18c3355c
|
57cd5fe4852aebc3f998f67036da0fcd2f7bf258
|
||||||
Loading…
Add table
Add a link
Reference in a new issue