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
This commit is contained in:
Jean-Philippe Andre 2013-08-07 15:45:35 +09:00
parent 9d731364c1
commit 28a5c6f587
3 changed files with 113 additions and 85 deletions

View File

@ -4,26 +4,54 @@
#include <Eina.h> #include <Eina.h>
#include "evas_cs2.h" #include "evas_cs2.h"
#ifndef CSERVE2_LOG_LEVEL
#define CSERVE2_LOG_LEVEL 2
#endif
#ifdef CRIT #ifdef CRIT
#undef CRIT #undef CRIT
#endif #endif
#if CSERVE2_LOG_LEVEL >= 0
#define CRIT(...) EINA_LOG_DOM_CRIT(_evas_cserve2_bin_log_dom, __VA_ARGS__) #define CRIT(...) EINA_LOG_DOM_CRIT(_evas_cserve2_bin_log_dom, __VA_ARGS__)
#else
#define CRIT(...) do {} while(0)
#endif
#ifdef ERR #ifdef ERR
#undef ERR #undef ERR
#endif #endif
#if CSERVE2_LOG_LEVEL >= 1
#define ERR(...) EINA_LOG_DOM_ERR(_evas_cserve2_bin_log_dom, __VA_ARGS__) #define ERR(...) EINA_LOG_DOM_ERR(_evas_cserve2_bin_log_dom, __VA_ARGS__)
#ifdef DBG #else
#undef DBG #define ERR(...) do {} while(0)
#endif #endif
#define DBG(...) EINA_LOG_DOM_DBG(_evas_cserve2_bin_log_dom, __VA_ARGS__)
#ifdef WRN #ifdef WRN
#undef WRN #undef WRN
#endif #endif
#if CSERVE2_LOG_LEVEL >= 2
#define WRN(...) EINA_LOG_DOM_WARN(_evas_cserve2_bin_log_dom, __VA_ARGS__) #define WRN(...) EINA_LOG_DOM_WARN(_evas_cserve2_bin_log_dom, __VA_ARGS__)
#else
#define WRN(...) do {} while(0)
#endif
#ifdef INF #ifdef INF
#undef INF #undef INF
#endif #endif
#if CSERVE2_LOG_LEVEL >= 3
#define INF(...) EINA_LOG_DOM_INFO(_evas_cserve2_bin_log_dom, __VA_ARGS__) #define INF(...) EINA_LOG_DOM_INFO(_evas_cserve2_bin_log_dom, __VA_ARGS__)
#else
#define INF(...) do {} while(0)
#endif
#ifdef DBG
#undef DBG
#endif
#if CSERVE2_LOG_LEVEL >= 4
#define DBG(...) EINA_LOG_DOM_DBG(_evas_cserve2_bin_log_dom, __VA_ARGS__)
#else
#define DBG(...) do {} while(0)
#endif
#define DEBUG_LOAD_TIME 1 #define DEBUG_LOAD_TIME 1

View File

