summaryrefslogtreecommitdiffstats
path: root/src/utils
diff options
context:
space:
mode:
authorPhilipp Sehmisch <tmw@crushnet.org>2006-04-30 10:47:02 +0000
committerPhilipp Sehmisch <tmw@crushnet.org>2006-04-30 10:47:02 +0000
commit46cf9258d20113a48f7d5811ea112df6504dc30e (patch)
tree031e25852528373a0d3dacb7d36161f0ae9b6130 /src/utils
parentecc2253758c536753036ae4ab5ed5e7b1d891c8d (diff)
downloadmanaserv-46cf9258d20113a48f7d5811ea112df6504dc30e.tar.gz
manaserv-46cf9258d20113a48f7d5811ea112df6504dc30e.tar.xz
manaserv-46cf9258d20113a48f7d5811ea112df6504dc30e.zip
made sure every compiler uses a 64bit unsigned integer for getTimeInMillisec.
Diffstat (limited to 'src/utils')
-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 25d96cb..97965c7 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 1fdf7af..a921a82 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