summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdrian Knoth <adi@drcomp.erfurt.thur.de>2014-03-14 17:34:21 +0100
committerAdrian Knoth <adi@drcomp.erfurt.thur.de>2014-03-14 17:34:21 +0100
commitc97157fc6ecac0d4b086bcfcf5588e4751ce4d6b (patch)
tree57a481c9c09251d4d37cd215283a273d40991bbb
parent144f712ac2f42acf0c63d90320a663a7c399512e (diff)
downloadjack1-c97157fc6ecac0d4b086bcfcf5588e4751ce4d6b.tar.gz
Don't rely on CPU cycles to measure time.
We have a proper clocksource in the kernel, use this instead. This commit also fixes jackd on ARM boards with newer Linux kernels where /proc/cpuinfo has changed.
-rw-r--r--config/os/gnu-linux/time.c65
1 files changed, 1 insertions, 64 deletions
diff --git a/config/os/gnu-linux/time.c b/config/os/gnu-linux/time.c
index 7301200..982a290 100644
--- a/config/os/gnu-linux/time.c
+++ b/config/os/gnu-linux/time.c
@@ -23,7 +23,6 @@
#include <stdint.h>
-static jack_time_t __jack_cpu_mhz = 0;
jack_time_t (*_jack_get_microseconds)(void) = 0;
#if defined(__gnu_linux__) && (defined(__i386__) || defined(__x86_64__))
@@ -113,68 +112,10 @@ jack_get_microseconds_from_hpet (void)
#endif /* HPET_SUPPORT */
-jack_time_t
-jack_get_microseconds_from_cycles (void) {
- return get_cycles() / __jack_cpu_mhz;
-}
-
-/*
- * This is another kludge. It looks CPU-dependent, but actually it
- * reflects the lack of standards for the Linux kernel formatting of
- * /proc/cpuinfo.
- */
-
-jack_time_t
-jack_get_mhz (void)
-{
- FILE *f = fopen("/proc/cpuinfo", "r");
- if (f == 0)
- {
- perror("can't open /proc/cpuinfo\n");
- exit(1);
- }
-
- for ( ; ; )
- {
- jack_time_t mhz;
- int ret;
- char buf[1000];
-
- if (fgets(buf, sizeof(buf), f) == NULL) {
- jack_error ("FATAL: cannot locate cpu MHz in "
- "/proc/cpuinfo\n");
- exit(1);
- }
-
-#if defined(__powerpc__)
- ret = sscanf(buf, "clock\t: %" SCNu64 "MHz", &mhz);
-#elif defined( __i386__ ) || defined (__hppa__) || defined (__ia64__) || \
- defined(__x86_64__)
- ret = sscanf(buf, "cpu MHz : %" SCNu64, &mhz);
-#elif defined( __sparc__ )
- ret = sscanf(buf, "Cpu0Bogo : %" SCNu64, &mhz);
-#elif defined( __mc68000__ )
- ret = sscanf(buf, "Clocking: %" SCNu64, &mhz);
-#elif defined( __s390__ )
- ret = sscanf(buf, "bogomips per cpu: %" SCNu64, &mhz);
-#elif defined( __sh__ )
- ret = sscanf(buf, "bogomips : %" SCNu64, &mhz);
-#else /* MIPS, ARM, alpha */
- ret = sscanf(buf, "BogoMIPS : %" SCNu64, &mhz);
-#endif
-
- if (ret == 1)
- {
- fclose(f);
- return (jack_time_t)mhz;
- }
- }
-}
-
void
jack_init_time ()
{
- __jack_cpu_mhz = jack_get_mhz ();
+ /* nothing to do on a generic system - we use the system clock */
}
void
@@ -182,10 +123,6 @@ jack_set_clock_source (jack_timer_type_t clocksrc)
{
switch (clocksrc)
{
- case JACK_TIMER_CYCLE_COUNTER:
- _jack_get_microseconds = jack_get_microseconds_from_cycles;
- break;
-
case JACK_TIMER_HPET:
if (jack_hpet_init () == 0) {
_jack_get_microseconds = jack_get_microseconds_from_hpet;