summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLucas <Coquinho@users.noreply.github.com>2020-07-28 20:26:35 +0000
committerStefan Schmidt <s.schmidt@samsung.com>2020-07-29 09:50:52 +0200
commitf09080fad504653a32c902b9dff6ff7940ec6f92 (patch)
tree244b50e87beaab3d5e141ea9ba72ee66f62e95ca
parenta25bc7e76972230cd51dde3d0227ef6886612ce4 (diff)
evil: Remove unnecessary delay for evil startup
Apparently there were two loops intended for an older (and dropped off) implementation of `gettimeofday`. This patch simplifies the code removing these loops and significantly lowering evil startup. Without this patch `ecore-suite`, `efl-app` and `evas-suite` gets timeout in Windows: ``` 25/29 ecore-suite TIMEOUT 30.12s 26/29 efl-app TIMEOUT 30.14s ... 29/29 evas-suite TIMEOUT 60.07s ``` Reviewed-by: Vincent Torri <vincent.torri@gmail.com> Reviewed-by: Stefan Schmidt <stefan@datenfreihafen.org> Differential Revision: https://phab.enlightenment.org/D12064
-rw-r--r--src/lib/evil/evil_main.c28
-rw-r--r--src/lib/evil/evil_main.h5
-rw-r--r--src/lib/evil/evil_unistd.c30
3 files changed, 5 insertions, 58 deletions
diff --git a/src/lib/evil/evil_main.c b/src/lib/evil/evil_main.c
index cd7fde8555..6a3678f0a1 100644
--- a/src/lib/evil/evil_main.c
+++ b/src/lib/evil/evil_main.c
@@ -11,19 +11,14 @@ static int _evil_init_count = 0;
11 11
12extern LONGLONG _evil_time_freq; 12extern LONGLONG _evil_time_freq;
13extern LONGLONG _evil_time_count; 13extern LONGLONG _evil_time_count;
14extern long _evil_time_second;
15 14
16extern DWORD _evil_tls_index; 15extern DWORD _evil_tls_index;
17 16
18long _evil_systemtime_to_time(SYSTEMTIME st);
19
20int 17int
21evil_init(void) 18evil_init(void)
22{ 19{
23 SYSTEMTIME st;
24 LARGE_INTEGER freq; 20 LARGE_INTEGER freq;
25 LARGE_INTEGER count; 21 LARGE_INTEGER count;
26 WORD second = 59;
27 22
28 if (++_evil_init_count != 1) 23 if (++_evil_init_count != 1)
29 return _evil_init_count; 24 return _evil_init_count;
@@ -39,30 +34,11 @@ evil_init(void)
39 } 34 }
40 } 35 }
41 36
42 if (!QueryPerformanceFrequency(&freq)) 37 QueryPerformanceFrequency(&freq);
43 return 0;
44 38
45 _evil_time_freq = freq.QuadPart; 39 _evil_time_freq = freq.QuadPart;
46 40
47 /* be sure that second + 1 != 0 */ 41 QueryPerformanceCounter(&count);
48 while (second == 59)
49 {
50 GetSystemTime(&st);
51 second = st.wSecond;
52 }
53
54 /* retrieve the tick corresponding to the time we retrieve above */
55 while (1)
56 {
57 GetSystemTime(&st);
58 QueryPerformanceCounter(&count);
59 if (st.wSecond == second + 1)
60 break;
61 }
62
63 _evil_time_second = _evil_systemtime_to_time(st);
64 if (_evil_time_second < 0)
65 return --_evil_init_count;
66 42
67 _evil_time_count = count.QuadPart; 43 _evil_time_count = count.QuadPart;
68 44
diff --git a/src/lib/evil/evil_main.h b/src/lib/evil/evil_main.h
index 44b8356e4d..40fd38f15f 100644
--- a/src/lib/evil/evil_main.h
+++ b/src/lib/evil/evil_main.h
@@ -93,9 +93,8 @@
93 * @brief Initialize the Evil library. 93 * @brief Initialize the Evil library.
94 * 94 *
95 * This function initializes the Evil library. It must be called before 95 * This function initializes the Evil library. It must be called before
96 * using evil_time_get(), gettimeofday() or pipe(). It returns 0 on 96 * using evil_time_get() or pipe(). It returns 0 on failure, otherwise it
97 * failure, otherwise it returns the number of times it has already been 97 * returns the number of times it has already been called.
98 * called.
99 * 98 *
100 * When Evil is not used anymore, call evil_shutdown() to shut down 99 * When Evil is not used anymore, call evil_shutdown() to shut down
101 * the Evil library. 100 * the Evil library.
diff --git a/src/lib/evil/evil_unistd.c b/src/lib/evil/evil_unistd.c
index 3eebf97e1e..535ef71231 100644
--- a/src/lib/evil/evil_unistd.c
+++ b/src/lib/evil/evil_unistd.c
@@ -17,34 +17,6 @@
17 17
18LONGLONG _evil_time_freq; 18LONGLONG _evil_time_freq;
19LONGLONG _evil_time_count; 19LONGLONG _evil_time_count;
20long _evil_time_second;
21
22
23long _evil_systemtime_to_time(SYSTEMTIME st);
24
25long
26_evil_systemtime_to_time(SYSTEMTIME st)
27{
28 int days[] = {
29 -1, 30, 58, 89, 119, 150, 180, 211, 242, 272, 303, 333, 364
30 };
31 int day;
32 time_t t;
33
34 st.wYear -= 1900;
35 if ((st.wYear < 70) || (st.wYear > 138))
36 return -1;
37
38 day = st.wDay + days[st.wMonth - 1];
39
40 if (!(st.wYear & 3) && (st.wMonth > 2) )
41 day++;
42
43 t = ((st.wYear - 70) * 365 + ((st.wYear - 1) >> 2) - 17 + day) * 24 + st.wHour;
44 t = (t * 60 + st.wMinute) * 60 + st.wSecond;
45
46 return (long)t;
47}
48 20
49/* 21/*
50 * Time related functions 22 * Time related functions
@@ -58,7 +30,7 @@ evil_time_get(void)
58 30
59 QueryPerformanceCounter(&count); 31 QueryPerformanceCounter(&count);
60 32
61 return (double)_evil_time_second + (double)(count.QuadPart - _evil_time_count)/ (double)_evil_time_freq; 33 return (double)(count.QuadPart - _evil_time_count)/ (double)_evil_time_freq;
62} 34}
63 35
64 36