Browse Source

Use 32-bit reads on HPET on 32-bit platforms. 64-bit reads should be OK on x86-64 and for example Intel ICH7.

git-svn-id: svn+ssh://jackaudio.org/trunk/jack@991 0c269be4-1314-0410-8aa9-9f06e86f4224
tags/0.109.0
sonarnerd 18 years ago
parent
commit
34d9717147
1 changed files with 13 additions and 0 deletions
  1. +13
    -0
      config/os/gnu-linux/time.c

+ 13
- 0
config/os/gnu-linux/time.c View File

@@ -30,6 +30,11 @@ jack_time_t (*_jack_get_microseconds)(void) = 0;
#define HPET_MMAP_SIZE 1024 #define HPET_MMAP_SIZE 1024
#define HPET_PERIOD 0x004 #define HPET_PERIOD 0x004
#define HPET_COUNTER 0x0f0 #define HPET_COUNTER 0x0f0
#if defined(__x86_64__)
#define HPET_64BIT
#else
#define HPET_32BIT
#endif
static int hpet_fd; static int hpet_fd;
static unsigned char *hpet_ptr; static unsigned char *hpet_ptr;
static unsigned int hpet_period; /* period length in femto secs */ static unsigned int hpet_period; /* period length in femto secs */
@@ -64,10 +69,18 @@ jack_hpet_init ()
static jack_time_t static jack_time_t
jack_get_microseconds_from_hpet (void) jack_get_microseconds_from_hpet (void)
{ {
#ifdef HPET_64BIT
unsigned long long hpet_counter; unsigned long long hpet_counter;
#else
unsigned int hpet_counter;
#endif
long double hpet_time; long double hpet_time;


#ifdef HPET_64BIT
hpet_counter = *((unsigned long long *) (hpet_ptr + HPET_COUNTER)); hpet_counter = *((unsigned long long *) (hpet_ptr + HPET_COUNTER));
#else
hpet_counter = *((unsigned int *) (hpet_ptr + HPET_COUNTER));
#endif
hpet_time = (long double) hpet_counter * (long double) hpet_period * hpet_time = (long double) hpet_counter * (long double) hpet_period *
(long double) 1e-9; (long double) 1e-9;
return ((jack_time_t) (hpet_time + 0.5)); return ((jack_time_t) (hpet_time + 0.5));


Loading…
Cancel
Save