src: unsigned variable not handled properly.
[platform/core/multimedia/libmm-ta.git] / src / mm_ta.h
1 /*
2  * libmm-ta
3  *
4  * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
5  *
6  * Contact: Jonghyuk Choi <jhchoi.choi@samsung.com>
7  *
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  *
12  * http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  *
20  */
21
22 #ifndef _MM_TA_H_
23 #define _MM_TA_H_
24  
25 #define GST_TA_MAX_CHECKPOINT   500
26 #define GST_TA_MAX_ACCUM                500
27
28 typedef struct _gst_ta_checkpoint
29 {
30         unsigned long timestamp;
31         char* name;
32 } gst_ta_checkpoint;
33
34 typedef struct _gst_ta_accum_item
35 {
36         unsigned long elapsed_accum;
37         unsigned long num_calls;
38         unsigned long elapsed_min;
39         unsigned long elapsed_max;
40         unsigned long first_start;
41         unsigned long last_end;
42
43         char* name;
44
45         unsigned long timestamp;
46         int on_estimate;
47         int num_unpair;
48 } gst_ta_accum_item;
49
50 #define MMTA_SHOW_STDOUT        0
51 #define MMTA_SHOW_STDERR        1
52 #define MMTA_SHOW_FILE  2       
53
54 /* COMMON */
55 int gst_ta_init(void);
56 int gst_ta_release(void);
57 void gst_ta_set_enable(int enable);
58 char* gst_ta_fmt(const char* fmt, ...);
59
60 /* CHECK POINT */
61 int gst_ta_add_checkpoint(char* name, int show, char* filename, int line);
62 void gst_ta_show_checkpoints(void);
63 void gst_ta_show_diff(char* name1, char* name2);
64
65 int gst_ta_get_numof_checkpoints();
66 unsigned long gst_ta_get_diff(char* name1, char* name2);
67 char* gst_ta_get_name(int idx);
68
69 /* ACCUM ITEM */
70 int gst_ta_accum_item_begin(char* name, int show, char* filename, int line);
71 int gst_ta_accum_item_end(char* name, int show, char* filename, int line);
72 void gst_ta_accum_show_result(int direction);
73
74 /* macro. */
75 #ifdef GST_EXT_TIME_ANALYSIS
76 #define MMTA_INIT()                                                             (       gst_ta_init()                                                                                           )
77 #define MMTA_RELEASE()                                                  (       gst_ta_release()                                                                                        )
78 #define MMTA_SET_ENABLE(enable)                         (       gst_ta_set_enable(enable)                                                               )
79
80 /* checkpoint handling */
81 #define MMTA_ADD_CHECKPOINT(name,show)          (       gst_ta_add_checkpoint(name,show,__FILE__,__LINE__)              )
82 #define MMTA_SHOW_CHECKPOINTS()                         (       gst_ta_show_checkpoints()                                                               )
83 #define MMTA_SHOW_DIFF(name1, name2)                    (       gst_ta_show_diff(name1, name2)                                                  )
84 #define MMTA_GET_NUMOF_CHECKPOINTS()                    (       gst_ta_get_numof_checkpoints()                                                  )
85 #define MMTA_GET_DIFF(name1, name2)                     (       gst_ta_get_diff(name1, name2)                                                   )
86 #define MMTA_GET_NAME(idx)                                              (       gst_ta_get_name(idx)                                                                    )
87
88 /* accum item handling */
89 #define MMTA_ACUM_ITEM_BEGIN(name,show)         (       gst_ta_accum_item_begin(name,show,__FILE__,__LINE__)    )
90 #define MMTA_ACUM_ITEM_END(name,show)           (       gst_ta_accum_item_end(name,show,__FILE__,__LINE__)              )
91 #define MMTA_ACUM_ITEM_SHOW_RESULT()            (       gst_ta_accum_show_result(MMTA_SHOW_STDOUT)                      ) 
92 #define MMTA_ACUM_ITEM_SHOW_RESULT_TO(x)        (       gst_ta_accum_show_result(x)                                                     ) 
93
94 #define __ta__(name, x) \
95 MMTA_ACUM_ITEM_BEGIN(name, 0); \
96 x \
97 MMTA_ACUM_ITEM_END(name, 0);
98                                         
99 #define __tafmt__(fmt, args...)                         (       gst_ta_fmt(fmt, ##args) )
100
101 #else
102
103 #define MMTA_INIT()
104 #define MMTA_RELEASE()
105 #define MMTA_SET_ENABLE(enable)
106
107 /* checkpoint handling */
108 #define MMTA_ADD_CHECKPOINT(name,show)
109 #define MMTA_SHOW_CHECKPOINTS()
110 #define MMTA_SHOW_DIFF(name1, name2)
111 #define MMTA_GET_NUMOF_CHECKPOINTS()
112 #define MMTA_GET_DIFF(name1, name2)
113 #define MMTA_GET_NAME(idx)
114
115 /* accum item handling */
116 #define MMTA_ACUM_ITEM_BEGIN(name,show)
117 #define MMTA_ACUM_ITEM_END(name,show)
118 #define MMTA_ACUM_ITEM_SHOW_RESULT()
119 #define MMTA_ACUM_ITEM_SHOW_RESULT_TO(x)
120 #define __ta__(name, x) x
121 #define __tafmt__(fmt, args...)
122
123 #endif
124
125 #endif  /*_MM_TA_H_*/
126