1
0
mirror of https://github.com/PDP-10/klh10.git synced 2026-02-05 07:55:23 +00:00

Replace CENV_SYSF_BSDTIMEVAL with HAVE_SETITIMER and HAVE_GETTIMEOFDAY

This commit is contained in:
Olaf Seibert
2016-01-21 19:52:40 +01:00
parent 14ba9636cd
commit e3e86227de
6 changed files with 24 additions and 20 deletions

View File

@@ -215,9 +215,6 @@
/* Specific OS Feature defs
This only has features of interest for KLH10 software.
*/
#ifndef CENV_SYSF_BSDTIMEVAL /* Has "timeval" struct & calls */
# define CENV_SYSF_BSDTIMEVAL (CENV_SYS_UNIX && !CENV_SYS_V7)
#endif
#ifndef CENV_SYSF_TERMIOS /* Has termios(3) tty stuff */
# define CENV_SYSF_TERMIOS (CENV_SYS_DECOSF|CENV_SYS_SOLARIS|CENV_SYS_XBSD \
|CENV_SYS_LINUX)

View File

@@ -730,7 +730,7 @@ dp_sleep(int secs)
#if CENV_SYS_DECOSF
sleep(secs); /* Independent of interval timers! */
#elif CENV_SYSF_BSDTIMEVAL && CENV_SYSF_SIGSET
#elif HAVE_SETITIMER && CENV_SYSF_SIGSET
/* Must save & restore ITIMER_REAL & SIGALRM, which conflict w/sleep() */
struct itimerval ztm, otm;
struct sigaction act, oact;

View File

@@ -1386,7 +1386,7 @@ quant_freeze(int32 qc)
** don't report runtime in a monotonically increasing way.
** See os_vrtmget() for more detail.
*/
#if CENV_SYSF_BSDTIMEVAL
#if HAVE_SETITIMER
if (rtm.tv_sec < 0 || rtm.tv_usec < 0) {
# if 0 /* Disable output for now. Perhaps bump a meter later */
fprintf(stderr, "[Neg quantum! %ld,%ld]\r\n",
@@ -1394,7 +1394,7 @@ quant_freeze(int32 qc)
# endif
return qc;
}
#endif /* CENV_SYSF_BSDTIMEVAL */
#endif /* HAVE_SETITIMER */
return qc + (int32)os_rtm_toqct(&rtm); /* Convert to quantum ticks! */
}

View File

