From 9d900b283a209f1ab4309b89e1b89f53b5d25669 Mon Sep 17 00:00:00 2001 From: Vincent Torri Date: Sun, 22 Feb 2009 19:20:23 +0000 Subject: [PATCH] * src/lib/evil_main.c: * src/lib/evil_unistd.c: * src/lib/evil_unistd.h: Use high resolution timer for gettimeofday() and export a convenient function for ecore_time_get(), to save some computations. * src/lib/evil_pwd.c: Use the correct name for GetUserNameEx() according to the platform. SVN revision: 39148 --- legacy/evil/ChangeLog | 13 +++++++++++++ legacy/evil/src/lib/evil_main.c | 32 +++++++++++++++---------------- legacy/evil/src/lib/evil_pwd.c | 6 +++++- legacy/evil/src/lib/evil_unistd.c | 30 +++++++++++++++++------------ legacy/evil/src/lib/evil_unistd.h | 7 ++----- 5 files changed, 53 insertions(+), 35 deletions(-) diff --git a/legacy/evil/ChangeLog b/legacy/evil/ChangeLog index b586a3f788..48f1c66e3a 100644 --- a/legacy/evil/ChangeLog +++ b/legacy/evil/ChangeLog @@ -1,3 +1,16 @@ +2009-02-22 Vincent Torri + + * src/lib/evil_main.c: + * src/lib/evil_unistd.c: + * src/lib/evil_unistd.h: + Use high resolution timer for gettimeofday() and + export a convenient function for ecore_time_get(), + to save some computations. + + * src/lib/evil_pwd.c: + Use the correct name for GetUserNameEx() according + to the platform. + 2009-02-16 Vincent Torri * src/lib/evil_stdio.c: diff --git a/legacy/evil/src/lib/evil_main.c b/legacy/evil/src/lib/evil_main.c index 7c91e010e2..d908640794 100644 --- a/legacy/evil/src/lib/evil_main.c +++ b/legacy/evil/src/lib/evil_main.c @@ -6,28 +6,24 @@ #include "Evil.h" #include "evil_private.h" -#if defined (_WIN32_WCE) && ! defined (__CEGCC__) - # define WIN32_LEAN_AND_MEAN # include # undef WIN32_LEAN_AND_MEAN -extern long _evil_time_second; -extern long _evil_time_millisecond; +static int _evil_init_count = 0; -#endif /* _WIN32_WCE && ! __CEGCC__ */ - -static int _evil_init_count = 0; +extern LONGLONG _evil_time_freq; +extern LONGLONG _evil_time_count; +extern long _evil_time_second; int evil_init() { -#if defined (_WIN32_WCE) && ! defined (__CEGCC__) - SYSTEMTIME st; - DWORD tick; - WORD second = 59; -#endif /* _WIN32_WCE && ! __CEGCC__ */ + SYSTEMTIME st; + LARGE_INTEGER freq; + LARGE_INTEGER count; + WORD second = 59; if (_evil_init_count > 0) { @@ -35,7 +31,11 @@ evil_init() return _evil_init_count; } -#if defined (_WIN32_WCE) && ! defined (__CEGCC__) + if (!QueryPerformanceFrequency(&freq)) + { + return 0; + } + _evil_time_freq = freq.QuadPart; /* be sure that second + 1 != 0 */ while (second == 59) @@ -48,7 +48,7 @@ evil_init() while (1) { GetSystemTime(&st); - tick = GetTickCount(); + QueryPerformanceCounter(&count); if (st.wSecond == second + 1) break; } @@ -56,9 +56,7 @@ evil_init() _evil_time_second = _evil_systemtime_to_time(st); if (_evil_time_second < 0) return 0; - _evil_time_millisecond = tick; - -#endif /* _WIN32_WCE && ! __CEGCC__ */ + _evil_time_count = count.QuadPart; _evil_init_count++; diff --git a/legacy/evil/src/lib/evil_pwd.c b/legacy/evil/src/lib/evil_pwd.c index 886220d2c5..56eaae9910 100644 --- a/legacy/evil/src/lib/evil_pwd.c +++ b/legacy/evil/src/lib/evil_pwd.c @@ -29,7 +29,11 @@ getpwuid (uid_t uid) length = PATH_MAX; /* get from USERPROFILE for win 98 ? */ - res = GetUserNameEx(NameUnknown, name, &length); +#ifdef _WIN32_WINNT + res = GetUserNameEx(NameDisplay, name, &length); +#else + res = GetUserNameEx(NameWindowsCeLocal, name, &length); +#endif #ifdef UNICODE if (res) { diff --git a/legacy/evil/src/lib/evil_unistd.c b/legacy/evil/src/lib/evil_unistd.c index fc7fd9af32..d9eea5a021 100644 --- a/legacy/evil/src/lib/evil_unistd.c +++ b/legacy/evil/src/lib/evil_unistd.c @@ -21,12 +21,9 @@ #include "evil_private.h" -#if defined (_WIN32_WCE) && ! defined (__CEGCC__) - -long _evil_time_second; -long _evil_time_millisecond; - -#endif /* _WIN32_WCE && ! __CEGCC__ */ +LONGLONG _evil_time_freq; +LONGLONG _evil_time_count; +long _evil_time_second; long @@ -58,21 +55,30 @@ _evil_systemtime_to_time(SYSTEMTIME st) * */ -#if defined (_WIN32_WCE) && ! defined (__CEGCC__) +double +evil_time_get() +{ + LARGE_INTEGER count; + + QueryPerformanceCounter(&count); + + return (double)_evil_time_second + (double)(count.QuadPart - _evil_time_count)/ (double)_evil_time_freq; +} int evil_gettimeofday(struct timeval *tp, void *tzp __UNUSED__) { - int milli_sec; + LARGE_INTEGER count; + LONGLONG diff; - milli_sec = (int)GetTickCount() - _evil_time_millisecond; - tp->tv_sec = _evil_time_second + milli_sec / 1000; - tp->tv_usec = (milli_sec % 1000) * 1000; + QueryPerformanceCounter(&count); + diff = count.QuadPart - _evil_time_count; + tp->tv_sec = _evil_time_second + diff / _evil_time_freq; + tp->tv_usec = (diff % _evil_time_freq) * 1000000000ll; return 1; } -#endif /* _WIN32_WCE && ! __CEGCC__ */ /* * Process identifer related functions diff --git a/legacy/evil/src/lib/evil_unistd.h b/legacy/evil/src/lib/evil_unistd.h index 4d558a5b2e..fc5c63c88f 100644 --- a/legacy/evil/src/lib/evil_unistd.h +++ b/legacy/evil/src/lib/evil_unistd.h @@ -7,14 +7,11 @@ * */ - -#if defined (_WIN32_WCE) && ! defined (__CEGCC__) +EAPI double evil_time_get(); EAPI int evil_gettimeofday(struct timeval * tp, void * tzp); -# define gettimeofday(tp, tzp) evil_gettimeofday(tp, tzp) - -#endif /* _WIN32_WCE && ! __CEGCC__ */ +#define gettimeofday(tp, tzp) evil_gettimeofday(tp, tzp) /*