summaryrefslogtreecommitdiff
path: root/src/porting.h
diff options
context:
space:
mode:
authorPerttu Ahola <celeron55@gmail.com>2010-12-21 18:08:24 +0200
committerPerttu Ahola <celeron55@gmail.com>2010-12-21 18:08:24 +0200
commit3f5bad938a3fcb601ad41924a4707476b8b87241 (patch)
treeddf9d7d49a93c092c31fcbdd6bf1c2ad42e43bc8 /src/porting.h
parent3b0bff2f743a3abf100368f94efafa7c2843a9b7 (diff)
downloadminetest-3f5bad938a3fcb601ad41924a4707476b8b87241.tar.gz
minetest-3f5bad938a3fcb601ad41924a4707476b8b87241.tar.bz2
minetest-3f5bad938a3fcb601ad41924a4707476b8b87241.zip
organizing stuff.
Diffstat (limited to 'src/porting.h')
-rw-r--r--src/porting.h37
1 files changed, 37 insertions, 0 deletions
diff --git a/src/porting.h b/src/porting.h
index 5938b91d4..19ac5c6bb 100644
--- a/src/porting.h
+++ b/src/porting.h
@@ -24,11 +24,48 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#ifndef PORTING_HEADER
#define PORTING_HEADER
+// Included for u64 and such
+#include "common_irrlicht.h"
+
#ifdef _WIN32
#define SWPRINTF_CHARSTRING L"%S"
#else
#define SWPRINTF_CHARSTRING L"%s"
#endif
+#ifdef _WIN32
+ #include <windows.h>
+ #define sleep_ms(x) Sleep(x)
+#else
+ #include <unistd.h>
+ #define sleep_ms(x) usleep(x*1000)
+#endif
+
+namespace porting
+{
+
+/*
+ Resolution is 10-20ms.
+ Remember to check for overflows.
+ Overflow can occur at any value higher than 10000000.
+*/
+#ifdef _WIN32 // Windows
+ #include <windows.h>
+ inline u32 getTimeMs()
+ {
+ return GetTickCount();
+ }
+#else // Posix
+ #include <sys/timeb.h>
+ inline u32 getTimeMs()
+ {
+ struct timeb tb;
+ ftime(&tb);
+ return tb.time * 1000 + tb.millitm;
+ }
+#endif
+
+} // namespace porting
+
#endif