diff --git a/funcs.c b/funcs.c index 8f467ed..145e1da 100644 --- a/funcs.c +++ b/funcs.c @@ -38,7 +38,7 @@ #endif #endif -__RCSID("$MirOS: src/bin/mksh/funcs.c,v 1.215 2012/05/04 21:15:32 tg Exp $"); +__RCSID("$MirOS: src/bin/mksh/funcs.c,v 1.216 2012/05/04 21:47:01 tg Exp $"); #if HAVE_KILLPG /* @@ -1884,7 +1884,7 @@ c_read(const char **wp) #if HAVE_SELECT if (hastimeout) { - gettimeofday(&tvlim, NULL); + mksh_TIME(tvlim); timeradd(&tvlim, &tv, &tvlim); } #endif @@ -1896,7 +1896,7 @@ c_read(const char **wp) FD_ZERO(&fdset); FD_SET(fd, &fdset); - gettimeofday(&tv, NULL); + mksh_TIME(tv); timersub(&tvlim, &tv, &tv); if (tv.tv_sec < 0) { /* timeout expired globally */ @@ -2504,7 +2504,7 @@ timex(struct op *t, int f, volatile int *xerrok) struct rusage ru0, ru1, cru0, cru1; struct timeval usrtime, systime, tv0, tv1; - gettimeofday(&tv0, NULL); + mksh_TIME(tv0); getrusage(RUSAGE_SELF, &ru0); getrusage(RUSAGE_CHILDREN, &cru0); if (t->left) { @@ -2521,7 +2521,7 @@ timex(struct op *t, int f, volatile int *xerrok) rv = execute(t->left, f | XTIME, xerrok); if (t->left->type == TCOM) tf |= t->left->str[0]; - gettimeofday(&tv1, NULL); + mksh_TIME(tv1); getrusage(RUSAGE_SELF, &ru1); getrusage(RUSAGE_CHILDREN, &cru1); } else diff --git a/main.c b/main.c index 2b171e6..df16896 100644 --- a/main.c +++ b/main.c @@ -34,7 +34,7 @@ #include #endif -__RCSID("$MirOS: src/bin/mksh/main.c,v 1.218 2012/05/04 21:15:33 tg Exp $"); +__RCSID("$MirOS: src/bin/mksh/main.c,v 1.219 2012/05/04 21:47:02 tg Exp $"); extern char **environ; @@ -135,7 +135,7 @@ rndsetup(void) sigsetjmp(bufptr->jbuf, 1); #endif /* introduce variation (and yes, second arg MBZ for portability) */ - gettimeofday(&bufptr->tv, NULL); + mksh_TIME(bufptr->tv); NZATInit(h); /* variation through pid, ppid, and the works */ @@ -1767,7 +1767,7 @@ DF(const char *fmt, ...) struct timeval tv; mksh_lockfd(shl_dbg_fd); - gettimeofday(&tv, NULL); + mksh_TIME(tv); shf_fprintf(shl_dbg, "[%d.%06d:%d] ", (int)tv.tv_sec, (int)tv.tv_usec, (int)getpid()); va_start(args, fmt); diff --git a/sh.h b/sh.h index c24a6a5..283d206 100644 --- a/sh.h +++ b/sh.h @@ -152,7 +152,7 @@ #endif #ifdef EXTERN -__RCSID("$MirOS: src/bin/mksh/sh.h,v 1.554 2012/05/04 21:15:34 tg Exp $"); +__RCSID("$MirOS: src/bin/mksh/sh.h,v 1.555 2012/05/04 21:47:03 tg Exp $"); #endif #define MKSH_VERSION "R40 2012/04/27" @@ -349,6 +349,15 @@ extern int __cdecl seteuid(uid_t); extern int __cdecl setegid(gid_t); #endif +#if defined(__COHERENT__) +#define mksh_TIME(tv) do { \ + (tv).tv_usec = 0; \ + (tv).tv_sec = time(NULL); \ +} while (/* CONSTCOND */ 0) +#else +#define mksh_TIME(tv) gettimeofday(&(tv), NULL) +#endif + /* remove redundancies */ #if defined(MirBSD) && (MirBSD >= 0x08A8) && !defined(MKSH_OPTSTATIC) diff --git a/var.c b/var.c index 26462f0..792a36e 100644 --- a/var.c +++ b/var.c @@ -27,7 +27,7 @@ #include #endif -__RCSID("$MirOS: src/bin/mksh/var.c,v 1.147 2012/04/22 21:50:35 tg Exp $"); +__RCSID("$MirOS: src/bin/mksh/var.c,v 1.148 2012/05/04 21:47:04 tg Exp $"); /*- * Variables @@ -1088,7 +1088,7 @@ getspec(struct tbl *vp) if (vp->flag & ISSET) { struct timeval tv; - gettimeofday(&tv, NULL); + mksh_TIME(tv); i = tv.tv_sec - seconds; } else return; @@ -1221,7 +1221,7 @@ setspec(struct tbl *vp) { struct timeval tv; - gettimeofday(&tv, NULL); + mksh_TIME(tv); seconds = tv.tv_sec - i; } break;