tizen 2.4 release
[framework/graphics/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         /* Prevent CID : 395957 */
40         if (newitm == NULL) goto finish;
41         newitm->value = value;
42         newitm->next = *gtl;
43         *gtl = newitm;
44         ret = 1;
45         goto finish;
46
47 finish:
48         AST(mutex_unlock(&general_trace_lists_access_mutex) == 1);
49         return ret;
50 }
51
52 int
53 remove_from_general_trace_list(General_Trace_List **gtl, void *value)
54 {
55         int ret = 0;
56         General_Trace_List *current = NULL;
57         General_Trace_List *priv = NULL;
58
59         AST(mutex_lock(&general_trace_lists_access_mutex) == 1);
60
61         current = *gtl;
62
63         while (current != NULL)
64         {
65                 if (current->value == value)
66                 {
67                         if (priv == NULL)
68                                 *gtl = current->next;
69                         else
70                                 priv->next = current->next;
71
72                         free(current);
73                         ret = 1;
74                         goto finish;
75                 }
76                 priv = current;
77                 current = current->next;
78         }
79         goto finish;
80
81 finish:
82         AST(mutex_unlock(&general_trace_lists_access_mutex) == 1);
83
84         return ret;
85 }
86