1
0
mirror of https://github.com/rcornwell/sims.git synced 2026-01-25 19:56:04 +00:00

SCP: Updated to current.

This commit is contained in:
Richard Cornwell
2023-05-09 12:22:10 -04:00
parent e4201d729a
commit 162b7eee94
10 changed files with 209 additions and 416 deletions

View File

@@ -1,6 +1,6 @@
/* sim_timer.c: simulator timer library
Copyright (c) 1993-2010, Robert M Supnik
Copyright (c) 1993-2022, Robert M Supnik
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
@@ -23,6 +23,11 @@
used in advertising or otherwise to promote the sale, use or other dealings
in this Software without prior written authorization from Robert M Supnik.
27-Sep-22 RMS Removed OS/2 and Mac "Classic" support
01-Feb-21 JDB Added cast for down-conversion
22-May-17 RMS Hacked for V4.0 CONST compatibility
23-Nov-15 RMS Fixed calibration lost path to reinitialize timer
28-Mar-15 RMS Revised to use sim_printf
21-Oct-11 MP Fixed throttling in several ways:
- Sleep for the observed clock tick size while throttling
- Recompute the throttling wait once every 10 seconds
@@ -536,92 +541,6 @@ return 0;
}
#endif
#elif defined (__OS2__)
/* OS/2 routines, from Bruce Ray */
const t_bool rtc_avail = FALSE;
uint32 sim_os_msec (void)
{
return 0;
}
void sim_os_sleep (unsigned int sec)
{
}
uint32 sim_os_ms_sleep_init (void)
{
return 0;
}
uint32 sim_os_ms_sleep (unsigned int msec)
{
return 0;
}
/* Metrowerks CodeWarrior Macintosh routines, from Ben Supnik */
#elif defined (__MWERKS__) && defined (macintosh)
#include <Timer.h>
#include <Mactypes.h>
#include <sioux.h>
#include <unistd.h>
#include <siouxglobals.h>
#define NANOS_PER_MILLI 1000000
#define MILLIS_PER_SEC 1000
const t_bool rtc_avail = TRUE;
uint32 sim_os_msec (void)
{
unsigned long long micros;
UnsignedWide macMicros;
unsigned long millis;
Microseconds (&macMicros);
micros = *((unsigned long long *) &macMicros);
millis = micros / 1000LL;
return (uint32) millis;
}
void sim_os_sleep (unsigned int sec)
{
sleep (sec);
}
uint32 sim_os_ms_sleep_init (void)
{
return _compute_minimum_sleep ();
}
uint32 sim_os_ms_sleep (unsigned int milliseconds)
{
uint32 stime = sim_os_msec ();
struct timespec treq;
treq.tv_sec = milliseconds / MILLIS_PER_SEC;
treq.tv_nsec = (milliseconds % MILLIS_PER_SEC) * NANOS_PER_MILLI;
(void) nanosleep (&treq, NULL);
return sim_os_msec () - stime;
}
#if defined(NEED_CLOCK_GETTIME)
int clock_gettime(int clk_id, struct timespec *tp)
{
struct timeval cur;
if (clk_id != CLOCK_REALTIME)
return -1;
gettimeofday (&cur, NULL);
tp->tv_sec = cur.tv_sec;
tp->tv_nsec = cur.tv_usec*1000;
return 0;
}
#endif
#else
/* UNIX routines */