mirror of
https://github.com/Interlisp/maiko.git
synced 2026-04-25 20:11:36 +00:00
Remove USETIMEFN define. (#143)
In the past, we didn't use `gettimeofday()` on all non-DOS platforms because it wasn't available, so we had to fall back to `time()`. Those days are long gone and we have `gettimeofday()` on all non-DOS platforms. This also removes some code that used `times()` when it used `time()`. This leaves us using `getrusage()` on all non-DOS platforms. This, much like `gettimeofday()`, is now available everywhere. Not all of the fields used here are guaranteed by POSIX, but the ones used here shouldn't be an issue for now.
This commit is contained in:
@@ -252,7 +252,6 @@ typedef signed char s_char;
|
|||||||
#ifdef LINUX
|
#ifdef LINUX
|
||||||
/* LINUX, the free POSIX-compliant Unix */
|
/* LINUX, the free POSIX-compliant Unix */
|
||||||
#define NOETHER 1
|
#define NOETHER 1
|
||||||
/* JDS trial 12/22/01 #define USETIMEFN 1 */
|
|
||||||
|
|
||||||
#undef REGISTER
|
#undef REGISTER
|
||||||
#define REGISTER
|
#define REGISTER
|
||||||
|
|||||||
48
src/timer.c
48
src/timer.c
@@ -36,7 +36,6 @@ void (*prev_int_1c)(); /* keeps address of previous 1c handlr*/
|
|||||||
void DOStimer();
|
void DOStimer();
|
||||||
|
|
||||||
unsigned long tick_count = 0; /* approx 18 ticks per sec */
|
unsigned long tick_count = 0; /* approx 18 ticks per sec */
|
||||||
#define USETIMEFN
|
|
||||||
|
|
||||||
#else
|
#else
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
@@ -54,16 +53,13 @@ unsigned long tick_count = 0; /* approx 18 ticks per sec */
|
|||||||
#endif /* DOS */
|
#endif /* DOS */
|
||||||
|
|
||||||
#ifdef OS5
|
#ifdef OS5
|
||||||
#include <sys/times.h>
|
|
||||||
#include <stropts.h>
|
#include <stropts.h>
|
||||||
/* JDS 991228 removed #define USETIMEFN */
|
|
||||||
extern int ether_fd;
|
extern int ether_fd;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef LINUX
|
#ifdef LINUX
|
||||||
#include <sys/ioctl.h>
|
#include <sys/ioctl.h>
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
#include <sys/times.h>
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <setjmp.h>
|
#include <setjmp.h>
|
||||||
@@ -140,7 +136,7 @@ void update_miscstats() {
|
|||||||
MiscStats->diskiotime = 0; /* ?? not available ?? */
|
MiscStats->diskiotime = 0; /* ?? not available ?? */
|
||||||
MiscStats->diskops = 0;
|
MiscStats->diskops = 0;
|
||||||
MiscStats->secondstmp = MiscStats->secondsclock = (time(0) + UNIX_ALTO_TIME_DIFF);
|
MiscStats->secondstmp = MiscStats->secondsclock = (time(0) + UNIX_ALTO_TIME_DIFF);
|
||||||
#elif !defined(USETIMEFN)
|
#else
|
||||||
struct timeval timev;
|
struct timeval timev;
|
||||||
struct rusage ru;
|
struct rusage ru;
|
||||||
|
|
||||||
@@ -157,20 +153,6 @@ void update_miscstats() {
|
|||||||
;
|
;
|
||||||
gettimeofday(&timev, NULL);
|
gettimeofday(&timev, NULL);
|
||||||
MiscStats->secondstmp = MiscStats->secondsclock = (timev.tv_sec + UNIX_ALTO_TIME_DIFF);
|
MiscStats->secondstmp = MiscStats->secondsclock = (timev.tv_sec + UNIX_ALTO_TIME_DIFF);
|
||||||
#else
|
|
||||||
struct tms ru;
|
|
||||||
|
|
||||||
times(&ru); /* Get system time used */
|
|
||||||
|
|
||||||
MiscStats->totaltime =
|
|
||||||
ru.tms_utime * 10 + ru.tms_stime * 10 + ru.tms_cutime * 10 + ru.tms_cstime * 10;
|
|
||||||
MiscStats->swapwaittime = ru.tms_stime * 10 + ru.tms_cstime * 10;
|
|
||||||
MiscStats->pagefaults = 0; /* can't tell this on ISC */
|
|
||||||
MiscStats->swapwrites = 0;
|
|
||||||
MiscStats->diskiotime = 0; /* ?? not available ?? */
|
|
||||||
MiscStats->diskops = 0;
|
|
||||||
MiscStats->secondstmp = MiscStats->secondsclock = (time(0) + UNIX_ALTO_TIME_DIFF);
|
|
||||||
|
|
||||||
#endif /* DOS */
|
#endif /* DOS */
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -236,24 +218,20 @@ LispPTR subr_gettime(LispPTR args[])
|
|||||||
|
|
||||||
static int gettime(int casep)
|
static int gettime(int casep)
|
||||||
{
|
{
|
||||||
#ifndef USETIMEFN
|
#ifdef DOS
|
||||||
struct timeval timev;
|
|
||||||
#elif DOS
|
|
||||||
struct dostime_t dtm; /* for hundredths of secs */
|
struct dostime_t dtm; /* for hundredths of secs */
|
||||||
#endif /* USETIMEFN */
|
#else
|
||||||
|
struct timeval timev;
|
||||||
|
#endif /* DOS */
|
||||||
switch (casep) {
|
switch (casep) {
|
||||||
case 0: /* elapsed time in alto milliseconds */
|
case 0: /* elapsed time in alto milliseconds */
|
||||||
#ifdef USETIMEFN
|
|
||||||
#ifdef DOS
|
#ifdef DOS
|
||||||
_dos_gettime(&dtm);
|
_dos_gettime(&dtm);
|
||||||
return ((time(0) + UNIX_ALTO_TIME_DIFF) * 1000) + (10 * dtm.hsecond);
|
return ((time(0) + UNIX_ALTO_TIME_DIFF) * 1000) + (10 * dtm.hsecond);
|
||||||
#else /* DOS */
|
#else /* DOS */
|
||||||
return ((time(0) + UNIX_ALTO_TIME_DIFF)) * 1000;
|
|
||||||
#endif /* DOS */
|
|
||||||
#else /* USETIMEFN */
|
|
||||||
gettimeofday(&timev, NULL);
|
gettimeofday(&timev, NULL);
|
||||||
return ((timev.tv_sec + UNIX_ALTO_TIME_DIFF) * 1000 + timev.tv_usec / 1000);
|
return ((timev.tv_sec + UNIX_ALTO_TIME_DIFF) * 1000 + timev.tv_usec / 1000);
|
||||||
#endif /* USETIMEFN */
|
#endif /* DOS */
|
||||||
|
|
||||||
case 1: /* starting elapsed time in milliseconds */ return (MiscStats->starttime);
|
case 1: /* starting elapsed time in milliseconds */ return (MiscStats->starttime);
|
||||||
|
|
||||||
@@ -264,7 +242,7 @@ static int gettime(int casep)
|
|||||||
case 3: /* total GC time in milliseconds */ return (MiscStats->gctime);
|
case 3: /* total GC time in milliseconds */ return (MiscStats->gctime);
|
||||||
|
|
||||||
case 4: /* current time of day in Alto format */
|
case 4: /* current time of day in Alto format */
|
||||||
#ifdef USETIMEFN
|
#ifdef DOS
|
||||||
return (time(0) + UNIX_ALTO_TIME_DIFF);
|
return (time(0) + UNIX_ALTO_TIME_DIFF);
|
||||||
#else
|
#else
|
||||||
gettimeofday(&timev, NULL);
|
gettimeofday(&timev, NULL);
|
||||||
@@ -272,7 +250,7 @@ static int gettime(int casep)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
case 5: /* current time of day in Interlisp format */
|
case 5: /* current time of day in Interlisp format */
|
||||||
#ifdef USETIMEFN
|
#ifdef DOS
|
||||||
return (time(0) + LISP_UNIX_TIME_DIFF);
|
return (time(0) + LISP_UNIX_TIME_DIFF);
|
||||||
#else
|
#else
|
||||||
gettimeofday(&timev, NULL);
|
gettimeofday(&timev, NULL);
|
||||||
@@ -379,19 +357,15 @@ LispPTR N_OP_rclk(LispPTR tos)
|
|||||||
struct dostime_t dtm;
|
struct dostime_t dtm;
|
||||||
#endif /* DOS */
|
#endif /* DOS */
|
||||||
|
|
||||||
#ifdef USETIMEFN
|
|
||||||
#ifdef DOS
|
#ifdef DOS
|
||||||
_dos_gettime(&dtm);
|
_dos_gettime(&dtm);
|
||||||
usec = (time(0) * 1000000) + (10000 * dtm.hsecond);
|
usec = (time(0) * 1000000) + (10000 * dtm.hsecond);
|
||||||
#else
|
|
||||||
usec = time(0) * 1000000;
|
|
||||||
#endif /* DOS */
|
|
||||||
#else
|
#else
|
||||||
struct timeval timev;
|
struct timeval timev;
|
||||||
|
|
||||||
gettimeofday(&timev, NULL);
|
gettimeofday(&timev, NULL);
|
||||||
usec = (timev.tv_sec * 1000000UL) + timev.tv_usec;
|
usec = (timev.tv_sec * 1000000UL) + timev.tv_usec;
|
||||||
#endif /* USETIMEFN */
|
#endif /* DOS */
|
||||||
*((unsigned int *)(Addr68k_from_LADDR(tos))) = usec;
|
*((unsigned int *)(Addr68k_from_LADDR(tos))) = usec;
|
||||||
return (tos);
|
return (tos);
|
||||||
} /* end N_OP_rclk */
|
} /* end N_OP_rclk */
|
||||||
@@ -411,13 +385,13 @@ LispPTR N_OP_rclk(LispPTR tos)
|
|||||||
/************************************************************************/
|
/************************************************************************/
|
||||||
|
|
||||||
void update_timer() {
|
void update_timer() {
|
||||||
#ifdef USETIMEFN
|
#ifdef DOS
|
||||||
MiscStats->secondstmp = MiscStats->secondsclock = time(0) + UNIX_ALTO_TIME_DIFF;
|
MiscStats->secondstmp = MiscStats->secondsclock = time(0) + UNIX_ALTO_TIME_DIFF;
|
||||||
#else
|
#else
|
||||||
struct timeval timev;
|
struct timeval timev;
|
||||||
gettimeofday(&timev, NIL);
|
gettimeofday(&timev, NIL);
|
||||||
MiscStats->secondstmp = MiscStats->secondsclock = (timev.tv_sec + UNIX_ALTO_TIME_DIFF);
|
MiscStats->secondstmp = MiscStats->secondsclock = (timev.tv_sec + UNIX_ALTO_TIME_DIFF);
|
||||||
#endif /* USETIMEFN */
|
#endif /* DOS */
|
||||||
}
|
}
|
||||||
|
|
||||||
/************************************************************************/
|
/************************************************************************/
|
||||||
|
|||||||
Reference in New Issue
Block a user