d29f066796bc68a80393917e9fbfff587e34920c
[ira/wip.git] / source3 / include / smbprofile.h
1 #ifndef _PROFILE_H_
2 #define _PROFILE_H_
3 /* 
4    Unix SMB/CIFS implementation.
5    store smbd profiling information in shared memory
6    Copyright (C) Andrew Tridgell 1999
7    Copyright (C) James Peach 2006
8
9    This program is free software; you can redistribute it and/or modify
10    it under the terms of the GNU General Public License as published by
11    the Free Software Foundation; either version 2 of the License, or
12    (at your option) any later version.
13    
14    This program is distributed in the hope that it will be useful,
15    but WITHOUT ANY WARRANTY; without even the implied warranty of
16    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17    GNU General Public License for more details.
18    
19    You should have received a copy of the GNU General Public License
20    along with this program; if not, write to the Free Software
21    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22
23 */
24
25 /* this file defines the profile structure in the profile shared
26    memory area */
27
28 #define PROF_SHMEM_KEY ((key_t)0x07021999)
29 #define PROF_SHM_MAGIC 0x6349985
30 #define PROF_SHM_VERSION 11
31
32 /* time values in the following structure are in microseconds */
33
34 #define __profile_stats_value(which, domain) domain[which]
35
36 enum profile_stats_values
37 {
38         PR_VALUE_SMBD_IDLE = 0,
39 #define smbd_idle_count __profile_stats_value(PR_VALUE_SMBD_IDLE, count)
40 #define smbd_idle_time __profile_stats_value(PR_VALUE_SMBD_IDLE, time)
41
42 /* system call counters */
43         PR_VALUE_SYSCALL_OPENDIR,
44 #define syscall_opendir_count __profile_stats_value(PR_VALUE_SYSCALL_OPENDIR, count)
45 #define syscall_opendir_time __profile_stats_value(PR_VALUE_SYSCALL_OPENDIR, time)
46
47         PR_VALUE_SYSCALL_READDIR,
48 #define syscall_readdir_count __profile_stats_value(PR_VALUE_SYSCALL_READDIR, count)
49 #define syscall_readdir_time __profile_stats_value(PR_VALUE_SYSCALL_READDIR, time)
50
51         PR_VALUE_SYSCALL_SEEKDIR,
52 #define syscall_seekdir_count __profile_stats_value(PR_VALUE_SYSCALL_SEEKDIR, count)
53 #define syscall_seekdir_time __profile_stats_value(PR_VALUE_SYSCALL_SEEKDIR, time)
54
55         PR_VALUE_SYSCALL_TELLDIR,
56 #define syscall_telldir_count __profile_stats_value(PR_VALUE_SYSCALL_TELLDIR, count)
57 #define syscall_telldir_time __profile_stats_value(PR_VALUE_SYSCALL_TELLDIR, time)
58
59         PR_VALUE_SYSCALL_REWINDDIR,
60 #define syscall_rewinddir_count __profile_stats_value(PR_VALUE_SYSCALL_REWINDDIR, count)
61 #define syscall_rewinddir_time __profile_stats_value(PR_VALUE_SYSCALL_REWINDDIR, time)
62
63         PR_VALUE_SYSCALL_MKDIR,
64 #define syscall_mkdir_count __profile_stats_value(PR_VALUE_SYSCALL_MKDIR, count)
65 #define syscall_mkdir_time __profile_stats_value(PR_VALUE_SYSCALL_MKDIR, time)
66
67         PR_VALUE_SYSCALL_RMDIR,
68 #define syscall_rmdir_count __profile_stats_value(PR_VALUE_SYSCALL_RMDIR, count)
69 #define syscall_rmdir_time __profile_stats_value(PR_VALUE_SYSCALL_RMDIR, time)
70
71         PR_VALUE_SYSCALL_CLOSEDIR,
72 #define syscall_closedir_count __profile_stats_value(PR_VALUE_SYSCALL_CLOSEDIR, count)
73 #define syscall_closedir_time __profile_stats_value(PR_VALUE_SYSCALL_CLOSEDIR, time)
74
75         PR_VALUE_SYSCALL_OPEN,
76 #define syscall_open_count __profile_stats_value(PR_VALUE_SYSCALL_OPEN, count)
77 #define syscall_open_time __profile_stats_value(PR_VALUE_SYSCALL_OPEN, time)
78
79         PR_VALUE_SYSCALL_CLOSE,
80 #define syscall_close_count __profile_stats_value(PR_VALUE_SYSCALL_CLOSE, count)
81 #define syscall_close_time __profile_stats_value(PR_VALUE_SYSCALL_CLOSE, time)
82
83         PR_VALUE_SYSCALL_READ,
84 #define syscall_read_count __profile_stats_value(PR_VALUE_SYSCALL_READ, count)
85 #define syscall_read_time __profile_stats_value(PR_VALUE_SYSCALL_READ, time)
86
87         PR_VALUE_SYSCALL_PREAD,
88 #define syscall_pread_count __profile_stats_value(PR_VALUE_SYSCALL_PREAD, count)
89 #define syscall_pread_time __profile_stats_value(PR_VALUE_SYSCALL_PREAD, time)
90
91         PR_VALUE_SYSCALL_WRITE,
92 #define syscall_write_count __profile_stats_value(PR_VALUE_SYSCALL_WRITE, count)
93 #define syscall_write_time __profile_stats_value(PR_VALUE_SYSCALL_WRITE, time)
94
95         PR_VALUE_SYSCALL_PWRITE,
96 #define syscall_pwrite_count __profile_stats_value(PR_VALUE_SYSCALL_PWRITE, count)
97 #define syscall_pwrite_time __profile_stats_value(PR_VALUE_SYSCALL_PWRITE, time)
98
99         PR_VALUE_SYSCALL_LSEEK,
100 #define syscall_lseek_count __profile_stats_value(PR_VALUE_SYSCALL_LSEEK, count)
101 #define syscall_lseek_time __profile_stats_value(PR_VALUE_SYSCALL_LSEEK, time)
102
103         PR_VALUE_SYSCALL_SENDFILE,
104 #define syscall_sendfile_count __profile_stats_value(PR_VALUE_SYSCALL_SENDFILE, count)
105 #define syscall_sendfile_time __profile_stats_value(PR_VALUE_SYSCALL_SENDFILE, time)
106
107         PR_VALUE_SYSCALL_RENAME,
108 #define syscall_rename_count __profile_stats_value(PR_VALUE_SYSCALL_RENAME, count)
109 #define syscall_rename_time __profile_stats_value(PR_VALUE_SYSCALL_RENAME, time)
110
111         PR_VALUE_SYSCALL_FSYNC,
112 #define syscall_fsync_count __profile_stats_value(PR_VALUE_SYSCALL_FSYNC, count)
113 #define syscall_fsync_time __profile_stats_value(PR_VALUE_SYSCALL_FSYNC, time)
114
115         PR_VALUE_SYSCALL_STAT,
116 #define syscall_stat_count __profile_stats_value(PR_VALUE_SYSCALL_STAT, count)
117 #define syscall_stat_time __profile_stats_value(PR_VALUE_SYSCALL_STAT, time)
118
119         PR_VALUE_SYSCALL_FSTAT,
120 #define syscall_fstat_count __profile_stats_value(PR_VALUE_SYSCALL_FSTAT, count)
121 #define syscall_fstat_time __profile_stats_value(PR_VALUE_SYSCALL_FSTAT, time)
122
123         PR_VALUE_SYSCALL_LSTAT,
124 #define syscall_lstat_count __profile_stats_value(PR_VALUE_SYSCALL_LSTAT, count)
125 #define syscall_lstat_time __profile_stats_value(PR_VALUE_SYSCALL_LSTAT, time)
126
127         PR_VALUE_SYSCALL_UNLINK,
128 #define syscall_unlink_count __profile_stats_value(PR_VALUE_SYSCALL_UNLINK, count)
129 #define syscall_unlink_time __profile_stats_value(PR_VALUE_SYSCALL_UNLINK, time)
130
131         PR_VALUE_SYSCALL_CHMOD,
132 #define syscall_chmod_count __profile_stats_value(PR_VALUE_SYSCALL_CHMOD, count)
133 #define syscall_chmod_time __profile_stats_value(PR_VALUE_SYSCALL_CHMOD, time)
134
135         PR_VALUE_SYSCALL_FCHMOD,
136 #define syscall_fchmod_count __profile_stats_value(PR_VALUE_SYSCALL_FCHMOD, count)
137 #define syscall_fchmod_time __profile_stats_value(PR_VALUE_SYSCALL_FCHMOD, time)
138
139         PR_VALUE_SYSCALL_CHOWN,
140 #define syscall_chown_count __profile_stats_value(PR_VALUE_SYSCALL_CHOWN, count)
141 #define syscall_chown_time __profile_stats_value(PR_VALUE_SYSCALL_CHOWN, time)
142
143         PR_VALUE_SYSCALL_FCHOWN,
144 #define syscall_fchown_count __profile_stats_value(PR_VALUE_SYSCALL_FCHOWN, count)
145 #define syscall_fchown_time __profile_stats_value(PR_VALUE_SYSCALL_FCHOWN, time)
146
147         PR_VALUE_SYSCALL_CHDIR,
148 #define syscall_chdir_count __profile_stats_value(PR_VALUE_SYSCALL_CHDIR, count)
149 #define syscall_chdir_time __profile_stats_value(PR_VALUE_SYSCALL_CHDIR, time)
150
151         PR_VALUE_SYSCALL_GETWD,
152 #define syscall_getwd_count __profile_stats_value(PR_VALUE_SYSCALL_GETWD, count)
153 #define syscall_getwd_time __profile_stats_value(PR_VALUE_SYSCALL_GETWD, time)
154
155         PR_VALUE_SYSCALL_UTIME,
156 #define syscall_utime_count __profile_stats_value(PR_VALUE_SYSCALL_UTIME, count)
157 #define syscall_utime_time __profile_stats_value(PR_VALUE_SYSCALL_UTIME, time)
158
159         PR_VALUE_SYSCALL_FTRUNCATE,
160 #define syscall_ftruncate_count __profile_stats_value(PR_VALUE_SYSCALL_FTRUNCATE, count)
161 #define syscall_ftruncate_time __profile_stats_value(PR_VALUE_SYSCALL_FTRUNCATE, time)
162
163         PR_VALUE_SYSCALL_FCNTL_LOCK,
164 #define syscall_fcntl_lock_count __profile_stats_value(PR_VALUE_SYSCALL_FCNTL_LOCK, count)
165 #define syscall_fcntl_lock_time __profile_stats_value(PR_VALUE_SYSCALL_FCNTL_LOCK, time)
166
167         PR_VALUE_SYSCALL_FCNTL_GETLOCK,
168 #define syscall_fcntl_getlock_count __profile_stats_value(PR_VALUE_SYSCALL_FCNTL_GETLOCK, count)
169 #define syscall_fcntl_getlock_time __profile_stats_value(PR_VALUE_SYSCALL_FCNTL_GETLOCK, time)
170
171         PR_VALUE_SYSCALL_READLINK,
172 #define syscall_readlink_count __profile_stats_value(PR_VALUE_SYSCALL_READLINK, count)
173 #define syscall_readlink_time __profile_stats_value(PR_VALUE_SYSCALL_READLINK, time)
174
175         PR_VALUE_SYSCALL_SYMLINK,
176 #define syscall_symlink_count __profile_stats_value(PR_VALUE_SYSCALL_SYMLINK, count)
177 #define syscall_symlink_time __profile_stats_value(PR_VALUE_SYSCALL_SYMLINK, time)
178
179         PR_VALUE_SYSCALL_LINK,
180 #define syscall_link_count __profile_stats_value(PR_VALUE_SYSCALL_LINK, count)
181 #define syscall_link_time __profile_stats_value(PR_VALUE_SYSCALL_LINK, time)
182
183         PR_VALUE_SYSCALL_MKNOD,
184 #define syscall_mknod_count __profile_stats_value(PR_VALUE_SYSCALL_MKNOD, count)
185 #define syscall_mknod_time __profile_stats_value(PR_VALUE_SYSCALL_MKNOD, time)
186
187         PR_VALUE_SYSCALL_REALPATH,
188 #define syscall_realpath_count __profile_stats_value(PR_VALUE_SYSCALL_REALPATH, count)
189 #define syscall_realpath_time __profile_stats_value(PR_VALUE_SYSCALL_REALPATH, time)
190
191         PR_VALUE_SYSCALL_GET_QUOTA,
192 #define syscall_get_quota_count __profile_stats_value(PR_VALUE_SYSCALL_GET_QUOTA, count)
193 #define syscall_get_quota_time __profile_stats_value(PR_VALUE_SYSCALL_GET_QUOTA, time)
194
195         PR_VALUE_SYSCALL_SET_QUOTA,
196 #define syscall_set_quota_count __profile_stats_value(PR_VALUE_SYSCALL_SET_QUOTA, count)
197 #define syscall_set_quota_time __profile_stats_value(PR_VALUE_SYSCALL_SET_QUOTA, time)
198
199 /* counters for individual SMB types */
200         PR_VALUE_SMBMKDIR,
201 #define SMBmkdir_count __profile_stats_value(PR_VALUE_SMBMKDIR, count)
202 #define SMBmkdir_time __profile_stats_value(PR_VALUE_SMBMKDIR, time)
203
204         PR_VALUE_SMBRMDIR,
205 #define SMBrmdir_count __profile_stats_value(PR_VALUE_SMBRMDIR, count)
206 #define SMBrmdir_time __profile_stats_value(PR_VALUE_SMBRMDIR, time)
207
208         PR_VALUE_SMBOPEN,
209 #define SMBopen_count __profile_stats_value(PR_VALUE_SMBOPEN, count)
210 #define SMBopen_time __profile_stats_value(PR_VALUE_SMBOPEN, time)
211
212         PR_VALUE_SMBCREATE,
213 #define SMBcreate_count __profile_stats_value(PR_VALUE_SMBCREATE, count)
214 #define SMBcreate_time __profile_stats_value(PR_VALUE_SMBCREATE, time)
215
216         PR_VALUE_SMBCLOSE,
217 #define SMBclose_count __profile_stats_value(PR_VALUE_SMBCLOSE, count)
218 #define SMBclose_time __profile_stats_value(PR_VALUE_SMBCLOSE, time)
219
220         PR_VALUE_SMBFLUSH,
221 #define SMBflush_count __profile_stats_value(PR_VALUE_SMBFLUSH, count)
222 #define SMBflush_time __profile_stats_value(PR_VALUE_SMBFLUSH, time)
223
224         PR_VALUE_SMBUNLINK,
225 #define SMBunlink_count __profile_stats_value(PR_VALUE_SMBUNLINK, count)
226 #define SMBunlink_time __profile_stats_value(PR_VALUE_SMBUNLINK, time)
227
228         PR_VALUE_SMBMV,
229 #define SMBmv_count __profile_stats_value(PR_VALUE_SMBMV, count)
230 #define SMBmv_time __profile_stats_value(PR_VALUE_SMBMV, time)
231
232         PR_VALUE_SMBGETATR,
233 #define SMBgetatr_count __profile_stats_value(PR_VALUE_SMBGETATR, count)
234 #define SMBgetatr_time __profile_stats_value(PR_VALUE_SMBGETATR, time)
235
236         PR_VALUE_SMBSETATR,
237 #define SMBsetatr_count __profile_stats_value(PR_VALUE_SMBSETATR, count)
238 #define SMBsetatr_time __profile_stats_value(PR_VALUE_SMBSETATR, time)
239
240         PR_VALUE_SMBREAD,
241 #define SMBread_count __profile_stats_value(PR_VALUE_SMBREAD, count)
242 #define SMBread_time __profile_stats_value(PR_VALUE_SMBREAD, time)
243
244         PR_VALUE_SMBWRITE,
245 #define SMBwrite_count __profile_stats_value(PR_VALUE_SMBWRITE, count)
246 #define SMBwrite_time __profile_stats_value(PR_VALUE_SMBWRITE, time)
247
248         PR_VALUE_SMBLOCK,
249 #define SMBlock_count __profile_stats_value(PR_VALUE_SMBLOCK, count)
250 #define SMBlock_time __profile_stats_value(PR_VALUE_SMBLOCK, time)
251
252         PR_VALUE_SMBUNLOCK,
253 #define SMBunlock_count __profile_stats_value(PR_VALUE_SMBUNLOCK, count)
254 #define SMBunlock_time __profile_stats_value(PR_VALUE_SMBUNLOCK, time)
255
256         PR_VALUE_SMBCTEMP,
257 #define SMBctemp_count __profile_stats_value(PR_VALUE_SMBCTEMP, count)
258 #define SMBctemp_time __profile_stats_value(PR_VALUE_SMBCTEMP, time)
259
260         /* SMBmknew stats are currently combined with SMBcreate */
261         PR_VALUE_SMBMKNEW,
262 #define SMBmknew_count __profile_stats_value(PR_VALUE_SMBMKNEW, count)
263 #define SMBmknew_time __profile_stats_value(PR_VALUE_SMBMKNEW, time)
264
265         PR_VALUE_SMBCHKPTH,
266 #define SMBchkpth_count __profile_stats_value(PR_VALUE_SMBCHKPTH, count)
267 #define SMBchkpth_time __profile_stats_value(PR_VALUE_SMBCHKPTH, time)
268
269         PR_VALUE_SMBEXIT,
270 #define SMBexit_count __profile_stats_value(PR_VALUE_SMBEXIT, count)
271 #define SMBexit_time __profile_stats_value(PR_VALUE_SMBEXIT, time)
272
273         PR_VALUE_SMBLSEEK,
274 #define SMBlseek_count __profile_stats_value(PR_VALUE_SMBLSEEK, count)
275 #define SMBlseek_time __profile_stats_value(PR_VALUE_SMBLSEEK, time)
276
277         PR_VALUE_SMBLOCKREAD,
278 #define SMBlockread_count __profile_stats_value(PR_VALUE_SMBLOCKREAD, count)
279 #define SMBlockread_time __profile_stats_value(PR_VALUE_SMBLOCKREAD, time)
280
281         PR_VALUE_SMBWRITEUNLOCK,
282 #define SMBwriteunlock_count __profile_stats_value(PR_VALUE_SMBWRITEUNLOCK, count)
283 #define SMBwriteunlock_time __profile_stats_value(PR_VALUE_SMBWRITEUNLOCK, time)
284
285         PR_VALUE_SMBREADBRAW,
286 #define SMBreadbraw_count __profile_stats_value(PR_VALUE_SMBREADBRAW, count)
287 #define SMBreadbraw_time __profile_stats_value(PR_VALUE_SMBREADBRAW, time)
288
289         PR_VALUE_SMBREADBMPX,
290 #define SMBreadBmpx_count __profile_stats_value(PR_VALUE_SMBREADBMPX, count)
291 #define SMBreadBmpx_time __profile_stats_value(PR_VALUE_SMBREADBMPX, time)
292
293         PR_VALUE_SMBREADBS,
294 #define SMBreadBs_count __profile_stats_value(PR_VALUE_SMBREADBS, count)
295 #define SMBreadBs_time __profile_stats_value(PR_VALUE_SMBREADBS, time)
296
297         PR_VALUE_SMBWRITEBRAW,
298 #define SMBwritebraw_count __profile_stats_value(PR_VALUE_SMBWRITEBRAW, count)
299 #define SMBwritebraw_time __profile_stats_value(PR_VALUE_SMBWRITEBRAW, time)
300
301         PR_VALUE_SMBWRITEBMPX,
302 #define SMBwriteBmpx_count __profile_stats_value(PR_VALUE_SMBWRITEBMPX, count)
303 #define SMBwriteBmpx_time __profile_stats_value(PR_VALUE_SMBWRITEBMPX, time)
304
305         PR_VALUE_SMBWRITEBS,
306 #define SMBwriteBs_count __profile_stats_value(PR_VALUE_SMBWRITEBS, count)
307 #define SMBwriteBs_time __profile_stats_value(PR_VALUE_SMBWRITEBS, time)
308
309         PR_VALUE_SMBWRITEC,
310 #define SMBwritec_count __profile_stats_value(PR_VALUE_SMBWRITEC, count)
311 #define SMBwritec_time __profile_stats_value(PR_VALUE_SMBWRITEC, time)
312
313         PR_VALUE_SMBSETATTRE,
314 #define SMBsetattrE_count __profile_stats_value(PR_VALUE_SMBSETATTRE, count)
315 #define SMBsetattrE_time __profile_stats_value(PR_VALUE_SMBSETATTRE, time)
316
317         PR_VALUE_SMBGETATTRE,
318 #define SMBgetattrE_count __profile_stats_value(PR_VALUE_SMBGETATTRE, count)
319 #define SMBgetattrE_time __profile_stats_value(PR_VALUE_SMBGETATTRE, time)
320
321         PR_VALUE_SMBLOCKINGX,
322 #define SMBlockingX_count __profile_stats_value(PR_VALUE_SMBLOCKINGX, count)
323 #define SMBlockingX_time __profile_stats_value(PR_VALUE_SMBLOCKINGX, time)
324
325         PR_VALUE_SMBTRANS,
326 #define SMBtrans_count __profile_stats_value(PR_VALUE_SMBTRANS, count)
327 #define SMBtrans_time __profile_stats_value(PR_VALUE_SMBTRANS, time)
328
329         PR_VALUE_SMBTRANSS,
330 #define SMBtranss_count __profile_stats_value(PR_VALUE_SMBTRANSS, count)
331 #define SMBtranss_time __profile_stats_value(PR_VALUE_SMBTRANSS, time)
332
333         PR_VALUE_SMBIOCTL,
334 #define SMBioctl_count __profile_stats_value(PR_VALUE_SMBIOCTL, count)
335 #define SMBioctl_time __profile_stats_value(PR_VALUE_SMBIOCTL, time)
336
337         PR_VALUE_SMBIOCTLS,
338 #define SMBioctls_count __profile_stats_value(PR_VALUE_SMBIOCTLS, count)
339 #define SMBioctls_time __profile_stats_value(PR_VALUE_SMBIOCTLS, time)
340
341         PR_VALUE_SMBCOPY,
342 #define SMBcopy_count __profile_stats_value(PR_VALUE_SMBCOPY, count)
343 #define SMBcopy_time __profile_stats_value(PR_VALUE_SMBCOPY, time)
344
345         PR_VALUE_SMBMOVE,
346 #define SMBmove_count __profile_stats_value(PR_VALUE_SMBMOVE, count)
347 #define SMBmove_time __profile_stats_value(PR_VALUE_SMBMOVE, time)
348
349         PR_VALUE_SMBECHO,
350 #define SMBecho_count __profile_stats_value(PR_VALUE_SMBECHO, count)
351 #define SMBecho_time __profile_stats_value(PR_VALUE_SMBECHO, time)
352
353         PR_VALUE_SMBWRITECLOSE,
354 #define SMBwriteclose_count __profile_stats_value(PR_VALUE_SMBWRITECLOSE, count)
355 #define SMBwriteclose_time __profile_stats_value(PR_VALUE_SMBWRITECLOSE, time)
356
357         PR_VALUE_SMBOPENX,
358 #define SMBopenX_count __profile_stats_value(PR_VALUE_SMBOPENX, count)
359 #define SMBopenX_time __profile_stats_value(PR_VALUE_SMBOPENX, time)
360
361         PR_VALUE_SMBREADX,
362 #define SMBreadX_count __profile_stats_value(PR_VALUE_SMBREADX, count)
363 #define SMBreadX_time __profile_stats_value(PR_VALUE_SMBREADX, time)
364
365         PR_VALUE_SMBWRITEX,
366 #define SMBwriteX_count __profile_stats_value(PR_VALUE_SMBWRITEX, count)
367 #define SMBwriteX_time __profile_stats_value(PR_VALUE_SMBWRITEX, time)
368
369         PR_VALUE_SMBTRANS2,
370 #define SMBtrans2_count __profile_stats_value(PR_VALUE_SMBTRANS2, count)
371 #define SMBtrans2_time __profile_stats_value(PR_VALUE_SMBTRANS2, time)
372
373         PR_VALUE_SMBTRANSS2,
374 #define SMBtranss2_count __profile_stats_value(PR_VALUE_SMBTRANSS2, count)
375 #define SMBtranss2_time __profile_stats_value(PR_VALUE_SMBTRANSS2, time)
376
377         PR_VALUE_SMBFINDCLOSE,
378 #define SMBfindclose_count __profile_stats_value(PR_VALUE_SMBFINDCLOSE, count)
379 #define SMBfindclose_time __profile_stats_value(PR_VALUE_SMBFINDCLOSE, time)
380
381         PR_VALUE_SMBFINDNCLOSE,
382 #define SMBfindnclose_count __profile_stats_value(PR_VALUE_SMBFINDNCLOSE, count)
383 #define SMBfindnclose_time __profile_stats_value(PR_VALUE_SMBFINDNCLOSE, time)
384
385         PR_VALUE_SMBTCON,
386 #define SMBtcon_count __profile_stats_value(PR_VALUE_SMBTCON, count)
387 #define SMBtcon_time __profile_stats_value(PR_VALUE_SMBTCON, time)
388
389         PR_VALUE_SMBTDIS,
390 #define SMBtdis_count __profile_stats_value(PR_VALUE_SMBTDIS, count)
391 #define SMBtdis_time __profile_stats_value(PR_VALUE_SMBTDIS, time)
392
393         PR_VALUE_SMBNEGPROT,
394 #define SMBnegprot_count __profile_stats_value(PR_VALUE_SMBNEGPROT, count)
395 #define SMBnegprot_time __profile_stats_value(PR_VALUE_SMBNEGPROT, time)
396
397         PR_VALUE_SMBSESSSETUPX,
398 #define SMBsesssetupX_count __profile_stats_value(PR_VALUE_SMBSESSSETUPX, count)
399 #define SMBsesssetupX_time __profile_stats_value(PR_VALUE_SMBSESSSETUPX, time)
400
401         PR_VALUE_SMBULOGOFFX,
402 #define SMBulogoffX_count __profile_stats_value(PR_VALUE_SMBULOGOFFX, count)
403 #define SMBulogoffX_time __profile_stats_value(PR_VALUE_SMBULOGOFFX, time)
404
405         PR_VALUE_SMBTCONX,
406 #define SMBtconX_count __profile_stats_value(PR_VALUE_SMBTCONX, count)
407 #define SMBtconX_time __profile_stats_value(PR_VALUE_SMBTCONX, time)
408
409         PR_VALUE_SMBDSKATTR,
410 #define SMBdskattr_count __profile_stats_value(PR_VALUE_SMBDSKATTR, count)
411 #define SMBdskattr_time __profile_stats_value(PR_VALUE_SMBDSKATTR, time)
412
413         PR_VALUE_SMBSEARCH,
414 #define SMBsearch_count __profile_stats_value(PR_VALUE_SMBSEARCH, count)
415 #define SMBsearch_time __profile_stats_value(PR_VALUE_SMBSEARCH, time)
416
417         /* SBMffirst stats combined with SMBsearch */
418         PR_VALUE_SMBFFIRST,
419 #define SMBffirst_count __profile_stats_value(PR_VALUE_SMBFFIRST, count)
420 #define SMBffirst_time __profile_stats_value(PR_VALUE_SMBFFIRST, time)
421
422         /* SBMfunique stats combined with SMBsearch */
423         PR_VALUE_SMBFUNIQUE,
424 #define SMBfunique_count __profile_stats_value(PR_VALUE_SMBFUNIQUE, count)
425 #define SMBfunique_time __profile_stats_value(PR_VALUE_SMBFUNIQUE, time)
426
427         PR_VALUE_SMBFCLOSE,
428 #define SMBfclose_count __profile_stats_value(PR_VALUE_SMBFCLOSE, count)
429 #define SMBfclose_time __profile_stats_value(PR_VALUE_SMBFCLOSE, time)
430
431         PR_VALUE_SMBNTTRANS,
432 #define SMBnttrans_count __profile_stats_value(PR_VALUE_SMBNTTRANS, count)
433 #define SMBnttrans_time __profile_stats_value(PR_VALUE_SMBNTTRANS, time)
434
435         PR_VALUE_SMBNTTRANSS,
436 #define SMBnttranss_count __profile_stats_value(PR_VALUE_SMBNTTRANSS, count)
437 #define SMBnttranss_time __profile_stats_value(PR_VALUE_SMBNTTRANSS, time)
438
439         PR_VALUE_SMBNTCREATEX,
440 #define SMBntcreateX_count __profile_stats_value(PR_VALUE_SMBNTCREATEX, count)
441 #define SMBntcreateX_time __profile_stats_value(PR_VALUE_SMBNTCREATEX, time)
442
443         PR_VALUE_SMBNTCANCEL,
444 #define SMBntcancel_count __profile_stats_value(PR_VALUE_SMBNTCANCEL, count)
445 #define SMBntcancel_time __profile_stats_value(PR_VALUE_SMBNTCANCEL, time)
446
447         PR_VALUE_SMBNTRENAME,
448 #define SMBntrename_count __profile_stats_value(PR_VALUE_SMBNTRENAME, count)
449 #define SMBntrename_time __profile_stats_value(PR_VALUE_SMBNTRENAME, time)
450
451         PR_VALUE_SMBSPLOPEN,
452 #define SMBsplopen_count __profile_stats_value(PR_VALUE_SMBSPLOPEN, count)
453 #define SMBsplopen_time __profile_stats_value(PR_VALUE_SMBSPLOPEN, time)
454
455         PR_VALUE_SMBSPLWR,
456 #define SMBsplwr_count __profile_stats_value(PR_VALUE_SMBSPLWR, count)
457 #define SMBsplwr_time __profile_stats_value(PR_VALUE_SMBSPLWR, time)
458
459         PR_VALUE_SMBSPLCLOSE,
460 #define SMBsplclose_count __profile_stats_value(PR_VALUE_SMBSPLCLOSE, count)
461 #define SMBsplclose_time __profile_stats_value(PR_VALUE_SMBSPLCLOSE, time)
462
463         PR_VALUE_SMBSPLRETQ,
464 #define SMBsplretq_count __profile_stats_value(PR_VALUE_SMBSPLRETQ, count)
465 #define SMBsplretq_time __profile_stats_value(PR_VALUE_SMBSPLRETQ, time)
466
467         PR_VALUE_SMBSENDS,
468 #define SMBsends_count __profile_stats_value(PR_VALUE_SMBSENDS, count)
469 #define SMBsends_time __profile_stats_value(PR_VALUE_SMBSENDS, time)
470
471         PR_VALUE_SMBSENDB,
472 #define SMBsendb_count __profile_stats_value(PR_VALUE_SMBSENDB, count)
473 #define SMBsendb_time __profile_stats_value(PR_VALUE_SMBSENDB, time)
474
475         PR_VALUE_SMBFWDNAME,
476 #define SMBfwdname_count __profile_stats_value(PR_VALUE_SMBFWDNAME, count)
477 #define SMBfwdname_time __profile_stats_value(PR_VALUE_SMBFWDNAME, time)
478
479         PR_VALUE_SMBCANCELF,
480 #define SMBcancelf_count __profile_stats_value(PR_VALUE_SMBCANCELF, count)
481 #define SMBcancelf_time __profile_stats_value(PR_VALUE_SMBCANCELF, time)
482
483         PR_VALUE_SMBGETMAC,
484 #define SMBgetmac_count __profile_stats_value(PR_VALUE_SMBGETMAC, count)
485 #define SMBgetmac_time __profile_stats_value(PR_VALUE_SMBGETMAC, time)
486
487         PR_VALUE_SMBSENDSTRT,
488 #define SMBsendstrt_count __profile_stats_value(PR_VALUE_SMBSENDSTRT, count)
489 #define SMBsendstrt_time __profile_stats_value(PR_VALUE_SMBSENDSTRT, time)
490
491         PR_VALUE_SMBSENDEND,
492 #define SMBsendend_count __profile_stats_value(PR_VALUE_SMBSENDEND, count)
493 #define SMBsendend_time __profile_stats_value(PR_VALUE_SMBSENDEND, time)
494
495         PR_VALUE_SMBSENDTXT,
496 #define SMBsendtxt_count __profile_stats_value(PR_VALUE_SMBSENDTXT, count)
497 #define SMBsendtxt_time __profile_stats_value(PR_VALUE_SMBSENDTXT, time)
498
499         PR_VALUE_SMBINVALID,
500 #define SMBinvalid_count __profile_stats_value(PR_VALUE_SMBINVALID, count)
501 #define SMBinvalid_time __profile_stats_value(PR_VALUE_SMBINVALID, time)
502
503 /* Pathworks setdir command */
504         PR_VALUE_PATHWORKS_SETDIR,
505 #define pathworks_setdir_count __profile_stats_value(PR_VALUE_PATHWORKS_SETDIR, count)
506 #define pathworks_setdir_time __profile_stats_value(PR_VALUE_PATHWORKS_SETDIR, time)
507
508 /* These are the TRANS2 sub commands */
509         PR_VALUE_TRANS2_OPEN,
510 #define Trans2_open_count __profile_stats_value(PR_VALUE_TRANS2_OPEN, count)
511 #define Trans2_open_time __profile_stats_value(PR_VALUE_TRANS2_OPEN, time)
512
513         PR_VALUE_TRANS2_FINDFIRST,
514 #define Trans2_findfirst_count __profile_stats_value(PR_VALUE_TRANS2_FINDFIRST, count)
515 #define Trans2_findfirst_time __profile_stats_value(PR_VALUE_TRANS2_FINDFIRST, time)
516
517         PR_VALUE_TRANS2_FINDNEXT,
518 #define Trans2_findnext_count __profile_stats_value(PR_VALUE_TRANS2_FINDNEXT, count)
519 #define Trans2_findnext_time __profile_stats_value(PR_VALUE_TRANS2_FINDNEXT, time)
520
521         PR_VALUE_TRANS2_QFSINFO,
522 #define Trans2_qfsinfo_count __profile_stats_value(PR_VALUE_TRANS2_QFSINFO, count)
523 #define Trans2_qfsinfo_time __profile_stats_value(PR_VALUE_TRANS2_QFSINFO, time)
524
525         PR_VALUE_TRANS2_SETFSINFO,
526 #define Trans2_setfsinfo_count __profile_stats_value(PR_VALUE_TRANS2_SETFSINFO, count)
527 #define Trans2_setfsinfo_time __profile_stats_value(PR_VALUE_TRANS2_SETFSINFO, time)
528
529         PR_VALUE_TRANS2_QPATHINFO,
530 #define Trans2_qpathinfo_count __profile_stats_value(PR_VALUE_TRANS2_QPATHINFO, count)
531 #define Trans2_qpathinfo_time __profile_stats_value(PR_VALUE_TRANS2_QPATHINFO, time)
532
533         PR_VALUE_TRANS2_SETPATHINFO,
534 #define Trans2_setpathinfo_count __profile_stats_value(PR_VALUE_TRANS2_SETPATHINFO, count)
535 #define Trans2_setpathinfo_time __profile_stats_value(PR_VALUE_TRANS2_SETPATHINFO, time)
536
537         PR_VALUE_TRANS2_QFILEINFO,
538 #define Trans2_qfileinfo_count __profile_stats_value(PR_VALUE_TRANS2_QFILEINFO, count)
539 #define Trans2_qfileinfo_time __profile_stats_value(PR_VALUE_TRANS2_QFILEINFO, time)
540
541         PR_VALUE_TRANS2_SETFILEINFO,
542 #define Trans2_setfileinfo_count __profile_stats_value(PR_VALUE_TRANS2_SETFILEINFO, count)
543 #define Trans2_setfileinfo_time __profile_stats_value(PR_VALUE_TRANS2_SETFILEINFO, time)
544
545         PR_VALUE_TRANS2_FSCTL,
546 #define Trans2_fsctl_count __profile_stats_value(PR_VALUE_TRANS2_FSCTL, count)
547 #define Trans2_fsctl_time __profile_stats_value(PR_VALUE_TRANS2_FSCTL, time)
548
549         PR_VALUE_TRANS2_IOCTL,
550 #define Trans2_ioctl_count __profile_stats_value(PR_VALUE_TRANS2_IOCTL, count)
551 #define Trans2_ioctl_time __profile_stats_value(PR_VALUE_TRANS2_IOCTL, time)
552
553         PR_VALUE_TRANS2_FINDNOTIFYFIRST,
554 #define Trans2_findnotifyfirst_count __profile_stats_value(PR_VALUE_TRANS2_FINDNOTIFYFIRST, count)
555 #define Trans2_findnotifyfirst_time __profile_stats_value(PR_VALUE_TRANS2_FINDNOTIFYFIRST, time)
556
557         PR_VALUE_TRANS2_FINDNOTIFYNEXT,
558 #define Trans2_findnotifynext_count __profile_stats_value(PR_VALUE_TRANS2_FINDNOTIFYNEXT, count)
559 #define Trans2_findnotifynext_time __profile_stats_value(PR_VALUE_TRANS2_FINDNOTIFYNEXT, time)
560
561         PR_VALUE_TRANS2_MKDIR,
562 #define Trans2_mkdir_count __profile_stats_value(PR_VALUE_TRANS2_MKDIR, count)
563 #define Trans2_mkdir_time __profile_stats_value(PR_VALUE_TRANS2_MKDIR, time)
564
565         PR_VALUE_TRANS2_SESSION_SETUP,
566 #define Trans2_session_setup_count __profile_stats_value(PR_VALUE_TRANS2_SESSION_SETUP, count)
567 #define Trans2_session_setup_time __profile_stats_value(PR_VALUE_TRANS2_SESSION_SETUP, time)
568
569         PR_VALUE_TRANS2_GET_DFS_REFERRAL,
570 #define Trans2_get_dfs_referral_count __profile_stats_value(PR_VALUE_TRANS2_GET_DFS_REFERRAL, count)
571 #define Trans2_get_dfs_referral_time __profile_stats_value(PR_VALUE_TRANS2_GET_DFS_REFERRAL, time)
572
573         PR_VALUE_TRANS2_REPORT_DFS_INCONSISTANCY,
574 #define Trans2_report_dfs_inconsistancy_count __profile_stats_value(PR_VALUE_TRANS2_REPORT_DFS_INCONSISTANCY, count)
575 #define Trans2_report_dfs_inconsistancy_time __profile_stats_value(PR_VALUE_TRANS2_REPORT_DFS_INCONSISTANCY, time)
576
577 /* These are the NT transact sub commands. */
578         PR_VALUE_NT_TRANSACT_CREATE,
579 #define NT_transact_create_count __profile_stats_value(PR_VALUE_NT_TRANSACT_CREATE, count)
580 #define NT_transact_create_time __profile_stats_value(PR_VALUE_NT_TRANSACT_CREATE, time)
581
582         PR_VALUE_NT_TRANSACT_IOCTL,
583 #define NT_transact_ioctl_count __profile_stats_value(PR_VALUE_NT_TRANSACT_IOCTL, count)
584 #define NT_transact_ioctl_time __profile_stats_value(PR_VALUE_NT_TRANSACT_IOCTL, time)
585
586         PR_VALUE_NT_TRANSACT_SET_SECURITY_DESC,
587 #define NT_transact_set_security_desc_count __profile_stats_value(PR_VALUE_NT_TRANSACT_SET_SECURITY_DESC, count)
588 #define NT_transact_set_security_desc_time __profile_stats_value(PR_VALUE_NT_TRANSACT_SET_SECURITY_DESC, time)
589
590         PR_VALUE_NT_TRANSACT_NOTIFY_CHANGE,
591 #define NT_transact_notify_change_count __profile_stats_value(PR_VALUE_NT_TRANSACT_NOTIFY_CHANGE, count)
592 #define NT_transact_notify_change_time __profile_stats_value(PR_VALUE_NT_TRANSACT_NOTIFY_CHANGE, time)
593
594         PR_VALUE_NT_TRANSACT_RENAME,
595 #define NT_transact_rename_count __profile_stats_value(PR_VALUE_NT_TRANSACT_RENAME, count)
596 #define NT_transact_rename_time __profile_stats_value(PR_VALUE_NT_TRANSACT_RENAME, time)
597
598         PR_VALUE_NT_TRANSACT_QUERY_SECURITY_DESC,
599 #define NT_transact_query_security_desc_count __profile_stats_value(PR_VALUE_NT_TRANSACT_QUERY_SECURITY_DESC, count)
600 #define NT_transact_query_security_desc_time __profile_stats_value(PR_VALUE_NT_TRANSACT_QUERY_SECURITY_DESC, time)
601
602         PR_VALUE_NT_TRANSACT_GET_USER_QUOTA,
603 #define NT_transact_get_user_quota_count __profile_stats_value(PR_VALUE_NT_TRANSACT_GET_USER_QUOTA, count)
604 #define NT_transact_get_user_quota_time __profile_stats_value(PR_VALUE_NT_TRANSACT_GET_USER_QUOTA, time)
605
606         PR_VALUE_NT_TRANSACT_SET_USER_QUOTA,
607 #define NT_transact_set_user_quota_count __profile_stats_value(PR_VALUE_NT_TRANSACT_SET_USER_QUOTA, count)
608 #define NT_transact_set_user_quota_time __profile_stats_value(PR_VALUE_NT_TRANSACT_SET_USER_QUOTA, time)
609
610 /* These are ACL manipulation calls */
611         PR_VALUE_GET_NT_ACL,
612 #define get_nt_acl_count __profile_stats_value(PR_VALUE_GET_NT_ACL, count)
613 #define get_nt_acl_time __profile_stats_value(PR_VALUE_GET_NT_ACL, time)
614
615         PR_VALUE_FGET_NT_ACL,
616 #define fget_nt_acl_count __profile_stats_value(PR_VALUE_FGET_NT_ACL, count)
617 #define fget_nt_acl_time __profile_stats_value(PR_VALUE_FGET_NT_ACL, time)
618
619         PR_VALUE_SET_NT_ACL,
620 #define set_nt_acl_count __profile_stats_value(PR_VALUE_SET_NT_ACL, count)
621 #define set_nt_acl_time __profile_stats_value(PR_VALUE_SET_NT_ACL, time)
622
623         PR_VALUE_FSET_NT_ACL,
624 #define fset_nt_acl_count __profile_stats_value(PR_VALUE_FSET_NT_ACL, count)
625 #define fset_nt_acl_time __profile_stats_value(PR_VALUE_FSET_NT_ACL, time)
626
627         PR_VALUE_CHMOD_ACL,
628 #define chmod_acl_count __profile_stats_value(PR_VALUE_CHMOD_ACL, count)
629 #define chmod_acl_time __profile_stats_value(PR_VALUE_CHMOD_ACL, time)
630
631         PR_VALUE_FCHMOD_ACL,
632 #define fchmod_acl_count __profile_stats_value(PR_VALUE_FCHMOD_ACL, count)
633 #define fchmod_acl_time __profile_stats_value(PR_VALUE_FCHMOD_ACL, time)
634
635 /* These are nmbd stats */
636         PR_VALUE_NAME_RELEASE,
637 #define name_release_count __profile_stats_value(PR_VALUE_NAME_RELEASE, count)
638 #define name_release_time __profile_stats_value(PR_VALUE_NAME_RELEASE, time)
639
640         PR_VALUE_NAME_REFRESH,
641 #define name_refresh_count __profile_stats_value(PR_VALUE_NAME_REFRESH, count)
642 #define name_refresh_time __profile_stats_value(PR_VALUE_NAME_REFRESH, time)
643
644         PR_VALUE_NAME_REGISTRATION,
645 #define name_registration_count __profile_stats_value(PR_VALUE_NAME_REGISTRATION, count)
646 #define name_registration_time __profile_stats_value(PR_VALUE_NAME_REGISTRATION, time)
647
648         PR_VALUE_NODE_STATUS,
649 #define node_status_count __profile_stats_value(PR_VALUE_NODE_STATUS, count)
650 #define node_status_time __profile_stats_value(PR_VALUE_NODE_STATUS, time)
651
652         PR_VALUE_NAME_QUERY,
653 #define name_query_count __profile_stats_value(PR_VALUE_NAME_QUERY, count)
654 #define name_query_time __profile_stats_value(PR_VALUE_NAME_QUERY, time)
655
656         PR_VALUE_HOST_ANNOUNCE,
657 #define host_announce_count __profile_stats_value(PR_VALUE_HOST_ANNOUNCE, count)
658 #define host_announce_time __profile_stats_value(PR_VALUE_HOST_ANNOUNCE, time)
659
660         PR_VALUE_WORKGROUP_ANNOUNCE,
661 #define workgroup_announce_count __profile_stats_value(PR_VALUE_WORKGROUP_ANNOUNCE, count)
662 #define workgroup_announce_time __profile_stats_value(PR_VALUE_WORKGROUP_ANNOUNCE, time)
663
664         PR_VALUE_LOCAL_MASTER_ANNOUNCE,
665 #define local_master_announce_count __profile_stats_value(PR_VALUE_LOCAL_MASTER_ANNOUNCE, count)
666 #define local_master_announce_time __profile_stats_value(PR_VALUE_LOCAL_MASTER_ANNOUNCE, time)
667
668         PR_VALUE_MASTER_BROWSER_ANNOUNCE,
669 #define master_browser_announce_count __profile_stats_value(PR_VALUE_MASTER_BROWSER_ANNOUNCE, count)
670 #define master_browser_announce_time __profile_stats_value(PR_VALUE_MASTER_BROWSER_ANNOUNCE, time)
671
672         PR_VALUE_LM_HOST_ANNOUNCE,
673 #define lm_host_announce_count __profile_stats_value(PR_VALUE_LM_HOST_ANNOUNCE, count)
674 #define lm_host_announce_time __profile_stats_value(PR_VALUE_LM_HOST_ANNOUNCE, time)
675
676         PR_VALUE_GET_BACKUP_LIST,
677 #define get_backup_list_count __profile_stats_value(PR_VALUE_GET_BACKUP_LIST, count)
678 #define get_backup_list_time __profile_stats_value(PR_VALUE_GET_BACKUP_LIST, time)
679
680         PR_VALUE_RESET_BROWSER,
681 #define reset_browser_count __profile_stats_value(PR_VALUE_RESET_BROWSER, count)
682 #define reset_browser_time __profile_stats_value(PR_VALUE_RESET_BROWSER, time)
683
684         PR_VALUE_ANNOUNCE_REQUEST,
685 #define announce_request_count __profile_stats_value(PR_VALUE_ANNOUNCE_REQUEST, count)
686 #define announce_request_time __profile_stats_value(PR_VALUE_ANNOUNCE_REQUEST, time)
687
688         PR_VALUE_LM_ANNOUNCE_REQUEST,
689 #define lm_announce_request_count __profile_stats_value(PR_VALUE_LM_ANNOUNCE_REQUEST, count)
690 #define lm_announce_request_time __profile_stats_value(PR_VALUE_LM_ANNOUNCE_REQUEST, time)
691
692         PR_VALUE_DOMAIN_LOGON,
693 #define domain_logon_count __profile_stats_value(PR_VALUE_DOMAIN_LOGON, count)
694 #define domain_logon_time __profile_stats_value(PR_VALUE_DOMAIN_LOGON, time)
695
696         PR_VALUE_SYNC_BROWSE_LISTS,
697 #define sync_browse_lists_count __profile_stats_value(PR_VALUE_SYNC_BROWSE_LISTS, count)
698 #define sync_browse_lists_time __profile_stats_value(PR_VALUE_SYNC_BROWSE_LISTS, time)
699
700         PR_VALUE_RUN_ELECTIONS,
701 #define run_elections_count __profile_stats_value(PR_VALUE_RUN_ELECTIONS, count)
702 #define run_elections_time __profile_stats_value(PR_VALUE_RUN_ELECTIONS, time)
703
704         PR_VALUE_ELECTION,
705 #define election_count __profile_stats_value(PR_VALUE_ELECTION, count)
706 #define election_time __profile_stats_value(PR_VALUE_ELECTION, time)
707
708         /* This mist remain the last value. */
709         PR_VALUE_MAX
710 }; /* enum profile_stats_values */
711
712 const char * profile_value_name(enum profile_stats_values val);
713
714 struct profile_stats {
715 /* general counters */
716         unsigned smb_count; /* how many SMB packets we have processed */
717         unsigned uid_changes; /* how many times we change our effective uid */
718
719 /* system call and protocol operation counters and cumulative times */
720         unsigned count[PR_VALUE_MAX];
721         unsigned time[PR_VALUE_MAX];
722
723 /* cumulative byte counts */
724         unsigned syscall_pread_bytes;
725         unsigned syscall_pwrite_bytes;
726         unsigned syscall_read_bytes;
727         unsigned syscall_write_bytes;
728         unsigned syscall_sendfile_bytes;
729
730 /* stat cache counters */
731         unsigned statcache_lookups;
732         unsigned statcache_misses;
733         unsigned statcache_hits;
734
735 /* write cache counters */
736         unsigned writecache_read_hits;
737         unsigned writecache_abutted_writes;
738         unsigned writecache_total_writes;
739         unsigned writecache_non_oplock_writes;
740         unsigned writecache_direct_writes;
741         unsigned writecache_init_writes;
742         unsigned writecache_flushed_writes[NUM_FLUSH_REASONS];
743         unsigned writecache_num_perfect_writes;
744         unsigned writecache_num_write_caches;
745         unsigned writecache_allocated_write_caches;
746 };
747
748 struct profile_header {
749         int prof_shm_magic;
750         int prof_shm_version;
751         struct profile_stats stats;
752 };
753
754 extern struct profile_header *profile_h;
755 extern struct profile_stats *profile_p;
756 extern struct timeval profile_starttime;
757 extern struct timeval profile_endtime;
758 extern struct timeval profile_starttime_nested;
759 extern struct timeval profile_endtime_nested;
760 extern BOOL do_profile_flag;
761 extern BOOL do_profile_times;
762
763 #ifdef WITH_PROFILE
764
765 /* these are helper macros - do not call them directly in the code
766  * use the DO_PROFILE_* START_PROFILE and END_PROFILE ones
767  * below which test for the profile flage first
768  */
769 #define INC_PROFILE_COUNT(x) profile_p->x++
770 #define DEC_PROFILE_COUNT(x) profile_p->x--
771 #define ADD_PROFILE_COUNT(x,y) profile_p->x += (y)
772
773 #if defined(HAVE_CLOCK_GETTIME)
774
775 extern clockid_t __profile_clock;
776
777 static inline SMB_BIG_UINT profile_timestamp(void)
778 {
779         struct timespec ts;
780
781         /* FIXME: On a single-CPU system, or a system where we have bound
782          * daemon threads to single CPUs (eg. using cpusets or processor
783          * affinity), it might be preferable to use CLOCK_PROCESS_CPUTIME_ID.
784          */
785
786         clock_gettime(__profile_clock, &ts);
787         return (ts.tv_sec * 1000000) + (ts.tv_nsec / 1000); /* usec */
788 }
789
790 #else
791
792 static inline SMB_BIG_UINT profile_timestamp(void)
793 {
794         struct timeval tv;
795         GetTimeOfDay(&tv);
796         return (tv.tv_sec * 1000000) + tv.tv_usec;
797 }
798
799 #endif
800
801 /* end of helper macros */
802
803 #define DO_PROFILE_INC(x) \
804         if (do_profile_flag) { \
805                 INC_PROFILE_COUNT(x); \
806         }
807
808 #define DO_PROFILE_DEC(x) \
809         if (do_profile_flag) { \
810                 DEC_PROFILE_COUNT(x); \
811         }
812
813 #define DO_PROFILE_DEC_INC(x,y) \
814         if (do_profile_flag) { \
815                 DEC_PROFILE_COUNT(x); \
816                 INC_PROFILE_COUNT(y); \
817         }
818
819 #define DO_PROFILE_ADD(x,n) \
820         if (do_profile_flag) { \
821                 ADD_PROFILE_COUNT(x,n); \
822         }
823
824 #define START_PROFILE(x) \
825         SMB_BIG_UINT __profstamp_##x = 0; \
826         if (do_profile_flag) { \
827                 __profstamp_##x = do_profile_times ? profile_timestamp() : 0;\
828                 INC_PROFILE_COUNT(x##_count); \
829         }
830
831 #define START_PROFILE_BYTES(x,n) \
832         SMB_BIG_UINT __profstamp_##x = 0; \
833         if (do_profile_flag) { \
834                 __profstamp_##x = do_profile_times ? profile_timestamp() : 0;\
835                 INC_PROFILE_COUNT(x##_count); \
836                 ADD_PROFILE_COUNT(x##_bytes, n); \
837         }
838
839 #define END_PROFILE(x) \
840         if (do_profile_times) { \
841                 ADD_PROFILE_COUNT(x##_time, \
842                     profile_timestamp() - __profstamp_##x); \
843         }
844
845 #define START_PROFILE_NESTED(x) START_PROFILE(x)
846 #define END_PROFILE_NESTED(x) END_PROFILE(x)
847
848 #else /* WITH_PROFILE */
849
850 #define DO_PROFILE_INC(x)
851 #define DO_PROFILE_DEC(x)
852 #define DO_PROFILE_DEC_INC(x,y)
853 #define DO_PROFILE_ADD(x,n)
854 #define START_PROFILE(x)
855 #define START_PROFILE_NESTED(x)
856 #define START_PROFILE_BYTES(x,n)
857 #define END_PROFILE(x)
858 #define END_PROFILE_NESTED(x)
859
860 #endif /* WITH_PROFILE */
861
862 #endif