diff options
Diffstat (limited to 'src/porting.h')
-rw-r--r-- | src/porting.h | 37 |
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 |