@ -1691,7 +1691,6 @@ _glyphs_loaded_msg_create(Glyphs_Request *req, int *resp_size)
Eina_List *ll, *answers = NULL; Eina_List *ll, *answers = NULL;
const char *shmname; const char *shmname;
unsigned int shmsize; unsigned int shmsize;
unsigned int intsize;
char *resp, *buf; char *resp, *buf;
Glyphs_Group *iter; Glyphs_Group *iter;
@ -1706,20 +1705,18 @@ _glyphs_loaded_msg_create(Glyphs_Request *req, int *resp_size)
// ncaches * sizeof(cache) + nglyphs1 * sizeof(glyph) + // ncaches * sizeof(cache) + nglyphs1 * sizeof(glyph) +
// nglyphs2 * sizeof(glyph)... // nglyphs2 * sizeof(glyph)...
intsize = sizeof(unsigned int);
EINA_LIST_FOREACH(answers, ll, iter) EINA_LIST_FOREACH(answers, ll, iter)
{ {
shmname = cserve2_shm_name_get(iter->fc->shm); shmname = cserve2_shm_name_get(iter->fc->shm);
shmsize = eina_stringshare_strlen(shmname) + 1; shmsize = eina_stringshare_strlen(shmname) + 1;
// shm namelen + name // shm namelen + name
size += intsize + shmsize; size += sizeof(int) + shmsize;
// nglyphs // nglyphs
size += intsize; size += sizeof(int);
// nglyphs * (index + offset + size + rows + width + pitch + // nglyphs * (index + offset + size + rows + width + pitch +
// num_grays + pixel_mode) // num_grays + pixel_mode)
size += eina_list_count(iter->glyphs) * 8 * intsize; size += eina_list_count(iter->glyphs) * 8 * sizeof(int);
} }
resp = malloc(size); resp = malloc(size);
@ -1733,35 +1730,35 @@ _glyphs_loaded_msg_create(Glyphs_Request *req, int *resp_size)
shmname = cserve2_shm_name_get(iter->fc->shm); shmname = cserve2_shm_name_get(iter->fc->shm);
shmsize = eina_stringshare_strlen(shmname) + 1; shmsize = eina_stringshare_strlen(shmname) + 1;
memcpy(buf, &shmsize, intsize); memcpy(buf, &shmsize, sizeof(int));
buf += intsize; buf += sizeof(int);
memcpy(buf, shmname, shmsize); memcpy(buf, shmname, shmsize);
buf += shmsize; buf += shmsize;
nglyphs = eina_list_count(iter->glyphs); nglyphs = eina_list_count(iter->glyphs);
memcpy(buf, &nglyphs, intsize); memcpy(buf, &nglyphs, sizeof(int));
buf += intsize; buf += sizeof(int);
iter->fc->inuse -= eina_list_count(iter->glyphs); iter->fc->inuse -= eina_list_count(iter->glyphs);
EINA_LIST_FREE(iter->glyphs, gl) EINA_LIST_FREE(iter->glyphs, gl)
{ {
memcpy(buf, &gl->index, intsize); memcpy(buf, &gl->index, sizeof(int));
buf += intsize; buf += sizeof(int);
memcpy(buf, &gl->offset, intsize); memcpy(buf, &gl->offset, sizeof(int));
buf += intsize; buf += sizeof(int);
memcpy(buf, &gl->size, intsize); memcpy(buf, &gl->size, sizeof(int));
buf += intsize; buf += sizeof(int);
memcpy(buf, &gl->rows, intsize); memcpy(buf, &gl->rows, sizeof(int));
buf += intsize; buf += sizeof(int);
memcpy(buf, &gl->width, intsize); memcpy(buf, &gl->width, sizeof(int));
buf += intsize; buf += sizeof(int);
memcpy(buf, &gl->pitch, intsize); memcpy(buf, &gl->pitch, sizeof(int));
buf += intsize; buf += sizeof(int);
memcpy(buf, &gl->num_grays, intsize); memcpy(buf, &gl->num_grays, sizeof(int));
buf += intsize; buf += sizeof(int);
memcpy(buf, &gl->pixel_mode, intsize); memcpy(buf, &gl->pixel_mode, sizeof(int));
buf += intsize; buf += sizeof(int);
} }
/* We are removing SHMs from the beginning of the list, so this /* We are removing SHMs from the beginning of the list, so this
@ -1944,19 +1941,20 @@ _glyphs_load_request_free(void *msg, void *data)
} }
static Msg_Font_Glyphs_Loaded * static Msg_Font_Glyphs_Loaded *
_glyphs_load_request_response(Glyphs_Request *req, Slave_Msg_Font_Glyphs_Loaded *msg, int *size) _glyphs_load_request_response(Glyphs_Request *req,
Slave_Msg_Font_Glyphs_Loaded *msg, int *size)
{ {
Font_Entry *fe = req->fe; Font_Entry *fe = req->fe;
Font_Cache *fc = NULL; Font_Cache *fc = NULL;
unsigned int i = 0; unsigned int i;
if (fe->last_cache && fe->last_cache->shm == msg->caches[0]->shm) if (fe->last_cache && fe->last_cache->shm == msg->caches[0]->shm)
fc = fe->last_cache; fc = fe->last_cache;
while (i < msg->ncaches) for (i = 0; i < msg->ncaches; i++)
{ {
unsigned int j; unsigned int j;
Slave_Msg_Font_Cache *c = msg->caches[i++]; Slave_Msg_Font_Cache *c = msg->caches[i];
if (!fc) if (!fc)
{ {
@ -2166,11 +2164,10 @@ _font_entry_debug_size_cb(const Eina_Hash *hash EINA_UNUSED, const void *key EIN
unsigned int size = di->size; unsigned int size = di->size;
Font_Entry *fe = data; Font_Entry *fe = data;
Font_Cache *fc; Font_Cache *fc;
unsigned int intsize = sizeof(unsigned int);
const char *str; const char *str;
// filelen // filelen
size += intsize; size += sizeof(int);
// file // file
if (fe->src->file) if (fe->src->file)
@ -2180,7 +2177,7 @@ _font_entry_debug_size_cb(const Eina_Hash *hash EINA_UNUSED, const void *key EIN
} }
// namelen // namelen
size += intsize; size += sizeof(int);
// name // name
if (fe->src->name) if (fe->src->name)
@ -2190,38 +2187,38 @@ _font_entry_debug_size_cb(const Eina_Hash *hash EINA_UNUSED, const void *key EIN
} }
// rend_flags, size, dpi // rend_flags, size, dpi
size += 3 * intsize; size += 3 * sizeof(int);
// unused // unused
size += intsize; size += sizeof(int);
// ncaches // ncaches
size += intsize; size += sizeof(int);
EINA_INLIST_FOREACH(fe->caches, fc) EINA_INLIST_FOREACH(fe->caches, fc)
{ {
Glyph_Entry *gl; Glyph_Entry *gl;
// shmnamelen + shmname // shmnamelen + shmname
size += intsize; size += sizeof(int);
size += strlen(cserve2_shm_name_get(fc->shm)) + 1; size += strlen(cserve2_shm_name_get(fc->shm)) + 1;
// size + usage // size + usage
size += 2 * intsize; size += 2 * sizeof(int);
// nglyphs // nglyphs
size += intsize; size += sizeof(int);
EINA_INLIST_FOREACH(fc->glyphs, gl) EINA_INLIST_FOREACH(fc->glyphs, gl)
{ {
// index, offset, size // index, offset, size
size += 3 * intsize; size += 3 * sizeof(int);
// rows, width, pitch // rows, width, pitch
size += 3 * intsize; size += 3 * sizeof(int);
// num_grays, pixel_mode // num_grays, pixel_mode
size += 2 * intsize; size += 2 * sizeof(int);
} }
} }
@ -2241,7 +2238,6 @@ _font_entry_debug_cb(const Eina_Hash *hash EINA_UNUSED, const void *key EINA_UNU
unsigned int len; unsigned int len;
unsigned int unused; unsigned int unused;
unsigned int ncaches; unsigned int ncaches;
unsigned int intsize = sizeof(unsigned int);
const char *str; const char *str;
// filelen + file // filelen + file
@ -2251,8 +2247,8 @@ _font_entry_debug_cb(const Eina_Hash *hash EINA_UNUSED, const void *key EINA_UNU
str = cserve2_shared_string_get(fe->src->file); str = cserve2_shared_string_get(fe->src->file);
len = strlen(str) + 1; len = strlen(str) + 1;
} }
memcpy(buf, &len, intsize); memcpy(buf, &len, sizeof(int));
buf += intsize; buf += sizeof(int);
if (len) memcpy(buf, cserve2_shared_string_get(fe->src->file), len); if (len) memcpy(buf, cserve2_shared_string_get(fe->src->file), len);
buf += len; buf += len;
@ -2263,28 +2259,28 @@ _font_entry_debug_cb(const Eina_Hash *hash EINA_UNUSED, const void *key EINA_UNU
str = cserve2_shared_string_get(fe->src->name); str = cserve2_shared_string_get(fe->src->name);
len = strlen(str) + 1; len = strlen(str) + 1;
} }
memcpy(buf, &len, intsize); memcpy(buf, &len, sizeof(int));
buf += intsize; buf += sizeof(int);
if (len) memcpy(buf, cserve2_shared_string_get(fe->src->name), len); if (len) memcpy(buf, cserve2_shared_string_get(fe->src->name), len);
buf += len; buf += len;
// rend_flags, size, dpi // rend_flags, size, dpi
memcpy(buf, &fe->rend_flags, intsize); memcpy(buf, &fe->rend_flags, sizeof(int));
buf += intsize; buf += sizeof(int);
memcpy(buf, &fe->size, intsize); memcpy(buf, &fe->size, sizeof(int));
buf += intsize; buf += sizeof(int);
memcpy(buf, &fe->dpi, intsize); memcpy(buf, &fe->dpi, sizeof(int));
buf += intsize; buf += sizeof(int);
// unused // unused
unused = fe->unused; unused = fe->unused;
memcpy(buf, &unused, intsize); memcpy(buf, &unused, sizeof(int));
buf += intsize; buf += sizeof(int);
// ncaches // ncaches
ncaches = eina_inlist_count(fe->caches); ncaches = eina_inlist_count(fe->caches);
memcpy(buf, &ncaches, intsize); memcpy(buf, &ncaches, sizeof(int));
buf += intsize; buf += sizeof(int);
EINA_INLIST_FOREACH(fe->caches, fc) EINA_INLIST_FOREACH(fe->caches, fc)
{ {
@ -2295,43 +2291,45 @@ _font_entry_debug_cb(const Eina_Hash *hash EINA_UNUSED, const void *key EINA_UNU
// shmnamelen + shmname // shmnamelen + shmname
shmname = cserve2_shm_name_get(fc->shm); shmname = cserve2_shm_name_get(fc->shm);
len = strlen(shmname) + 1; len = strlen(shmname) + 1;
memcpy(buf, &len, intsize); memcpy(buf, &len, sizeof(int));
buf += intsize; buf += sizeof(int);
memcpy(buf, shmname, len); memcpy(buf, shmname, len);
buf += len; buf += len;
// TODO: Simplify memcpy operations (can be factorized into 1)
// size, usage, nglyphs // size, usage, nglyphs
shmsize = cserve2_shm_size_get(fc->shm); shmsize = cserve2_shm_size_get(fc->shm);
memcpy(buf, &shmsize, intsize); memcpy(buf, &shmsize, sizeof(int));
buf += intsize; buf += sizeof(int);
memcpy(buf, &fc->usage, intsize); memcpy(buf, &fc->usage, sizeof(int));
buf += intsize; buf += sizeof(int);
memcpy(buf, &fc->nglyphs, intsize); memcpy(buf, &fc->nglyphs, sizeof(int));
buf += intsize; buf += sizeof(int);
EINA_INLIST_FOREACH(fc->glyphs, gl) EINA_INLIST_FOREACH(fc->glyphs, gl)
{ {
// index, offset, size // index, offset, size
memcpy(buf, &gl->index, intsize); memcpy(buf, &gl->index, sizeof(int));
buf += intsize; buf += sizeof(int);
memcpy(buf, &gl->offset, intsize); memcpy(buf, &gl->offset, sizeof(int));
buf += intsize; buf += sizeof(int);
memcpy(buf, &gl->size, intsize); memcpy(buf, &gl->size, sizeof(int));
buf += intsize; buf += sizeof(int);
// rows, width, pitch // rows, width, pitch
memcpy(buf, &gl->rows, intsize); memcpy(buf, &gl->rows, sizeof(int));
buf += intsize; buf += sizeof(int);
memcpy(buf, &gl->width, intsize); memcpy(buf, &gl->width, sizeof(int));
buf += intsize; buf += sizeof(int);
memcpy(buf, &gl->pitch, intsize); memcpy(buf, &gl->pitch, sizeof(int));
buf += intsize; buf += sizeof(int);
// num_grays, pixel_mode // num_grays, pixel_mode
memcpy(buf, &gl->num_grays, intsize); memcpy(buf, &gl->num_grays, sizeof(int));
buf += intsize; buf += sizeof(int);
memcpy(buf, &gl->pixel_mode, intsize); memcpy(buf, &gl->pixel_mode, sizeof(int));
buf += intsize; buf += sizeof(int);
} }
} }

View File

@ -90,8 +90,9 @@ _signal_handle_child(struct signalfd_siginfo *sinfo EINA_UNUSED)
} }
static void static void
_signal_handle_exit(struct signalfd_siginfo *sinfo) _signal_handle_exit(struct signalfd_siginfo *sinfo EINA_UNUSED)
{ {
#if CSERVE2_LOG_LEVEL >= 4
const char *name; const char *name;
switch (sinfo->ssi_signo) switch (sinfo->ssi_signo)
@ -103,6 +104,7 @@ _signal_handle_exit(struct signalfd_siginfo *sinfo)
} }
DBG("Received %s. Honoring request.", name); DBG("Received %s. Honoring request.", name);
#endif
terminate = EINA_TRUE; terminate = EINA_TRUE;
} }