aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJon Lund Steffensen <jonlst@gmail.com>2014-12-28 13:10:27 -0500
committerJon Lund Steffensen <jonlst@gmail.com>2014-12-28 13:10:31 -0500
commit4adf25952f8af0a8b61b3737b46c6a7146fd034a (patch)
treeb808a18145e730eb2dea7a426b6ac9fa22d8070a
parentcontrib: Add appdata file to RPM package (diff)
downloadredshift-ng-4adf25952f8af0a8b61b3737b46c6a7146fd034a.tar.gz
redshift-ng-4adf25952f8af0a8b61b3737b46c6a7146fd034a.tar.bz2
redshift-ng-4adf25952f8af0a8b61b3737b46c6a7146fd034a.tar.xz
systemtime: Fix includes and check for _POSIX_TIMERS
Fix missing include of windows.h on windows platform. Change check for _POSIX_TIMERS to check that it is greater than 0. On OS X, the POSIX timers are not available and _POSIX_TIMERS is -1.
-rw-r--r--src/systemtime.c9
-rw-r--r--src/systemtime.h8
2 files changed, 8 insertions, 9 deletions
diff --git a/src/systemtime.c b/src/systemtime.c
index 12b74cc..84106c5 100644
--- a/src/systemtime.c
+++ b/src/systemtime.c
@@ -18,17 +18,22 @@
*/
#include <stdio.h>
+#include <unistd.h>
#ifndef _WIN32
-# ifdef _POSIX_TIMERS
+# if _POSIX_TIMERS > 0
# include <time.h>
# else
# include <sys/time.h>
# endif
+#else
+# include <windows.h>
#endif
#include "systemtime.h"
+
+/* Return current time in T as the number of seconds since the epoch. */
int
systemtime_get_time(double *t)
{
@@ -41,7 +46,7 @@ systemtime_get_time(double *t)
/* FILETIME is tenths of microseconds since 1601-01-01 UTC */
*t = (i.QuadPart / 10000000.0) - 11644473600.0;
-#elif defined(_POSIX_TIMERS) /* POSIX timers */
+#elif _POSIX_TIMERS > 0 /* POSIX timers */
struct timespec now;
int r = clock_gettime(CLOCK_REALTIME, &now);
if (r < 0) {
diff --git a/src/systemtime.h b/src/systemtime.h
index 90da169..0a6a66c 100644
--- a/src/systemtime.h
+++ b/src/systemtime.h
@@ -14,18 +14,12 @@
You should have received a copy of the GNU General Public License
along with Redshift. If not, see <http://www.gnu.org/licenses/>.
- Copyright (c) 2010 Jon Lund Steffensen <jonlst@gmail.com>
+ Copyright (c) 2010-2014 Jon Lund Steffensen <jonlst@gmail.com>
*/
#ifndef REDSHIFT_SYSTEMTIME_H
#define REDSHIFT_SYSTEMTIME_H
-#ifndef _WIN32
-# include <time.h>
-#else
-# include <windows.h>
-#endif
-
int systemtime_get_time(double *now);