summaryrefslogtreecommitdiff
path: root/usr/src/cmd/stat/common/acquire.c
diff options
context:
space:
mode:
Diffstat (limited to 'usr/src/cmd/stat/common/acquire.c')
-rw-r--r--usr/src/cmd/stat/common/acquire.c68
1 files changed, 63 insertions, 5 deletions
diff --git a/usr/src/cmd/stat/common/acquire.c b/usr/src/cmd/stat/common/acquire.c
index e3c911283c..cf17de7c3f 100644
--- a/usr/src/cmd/stat/common/acquire.c
+++ b/usr/src/cmd/stat/common/acquire.c
@@ -2,9 +2,8 @@
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* or http://www.opensolaris.org/os/licensing.
@@ -20,7 +19,7 @@
* CDDL HEADER END
*/
/*
- * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
@@ -34,6 +33,7 @@
#include <unistd.h>
#include <strings.h>
#include <errno.h>
+#include <limits.h>
#include <poll.h>
#define ARRAY_SIZE(a) (sizeof (a) / sizeof (*a))
@@ -345,7 +345,8 @@ retry:
if (!err && (types & SNAP_PSETS))
err = acquire_psets(ss);
- if (!err && (types & (SNAP_IODEVS | SNAP_CONTROLLERS | SNAP_IOPATHS)))
+ if (!err && (types & (SNAP_IODEVS | SNAP_CONTROLLERS |
+ SNAP_IOPATHS_LI | SNAP_IOPATHS_LTI)))
err = acquire_iodevs(ss, kc, iodev_filter);
if (!err && (types & SNAP_SYSTEM))
@@ -538,3 +539,60 @@ nr_active_cpus(struct snapshot *ss)
return (count);
}
+
+/*
+ * Return the number of ticks delta between two hrtime_t
+ * values. Attempt to cater for various kinds of overflow
+ * in hrtime_t - no matter how improbable.
+ */
+uint64_t
+hrtime_delta(hrtime_t old, hrtime_t new)
+{
+ uint64_t del;
+
+ if ((new >= old) && (old >= 0L))
+ return (new - old);
+ else {
+ /*
+ * We've overflowed the positive portion of an
+ * hrtime_t.
+ */
+ if (new < 0L) {
+ /*
+ * The new value is negative. Handle the
+ * case where the old value is positive or
+ * negative.
+ */
+ uint64_t n1;
+ uint64_t o1;
+
+ n1 = -new;
+ if (old > 0L)
+ return (n1 - old);
+ else {
+ o1 = -old;
+ del = n1 - o1;
+ return (del);
+ }
+ } else {
+ /*
+ * Either we've just gone from being negative
+ * to positive *or* the last entry was positive
+ * and the new entry is also positive but *less*
+ * than the old entry. This implies we waited
+ * quite a few days on a very fast system between
+ * iostat displays.
+ */
+ if (old < 0L) {
+ uint64_t o2;
+
+ o2 = -old;
+ del = UINT64_MAX - o2;
+ } else {
+ del = UINT64_MAX - old;
+ }
+ del += new;
+ return (del);
+ }
+ }
+}