summaryrefslogtreecommitdiffstats
path: root/sys
diff options
context:
space:
mode:
authordwmalone <dwmalone@FreeBSD.org>2007-06-04 18:14:28 +0000
committerdwmalone <dwmalone@FreeBSD.org>2007-06-04 18:14:28 +0000
commit360dc5b21c582598a9aaf5b3cd6f3832b847ef41 (patch)
treed9ad78a6261e23cb6ff352560e4bd30042263c5c /sys
parent79a4f2f433b1fe77a78af77b36bf1611ecc780b7 (diff)
downloadFreeBSD-src-360dc5b21c582598a9aaf5b3cd6f3832b847ef41.zip
FreeBSD-src-360dc5b21c582598a9aaf5b3cd6f3832b847ef41.tar.gz
Add a function for exporting 64 bit types.
Diffstat (limited to 'sys')
-rw-r--r--sys/kern/kern_sysctl.c25
-rw-r--r--sys/sys/sysctl.h1
2 files changed, 26 insertions, 0 deletions
diff --git a/sys/kern/kern_sysctl.c b/sys/kern/kern_sysctl.c
index 666a541..6100f41 100644
--- a/sys/kern/kern_sysctl.c
+++ b/sys/kern/kern_sysctl.c
@@ -892,6 +892,31 @@ sysctl_handle_long(SYSCTL_HANDLER_ARGS)
}
/*
+ * Handle a 64 bit int, signed or unsigned. arg1 points to it.
+ */
+
+int
+sysctl_handle_quad(SYSCTL_HANDLER_ARGS)
+{
+ int error = 0;
+ uint64_t tmpout;
+
+ /*
+ * Attempt to get a coherent snapshot by making a copy of the data.
+ */
+ if (!arg1)
+ return (EINVAL);
+ tmpout = *(uint64_t *)arg1;
+ error = SYSCTL_OUT(req, &tmpout, sizeof(uint64_t));
+
+ if (error || !req->newptr)
+ return (error);
+
+ error = SYSCTL_IN(req, arg1, sizeof(uint64_t));
+ return (error);
+}
+
+/*
* Handle our generic '\0' terminated 'C' string.
* Two cases:
* a variable string: point arg1 at it, arg2 is max length.
diff --git a/sys/sys/sysctl.h b/sys/sys/sysctl.h
index 87dad4e..5d07d6b 100644
--- a/sys/sys/sysctl.h
+++ b/sys/sys/sysctl.h
@@ -170,6 +170,7 @@ struct sysctl_oid {
int sysctl_handle_int(SYSCTL_HANDLER_ARGS);
int sysctl_msec_to_ticks(SYSCTL_HANDLER_ARGS);
int sysctl_handle_long(SYSCTL_HANDLER_ARGS);
+int sysctl_handle_quad(SYSCTL_HANDLER_ARGS);
int sysctl_handle_intptr(SYSCTL_HANDLER_ARGS);
int sysctl_handle_string(SYSCTL_HANDLER_ARGS);
int sysctl_handle_opaque(SYSCTL_HANDLER_ARGS);
OpenPOWER on IntegriCloud