Add coding style guide.
[platform/core/uifw/coregl.git] / src / coregl_trace.c
1 #include "coregl_internal.h"
2
3 #include <stdlib.h>
4 #include <string.h>
5 #include <sys/time.h>
6
7 int                 trace_api_flag = 0;
8 int                 trace_api_all_flag = 0;
9 int                 trace_api_frame_flag = 0;
10 int                 trace_ctx_flag = 0;
11 int                 trace_ctx_force_flag = 0;
12 int                 trace_mem_flag = 0;
13 int                 trace_mem_all_flag = 0;
14 int                 trace_state_flag = 0;
15 int                 trace_surface_flag = 0;
16 int                 trace_surface_all_flag = 0;
17 int                 trace_surface_sequence_sort_flag = 0;
18 int                 trace_surface_filter_period_begin = 0;
19 int                 trace_surface_filter_period_end = 0;
20 int                 trace_surface_filter_type = 0;
21 int                 trace_surface_filter_handle = 0;
22 int                 trace_surface_filter_size_w = 0;
23 int                 trace_surface_filter_size_h = 0;
24 int                 trace_surface_print_only_flag = 0;
25
26 General_Trace_List *thread_trace_list = NULL;
27 Mutex               general_trace_lists_access_mutex = MUTEX_INITIALIZER;
28
29
30 int
31 add_to_general_trace_list(General_Trace_List **gtl, void *value)
32 {
33         int ret = 0;
34         General_Trace_List *newitm = NULL;
35
36         AST(mutex_lock(&general_trace_lists_access_mutex) == 1);
37
38         newitm = (General_Trace_List *)calloc(1, sizeof(General_Trace_List));
39         newitm->value = value;
40         newitm->next = *gtl;
41         *gtl = newitm;
42         ret = 1;
43         goto finish;
44
45 finish:
46         AST(mutex_unlock(&general_trace_lists_access_mutex) == 1);
47         return ret;
48 }
49
50 int
51 remove_from_general_trace_list(General_Trace_List **gtl, void *value)
52 {
53         int ret = 0;
54         General_Trace_List *current = NULL;
55         General_Trace_List *priv = NULL;
56
57         AST(mutex_lock(&general_trace_lists_access_mutex) == 1);
58
59         current = *gtl;
60
61         while (current != NULL) {
62                 if (current->value == value) {
63                         if (priv == NULL)
64                                 *gtl = current->next;
65                         else
66                                 priv->next = current->next;
67
68                         free(current);
69                         ret = 1;
70                         goto finish;
71                 }
72                 priv = current;
73                 current = current->next;
74         }
75         goto finish;
76
77 finish:
78         AST(mutex_unlock(&general_trace_lists_access_mutex) == 1);
79
80         return ret;
81 }
82