summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/utils/timer.cpp10
-rw-r--r--src/utils/timer.h20
2 files changed, 18 insertions, 12 deletions
diff --git a/src/utils/timer.cpp b/src/utils/timer.cpp
index 25d96cbc..97965c75 100644
--- a/src/utils/timer.cpp
+++ b/src/utils/timer.cpp
@@ -26,7 +26,7 @@ namespace tmwserv
namespace utils
{
-Timer::Timer(signed int ms, bool createActive)
+Timer::Timer(unsigned int ms, bool createActive)
{
active = createActive;
interval = ms;
@@ -55,18 +55,18 @@ void Timer::stop()
active = false;
};
-void Timer::changeInterval(signed int newinterval)
+void Timer::changeInterval(unsigned int newinterval)
{
interval = newinterval;
};
-signed long long int Timer::getTimeInMillisec()
+uint64_t Timer::getTimeInMillisec()
{
- signed long long int timeInMillisec;
+ uint64_t timeInMillisec;
timeval time;
gettimeofday(&time, 0);
- timeInMillisec = (signed long long int)time.tv_sec * 1000 + time.tv_usec / 1000;
+ timeInMillisec = (uint64_t)time.tv_sec * 1000 + time.tv_usec / 1000;
return timeInMillisec;
};
diff --git a/src/utils/timer.h b/src/utils/timer.h
index 1fdf7af5..a921a828 100644
--- a/src/utils/timer.h
+++ b/src/utils/timer.h
@@ -24,8 +24,15 @@
#include <sys/time.h>
+/* I need a 64-bit unsigned integer */
+#ifdef _MSC_VER
+ typedef __uint64 uint64_t // when using MSVC use its internal type
+#else
+ #include <stdint.h> // on other compilers use the C99 official header
+#endif
+
#ifdef _WIN32
-#include "wingettimeofday.h"
+ #include "wingettimeofday.h"
#endif
namespace tmwserv
@@ -35,7 +42,6 @@ namespace utils
/**
* This class is for timing purpose as a replacement for SDL_TIMER
- * connections from and connecting to other computers.
*/
class Timer
@@ -44,7 +50,7 @@ class Timer
/**
* Constructor.
*/
- Timer(signed int ms, bool createActive = true);
+ Timer(unsigned int ms, bool createActive = true);
/**
* returns the number of elapsed tics since last call
@@ -64,23 +70,23 @@ class Timer
/**
* changes the interval between two pulses
*/
- void changeInterval (signed int newinterval);
+ void changeInterval (unsigned int newinterval);
private:
/**
* calls gettimeofday() and converts it into milliseconds
*/
- signed long long int getTimeInMillisec();
+ uint64_t getTimeInMillisec();
/**
* interval between two pulses
*/
- signed int interval;
+ unsigned int interval;
/**
* the time the last pulse occured
*/
- signed long long int lastpulse;
+ uint64_t lastpulse;
/**
* activity status of the timer