From: Takashi Iwai Date: Fri, 7 Mar 2008 13:35:25 +0000 (+0100) Subject: Fix the build with old glibc X-Git-Tag: v1.0.17rc1~19 X-Git-Url: https://git.alsa-project.org/?a=commitdiff_plain;h=91726ddf83b27d21788d0ba044b628a79a3872ea;p=alsa-lib.git Fix the build with old glibc The old systems don't support CLOCK_MONOTONIC although clock_gettime() API itself exists. This causes compile errors. --- diff --git a/src/pcm/pcm_file.c b/src/pcm/pcm_file.c index 4b8eaa5c..a006696c 100644 --- a/src/pcm/pcm_file.c +++ b/src/pcm/pcm_file.c @@ -469,7 +469,7 @@ int snd_pcm_file_open(snd_pcm_t **pcmp, const char *name, pcm->poll_fd = slave->poll_fd; pcm->poll_events = slave->poll_events; pcm->mmap_shadow = 1; -#ifdef HAVE_CLOCK_GETTIME +#if defined(HAVE_CLOCK_GETTIME) && defined(CLOCK_MONOTONIC) pcm->monotonic = clock_gettime(CLOCK_MONOTONIC, ×pec) == 0; #else pcm->monotonic = 0; diff --git a/src/pcm/pcm_hw.c b/src/pcm/pcm_hw.c index 8495f71b..1b103b52 100644 --- a/src/pcm/pcm_hw.c +++ b/src/pcm/pcm_hw.c @@ -994,7 +994,7 @@ int snd_pcm_hw_open_fd(snd_pcm_t **pcmp, const char *name, if (SNDRV_PROTOCOL_INCOMPATIBLE(ver, SNDRV_PCM_VERSION_MAX)) return -SND_ERROR_INCOMPATIBLE_VERSION; -#ifdef HAVE_CLOCK_GETTIME +#if defined(HAVE_CLOCK_GETTIME) && defined(CLOCK_MONOTONIC) if (SNDRV_PROTOCOL_VERSION(2, 0, 9) <= ver) { struct timespec timespec; if (clock_gettime(CLOCK_MONOTONIC, ×pec) == 0) { diff --git a/src/pcm/pcm_local.h b/src/pcm/pcm_local.h index 8d4ae400..661d40ee 100644 --- a/src/pcm/pcm_local.h +++ b/src/pcm/pcm_local.h @@ -944,13 +944,17 @@ typedef union snd_tmp_double { /* get the current timestamp */ static inline void gettimestamp(snd_htimestamp_t *tstamp, int monotonic) { +#if defined(HAVE_CLOCK_GETTIME) && defined(CLOCK_MONOTONIC) if (monotonic) { clock_gettime(CLOCK_MONOTONIC, tstamp); } else { +#endif struct timeval tv; gettimeofday(&tv, 0); tstamp->tv_sec = tv.tv_sec; tstamp->tv_nsec = tv.tv_usec * 1000L; +#if defined(HAVE_CLOCK_GETTIME) && defined(CLOCK_MONOTONIC) } +#endif }