removed support for -r, -h, and rmail
[unix-history] / usr / src / usr.bin / gprof / hertz.c
CommitLineData
c0bc4ef7
DF
1/*
2 * Copyright (c) 1983 Regents of the University of California.
ddb85eed
KB
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms are permitted
6 * provided that this notice is preserved and that due credit is given
7 * to the University of California at Berkeley. The name of the University
8 * may not be used to endorse or promote products derived from this
9 * software without specific prior written permission. This software
10 * is provided ``as is'' without express or implied warranty.
c0bc4ef7
DF
11 */
12
551f2768 13#ifndef lint
ddb85eed
KB
14static char sccsid[] = "@(#)hertz.c 5.2 (Berkeley) %G%";
15#endif /* not lint */
551f2768 16
39bd51fe
KM
17#include <sys/time.h>
18
551f2768
PK
19 /*
20 * discover the tick frequency of the machine
648db063 21 * if something goes wrong, we return 0, an impossible hertz.
551f2768 22 */
648db063 23#define HZ_WRONG 0
10ac51bc 24
551f2768
PK
25hertz()
26{
39bd51fe 27 struct itimerval tim;
551f2768 28
39bd51fe
KM
29 tim.it_interval.tv_sec = 0;
30 tim.it_interval.tv_usec = 1;
31 tim.it_value.tv_sec = 0;
32 tim.it_value.tv_usec = 0;
33 setitimer(ITIMER_REAL, &tim, 0);
34 setitimer(ITIMER_REAL, 0, &tim);
35 if (tim.it_interval.tv_usec < 2)
36 return(HZ_WRONG);
37 return (1000000 / tim.it_interval.tv_usec);
551f2768 38}