Fix APPLE identifier.
[awesomized/libmemcached] / libtest / alarm.cc
index 08ac787cf2838b11f2a54d9fc477aa28b09b01e4..6193fbb3cd094065a089c9a21cc84a1c67ae0127 100644 (file)
@@ -34,7 +34,8 @@
  *
  */
 
-#include <config.h>
+#include "libtest/yatlcon.h"
+
 #include <libtest/common.h>
 
 #include <sys/time.h>
@@ -59,7 +60,23 @@ void set_alarm()
 
 void set_alarm(long tv_sec, long tv_usec)
 {
-#if defined(TARGET_OS_OSX) && TARGET_OS_OSX
+  // For the moment use any value to YATL_ALARM to cancel alarming.
+  if (getenv("YATL_ALARM"))
+  {
+    errno= 0;
+    tv_sec= strtol(getenv("YATL_ALARM"), (char **) NULL, 10);
+
+    if (errno != 0)
+    {
+      FATAL("Bad value for YATL_ALARM");
+    }
+    else if (tv_sec == 0)
+    {
+      cancel_alarm();
+    }
+  }
+
+#ifdef __APPLE__
   struct timeval it_value= { time_t(tv_sec), suseconds_t(tv_usec) };
 #else
   struct timeval it_value= { tv_sec, tv_usec };