34 lines
778 B
C
Executable File
34 lines
778 B
C
Executable File
/* Copyright (c) 1988 AT&T */
|
|
/* All Rights Reserved */
|
|
|
|
/* THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF AT&T */
|
|
/* The copyright notice above does not evidence any */
|
|
/* actual or intended publication of such source code. */
|
|
|
|
#ident "@(#)clock.c 1.8 92/07/14 SMI" /* SVr4.0 1.6.2.3 */
|
|
|
|
/*LINTLIBRARY*/
|
|
|
|
#include "synonyms.h"
|
|
#include <sys/types.h>
|
|
#include <sys/times.h>
|
|
#include <sys/param.h> /* for HZ (clock frequency in Hz) */
|
|
#define TIMES(B) (B.tms_utime+B.tms_stime+B.tms_cutime+B.tms_cstime)
|
|
|
|
extern int gethz();
|
|
static long first = 0L;
|
|
|
|
long
|
|
clock()
|
|
{
|
|
struct tms buffer;
|
|
static int Hz = 0;
|
|
|
|
if (!Hz && (Hz = gethz()) == 0)
|
|
Hz = HZ;
|
|
|
|
if (times(&buffer) != -1L && first == 0L)
|
|
first = TIMES(buffer);
|
|
return ((TIMES(buffer) - first) * (1000000L/Hz));
|
|
}
|