Implement time functions in eina for WIN32

This commit is contained in:
Felipe Magno de Almeida 2020-05-04 19:10:47 -03:00
parent df3a9dab23
commit 253f8eaa77
3 changed files with 18 additions and 8 deletions

View File

@ -184,6 +184,10 @@ get_time(void)
struct timespec t;
clock_gettime(CLOCK_MONOTONIC, &t);
return (double)t.tv_sec + (((double)t.tv_nsec) / 1000000000.0);
#elif defined (_MSC_VER)
struct timespec t;
timespec_get (&t, TIME_UTC);
return (double)t.tv_sec + (((double)t.tv_nsec) / 1000000000.0);
#else
struct timeval timev;
gettimeofday(&timev, NULL);

View File

@ -39,7 +39,12 @@ _eina_time_get(Eina_Nano_Time *tp)
if (!clock_gettime(CLOCK_REALTIME, tp))
return 0;
# endif
#ifdef _MSC_VER
if (timespec_get(tp , TIME_UTC))
return 0;
else
return -1;
#else
/* FIXME: Have a look if and how we can support CLOCK_MONOTONIC */
struct timeval tv;
@ -51,6 +56,7 @@ _eina_time_get(Eina_Nano_Time *tp)
tp->tv_nsec = tv.tv_usec * 1000L;
return 0;
#endif
}
static inline long int

View File

@ -15,15 +15,15 @@
#include <../ucrt/time.h>
#include <sys/types.h>
typedef unsigned short u_short;
// typedef unsigned short u_short;
struct timezone {
int tz_minuteswest; /* minutes west of Greenwich */
int tz_dsttime; /* type of DST correction */
};
// struct timezone {
// int tz_minuteswest; /* minutes west of Greenwich */
// int tz_dsttime; /* type of DST correction */
// };
int gettimeofday(struct timeval * tp, struct timezone * tzp);
// int gettimeofday(struct timeval * tp, struct timezone * tzp);
struct tm *localtime_r(const time_t * time, struct tm * result);
// struct tm *localtime_r(const time_t * time, struct tm * result);
#endif