* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/
-
-#ifndef lint
-static char sccsid[] = "@(#)hertz.c 5.4 (Berkeley) 6/1/90";
-#endif /* not lint */
-
#include <sys/time.h>
+#include "hertz.h"
+
- /*
- * discover the tick frequency of the machine
- * if something goes wrong, we return 0, an impossible hertz.
- */
-#define HZ_WRONG 0
+#ifdef __MSDOS__
+#define HERTZ 18
+#endif
-hertz()
+int
+hertz ()
{
- struct itimerval tim;
+#ifdef HERTZ
+ return HERTZ;
+#else
+ struct itimerval tim;
- tim.it_interval.tv_sec = 0;
- tim.it_interval.tv_usec = 1;
- tim.it_value.tv_sec = 0;
- tim.it_value.tv_usec = 0;
- setitimer(ITIMER_REAL, &tim, 0);
- setitimer(ITIMER_REAL, 0, &tim);
- if (tim.it_interval.tv_usec < 2)
- return(HZ_WRONG);
- return (1000000 / tim.it_interval.tv_usec);
+ tim.it_interval.tv_sec = 0;
+ tim.it_interval.tv_usec = 1;
+ tim.it_value.tv_sec = 0;
+ tim.it_value.tv_usec = 0;
+ setitimer (ITIMER_REAL, &tim, 0);
+ setitimer (ITIMER_REAL, 0, &tim);
+ if (tim.it_interval.tv_usec < 2)
+ {
+ return HZ_WRONG;
+ }
+ return 1000000 / tim.it_interval.tv_usec;
+#endif
}