[tor-commits] [tlsdate/debian-master] Change check for RTC to be configure based.

ioerror at torproject.org ioerror at torproject.org
Thu Oct 31 10:51:32 UTC 2013


commit fddd223536b0f68ab5a09a35c454cca9d96d38c6
Author: Nick Mathewson <nickm at torproject.org>
Date:   Thu Oct 10 15:01:53 2013 -0400

    Change check for RTC to be configure based.
    
    Previously I had disabled it with #ifdef __linux__, but that's not
    very good autoconf style.
---
 configure.ac |    7 +++++++
 src/util.c   |   10 +++++++---
 2 files changed, 14 insertions(+), 3 deletions(-)

diff --git a/configure.ac b/configure.ac
index 231547e..f1a424f 100644
--- a/configure.ac
+++ b/configure.ac
@@ -143,6 +143,13 @@ AC_CHECK_HEADERS([sys/wait.h], ,[AC_MSG_ERROR([Required headers missing; compila
 AC_CHECK_HEADERS([time.h], ,[AC_MSG_ERROR([Required headers missing; compilation will not succeed])])
 AC_CHECK_HEADERS([unistd.h], ,[AC_MSG_ERROR([Required headers missing; compilation will not succeed])])
 
+AC_CHECK_HEADERS([linux/rtc.h])
+AC_CHECK_TYPES([struct rtc_time], [], [], [
+#ifdef HAVE_LINUX_RTC_H
+#include <linux/rtc.h>
+#endif
+])
+
 AC_CHECK_FUNCS([strnlen])
 AM_CONDITIONAL(HAVE_STRNLEN, [test "x${ac_cv_func_strnlen}" = xyes])
 
diff --git a/src/util.c b/src/util.c
index 129de8d..4f1d0e0 100644
--- a/src/util.c
+++ b/src/util.c
@@ -11,7 +11,7 @@
 #include <fcntl.h>
 #include <grp.h>
 #include <limits.h>
-#ifdef __linux__
+#ifdef HAVE_LINUX_RTC_H
 #include <linux/rtc.h>
 #endif
 #include <pwd.h>
@@ -29,6 +29,10 @@
 
 #include "src/util.h"
 
+#if defined(HAVE_STRUCT_RTC_TIME) && defined(RTC_SET_TIME) && defined(RTC_RD_TIME)
+#define ENABLE_RTC
+#endif
+
 const char *kTempSuffix = DEFAULT_DAEMON_TMPSUFFIX;
 
 /** helper function to print message and die */
@@ -145,7 +149,7 @@ wait_with_timeout(int *status, int timeout_secs)
   return exited;
 }
 
-#ifdef __linux__
+#ifdef ENABLE_RTC
 struct rtc_handle
 {
 	int fd;
@@ -308,7 +312,7 @@ int pgrp_kill(void)
 }
 
 static struct platform default_platform = {
-#ifdef __linux__
+#ifdef ENABLE_RTC
 	.rtc_open = rtc_open,
 	.rtc_write = rtc_write,
 	.rtc_read = rtc_read,





More information about the tor-commits mailing list