update swap display description
[unix-history] / usr / src / usr.bin / gprof / hertz.c
CommitLineData
c0bc4ef7 1/*
7e9de516
KB
2 * Copyright (c) 1983, 1993
3 * The Regents of the University of California. All rights reserved.
ddb85eed 4 *
6ecf3d85 5 * %sccs.include.redist.c%
c0bc4ef7
DF
6 */
7
551f2768 8#ifndef lint
7e9de516 9static char sccsid[] = "@(#)hertz.c 8.1 (Berkeley) %G%";
ddb85eed 10#endif /* not lint */
551f2768 11
39bd51fe
KM
12#include <sys/time.h>
13
551f2768
PK
14 /*
15 * discover the tick frequency of the machine
648db063 16 * if something goes wrong, we return 0, an impossible hertz.
551f2768 17 */
648db063 18#define HZ_WRONG 0
10ac51bc 19
551f2768
PK
20hertz()
21{
39bd51fe 22 struct itimerval tim;
551f2768 23
39bd51fe
KM
24 tim.it_interval.tv_sec = 0;
25 tim.it_interval.tv_usec = 1;
26 tim.it_value.tv_sec = 0;
27 tim.it_value.tv_usec = 0;
28 setitimer(ITIMER_REAL, &tim, 0);
29 setitimer(ITIMER_REAL, 0, &tim);
30 if (tim.it_interval.tv_usec < 2)
31 return(HZ_WRONG);
32 return (1000000 / tim.it_interval.tv_usec);
551f2768 33}