From 6290bd4353974745f46e2711947d063503f29323 Mon Sep 17 00:00:00 2001 From: Wolf Bergenheim Date: Thu, 9 Sep 2010 10:12:20 +0300 Subject: Changed timer to return ms as a long int --- resourceqt-client/client.cpp | 24 ++++++++++++------------ resourceqt-client/resourceqt-client.pro | 3 ++- resourceqt-client/time-stat.c | 7 ++++--- resourceqt-client/time-stat.h | 2 +- 4 files changed, 19 insertions(+), 17 deletions(-) (limited to 'resourceqt-client') diff --git a/resourceqt-client/client.cpp b/resourceqt-client/client.cpp index daf0486..7f999b2 100644 --- a/resourceqt-client/client.cpp +++ b/resourceqt-client/client.cpp @@ -185,9 +185,9 @@ void Client::showResources(const QList &resList) void Client::resourceAcquiredHandler(const QList& /*grantedResList*/) { - double ms = stop_timer(); - if( ms > 0.0 ) { - output << "Operation took " << (quint32)ms << "ms"; + long int ms = stop_timer(); + if( ms > 0 ) { + output << "Operation took " << ms << "ms"; } QList list = resourceSet->resources(); @@ -203,9 +203,9 @@ void Client::resourceAcquiredHandler(const QList& /*grantedResList void Client::resourceDeniedHandler() { - double ms = stop_timer(); - if( ms > 0.0 ) { - output << "Operation took " << (quint32)ms << "ms"; + long int ms = stop_timer(); + if( ms > 0 ) { + output << "Operation took " << ms << "ms"; } output << "\nManager denies access to resources!" << endl; @@ -214,9 +214,9 @@ void Client::resourceDeniedHandler() void Client::resourceLostHandler() { - double ms = stop_timer(); - if( ms > 0.0 ) { - output << "Operation took " << (quint32)ms << "ms"; + long int ms = stop_timer(); + if( ms > 0 ) { + output << "Operation took " << ms << "ms"; } output << "\nLost resources from manager!" << endl; @@ -225,9 +225,9 @@ void Client::resourceLostHandler() void Client::resourceReleasedHandler() { - double ms = stop_timer(); - if( ms > 0.0 ) { - output << "Operation took " << (quint32)ms << "ms"; + long int ms = stop_timer(); + if( ms > 0 ) { + output << "Operation took " << ms << "ms"; } output << "\nAll resources released" << endl; diff --git a/resourceqt-client/resourceqt-client.pro b/resourceqt-client/resourceqt-client.pro index bd2c178..ce378c6 100644 --- a/resourceqt-client/resourceqt-client.pro +++ b/resourceqt-client/resourceqt-client.pro @@ -11,7 +11,8 @@ CONFIG -= app_bundle INCLUDEPATH += $${LIBRESOURCEINC} QMAKE_CXXFLAGS += -Wall -LIBS += -L$${LIBRESOURCEQT}/build -lresourceqt -L$${LIBDBUSQEVENTLOOP}/build -ldbus-qeventloop +QMAKE_CFLAGS += -std=c99 -D_POSIX_C_SOURCE=199309L +LIBS += -L$${LIBRESOURCEQT}/build -lresourceqt -L$${LIBDBUSQEVENTLOOP}/build -ldbus-qeventloop -lm -lrt # Input HEADERS = client.h commandlineparser.h time-stat.h diff --git a/resourceqt-client/time-stat.c b/resourceqt-client/time-stat.c index 6fb4fdc..c18daa5 100644 --- a/resourceqt-client/time-stat.c +++ b/resourceqt-client/time-stat.c @@ -1,6 +1,7 @@ +#include #include "time-stat.h" -static struct timespec start_time = {0,0}; +static struct timespec start_time; int start_timer(void) { @@ -13,7 +14,7 @@ int start_timer(void) return 0; } -double stop_timer(void) +long int stop_timer(void) { struct timespec end_time; int r; @@ -28,6 +29,6 @@ double stop_timer(void) start_time.tv_sec = 0; start_time.tv_nsec = 0; - return milliseconds; + return lround(milliseconds); } diff --git a/resourceqt-client/time-stat.h b/resourceqt-client/time-stat.h index 0bd5eaf..e32a4cb 100644 --- a/resourceqt-client/time-stat.h +++ b/resourceqt-client/time-stat.h @@ -7,7 +7,7 @@ extern "C" { #endif int start_timer(void); -double stop_timer(void); +long int stop_timer(void); #ifdef __cplusplus } #endif -- cgit v1.2.3