* 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>
* src/lib/evil_stdio.c:

View File

@ -6,28 +6,24 @@
#include "Evil.h"
#include "evil_private.h"
#if defined (_WIN32_WCE) && ! defined (__CEGCC__)
# define WIN32_LEAN_AND_MEAN
# include <winsock2.h>
# 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++;

View File

@ -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)
{

View File

@ -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

View File

@ -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)
/*