home *** CD-ROM | disk | FTP | other *** search
- /****************************************************************************
- *
- * $Source: /unixb/home/unixlib/source/unixlib37/src/unix/c/RCS/time,v $
- * $Date: 1996/04/19 21:35:27 $
- * $Revision: 1.1 $
- * $State: Rel $
- * $Author: simon $
- *
- * $Log: time,v $
- * Revision 1.1 1996/04/19 21:35:27 simon
- * Initial revision
- *
- ***************************************************************************/
-
- static const char rcs_id[] = "$Id: time,v 1.1 1996/04/19 21:35:27 simon Rel $";
-
- #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;
- _kernel_oserror *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;
- _kernel_oserror *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;
- }
-