summaryrefslogtreecommitdiff
path: root/src/lib/cov_preload.c
blob: 870a0e986d20c3c66c1188b12afa0a8af75cef50 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#define _GNU_SOURCE
#include <dlfcn.h>

#ifndef ELM_INTERNAL_API_ARGESFSDFEFC
#define ELM_INTERNAL_API_ARGESFSDFEFC
#endif
#include <Elementary.h>

#include "stats_common.h"

Stat_Infos infos;
static Eina_Bool _changed = EINA_FALSE;

static void
_init()
{
   static Eina_Bool _inited = EINA_FALSE;
   if (!_inited)
     {
        infos.l = NULL;
        _inited = EINA_TRUE;
     }
}

EAPI int
eina_shutdown()
{
   int (*foo)() = dlsym(RTLD_NEXT, __func__);

   if (_changed)
     {
        stats_save(&infos, "espion_stats.eet", STATS_EET_FORMAT);
        _changed = EINA_FALSE;
     }

   return foo();
}

static Stat_Info *
_info_update(const char *func, Stat_Info *info)
{
   _init();
   if (!info)
     {
        info = calloc(1, sizeof(*info));
        info->api_name = func;
        infos.l = eina_list_append(infos.l, info);
     }
   info->counter++;
   _changed = EINA_TRUE;
   return info;
}

#include "covers.c"