/************************************************************************ * Minetest-c55 * Copyright (C) 2010 celeron55, Perttu Ahola * * porting.h * voxelands - 3d voxel world sandbox game * Copyright (C) Lisa 'darkrose' Milne 2014 * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see * * License updated from GPLv2 or later to GPLv3 or later by Lisa Milne * for Voxelands. ************************************************************************/ /* Random portability stuff */ #ifndef PORTING_HEADER #define PORTING_HEADER #include // Included for u32 and such #include "common_irrlicht.h" #include "debug.h" #include "constants.h" #ifdef _MSC_VER #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 #if defined(__APPLE__) || defined(__FreeBSD__) #include #include #endif namespace porting { /* Signal handler (grabs Ctrl-C on POSIX systems) */ void signal_handler_init(void); // Returns a pointer to a bool. // When the bool is true, program should quit. bool * signal_handler_killstatus(void); /* 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 timeval tv; gettimeofday(&tv, NULL); return tv.tv_sec * 1000 + tv.tv_usec / 1000; } /*#include inline u32 getTimeMs() { struct timeb tb; ftime(&tb); return tb.time * 1000 + tb.millitm; }*/ #endif std::string getUser(); } // namespace porting #endif // PORTING_HEADER