Просмотр исходного кода

Support for systems where clock_gettime is not available

On some systems clock_gettime is not available so we are
testing availability and value of _POSIX_MONOTONIC_CLOCK.

On system without support of clock_gettime, we are using
old behaviour with function gettimeofday.


git-svn-id: http://svn.fedorahosted.org/svn/corosync/trunk@2376 fd59a12c-fef9-0310-b244-a6a79926bd2f
Jan Friesse 16 лет назад
Родитель
Сommit
2ef1853fe2
1 измененных файлов с 13 добавлено и 0 удалено
  1. 13 0
      exec/tlist.h

+ 13 - 0
exec/tlist.h

@@ -42,6 +42,7 @@
 #include <errno.h>
 #include <string.h>
 #include <sys/param.h>
+#include <unistd.h>
 
 #include <corosync/list.h>
 
@@ -92,6 +93,7 @@ static inline unsigned long long timerlist_nano_from_epoch (void)
 	return (nano_from_epoch);
 }
 
+#if defined _POSIX_MONOTONIC_CLOCK && _POSIX_MONOTONIC_CLOCK >= 0
 static inline unsigned long long timerlist_nano_current_get (void)
 {
 	unsigned long long nano_monotonic;
@@ -113,6 +115,17 @@ static inline unsigned long long timerlist_nano_monotonic_hz (void) {
 
 	return (nano_monotonic_hz);
 }
+#else
+#warning "Your system doesn't support monotonic timer. gettimeofday will be used"
+static inline unsigned long long timerlist_nano_current_get (void)
+{
+	return (timerlist_nano_from_epoch ());
+}
+
+static inline unsigned long long timerlist_nano_monotonic_hz (void) {
+	return HZ;
+}
+#endif
 
 static inline void timerlist_add (struct timerlist *timerlist, struct timerlist_timer *timer)
 {