summaryrefslogtreecommitdiff
path: root/src/bin
diff options
context:
space:
mode:
authorJean-Philippe Andre <jp.andre@samsung.com>2013-08-07 15:45:35 +0900
committerJean-Philippe Andre <jp.andre@samsung.com>2013-10-28 15:47:13 +0900
commit28a5c6f587992b5cf5506129c86cdde95253d525 (patch)
tree7a656ce46a7b437038ee04086dbb9893f676667a /src/bin
parent9d731364c1268fd824d4dc697a21fe6357908c37 (diff)
evas/cserve2: Add compile-time log level flag for cserve2
DBG and INF messages pollute the logs and performance reports from valgrind, let's disable them at build-time for better benchmarking. Fix other compilation warnings and clean code a bit
Diffstat (limited to 'src/bin')
-rw-r--r--src/bin/evas/evas_cserve2.h34
-rw-r--r--src/bin/evas/evas_cserve2_cache.c160
-rw-r--r--src/bin/evas/evas_cserve2_main_loop_linux.c4
3 files changed, 113 insertions, 85 deletions
diff --git a/src/bin/evas/evas_cserve2.h b/src/bin/evas/evas_cserve2.h
index f4a1d8da32..02ee9664c0 100644
--- a/src/bin/evas/evas_cserve2.h
+++ b/src/bin/evas/evas_cserve2.h
@@ -4,26 +4,54 @@
4#include <Eina.h> 4#include <Eina.h>
5#include "evas_cs2.h" 5#include "evas_cs2.h"
6 6
7#ifndef CSERVE2_LOG_LEVEL
8#define CSERVE2_LOG_LEVEL 2
9#endif
10
7#ifdef CRIT 11#ifdef CRIT
8#undef CRIT 12#undef CRIT
9#endif 13#endif
14#if CSERVE2_LOG_LEVEL >= 0
10#define CRIT(...) EINA_LOG_DOM_CRIT(_evas_cserve2_bin_log_dom, __VA_ARGS__) 15#define CRIT(...) EINA_LOG_DOM_CRIT(_evas_cserve2_bin_log_dom, __VA_ARGS__)
16#else
17#define CRIT(...) do {} while(0)
18#endif
19
11#ifdef ERR 20#ifdef ERR
12#undef ERR 21#undef ERR
13#endif 22#endif
23#if CSERVE2_LOG_LEVEL >= 1
14#define ERR(...) EINA_LOG_DOM_ERR(_evas_cserve2_bin_log_dom, __VA_ARGS__) 24#define ERR(...) EINA_LOG_DOM_ERR(_evas_cserve2_bin_log_dom, __VA_ARGS__)
15#ifdef DBG 25#else
16#undef DBG 26#define ERR(...) do {} while(0)
17#endif 27#endif
18#define DBG(...) EINA_LOG_DOM_DBG(_evas_cserve2_bin_log_dom, __VA_ARGS__) 28
19#ifdef WRN 29#ifdef WRN
20#undef WRN 30#undef WRN
21#endif 31#endif
32#if CSERVE2_LOG_LEVEL >= 2
22#define WRN(...) EINA_LOG_DOM_WARN(_evas_cserve2_bin_log_dom, __VA_ARGS__) 33#define WRN(...) EINA_LOG_DOM_WARN(_evas_cserve2_bin_log_dom, __VA_ARGS__)
34#else
35#define WRN(...) do {} while(0)
36#endif
37
23#ifdef INF 38#ifdef INF
24#undef INF 39#undef INF
25#endif 40#endif
41#if CSERVE2_LOG_LEVEL >= 3
26#define INF(...) EINA_LOG_DOM_INFO(_evas_cserve2_bin_log_dom, __VA_ARGS__) 42#define INF(...) EINA_LOG_DOM_INFO(_evas_cserve2_bin_log_dom, __VA_ARGS__)
43#else
44#define INF(...) do {} while(0)
45#endif
46
47#ifdef DBG
48#undef DBG
49#endif
50#if CSERVE2_LOG_LEVEL >= 4
51#define DBG(...) EINA_LOG_DOM_DBG(_evas_cserve2_bin_log_dom, __VA_ARGS__)
52#else
53#define DBG(...) do {} while(0)
54#endif
27 55
28#define DEBUG_LOAD_TIME 1 56#define DEBUG_LOAD_TIME 1
29 57
diff --git a/src/bin/evas/evas_cserve2_cache.c b/src/bin/evas/evas_cserve2_cache.c
index 1a025a8332..3a66988767 100644
--- a/src/bin/evas/evas_cserve2_cache.c
+++ b/src/bin/evas/evas_cserve2_cache.c
@@ -1691,7 +1691,6 @@ _glyphs_loaded_msg_create(Glyphs_Request *req, int *resp_size)
1691 Eina_List *ll, *answers = NULL; 1691 Eina_List *ll, *answers = NULL;
1692 const char *shmname; 1692 const char *shmname;
1693 unsigned int shmsize; 1693 unsigned int shmsize;
1694 unsigned int intsize;
1695 char *resp, *buf; 1694 char *resp, *buf;
1696 Glyphs_Group *iter; 1695 Glyphs_Group *iter;
1697 1696
@@ -1706,20 +1705,18 @@ _glyphs_loaded_msg_create(Glyphs_Request *req, int *resp_size)
1706 // ncaches * sizeof(cache) + nglyphs1 * sizeof(glyph) + 1705 // ncaches * sizeof(cache) + nglyphs1 * sizeof(glyph) +
1707 // nglyphs2 * sizeof(glyph)... 1706 // nglyphs2 * sizeof(glyph)...
1708 1707
1709 intsize = sizeof(unsigned int);
1710
1711 EINA_LIST_FOREACH(answers, ll, iter) 1708 EINA_LIST_FOREACH(answers, ll, iter)
1712 { 1709 {
1713 shmname = cserve2_shm_name_get(iter->fc->shm); 1710 shmname = cserve2_shm_name_get(iter->fc->shm);
1714 shmsize = eina_stringshare_strlen(shmname) + 1; 1711 shmsize = eina_stringshare_strlen(shmname) + 1;
1715 // shm namelen + name 1712 // shm namelen + name
1716 size += intsize + shmsize; 1713 size += sizeof(int) + shmsize;
1717 1714
1718 // nglyphs 1715 // nglyphs
1719 size += intsize; 1716 size += sizeof(int);
1720 // nglyphs * (index + offset + size + rows + width + pitch + 1717 // nglyphs * (index + offset + size + rows + width + pitch +
1721 // num_grays + pixel_mode) 1718 // num_grays + pixel_mode)
1722 size += eina_list_count(iter->glyphs) * 8 * intsize; 1719 size += eina_list_count(iter->glyphs) * 8 * sizeof(int);
1723 } 1720 }
1724 1721
1725 resp = malloc(size); 1722 resp = malloc(size);
@@ -1733,35 +1730,35 @@ _glyphs_loaded_msg_create(Glyphs_Request *req, int *resp_size)
1733 1730
1734 shmname = cserve2_shm_name_get(iter->fc->shm); 1731 shmname = cserve2_shm_name_get(iter->fc->shm);
1735 shmsize = eina_stringshare_strlen(shmname) + 1; 1732 shmsize = eina_stringshare_strlen(shmname) + 1;
1736 memcpy(buf, &shmsize, intsize); 1733 memcpy(buf, &shmsize, sizeof(int));
1737 buf += intsize; 1734 buf += sizeof(int);
1738 memcpy(buf, shmname, shmsize); 1735 memcpy(buf, shmname, shmsize);
1739 buf += shmsize; 1736 buf += shmsize;
1740 1737
1741 nglyphs = eina_list_count(iter->glyphs); 1738 nglyphs = eina_list_count(iter->glyphs);
1742 memcpy(buf, &nglyphs, intsize); 1739 memcpy(buf, &nglyphs, sizeof(int));
1743 buf += intsize; 1740 buf += sizeof(int);
1744 1741
1745 iter->fc->inuse -= eina_list_count(iter->glyphs); 1742 iter->fc->inuse -= eina_list_count(iter->glyphs);
1746 1743
1747 EINA_LIST_FREE(iter->glyphs, gl) 1744 EINA_LIST_FREE(iter->glyphs, gl)
1748 { 1745 {
1749 memcpy(buf, &gl->index, intsize); 1746 memcpy(buf, &gl->index, sizeof(int));
1750 buf += intsize; 1747 buf += sizeof(int);
1751 memcpy(buf, &gl->offset, intsize); 1748 memcpy(buf, &gl->offset, sizeof(int));
1752 buf += intsize; 1749 buf += sizeof(int);
1753 memcpy(buf, &gl->size, intsize); 1750 memcpy(buf, &gl->size, sizeof(int));
1754 buf += intsize; 1751 buf += sizeof(int);
1755 memcpy(buf, &gl->rows, intsize); 1752 memcpy(buf, &gl->rows, sizeof(int));
1756 buf += intsize; 1753 buf += sizeof(int);
1757 memcpy(buf, &gl->width, intsize); 1754 memcpy(buf, &gl->width, sizeof(int));
1758 buf += intsize; 1755 buf += sizeof(int);
1759 memcpy(buf, &gl->pitch, intsize); 1756 memcpy(buf, &gl->pitch, sizeof(int));
1760 buf += intsize; 1757 buf += sizeof(int);
1761 memcpy(buf, &gl->num_grays, intsize); 1758 memcpy(buf, &gl->num_grays, sizeof(int));
1762 buf += intsize; 1759 buf += sizeof(int);
1763 memcpy(buf, &gl->pixel_mode, intsize); 1760 memcpy(buf, &gl->pixel_mode, sizeof(int));
1764 buf += intsize; 1761 buf += sizeof(int);
1765 } 1762 }
1766 1763
1767 /* We are removing SHMs from the beginning of the list, so this 1764 /* We are removing SHMs from the beginning of the list, so this
@@ -1944,19 +1941,20 @@ _glyphs_load_request_free(void *msg, void *data)
1944} 1941}
1945 1942
1946static Msg_Font_Glyphs_Loaded * 1943static Msg_Font_Glyphs_Loaded *
1947_glyphs_load_request_response(Glyphs_Request *req, Slave_Msg_Font_Glyphs_Loaded *msg, int *size) 1944_glyphs_load_request_response(Glyphs_Request *req,
1945 Slave_Msg_Font_Glyphs_Loaded *msg, int *size)
1948{ 1946{
1949 Font_Entry *fe = req->fe; 1947 Font_Entry *fe = req->fe;
1950 Font_Cache *fc = NULL; 1948 Font_Cache *fc = NULL;
1951 unsigned int i = 0; 1949 unsigned int i;
1952 1950
1953 if (fe->last_cache && fe->last_cache->shm == msg->caches[0]->shm) 1951 if (fe->last_cache && fe->last_cache->shm == msg->caches[0]->shm)
1954 fc = fe->last_cache; 1952 fc = fe->last_cache;
1955 1953
1956 while (i < msg->ncaches) 1954 for (i = 0; i < msg->ncaches; i++)
1957 { 1955 {
1958 unsigned int j; 1956 unsigned int j;
1959 Slave_Msg_Font_Cache *c = msg->caches[i++]; 1957 Slave_Msg_Font_Cache *c = msg->caches[i];
1960 1958
1961 if (!fc) 1959 if (!fc)
1962 { 1960 {
@@ -2166,11 +2164,10 @@ _font_entry_debug_size_cb(const Eina_Hash *hash EINA_UNUSED, const void *key EIN
2166 unsigned int size = di->size; 2164 unsigned int size = di->size;
2167 Font_Entry *fe = data; 2165 Font_Entry *fe = data;
2168 Font_Cache *fc; 2166 Font_Cache *fc;
2169 unsigned int intsize = sizeof(unsigned int);
2170 const char *str; 2167 const char *str;
2171 2168
2172 // filelen 2169 // filelen
2173 size += intsize; 2170 size += sizeof(int);
2174 2171
2175 // file 2172 // file
2176 if (fe->src->file) 2173 if (fe->src->file)
@@ -2180,7 +2177,7 @@ _font_entry_debug_size_cb(const Eina_Hash *hash EINA_UNUSED, const void *key EIN
2180 } 2177 }
2181 2178
2182 // namelen 2179 // namelen
2183 size += intsize; 2180 size += sizeof(int);
2184 2181
2185 // name 2182 // name
2186 if (fe->src->name) 2183 if (fe->src->name)
@@ -2190,38 +2187,38 @@ _font_entry_debug_size_cb(const Eina_Hash *hash EINA_UNUSED, const void *key EIN
2190 } 2187 }
2191 2188
2192 // rend_flags, size, dpi 2189 // rend_flags, size, dpi
2193 size += 3 * intsize; 2190 size += 3 * sizeof(int);
2194 2191
2195 // unused 2192 // unused
2196 size += intsize; 2193 size += sizeof(int);
2197 2194
2198 // ncaches 2195 // ncaches
2199 size += intsize; 2196 size += sizeof(int);
2200 2197
2201 EINA_INLIST_FOREACH(fe->caches, fc) 2198 EINA_INLIST_FOREACH(fe->caches, fc)
2202 { 2199 {
2203 Glyph_Entry *gl; 2200 Glyph_Entry *gl;
2204 2201
2205 // shmnamelen + shmname 2202 // shmnamelen + shmname
2206 size += intsize; 2203 size += sizeof(int);
2207 size += strlen(cserve2_shm_name_get(fc->shm)) + 1; 2204 size += strlen(cserve2_shm_name_get(fc->shm)) + 1;
2208 2205
2209 // size + usage 2206 // size + usage
2210 size += 2 * intsize; 2207 size += 2 * sizeof(int);
2211 2208
2212 // nglyphs 2209 // nglyphs
2213 size += intsize; 2210 size += sizeof(int);
2214 2211
2215 EINA_INLIST_FOREACH(fc->glyphs, gl) 2212 EINA_INLIST_FOREACH(fc->glyphs, gl)
2216 { 2213 {
2217 // index, offset, size 2214 // index, offset, size
2218 size += 3 * intsize; 2215 size += 3 * sizeof(int);
2219 2216
2220 // rows, width, pitch 2217 // rows, width, pitch
2221 size += 3 * intsize; 2218 size += 3 * sizeof(int);
2222 2219
2223 // num_grays, pixel_mode 2220 // num_grays, pixel_mode
2224 size += 2 * intsize; 2221 size += 2 * sizeof(int);
2225 } 2222 }
2226 } 2223 }
2227 2224
@@ -2241,7 +2238,6 @@ _font_entry_debug_cb(const Eina_Hash *hash EINA_UNUSED, const void *key EINA_UNU
2241 unsigned int len; 2238 unsigned int len;
2242 unsigned int unused; 2239 unsigned int unused;
2243 unsigned int ncaches; 2240 unsigned int ncaches;
2244 unsigned int intsize = sizeof(unsigned int);
2245 const char *str; 2241 const char *str;
2246 2242
2247 // filelen + file 2243 // filelen + file
@@ -2251,8 +2247,8 @@ _font_entry_debug_cb(const Eina_Hash *hash EINA_UNUSED, const void *key EINA_UNU
2251 str = cserve2_shared_string_get(fe->src->file); 2247 str = cserve2_shared_string_get(fe->src->file);
2252 len = strlen(str) + 1; 2248 len = strlen(str) + 1;
2253 } 2249 }
2254 memcpy(buf, &len, intsize); 2250 memcpy(buf, &len, sizeof(int));
2255 buf += intsize; 2251 buf += sizeof(int);
2256 if (len) memcpy(buf, cserve2_shared_string_get(fe->src->file), len); 2252 if (len) memcpy(buf, cserve2_shared_string_get(fe->src->file), len);
2257 buf += len; 2253 buf += len;
2258 2254
@@ -2263,28 +2259,28 @@ _font_entry_debug_cb(const Eina_Hash *hash EINA_UNUSED, const void *key EINA_UNU
2263 str = cserve2_shared_string_get(fe->src->name); 2259 str = cserve2_shared_string_get(fe->src->name);
2264 len = strlen(str) + 1; 2260 len = strlen(str) + 1;
2265 } 2261 }
2266 memcpy(buf, &len, intsize); 2262 memcpy(buf, &len, sizeof(int));
2267 buf += intsize; 2263 buf += sizeof(int);
2268 if (len) memcpy(buf, cserve2_shared_string_get(fe->src->name), len); 2264 if (len) memcpy(buf, cserve2_shared_string_get(fe->src->name), len);
2269 buf += len; 2265 buf += len;
2270 2266
2271 // rend_flags, size, dpi 2267 // rend_flags, size, dpi
2272 memcpy(buf, &fe->rend_flags, intsize); 2268 memcpy(buf, &fe->rend_flags, sizeof(int));
2273 buf += intsize; 2269 buf += sizeof(int);
2274 memcpy(buf, &fe->size, intsize); 2270 memcpy(buf, &fe->size, sizeof(int));
2275 buf += intsize; 2271 buf += sizeof(int);
2276 memcpy(buf, &fe->dpi, intsize); 2272 memcpy(buf, &fe->dpi, sizeof(int));
2277 buf += intsize; 2273 buf += sizeof(int);
2278 2274
2279 // unused 2275 // unused
2280 unused = fe->unused; 2276 unused = fe->unused;
2281 memcpy(buf, &unused, intsize); 2277 memcpy(buf, &unused, sizeof(int));
2282 buf += intsize; 2278 buf += sizeof(int);
2283 2279
2284 // ncaches 2280 // ncaches
2285 ncaches = eina_inlist_count(fe->caches); 2281 ncaches = eina_inlist_count(fe->caches);
2286 memcpy(buf, &ncaches, intsize); 2282 memcpy(buf, &ncaches, sizeof(int));
2287 buf += intsize; 2283 buf += sizeof(int);
2288 2284
2289 EINA_INLIST_FOREACH(fe->caches, fc) 2285 EINA_INLIST_FOREACH(fe->caches, fc)
2290 { 2286 {
@@ -2295,43 +2291,45 @@ _font_entry_debug_cb(const Eina_Hash *hash EINA_UNUSED, const void *key EINA_UNU
2295 // shmnamelen + shmname 2291 // shmnamelen + shmname
2296 shmname = cserve2_shm_name_get(fc->shm); 2292 shmname = cserve2_shm_name_get(fc->shm);
2297 len = strlen(shmname) + 1; 2293 len = strlen(shmname) + 1;
2298 memcpy(buf, &len, intsize); 2294 memcpy(buf, &len, sizeof(int));
2299 buf += intsize; 2295 buf += sizeof(int);
2300 memcpy(buf, shmname, len); 2296 memcpy(buf, shmname, len);
2301 buf += len; 2297 buf += len;
2302 2298
2299 // TODO: Simplify memcpy operations (can be factorized into 1)
2300
2303 // size, usage, nglyphs 2301 // size, usage, nglyphs
2304 shmsize = cserve2_shm_size_get(fc->shm); 2302 shmsize = cserve2_shm_size_get(fc->shm);
2305 memcpy(buf, &shmsize, intsize); 2303 memcpy(buf, &shmsize, sizeof(int));
2306 buf += intsize; 2304 buf += sizeof(int);
2307 memcpy(buf, &fc->usage, intsize); 2305 memcpy(buf, &fc->usage, sizeof(int));
2308 buf += intsize; 2306 buf += sizeof(int);
2309 memcpy(buf, &fc->nglyphs, intsize); 2307 memcpy(buf, &fc->nglyphs, sizeof(int));
2310 buf += intsize; 2308 buf += sizeof(int);
2311 2309
2312 EINA_INLIST_FOREACH(fc->glyphs, gl) 2310 EINA_INLIST_FOREACH(fc->glyphs, gl)
2313 { 2311 {
2314 // index, offset, size 2312 // index, offset, size
2315 memcpy(buf, &gl->index, intsize); 2313 memcpy(buf, &gl->index, sizeof(int));
2316 buf += intsize; 2314 buf += sizeof(int);
2317 memcpy(buf, &gl->offset, intsize); 2315 memcpy(buf, &gl->offset, sizeof(int));
2318 buf += intsize; 2316 buf += sizeof(int);
2319 memcpy(buf, &gl->size, intsize); 2317 memcpy(buf, &gl->size, sizeof(int));
2320 buf += intsize; 2318 buf += sizeof(int);
2321 2319
2322 // rows, width, pitch 2320 // rows, width, pitch
2323 memcpy(buf, &gl->rows, intsize); 2321 memcpy(buf, &gl->rows, sizeof(int));
2324 buf += intsize; 2322 buf += sizeof(int);
2325 memcpy(buf, &gl->width, intsize); 2323 memcpy(buf, &gl->width, sizeof(int));
2326 buf += intsize; 2324 buf += sizeof(int);
2327 memcpy(buf, &gl->pitch, intsize); 2325 memcpy(buf, &gl->pitch, sizeof(int));
2328 buf += intsize; 2326 buf += sizeof(int);
2329 2327
2330 // num_grays, pixel_mode 2328 // num_grays, pixel_mode
2331 memcpy(buf, &gl->num_grays, intsize); 2329 memcpy(buf, &gl->num_grays, sizeof(int));
2332 buf += intsize; 2330 buf += sizeof(int);
2333 memcpy(buf, &gl->pixel_mode, intsize); 2331 memcpy(buf, &gl->pixel_mode, sizeof(int));
2334 buf += intsize; 2332 buf += sizeof(int);
2335 } 2333 }
2336 } 2334 }
2337 2335
diff --git a/src/bin/evas/evas_cserve2_main_loop_linux.c b/src/bin/evas/evas_cserve2_main_loop_linux.c
index c29f9425de..18b4662e79 100644
--- a/src/bin/evas/evas_cserve2_main_loop_linux.c
+++ b/src/bin/evas/evas_cserve2_main_loop_linux.c
@@ -90,8 +90,9 @@ _signal_handle_child(struct signalfd_siginfo *sinfo EINA_UNUSED)
90} 90}
91 91
92static void 92static void
93_signal_handle_exit(struct signalfd_siginfo *sinfo) 93_signal_handle_exit(struct signalfd_siginfo *sinfo EINA_UNUSED)
94{ 94{
95#if CSERVE2_LOG_LEVEL >= 4
95 const char *name; 96 const char *name;
96 97
97 switch (sinfo->ssi_signo) 98 switch (sinfo->ssi_signo)
@@ -103,6 +104,7 @@ _signal_handle_exit(struct signalfd_siginfo *sinfo)
103 } 104 }
104 105
105 DBG("Received %s. Honoring request.", name); 106 DBG("Received %s. Honoring request.", name);
107#endif
106 terminate = EINA_TRUE; 108 terminate = EINA_TRUE;
107} 109}
108 110