Permalink
Browse files

Determine CLOCK_MONOTONIC_RAW support

  • Loading branch information...
1 parent 2eb4146 commit a0c71638cfc50e988ae838df2addcb4ab5070741 @maksbotan maksbotan committed with Jan 1, 2012
Showing with 13 additions and 0 deletions.
  1. +1 −0 .gitignore
  2. +5 −0 libdevcheck/CMakeLists.txt
  3. +2 −0 libdevcheck/config.h.in
  4. +5 −0 libdevcheck/libdevcheck.c
View
@@ -8,3 +8,4 @@ Makefile
whdd-cli
whdd-curses
version.h
+config.h
@@ -1,4 +1,9 @@
+include (CheckSymbolExists)
+check_symbol_exists (CLOCK_MONOTONIC_RAW "time.h" HAVE_CLOCK_MONOTONIC_RAW)
+configure_file (${CMAKE_CURRENT_SOURCE_DIR}/config.h.in
+ ${CMAKE_CURRENT_BINARY_DIR}/config.h)
+
add_custom_command (
OUTPUT version.h
COMMAND cd ${PROJECT_SOURCE_DIR}/libdevcheck/ && ./version.sh >
@@ -0,0 +1,2 @@
+
+#cmakedefine HAVE_CLOCK_MONOTONIC_RAW
@@ -7,6 +7,7 @@
#include "libdevcheck.h"
#include "action.h"
+#include "config.h"
clockid_t DC_BEST_CLOCK;
@@ -15,6 +16,7 @@ DC_Ctx *dc_init(void) {
if (!ctx)
return NULL;
+#ifdef HAVE_CLOCK_MONOTONIC_RAW
/* determine best available clock */
int r;
struct timespec dummy;
@@ -23,6 +25,9 @@ DC_Ctx *dc_init(void) {
if (r) {
DC_BEST_CLOCK = CLOCK_MONOTONIC;
}
+#else
+ DC_BEST_CLOCK = CLOCK_MONOTONIC;
+#endif
#define ACTION_REGISTER(x) { \
extern DC_Action x; \

0 comments on commit a0c7163

Please sign in to comment.