From 3f5bad938a3fcb601ad41924a4707476b8b87241 Mon Sep 17 00:00:00 2001 From: Perttu Ahola Date: Tue, 21 Dec 2010 18:08:24 +0200 Subject: organizing stuff. --- src/porting.h | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) (limited to 'src/porting.h') 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 + #define sleep_ms(x) Sleep(x) +#else + #include + #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 + inline u32 getTimeMs() + { + return GetTickCount(); + } +#else // Posix + #include + inline u32 getTimeMs() + { + struct timeb tb; + ftime(&tb); + return tb.time * 1000 + tb.millitm; + } +#endif + +} // namespace porting + #endif -- cgit v1.2.3