@@ -65,7 +65,7 @@
# include <errno.h>
# include <time.h> /* For struct tm, localtime() */
# if CENV_SYSF_BSDTIMEVAL
# if HAVE_SETITIMER
# include <sys/time.h> /* BSD: For setitimer() */
# include <sys/resource.h> /* BSD: For getrusage() */
# endif
@@ -909,7 +909,7 @@ and fits within 20 bits.
int
os_rtmget(register osrtm_t *art)
{
#if CENV_SYSF_BSDTIMEVAL
#if HAVE_SETITIMER /* && HAVE_GETTIMEOFDAY ; implied */
static osrtm_t os_last_rtm = {0,0};
if (!gettimeofday(art, (struct timezone *)NULL) == 0)
return FALSE;
@@ -949,7 +949,7 @@ os_vrtmget(register osrtm_t *art)
return TRUE;
}
return FALSE;
#elif CENV_SYSF_BSDTIMEVAL
#elif HAVE_GETRUSAGE
/* WARNING!!! Some systems turn out not to report getrusage runtime in a
** monotonically increasing way! This can result in negative deltas
** from one get to the next.
@@ -978,7 +978,7 @@ os_vrtmget(register osrtm_t *art)
void
os_rtmsub(register osrtm_t *a, register osrtm_t *b)
{
#if CENV_SYSF_BSDTIMEVAL
#if HAVE_SETITIMER
a->tv_sec -= b->tv_sec;
if ((a->tv_usec -= b->tv_usec) < 0) {
--a->tv_sec;
@@ -1062,7 +1062,7 @@ os_timer(int type,
register uint32 usecs,
ostimer_t *ostate)
{
#if CENV_SYSF_BSDTIMEVAL
#if HAVE_SETITIMER
struct itimerval itm;
if (type != ITIMER_VIRTUAL)
@@ -1127,7 +1127,7 @@ os_vtimer(ossighandler_t *irtn, uint32 usecs)
void
os_timer_restore(ostimer_t *ostate)
{
#if CENV_SYSF_BSDTIMEVAL && CENV_SYSF_SIGSET
#if HAVE_SETITIMER && CENV_SYSF_SIGSET
sigset_t blkset, savset;
int ret;
@@ -1161,7 +1161,7 @@ os_timer_restore(ostimer_t *ostate)
void
os_v2rt_idle(ossighandler_t *hdlarg)
{
#if CENV_SYSF_BSDTIMEVAL && CENV_SYSF_SIGSET
#if HAVE_SETITIMER && CENV_SYSF_SIGSET
sigset_t allmsk, oldmsk, nomsk;
struct itimerval ntval, vtval;
static ossighandler_t *handler = NULL;
@@ -1234,7 +1234,7 @@ os_sleep(int secs)
OS_STM_SET(stm, secs);
while (os_msleep(&stm) > 0) ;
#elif CENV_SYSF_BSDTIMEVAL
#elif HAVE_SETITIMER
/* Must save & restore ITIMER_REAL & SIGALRM, which conflict w/sleep() */
ostimer_t savetmr;
@@ -1351,7 +1351,7 @@ os_rtm_tokst(register osrtm_t *art,
register dw10_t d;
register w10_t w;
#if CENV_SYSF_BSDTIMEVAL
#if HAVE_SETITIMER
LRHSET(w, 017, 0507640); /* 4,100,000. */
d = op10xmul(w, op10utow(art->tv_sec));
w = op10utow((int32)((art->tv_usec << 2) + (art->tv_usec / 10)));
@@ -1384,7 +1384,7 @@ os_rtm_tokst(register osrtm_t *art,
unsigned long
os_rtm_toqct(register osrtm_t *art)
{
#if CENV_SYSF_BSDTIMEVAL
#if HAVE_SETITIMER
return ((unsigned long)(art->tv_sec * 4100000)
+ (art->tv_usec << 2) + (art->tv_usec/10)) >> 4;
#elif CENV_SYS_MAC
@@ -1417,7 +1417,7 @@ See io_rdtime().
unsigned long
os_rtm_toklt(register osrtm_t *art)
{
#if CENV_SYSF_BSDTIMEVAL
#if HAVE_SETITIMER
return ((unsigned long)art->tv_sec * 1000000) + art->tv_usec;
#elif CENV_SYS_MAC
return art->lo;

View File

@@ -198,7 +198,13 @@ extern osintf_t os_swap(osintf_t *, int);
/* Real-time - osrtm_t
*/
#if CENV_SYSF_BSDTIMEVAL /* timeval is a BSD artifact */
#if HAVE_SETITIMER && HAVE_GETTIMEOFDAY /* timeval is a BSD artifact */
/* The of setitimer(2) and gettimeofday(struct timeval *, ...)
* are used together, and the latter implies the existence of
* struct timeval.
* Further checks will omit HAVE_GETTIMEOFDAY; if it's missing
* it will error out below anyway.
*/
# include <sys/time.h>
typedef struct timeval osrtm_t;
# define OS_RTM_SEC(rtm) ((rtm).tv_sec)
@@ -223,7 +229,7 @@ typedef struct {
# define OS_ITIMER_VIRT 1
#endif
ossigact_t ostmr_sigact;
#if CENV_SYSF_BSDTIMEVAL
#if HAVE_SETITIMER
struct itimerval ostmr_itm;
#elif CENV_SYS_MAC
/* XXX: Mac implem uses static interval_timer* timer instead of a