(THRIFT-69) Fix Util::currentTime for use in applications.
This function didn't work properly when used outside of the Thrift library
because config.h isn't available. This patch fixes the issue by moving
the function definition into the library.
git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@675819 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/lib/cpp/src/concurrency/Util.h b/lib/cpp/src/concurrency/Util.h
index 4031be0..483d14a 100644
--- a/lib/cpp/src/concurrency/Util.h
+++ b/lib/cpp/src/concurrency/Util.h
@@ -7,17 +7,11 @@
#ifndef _THRIFT_CONCURRENCY_UTIL_H_
#define _THRIFT_CONCURRENCY_UTIL_H_ 1
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
#include <assert.h>
#include <stddef.h>
-#if defined(HAVE_CLOCK_GETTIME)
+#include <stdint.h>
#include <time.h>
-#else // defined(HAVE_CLOCK_GETTIME)
#include <sys/time.h>
-#endif // defined(HAVE_CLOCK_GETTIME)
namespace facebook { namespace thrift { namespace concurrency {
@@ -86,24 +80,7 @@
/**
* Get current time as milliseconds from epoch
*/
- static const int64_t currentTime() {
- int64_t result;
-
-#if defined(HAVE_CLOCK_GETTIME)
- struct timespec now;
- int ret = clock_gettime(CLOCK_REALTIME, &now);
- assert(ret == 0);
- toMilliseconds(result, now);
-#elif defined(HAVE_GETTIMEOFDAY)
- struct timeval now;
- int ret = gettimeofday(&now, NULL);
- assert(ret == 0);
- toMilliseconds(result, now);
-#endif // defined(HAVE_GETTIMEDAY)
-
- return result;
- }
-
+ static const int64_t currentTime();
};
}}} // facebook::thrift::concurrency