forked from enlightenment/efl
* src/bin/Makefile.am:
* src/bin/evil_suite.c: * src/bin/evil_test_gettimeofday.c: * src/bin/evil_test_gettimeofday.h: add a small test for gettimeofday * src/bin/evil_test_memcpy.c: fix warning * src/lib/Evil.h: * src/lib/Makefile.am: * src/lib/evil_main.c: * src/lib/evil_main.h: * src/lib/evil_unistd.c: * src/lib/evil_unistd.h: * src/lib/evil_private.h: add gettimeofday for Windows CE natively. It is necessary to initialise evil with evil_init() now, to have that feature. * src/lib/evil_stdio.c: * src/lib/evil_string.c: fix warnings SVN revision: 37734
This commit is contained in:
parent
d489f5edc2
commit
d7092143aa
|
@ -1,3 +1,29 @@
|
|||
2008-11-21 Vincent Torri <doursse at users dot sf dot net>
|
||||
|
||||
* src/bin/Makefile.am:
|
||||
* src/bin/evil_suite.c:
|
||||
* src/bin/evil_test_gettimeofday.c:
|
||||
* src/bin/evil_test_gettimeofday.h:
|
||||
add a small test for gettimeofday
|
||||
|
||||
* src/bin/evil_test_memcpy.c:
|
||||
fix warning
|
||||
|
||||
* src/lib/Evil.h:
|
||||
* src/lib/Makefile.am:
|
||||
* src/lib/evil_main.c:
|
||||
* src/lib/evil_main.h:
|
||||
* src/lib/evil_unistd.c:
|
||||
* src/lib/evil_unistd.h:
|
||||
* src/lib/evil_private.h:
|
||||
add gettimeofday for Windows CE natively. It is necessary
|
||||
to initialise evil with evil_init() now, to have that
|
||||
feature.
|
||||
|
||||
* src/lib/evil_stdio.c:
|
||||
* src/lib/evil_string.c:
|
||||
fix warnings
|
||||
|
||||
2008-11-12 Vincent Torri <doursse at users dot sf dot net>
|
||||
|
||||
* src/lib/evil_unistd.h:
|
||||
|
|
|
@ -5,7 +5,8 @@ AM_CPPFLAGS = \
|
|||
-I$(top_srcdir) \
|
||||
-I$(top_srcdir)/bin \
|
||||
-I$(top_srcdir)/src/lib \
|
||||
-I$(top_srcdir)/src/lib/dlfcn
|
||||
-I$(top_srcdir)/src/lib/dlfcn \
|
||||
@win32_cppflags@
|
||||
|
||||
AM_CFLAGS = @win32_cflags@
|
||||
|
||||
|
@ -14,6 +15,7 @@ bin_PROGRAMS = evil_suite test_dlfcn test_pipe test_evil
|
|||
evil_suite_SOURCES = \
|
||||
evil_suite.c \
|
||||
evil_test_environment.c \
|
||||
evil_test_gettimeofday.c \
|
||||
evil_test_link.c \
|
||||
evil_test_memcpy.c
|
||||
|
||||
|
|
|
@ -5,8 +5,10 @@
|
|||
#include <windows.h>
|
||||
#undef WIN32_LEAN_AND_MEAN
|
||||
|
||||
#include "Evil.h"
|
||||
#include "evil_suite.h"
|
||||
#include "evil_test_environment.h"
|
||||
#include "evil_test_gettimeofday.h"
|
||||
#include "evil_test_link.h"
|
||||
#include "evil_test_memcpy.h"
|
||||
|
||||
|
@ -150,17 +152,24 @@ int
|
|||
main()
|
||||
{
|
||||
test tests[] = {
|
||||
{ "environment", test_environment },
|
||||
{ "link ", test_link },
|
||||
{ "memcpy ", test_memcpy },
|
||||
{ NULL, NULL },
|
||||
{ "environment ", test_environment },
|
||||
{ "gettimeofday", test_gettimeofday },
|
||||
{ "link ", test_link },
|
||||
{ "memcpy ", test_memcpy },
|
||||
{ NULL, NULL },
|
||||
};
|
||||
suite *s;
|
||||
int i;
|
||||
|
||||
if (!evil_init())
|
||||
return EXIT_FAILURE;
|
||||
|
||||
s = suite_new();
|
||||
if (!s)
|
||||
return EXIT_FAILURE;
|
||||
{
|
||||
evil_shutdown();
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
for (i = 0; tests[i].name; ++i)
|
||||
{
|
||||
|
@ -171,6 +180,7 @@ main()
|
|||
suite_run(s);
|
||||
|
||||
suite_del(s);
|
||||
evil_shutdown();
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,37 @@
|
|||
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include "config.h"
|
||||
#endif /* HAVE_CONFIG_H */
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <Evil.h>
|
||||
|
||||
#include "evil_suite.h"
|
||||
|
||||
static int
|
||||
test_time_tests_run(suite *s)
|
||||
{
|
||||
struct timeval tp1;
|
||||
struct timeval tp2;
|
||||
|
||||
evil_gettimeofday (&tp1, NULL);
|
||||
|
||||
Sleep(20);
|
||||
|
||||
evil_gettimeofday (&tp2, NULL);
|
||||
|
||||
printf ("time : %ld %ld\n", tp1.tv_sec, tp1.tv_usec);
|
||||
printf ("time : %ld %ld\n", tp2.tv_sec, tp2.tv_usec);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int
|
||||
test_gettimeofday(suite *s)
|
||||
{
|
||||
|
||||
return test_time_tests_run(s);
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
#ifndef __EVIL_TEST_GETTIMEOFDAY__
|
||||
#define __EVIL_TEST_GETTIMEOFDAY__
|
||||
|
||||
|
||||
int test_gettimeofday(suite *s);
|
||||
|
||||
|
||||
#endif /* __EVIL_TEST_GETTIMEOFDAY__ */
|
|
@ -104,6 +104,7 @@ typedef unsigned long gid_t;
|
|||
|
||||
#include "evil_fcntl.h"
|
||||
#include "evil_langinfo.h"
|
||||
#include "evil_main.h"
|
||||
#include "evil_stdlib.h"
|
||||
#include "evil_stdio.h"
|
||||
#include "evil_string.h"
|
||||
|
|
|
@ -9,6 +9,7 @@ include_HEADERS = \
|
|||
Evil.h \
|
||||
evil_fcntl.h \
|
||||
evil_langinfo.h \
|
||||
evil_main.h \
|
||||
evil_stdlib.h \
|
||||
evil_stdio.h \
|
||||
evil_string.h \
|
||||
|
@ -35,6 +36,7 @@ evil_fcntl.c \
|
|||
evil_fnmatch.c \
|
||||
evil_fnmatch_list_of_states.c \
|
||||
evil_langinfo.c \
|
||||
evil_main.c \
|
||||
evil_mman.c \
|
||||
evil_pwd.c \
|
||||
evil_stdlib.c \
|
||||
|
|
|
@ -0,0 +1,72 @@
|
|||
|
||||
#if defined (_WIN32_WCE) && ! defined (__CEGCC__)
|
||||
|
||||
# define WIN32_LEAN_AND_MEAN
|
||||
# include <winsock2.h>
|
||||
# undef WIN32_LEAN_AND_MEAN
|
||||
|
||||
#include "Evil.h"
|
||||
#include "evil_private.h"
|
||||
|
||||
extern long _evil_time_second;
|
||||
extern long _evil_time_millisecond;
|
||||
|
||||
#endif /* _WIN32_WCE && ! __CEGCC__ */
|
||||
|
||||
static int _evil_init_count = 0;
|
||||
|
||||
int
|
||||
evil_init()
|
||||
{
|
||||
#if defined (_WIN32_WCE) && ! defined (__CEGCC__)
|
||||
SYSTEMTIME st;
|
||||
DWORD tick;
|
||||
WORD second = 59;
|
||||
#endif /* _WIN32_WCE && ! __CEGCC__ */
|
||||
|
||||
if (_evil_init_count > 0)
|
||||
{
|
||||
_evil_init_count++;
|
||||
return _evil_init_count;
|
||||
}
|
||||
|
||||
#if defined (_WIN32_WCE) && ! defined (__CEGCC__)
|
||||
|
||||
/* be sure that second + 1 != 0 */
|
||||
while (second == 59)
|
||||
{
|
||||
GetSystemTime(&st);
|
||||
second = st.wSecond;
|
||||
}
|
||||
|
||||
/* retrieve the tick corresponding to the time we retrieve above */
|
||||
while (1)
|
||||
{
|
||||
GetSystemTime(&st);
|
||||
tick = GetTickCount();
|
||||
if (st.wSecond == second + 1)
|
||||
break;
|
||||
}
|
||||
|
||||
_evil_time_second = _evil_systemtime_to_time(st);
|
||||
if (_evil_time_second < 0)
|
||||
return 0;
|
||||
_evil_time_millisecond = tick;
|
||||
|
||||
#endif /* _WIN32_WCE && ! __CEGCC__ */
|
||||
|
||||
_evil_init_count++;
|
||||
|
||||
return _evil_init_count;
|
||||
}
|
||||
|
||||
int
|
||||
evil_shutdown()
|
||||
{
|
||||
_evil_init_count--;
|
||||
if (_evil_init_count > 0) return _evil_init_count;
|
||||
|
||||
if (_evil_init_count < 0) _evil_init_count = 0;
|
||||
|
||||
return _evil_init_count;
|
||||
}
|
|
@ -0,0 +1,10 @@
|
|||
#ifndef __EVIL_MAIN_H__
|
||||
#define __EVIL_MAIN_H__
|
||||
|
||||
|
||||
EAPI int evil_init();
|
||||
|
||||
EAPI int evil_shutdown();
|
||||
|
||||
|
||||
#endif /* __EVIL_MAIN_H__ */
|
|
@ -6,6 +6,8 @@
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
long _evil_systemtime_to_time(SYSTEMTIME st);
|
||||
|
||||
void _evil_error_display(const char *fct, LONG res);
|
||||
|
||||
void _evil_last_error_display(const char *fct);
|
||||
|
|
|
@ -4,6 +4,8 @@
|
|||
#endif /* HAVE_CONFIG_H */
|
||||
|
||||
#include "Evil.h"
|
||||
#include "evil_private.h"
|
||||
|
||||
#undef fopen
|
||||
|
||||
|
||||
|
|
|
@ -38,8 +38,10 @@ int ffs(int i)
|
|||
/* remove the sign bit */
|
||||
x = i & -i;
|
||||
size = sizeof(int) << 3;
|
||||
for (i = size; i > 0; --i, x << 1)
|
||||
for (i = size; i > 0; --i, x <<= 1)
|
||||
if (x & (1 << (size - 1))) return i;
|
||||
|
||||
return x;
|
||||
}
|
||||
|
||||
#endif /* ! __CEGCC__ */
|
||||
|
|
|
@ -7,6 +7,8 @@
|
|||
#include <errno.h>
|
||||
#endif /* HAVE_ERRNO_H */
|
||||
|
||||
#include <sys/time.h>
|
||||
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#include <winsock2.h>
|
||||
#undef WIN32_LEAN_AND_MEAN
|
||||
|
@ -14,7 +16,16 @@
|
|||
#include "Evil.h"
|
||||
#include "evil_private.h"
|
||||
|
||||
static time_t
|
||||
|
||||
#if defined (_WIN32_WCE) && ! defined (__CEGCC__)
|
||||
|
||||
long _evil_time_second;
|
||||
long _evil_time_millisecond;
|
||||
|
||||
#endif /* _WIN32_WCE && ! __CEGCC__ */
|
||||
|
||||
|
||||
long
|
||||
_evil_systemtime_to_time(SYSTEMTIME st)
|
||||
{
|
||||
int days[] = {
|
||||
|
@ -35,9 +46,27 @@ _evil_systemtime_to_time(SYSTEMTIME st)
|
|||
time = ((st.wYear - 70) * 365 + ((st.wYear - 1) >> 2) - 17 + day) * 24 + st.wHour;
|
||||
time = (time * 60 + st.wMinute) * 60 + st.wSecond;
|
||||
|
||||
return time;
|
||||
return (long)time;
|
||||
}
|
||||
|
||||
/*
|
||||
* Time related functions
|
||||
*
|
||||
*/
|
||||
|
||||
#if defined (_WIN32_WCE) && ! defined (__CEGCC__)
|
||||
|
||||
int
|
||||
evil_gettimeofday(struct timeval *tp, void *tzp __UNUSED__)
|
||||
{
|
||||
tp->tv_sec = _evil_time_second;
|
||||
tp->tv_usec = (GetTickCount() - _evil_time_millisecond) * 1000;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
#endif /* _WIN32_WCE && ! __CEGCC__ */
|
||||
|
||||
/*
|
||||
* Process identifer related functions
|
||||
*
|
||||
|
|
|
@ -2,6 +2,21 @@
|
|||
#define __EVIL_UNISTD_H__
|
||||
|
||||
|
||||
/*
|
||||
* Time related functions
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#if defined (_WIN32_WCE) && ! defined (__CEGCC__)
|
||||
|
||||
EAPI int evil_gettimeofday(struct timeval * tp, void * tzp);
|
||||
|
||||
# define gettimeofday(tp, tzp) evil_gettimeofday(tp, tzp)
|
||||
|
||||
#endif /* _WIN32_WCE && ! __CEGCC__ */
|
||||
|
||||
|
||||
/*
|
||||
* Process identifer related functions
|
||||
*
|
||||
|
|
Loading…
Reference in New Issue