[VC++] Quick & dirty fix to avoid the gettimeofday function when _MSC_VER is defined

This commit is contained in:
Bertrand Songis
2016-03-15 07:12:37 +01:00
parent 0807edfc20
commit b1ebcb9ace
+11 -3
View File
@@ -17,17 +17,17 @@
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
*/ */
#include "opentx.h" #include "opentx.h"
#include <errno.h> #include <errno.h>
#include <fcntl.h> #include <fcntl.h>
#include <stdarg.h> #include <stdarg.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <sys/time.h>
#if defined WIN32 || !defined __GNUC__ #if defined(_MSC_VER)
#include <direct.h> #include <direct.h>
#define mkdir(s, f) _mkdir(s) #define mkdir(s, f) _mkdir(s)
#else
#include <sys/time.h>
#endif #endif
#if defined(SIMU_DISKIO) #if defined(SIMU_DISKIO)
@@ -96,16 +96,24 @@ void toplcdOff()
uint16_t getTmr16KHz() uint16_t getTmr16KHz()
{ {
#if defined(_MSC_VER)
return get_tmr10ms() * 16;
#else
struct timeval tv; struct timeval tv;
gettimeofday(&tv, NULL); gettimeofday(&tv, NULL);
return tv.tv_usec * 2 / 125; return tv.tv_usec * 2 / 125;
#endif
} }
uint16_t getTmr2MHz() uint16_t getTmr2MHz()
{ {
#if defined(_MSC_VER)
return get_tmr10ms() * 125;
#else
struct timeval tv; struct timeval tv;
gettimeofday(&tv, NULL); gettimeofday(&tv, NULL);
return tv.tv_usec * 2; return tv.tv_usec * 2;
#endif
} }
void simuInit() void simuInit()