Skip to content

Commit 7f7952c

Browse files
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.
1 parent 7a74d6e commit 7f7952c

File tree

2 files changed

+11
-38
lines changed

2 files changed

+11
-38
lines changed

inc/version.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,6 @@ typedef signed char s_char;
252252
#ifdef LINUX
253253
/* LINUX, the free POSIX-compliant Unix */
254254
#define NOETHER 1
255-
/* JDS trial 12/22/01 #define USETIMEFN 1 */
256255

257256
#undef REGISTER
258257
#define REGISTER

src/timer.c

Lines changed: 11 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ void (*prev_int_1c)(); /* keeps address of previous 1c handlr*/
3636
void DOStimer();
3737

3838
unsigned long tick_count = 0; /* approx 18 ticks per sec */
39-
#define USETIMEFN
4039

4140
#else
4241
#include <time.h>
@@ -54,16 +53,13 @@ unsigned long tick_count = 0; /* approx 18 ticks per sec */
5453
#endif /* DOS */
5554

5655
#ifdef OS5
57-
#include <sys/times.h>
5856
#include <stropts.h>
59-
/* JDS 991228 removed #define USETIMEFN */
6057
extern int ether_fd;
6158
#endif
6259

6360
#ifdef LINUX
6461
#include <sys/ioctl.h>
6562
#include <signal.h>
66-
#include <sys/times.h>
6763
#endif
6864

6965
#include <setjmp.h>
@@ -140,7 +136,7 @@ void update_miscstats() {
140136
MiscStats->diskiotime = 0; /* ?? not available ?? */
141137
MiscStats->diskops = 0;
142138
MiscStats->secondstmp = MiscStats->secondsclock = (time(0) + UNIX_ALTO_TIME_DIFF);
143-
#elif !defined(USETIMEFN)
139+
#else
144140
struct timeval timev;
145141
struct rusage ru;
146142

@@ -157,20 +153,6 @@ void update_miscstats() {
157153
;
158154
gettimeofday(&timev, NULL);
159155
MiscStats->secondstmp = MiscStats->secondsclock = (timev.tv_sec + UNIX_ALTO_TIME_DIFF);
160-
#else
161-
struct tms ru;
162-
163-
times(&ru); /* Get system time used */
164-
165-
MiscStats->totaltime =
166-
ru.tms_utime * 10 + ru.tms_stime * 10 + ru.tms_cutime * 10 + ru.tms_cstime * 10;
167-
MiscStats->swapwaittime = ru.tms_stime * 10 + ru.tms_cstime * 10;
168-
MiscStats->pagefaults = 0; /* can't tell this on ISC */
169-
MiscStats->swapwrites = 0;
170-
MiscStats->diskiotime = 0; /* ?? not available ?? */
171-
MiscStats->diskops = 0;
172-
MiscStats->secondstmp = MiscStats->secondsclock = (time(0) + UNIX_ALTO_TIME_DIFF);
173-
174156
#endif /* DOS */
175157
}
176158

@@ -236,24 +218,20 @@ LispPTR subr_gettime(LispPTR args[])
236218

237219
static int gettime(int casep)
238220
{
239-
#ifndef USETIMEFN
240-
struct timeval timev;
241-
#elif DOS
221+
#ifdef DOS
242222
struct dostime_t dtm; /* for hundredths of secs */
243-
#endif /* USETIMEFN */
223+
#else
224+
struct timeval timev;
225+
#endif /* DOS */
244226
switch (casep) {
245227
case 0: /* elapsed time in alto milliseconds */
246-
#ifdef USETIMEFN
247228
#ifdef DOS
248229
_dos_gettime(&dtm);
249230
return ((time(0) + UNIX_ALTO_TIME_DIFF) * 1000) + (10 * dtm.hsecond);
250231
#else /* DOS */
251-
return ((time(0) + UNIX_ALTO_TIME_DIFF)) * 1000;
252-
#endif /* DOS */
253-
#else /* USETIMEFN */
254232
gettimeofday(&timev, NULL);
255233
return ((timev.tv_sec + UNIX_ALTO_TIME_DIFF) * 1000 + timev.tv_usec / 1000);
256-
#endif /* USETIMEFN */
234+
#endif /* DOS */
257235

258236
case 1: /* starting elapsed time in milliseconds */ return (MiscStats->starttime);
259237

@@ -264,15 +242,15 @@ static int gettime(int casep)
264242
case 3: /* total GC time in milliseconds */ return (MiscStats->gctime);
265243

266244
case 4: /* current time of day in Alto format */
267-
#ifdef USETIMEFN
245+
#ifdef DOS
268246
return (time(0) + UNIX_ALTO_TIME_DIFF);
269247
#else
270248
gettimeofday(&timev, NULL);
271249
return (timev.tv_sec + UNIX_ALTO_TIME_DIFF);
272250
#endif
273251

274252
case 5: /* current time of day in Interlisp format */
275-
#ifdef USETIMEFN
253+
#ifdef DOS
276254
return (time(0) + LISP_UNIX_TIME_DIFF);
277255
#else
278256
gettimeofday(&timev, NULL);
@@ -379,19 +357,15 @@ LispPTR N_OP_rclk(LispPTR tos)
379357
struct dostime_t dtm;
380358
#endif /* DOS */
381359

382-
#ifdef USETIMEFN
383360
#ifdef DOS
384361
_dos_gettime(&dtm);
385362
usec = (time(0) * 1000000) + (10000 * dtm.hsecond);
386-
#else
387-
usec = time(0) * 1000000;
388-
#endif /* DOS */
389363
#else
390364
struct timeval timev;
391365

392366
gettimeofday(&timev, NULL);
393367
usec = (timev.tv_sec * 1000000UL) + timev.tv_usec;
394-
#endif /* USETIMEFN */
368+
#endif /* DOS */
395369
*((unsigned int *)(Addr68k_from_LADDR(tos))) = usec;
396370
return (tos);
397371
} /* end N_OP_rclk */
@@ -411,13 +385,13 @@ LispPTR N_OP_rclk(LispPTR tos)
411385
/************************************************************************/
412386

413387
void update_timer() {
414-
#ifdef USETIMEFN
388+
#ifdef DOS
415389
MiscStats->secondstmp = MiscStats->secondsclock = time(0) + UNIX_ALTO_TIME_DIFF;
416390
#else
417391
struct timeval timev;
418392
gettimeofday(&timev, NIL);
419393
MiscStats->secondstmp = MiscStats->secondsclock = (timev.tv_sec + UNIX_ALTO_TIME_DIFF);
420-
#endif /* USETIMEFN */
394+
#endif /* DOS */
421395
}
422396

423397
/************************************************************************/

0 commit comments

Comments
 (0)