home *** CD-ROM | disk | FTP | other *** search
- static char sccs_id[] = "@(#) time.c 1.0 " __DATE__ " HJR";
-
- /* time.c (c) Copyright 1990 H.Rogers */
-
- #include <time.h>
- #include <errno.h>
-
- #include <sys/times.h>
-
- #include "sys/os.h"
- #include "sys/syslib.h"
-
- clock_t
- clock (void)
- {
- unsigned int b[2];
- unsigned int t1, t2;
- os_error *e;
-
- *((char *) b) = 3;
- if (e = os_word (0x0e, b))
- {
- __seterr (e);
- return (-1);
- }
-
- t1 = (b[0]);
- t2 = (b[1] & 0xff);
-
- if (t2 - __time[1])
- {
- errno = ERANGE;
- return ((clock_t) - 1);
- }
-
- return (t1 - __time[0]);
- }
-
- time_t
- time (time_t * t)
- {
- unsigned int b[2];
- unsigned int t1, t2, tc;
- os_error *e;
-
- *((char *) b) = 3;
- if (e = os_word (0x0e, b))
- {
- __seterr (e);
- return (-1);
- }
-
- t1 = (b[0]);
- t2 = (b[1] & 0xff);
-
- tc = 0x6e996a00U;
- if (t1 < tc)
- t2--;
- t1 -= tc;
- t2 -= 0x33; /* 00:00:00 Jan. 1 1970 = 0x336e996a00 */
-
- t1 = (t1 / 100) + (t2 * 42949673U); /* 0x100000000 / 100 = 42949672.96 */
- t1 -= (t2 / 25); /* compensate for .04 error */
-
- if (t)
- *t = t1;
-
- return (t1);
- }
-
- clock_t
- times (struct tms * tmsp)
-
- {
- tmsp->tms_utime = clock (); /* user time */
- tmsp->tms_stime = 0; /* system time */
- tmsp->tms_cutime = 0; /* user time, children */
- tmsp->tms_cstime = 0; /* system time, children */
- return tmsp->tms_utime;
- }
-