FreeCalypso > hg > freecalypso-reveng
changeset 356:00060bb8b240
fluid-mnf/misc.c: fixed stopwatch functions for Unix
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Fri, 13 Mar 2020 20:47:37 +0000 |
parents | e77d478e3724 |
children | ebb9377cf52c |
files | fluid-mnf/misc.c |
diffstat | 1 files changed, 11 insertions(+), 15 deletions(-) [+] |
line wrap: on
line diff
--- a/fluid-mnf/misc.c Fri Mar 13 19:59:27 2020 +0000 +++ b/fluid-mnf/misc.c Fri Mar 13 20:47:37 2020 +0000 @@ -16,11 +16,7 @@ #include <stdio.h> #include <string.h> -#include <time.h> - -#if defined(MSC) || defined(BCC) -#include "windows.h" -#endif +#include <sys/time.h> /****************************************************************************** @@ -213,22 +209,22 @@ } } +static int get_milliseconds(void) +{ + struct timeval tv; + + gettimeofday(&tv, 0); + return ((int) tv.tv_sec * 1000) + ((int) tv.tv_usec / 1000); +} + int stopwatch_start(void) { -#if defined(MSC) || defined(BCC) - return GetTickCount(); -#else - return 1000 * time(NULL); -#endif + return get_milliseconds(); } int stopwatch_stop(int time_start) { -#if defined(MSC) || defined(BCC) - return GetTickCount() - time_start; -#else - return 1000 * (time(NULL) - time_start); -#endif + return get_milliseconds() - time_start; }