darwin port was unhappy because of this
[openafs.git] / src / afs / afs_stat.c
1 /*
2  * Copyright 2000, International Business Machines Corporation and others.
3  * All Rights Reserved.
4  * 
5  * This software has been released under the terms of the IBM Public
6  * License.  For details, see the LICENSE file in the top-level source
7  * directory or online at http://www.openafs.org/dl/license10.html
8  */
9
10 /* statistics-gathering package */
11
12 #include "../afs/param.h"       /*Should be always first*/
13 #include "../afs/sysincludes.h" /*Standard vendor system headers*/
14 #include "../afs/afsincludes.h" /*AFS-based standard headers*/
15 #include "afs_stats.h"
16
17 struct afs_CMStats afs_cmstats;
18 struct afs_stats_CMPerf afs_stats_cmperf;
19 struct afs_stats_CMFullPerf afs_stats_cmfullperf;
20 afs_int32 afs_stats_XferSumBytes[AFS_STATS_NUM_FS_XFER_OPS];
21
22
23
24 /*
25  * afs_InitStats
26  *
27  * Description:
28  *      Initialize all of the CM statistics structures.
29  *
30  * Parameters:
31  *      None.
32  *
33  * Environment:
34  *      This routine should only be called once, at initialization time.
35  */
36 void afs_InitStats()
37
38 { /*afs_InitStats*/
39
40     struct afs_stats_opTimingData *opTimeP;     /*Ptr to curr timing struct*/
41     struct afs_stats_xferData *xferP;           /*Ptr to curr xfer struct*/
42     int currIdx;                                /*Current index*/
43
44     /*
45      * First step is to zero everything out.
46      */
47     bzero((char *)(&afs_cmstats), sizeof(struct afs_CMStats));
48     bzero((char *)(&afs_stats_cmperf), sizeof(struct afs_stats_CMPerf));
49     bzero((char *)(&afs_stats_cmfullperf),
50           sizeof(struct afs_stats_CMFullPerf));
51
52     /*
53      * Some fields really should be non-zero at the start, so set 'em up.
54      */
55     afs_stats_cmperf.srvNumBuckets = NSERVERS;
56
57     opTimeP = &(afs_stats_cmfullperf.rpc.fsRPCTimes[0]);
58     for (currIdx = 0; currIdx < AFS_STATS_NUM_FS_RPC_OPS; currIdx++, opTimeP++)
59         opTimeP->minTime.tv_sec = 999999;
60
61     opTimeP = &(afs_stats_cmfullperf.rpc.cmRPCTimes[0]);
62     for (currIdx = 0; currIdx < AFS_STATS_NUM_CM_RPC_OPS; currIdx++, opTimeP++)
63         opTimeP->minTime.tv_sec = 999999;
64
65     xferP = &(afs_stats_cmfullperf.rpc.fsXferTimes[0]);
66     for (currIdx = 0; currIdx < AFS_STATS_NUM_FS_XFER_OPS; currIdx++, xferP++) {
67         xferP->minTime.tv_sec = 999999;
68         xferP->minBytes = 999999999;
69     }
70     
71 } /*afs_InitStats*/
72
73
74
75 afs_GetCMStat(ptr, size)
76      char **ptr; /* memory area */
77      unsigned *size; /* # of bytes */
78   {
79 #ifndef AFS_NOSTATS
80       AFS_STATCNT(afs_GetCMStat);
81       *ptr = (char *)&afs_cmstats;
82       *size = sizeof(afs_cmstats);
83 #endif /* AFS_NOSTATS */
84   }
85
86 afs_AddToMean(oldMean, newValue)
87      struct afs_MeanStats *oldMean;
88      afs_int32 newValue;
89   {
90       AFS_STATCNT(afs_AddToMean);
91   }