* 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
This commit is contained in:
Vincent Torri 2009-02-22 19:20:23 +00:00
parent 8477bdb496
commit 9d900b283a
5 changed files with 53 additions and 35 deletions

View File

@ -1,3 +1,16 @@
2009-02-22 Vincent Torri <doursse at users dot sf dot net>
* 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 <doursse at users dot sf dot net> 2009-02-16 Vincent Torri <doursse at users dot sf dot net>
* src/lib/evil_stdio.c: * src/lib/evil_stdio.c:

View File

@ -6,28 +6,24 @@
#include "Evil.h" #include "Evil.h"
#include "evil_private.h" #include "evil_private.h"
#if defined (_WIN32_WCE) && ! defined (__CEGCC__)
# define WIN32_LEAN_AND_MEAN # define WIN32_LEAN_AND_MEAN
# include <winsock2.h> # include <winsock2.h>
# undef WIN32_LEAN_AND_MEAN # undef WIN32_LEAN_AND_MEAN
extern long _evil_time_second; static int _evil_init_count = 0;
extern long _evil_time_millisecond;
#endif /* _WIN32_WCE && ! __CEGCC__ */ extern LONGLONG _evil_time_freq;
extern LONGLONG _evil_time_count;
static int _evil_init_count = 0; extern long _evil_time_second;
int int
evil_init() evil_init()
{ {
#if defined (_WIN32_WCE) && ! defined (__CEGCC__) SYSTEMTIME st;
SYSTEMTIME st; LARGE_INTEGER freq;
DWORD tick; LARGE_INTEGER count;
WORD second = 59; WORD second = 59;
#endif /* _WIN32_WCE && ! __CEGCC__ */
if (_evil_init_count > 0) if (_evil_init_count > 0)
{ {
@ -35,7 +31,11 @@ evil_init()
return _evil_init_count; 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 */ /* be sure that second + 1 != 0 */
while (second == 59) while (second == 59)
@ -48,7 +48,7 @@ evil_init()
while (1) while (1)
{ {
GetSystemTime(&st); GetSystemTime(&st);
tick = GetTickCount(); QueryPerformanceCounter(&count);
if (st.wSecond == second + 1) if (st.wSecond == second + 1)
break; break;
} }
@ -56,9 +56,7 @@ evil_init()
_evil_time_second = _evil_systemtime_to_time(st); _evil_time_second = _evil_systemtime_to_time(st);
if (_evil_time_second < 0) if (_evil_time_second < 0)
return 0; return 0;
_evil_time_millisecond = tick; _evil_time_count = count.QuadPart;
#endif /* _WIN32_WCE && ! __CEGCC__ */
_evil_init_count++; _evil_init_count++;

View File

@ -29,7 +29,11 @@ getpwuid (uid_t uid)
length = PATH_MAX; length = PATH_MAX;
/* get from USERPROFILE for win 98 ? */ /* 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 #ifdef UNICODE
if (res) if (res)
{ {

View File

@ -21,12 +21,9 @@
#include "evil_private.h" #include "evil_private.h"
#if defined (_WIN32_WCE) && ! defined (__CEGCC__) LONGLONG _evil_time_freq;
LONGLONG _evil_time_count;
long _evil_time_second; long _evil_time_second;
long _evil_time_millisecond;
#endif /* _WIN32_WCE && ! __CEGCC__ */
long 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 int
evil_gettimeofday(struct timeval *tp, void *tzp __UNUSED__) evil_gettimeofday(struct timeval *tp, void *tzp __UNUSED__)
{ {
int milli_sec; LARGE_INTEGER count;
LONGLONG diff;
milli_sec = (int)GetTickCount() - _evil_time_millisecond; QueryPerformanceCounter(&count);
tp->tv_sec = _evil_time_second + milli_sec / 1000; diff = count.QuadPart - _evil_time_count;
tp->tv_usec = (milli_sec % 1000) * 1000; tp->tv_sec = _evil_time_second + diff / _evil_time_freq;
tp->tv_usec = (diff % _evil_time_freq) * 1000000000ll;
return 1; return 1;
} }
#endif /* _WIN32_WCE && ! __CEGCC__ */
/* /*
* Process identifer related functions * Process identifer related functions

View File

@ -7,14 +7,11 @@
* *
*/ */
EAPI double evil_time_get();
#if defined (_WIN32_WCE) && ! defined (__CEGCC__)
EAPI int evil_gettimeofday(struct timeval * tp, void * tzp); EAPI int evil_gettimeofday(struct timeval * tp, void * tzp);
# define gettimeofday(tp, tzp) evil_gettimeofday(tp, tzp) #define gettimeofday(tp, tzp) evil_gettimeofday(tp, tzp)
#endif /* _WIN32_WCE && ! __CEGCC__ */
/* /*