summaryrefslogtreecommitdiff
path: root/resourceqt-client
diff options
context:
space:
mode:
Diffstat (limited to 'resourceqt-client')
-rw-r--r--resourceqt-client/client.cpp24
-rw-r--r--resourceqt-client/resourceqt-client.pro3
-rw-r--r--resourceqt-client/time-stat.c7
-rw-r--r--resourceqt-client/time-stat.h2
4 files changed, 19 insertions, 17 deletions
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<Resource*> &resList)
void Client::resourceAcquiredHandler(const QList<ResourceType>& /*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<Resource*> list = resourceSet->resources();
@@ -203,9 +203,9 @@ void Client::resourceAcquiredHandler(const QList<ResourceType>& /*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 <math.h>
#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