mirror of
https://github.com/Llewellynvdm/conky.git
synced 2024-11-05 21:07:52 +00:00
fallback to gettimeofday () if no clock_gettime () (mac os)
git-svn-id: https://conky.svn.sourceforge.net/svnroot/conky/trunk/conky1@830 7f574dfc-610e-0410-a909-a81674777703
This commit is contained in:
parent
1ff451efdd
commit
b85ae9209b
@ -1,5 +1,8 @@
|
||||
# $Id$
|
||||
|
||||
2007-01-14
|
||||
* Fallback to gettimeofday() when clock_gettime () not available (mac os).
|
||||
|
||||
2007-01-09
|
||||
* API change (timing in milliseconds) for dexter_timedsampler_new ().
|
||||
|
||||
|
@ -430,7 +430,10 @@ dnl Some functions
|
||||
dnl
|
||||
|
||||
AC_CHECK_FUNCS([calloc malloc free popen sysinfo getloadavg])
|
||||
AC_SEARCH_LIBS(clock_gettime, [rt], [], AC_MSG_ERROR([clock_gettime() not found]))
|
||||
AC_SEARCH_LIBS(clock_gettime, [rt],
|
||||
[AC_DEFINE(HAVE_CLOCK_GETTIME, 1, [Define if you have clock_gettime()])],
|
||||
[AC_CHECK_FUNCS([gettimeofday], [], [AC_MSG_ERROR([gettimeofday() not available!])])], [])
|
||||
|
||||
|
||||
dnl
|
||||
dnl Check for zlib
|
||||
|
15
src/linux.c
15
src/linux.c
@ -16,6 +16,9 @@
|
||||
#include <sys/types.h>
|
||||
#include <sys/sysinfo.h>
|
||||
#include <sys/stat.h>
|
||||
#ifndef HAVE_CLOCK_GETTIME
|
||||
#include <sys/time.h>
|
||||
#endif
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
// #include <assert.h>
|
||||
@ -2085,7 +2088,19 @@ void sampler_data_callback (gpointer sampler, gpointer sampler_data)
|
||||
|
||||
/* record data packet arrival time */
|
||||
g_mutex_lock (packet_mutex);
|
||||
#ifdef HAVE_CLOCK_GETTIME
|
||||
clock_gettime (CLOCK_REALTIME, &packet_arrival_time);
|
||||
#else
|
||||
{
|
||||
/* fallback to gettimeofday () */
|
||||
struct timeval tv;
|
||||
if (gettimeofday (&tv, NULL) == 0)
|
||||
{
|
||||
packet_arrival_time.tv_sec = tv.tv_sec;
|
||||
packet_arrival_time.tv_nsec = tv.tv_usec * 1000;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
g_mutex_unlock (packet_mutex);
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, "Conky: data packet arrived\n");
|
||||
|
@ -28,6 +28,9 @@
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <time.h>
|
||||
#ifndef HAVE_CLOCK_GETTIME
|
||||
#include <sys/time.h>
|
||||
#endif
|
||||
#include "timed_thread.h"
|
||||
|
||||
/* Abstraction layer for timed threads */
|
||||
@ -154,7 +157,22 @@ timed_thread_test (timed_thread* p_timed_thread)
|
||||
return (-1); /* could not acquire runnable_cond mutex, so tell caller to exit thread */
|
||||
|
||||
/* get the absolute time in the future we stop waiting for condition to signal */
|
||||
#ifdef HAVE_CLOCK_GETTIME
|
||||
clock_gettime (CLOCK_REALTIME, &abstime);
|
||||
#else
|
||||
{
|
||||
/* fallback to gettimeofday () */
|
||||
struct timeval tv;
|
||||
if (gettimeofday (&tv, NULL) != 0)
|
||||
{
|
||||
pthread_mutex_unlock (&p_timed_thread->runnable_mutex);
|
||||
return (-1);
|
||||
}
|
||||
|
||||
abstime.tv_sec = tv.tv_sec;
|
||||
abstime.tv_nsec = tv.tv_usec * 1000;
|
||||
}
|
||||
#endif
|
||||
/* seconds portion of the microseconds interval */
|
||||
reltime.tv_sec = (time_t)(p_timed_thread->interval_usecs / 1000000);
|
||||
/* remaining microseconds convert to nanoseconds */
|
||||
|
Loading…
Reference in New Issue
Block a user