OSDN Git Service

First version
[st-ro/stro.git] / 3rdparty / mysql / include / mysql / psi / mysql_stage.h
1 /* Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved.
2
3   This program is free software; you can redistribute it and/or modify
4   it under the terms of the GNU General Public License as published by
5   the Free Software Foundation; version 2 of the License.
6
7   This program is distributed in the hope that it will be useful,
8   but WITHOUT ANY WARRANTY; without even the implied warranty of
9   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
10   GNU General Public License for more details.
11
12   You should have received a copy of the GNU General Public License
13   along with this program; if not, write to the Free Software
14   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301  USA */
15
16 #ifndef MYSQL_STAGE_H
17 #define MYSQL_STAGE_H
18
19 /**
20   @file mysql/psi/mysql_stage.h
21   Instrumentation helpers for stages.
22 */
23
24 #include "mysql/psi/psi.h"
25
26 #ifndef PSI_STAGE_CALL
27 #define PSI_STAGE_CALL(M) PSI_DYNAMIC_CALL(M)
28 #endif
29
30 /**
31   @defgroup Stage_instrumentation Stage Instrumentation
32   @ingroup Instrumentation_interface
33   @{
34 */
35
36 /**
37   @def mysql_stage_register(P1, P2, P3)
38   Stage registration.
39 */
40 #ifdef HAVE_PSI_STAGE_INTERFACE
41 #define mysql_stage_register(P1, P2, P3) \
42   inline_mysql_stage_register(P1, P2, P3)
43 #else
44 #define mysql_stage_register(P1, P2, P3) \
45   do {} while (0)
46 #endif
47
48 /**
49   @def MYSQL_SET_STAGE
50   Set the current stage.
51   Use this API when the file and line
52   is passed from the caller.
53   @param K the stage key
54   @param F the source file name
55   @param L the source file line
56   @return the current stage progress
57 */
58 #ifdef HAVE_PSI_STAGE_INTERFACE
59   #define MYSQL_SET_STAGE(K, F, L) \
60     inline_mysql_set_stage(K, F, L)
61 #else
62   #define MYSQL_SET_STAGE(K, F, L) \
63     NULL
64 #endif
65
66 /**
67   @def mysql_set_stage
68   Set the current stage.
69   @param K the stage key
70   @return the current stage progress
71 */
72 #ifdef HAVE_PSI_STAGE_INTERFACE
73   #define mysql_set_stage(K) \
74     inline_mysql_set_stage(K, __FILE__, __LINE__)
75 #else
76   #define mysql_set_stage(K) \
77     NULL
78 #endif
79
80 /**
81   @def mysql_end_stage
82   End the last stage
83 */
84 #ifdef HAVE_PSI_STAGE_INTERFACE
85   #define mysql_end_stage \
86     inline_mysql_end_stage
87 #else
88   #define mysql_end_stage \
89   do {} while (0)
90 #endif
91
92 #ifdef HAVE_PSI_STAGE_INTERFACE
93 static inline void inline_mysql_stage_register(
94   const char *category, PSI_stage_info **info, int count)
95 {
96   PSI_STAGE_CALL(register_stage)(category, info, count);
97 }
98 #endif
99
100 #ifdef HAVE_PSI_STAGE_INTERFACE
101 static inline PSI_stage_progress*
102 inline_mysql_set_stage(PSI_stage_key key,
103                        const char *src_file, int src_line)
104 {
105   return PSI_STAGE_CALL(start_stage)(key, src_file, src_line);
106 }
107 #endif
108
109 #ifdef HAVE_PSI_STAGE_INTERFACE
110 static inline void
111 inline_mysql_end_stage()
112 {
113   PSI_STAGE_CALL(end_stage)();
114 }
115 #endif
116
117 #ifdef HAVE_PSI_STAGE_INTERFACE
118 #define mysql_stage_set_work_completed(P1, P2) \
119   inline_mysql_stage_set_work_completed(P1, P2)
120
121 #define mysql_stage_get_work_completed(P1) \
122   inline_mysql_stage_get_work_completed(P1)
123 #else
124 #define mysql_stage_set_work_completed(P1, P2) \
125   do {} while (0)
126
127 #define mysql_stage_get_work_completed(P1) \
128   do {} while (0)
129 #endif
130
131 #ifdef HAVE_PSI_STAGE_INTERFACE
132 #define mysql_stage_inc_work_completed(P1, P2) \
133   inline_mysql_stage_inc_work_completed(P1, P2)
134 #else
135 #define mysql_stage_inc_work_completed(P1, P2) \
136   do {} while (0)
137 #endif
138
139 #ifdef HAVE_PSI_STAGE_INTERFACE
140 #define mysql_stage_set_work_estimated(P1, P2) \
141   inline_mysql_stage_set_work_estimated(P1, P2)
142
143 #define mysql_stage_get_work_estimated(P1) \
144   inline_mysql_stage_get_work_estimated(P1)
145 #else
146 #define mysql_stage_set_work_estimated(P1, P2) \
147   do {} while (0)
148
149 #define mysql_stage_get_work_estimated(P1) \
150   do {} while (0)
151 #endif
152
153 #ifdef HAVE_PSI_STAGE_INTERFACE
154 static inline void
155 inline_mysql_stage_set_work_completed(PSI_stage_progress *progress,
156                                       ulonglong val)
157 {
158   if (progress != NULL)
159     progress->m_work_completed= val;
160 }
161
162 static inline ulonglong
163 inline_mysql_stage_get_work_completed(PSI_stage_progress *progress)
164 {
165   return progress->m_work_completed;
166 }
167 #endif
168
169 #ifdef HAVE_PSI_STAGE_INTERFACE
170 static inline void
171 inline_mysql_stage_inc_work_completed(PSI_stage_progress *progress,
172                                       ulonglong val)
173 {
174   if (progress != NULL)
175     progress->m_work_completed+= val;
176 }
177 #endif
178
179 #ifdef HAVE_PSI_STAGE_INTERFACE
180 static inline void
181 inline_mysql_stage_set_work_estimated(PSI_stage_progress *progress,
182                                       ulonglong val)
183 {
184   if (progress != NULL)
185     progress->m_work_estimated= val;
186 }
187
188 static inline ulonglong
189 inline_mysql_stage_get_work_estimated(PSI_stage_progress *progress)
190 {
191   return progress->m_work_estimated;
192 }
193 #endif
194
195 /** @} (end of group Stage_instrumentation) */
196
197 #endif
198