stats.c (7c478bd9) | stats.c (7aec1d6e) |
---|---|
1/* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the 5 * Common Development and Distribution License, Version 1.0 only 6 * (the "License"). You may not use this file except in compliance 7 * with the License. 8 * --- 6 unchanged lines hidden (view full) --- 15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16 * If applicable, add the following below this CDDL HEADER, with the 17 * fields enclosed by brackets "[]" replaced with your own identifying 18 * information: Portions Copyright [yyyy] [name of copyright owner] 19 * 20 * CDDL HEADER END 21 */ 22/* | 1/* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the 5 * Common Development and Distribution License, Version 1.0 only 6 * (the "License"). You may not use this file except in compliance 7 * with the License. 8 * --- 6 unchanged lines hidden (view full) --- 15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16 * If applicable, add the following below this CDDL HEADER, with the 17 * fields enclosed by brackets "[]" replaced with your own identifying 18 * information: Portions Copyright [yyyy] [name of copyright owner] 19 * 20 * CDDL HEADER END 21 */ 22/* |
23 * Copyright 2004 Sun Microsystems, Inc. All rights reserved. | 23 * Copyright 2006 Sun Microsystems, Inc. All rights reserved. |
24 * Use is subject to license terms. 25 * 26 * stats.c -- simple stats tracking table module 27 * 28 * this version of stats.c links with eft and implements the 29 * stats using the fmd's stats API. 30 */ 31 --- 42 unchanged lines hidden (view full) --- 74static struct stats * 75stats_new(const char *name, const char *desc, enum stats_type t) 76{ 77 struct stats *ret = MALLOC(sizeof (*ret)); 78 79 bzero(ret, sizeof (*ret)); 80 ret->t = t; 81 | 24 * Use is subject to license terms. 25 * 26 * stats.c -- simple stats tracking table module 27 * 28 * this version of stats.c links with eft and implements the 29 * stats using the fmd's stats API. 30 */ 31 --- 42 unchanged lines hidden (view full) --- 74static struct stats * 75stats_new(const char *name, const char *desc, enum stats_type t) 76{ 77 struct stats *ret = MALLOC(sizeof (*ret)); 78 79 bzero(ret, sizeof (*ret)); 80 ret->t = t; 81 |
82 (void) strlcpy(ret->fmd_stats.fmds_name, name, 83 sizeof (ret->fmd_stats.fmds_name)); | |
84 (void) strlcpy(ret->fmd_stats.fmds_desc, desc, 85 sizeof (ret->fmd_stats.fmds_desc)); 86 | 82 (void) strlcpy(ret->fmd_stats.fmds_desc, desc, 83 sizeof (ret->fmd_stats.fmds_desc)); 84 |
85 /* NULL name means generate a unique name */ 86 if (name == NULL) { 87 static int uniqstat; 88 89 (void) snprintf(ret->fmd_stats.fmds_name, 90 sizeof (ret->fmd_stats.fmds_name), 91 "stat.rules%d", uniqstat++); 92 } else { 93 (void) strlcpy(ret->fmd_stats.fmds_name, name, 94 sizeof (ret->fmd_stats.fmds_name)); 95 } 96 |
|
87 switch (t) { 88 case STATS_COUNTER: 89 ret->fmd_stats.fmds_type = FMD_TYPE_INT32; 90 break; 91 92 case STATS_ELAPSE: 93 ret->fmd_stats.fmds_type = FMD_TYPE_TIME; 94 break; --- 47 unchanged lines hidden (view full) --- 142 if (sp == NULL) 143 return; 144 145 ASSERT(sp->t == STATS_COUNTER); 146 147 sp->fmd_stats.fmds_value.i32 += n; 148} 149 | 97 switch (t) { 98 case STATS_COUNTER: 99 ret->fmd_stats.fmds_type = FMD_TYPE_INT32; 100 break; 101 102 case STATS_ELAPSE: 103 ret->fmd_stats.fmds_type = FMD_TYPE_TIME; 104 break; --- 47 unchanged lines hidden (view full) --- 152 if (sp == NULL) 153 return; 154 155 ASSERT(sp->t == STATS_COUNTER); 156 157 sp->fmd_stats.fmds_value.i32 += n; 158} 159 |
160void 161stats_counter_reset(struct stats *sp) 162{ 163 if (sp == NULL) 164 return; 165 166 ASSERT(sp->t == STATS_COUNTER); 167 168 sp->fmd_stats.fmds_value.i32 = 0; 169} 170 |
|
150int 151stats_counter_value(struct stats *sp) 152{ 153 if (sp == NULL) 154 return (0); 155 156 ASSERT(sp->t == STATS_COUNTER); 157 --- 70 unchanged lines hidden --- | 171int 172stats_counter_value(struct stats *sp) 173{ 174 if (sp == NULL) 175 return (0); 176 177 ASSERT(sp->t == STATS_COUNTER); 178 --- 70 unchanged lines hidden --- |