Print this page
codereview and testing fixes.
6558 kstat: desire type for timestamps
@@ -20,10 +20,11 @@
*/
/*
* Copyright 2006 Sun Microsystems, Inc. All rights reserved.
* Copyright 2013 David Hoeppner. All rights reserved.
* Copyright 2013 Nexenta Systems, Inc. All rights reserved.
+ * Copyright 2016 Garrett D'Amore
*/
#ifndef _STAT_KSTAT_H
#define _STAT_KSTAT_H
@@ -44,12 +45,10 @@
#include <sys/simmstat.h>
#include <sys/sysctrl.h>
#include <sys/fhc.h>
#endif
-#define KSTAT_DATA_HRTIME (KSTAT_DATA_STRING + 1)
-
typedef union ks_value {
char c[16];
int32_t i32;
uint32_t ui32;
struct {
@@ -60,17 +59,22 @@
uint32_t len;
} str;
int64_t i64;
uint64_t ui64;
+ hrtime_t t;
} ks_value_t;
#define SAVE_HRTIME(I, S, N) \
{ \
ks_value_t v; \
v.ui64 = S->N; \
+ if (g_hrtime_fmt == KS_HRFMT_DEFAULT) { \
nvpair_insert(I, #N, &v, KSTAT_DATA_UINT64); \
+ } else { \
+ nvpair_insert(I, #N, &v, KSTAT_DATA_TIME); \
+ } \
}
#define SAVE_INT32(I, S, N) \
{ \
ks_value_t v; \
@@ -113,11 +117,11 @@
#define SAVE_HRTIME_X(I, N, V) \
{ \
ks_value_t v; \
v.ui64 = V; \
- nvpair_insert(I, N, &v, KSTAT_DATA_HRTIME); \
+ nvpair_insert(I, N, &v, KSTAT_DATA_TIME); \
}
#define SAVE_INT32_X(I, N, V) \
{ \
ks_value_t v; \
@@ -168,10 +172,18 @@
#define KS_DFMT "\t%-30s "
#define KS_JFMT "\t\t\"%s\": "
#define KS_PFMT "%s:%d:%s:%s"
+#define KS_HRFMT_DEFAULT 'o'
+#define KS_HRFMT_BOOT 'b'
+#define KS_HRFMT_UNIX 'u'
+#define KS_HRFMT_DATE 'd'
+#define KS_HRFMT_NANO 'n'
+#define KS_HRFMT_ISO 'I'
+#define KS_HRFMT_ZISO 'Z'
+
typedef struct ks_instance {
list_node_t ks_next;
char ks_name[KSTAT_STRLEN];
char ks_module[KSTAT_STRLEN];
char ks_class[KSTAT_STRLEN];