Merge branch 'refs/heads/t/stale-pointer-fix'
[paraslash.git] / time.c
diff --git a/time.c b/time.c
index c405351a96f978c39b18ec0466a65fad012aff26..bb47b31b7b262ca8a988377d899e166abdd5d029 100644 (file)
--- a/time.c
+++ b/time.c
@@ -1,8 +1,4 @@
-/*
- * Copyright (C) 2005-2014 Andre Noll <maan@systemlinux.org>
- *
- * Licensed under the GPL v2. For licencing details see COPYING.
- */
+/* Copyright (C) 2005 Andre Noll <maan@tuebingen.mpg.de>, see file COPYING. */
 
 #include "para.h"
 /** \file time.c Helper functions for dealing with time values. */
@@ -31,18 +27,6 @@ void ms2tv(long unsigned n, struct timeval *tv)
        tv->tv_usec = (n % 1000) * 1000;
 }
 
-/**
- * Convert a double to a struct timeval.
- *
- * \param x The value to convert.
- * \param tv Result pointer.
- */
-void d2tv(double x, struct timeval *tv)
-{
-       tv->tv_sec = x;
-       tv->tv_usec = (x - (double)tv->tv_sec) * 1000.0 * 1000.0 + 0.5;
-}
-
 /**
  * Compute the difference of two time values.
  *
@@ -210,22 +194,14 @@ void compute_chunk_time(long unsigned chunk_num,
 struct timeval *clock_get_realtime(struct timeval *tv)
 {
        static struct timeval user_friendly;
+       struct timespec t;
+       int ret;
 
        if (!tv)
                tv = &user_friendly;
-#ifdef HAVE_CLOCK_GETTIME
-       {
-               struct timespec t;
-               int ret;
-
-               ret = clock_gettime(CLOCK_REALTIME, &t);
-               assert(ret == 0);
-               tv->tv_sec = t.tv_sec;
-               tv->tv_usec = t.tv_nsec / 1000;
-       }
-#else
-       #include <sys/time.h>
-       gettimeofday(tv, NULL);
-#endif /* HAVE_CLOCK_GETTIME */
+       ret = clock_gettime(CLOCK_REALTIME, &t);
+       assert(ret == 0);
+       tv->tv_sec = t.tv_sec;
+       tv->tv_usec = t.tv_nsec / 1000;
        return tv;
 }