svn commit: r298025 - in head/sys: kern sys
Warner Losh
imp at FreeBSD.org
Fri Apr 15 03:09:57 UTC 2016
Author: imp
Date: Fri Apr 15 03:09:55 2016
New Revision: 298025
URL: https://svnweb.freebsd.org/changeset/base/298025
Log:
Create wrappers for uint64_t and int64_t for the tunables. While not
strictly necessary, it is more convenient.
Modified:
head/sys/kern/kern_environment.c
head/sys/sys/kernel.h
head/sys/sys/systm.h
Modified: head/sys/kern/kern_environment.c
==============================================================================
--- head/sys/kern/kern_environment.c Fri Apr 15 02:53:52 2016 (r298024)
+++ head/sys/kern/kern_environment.c Fri Apr 15 03:09:55 2016 (r298025)
@@ -545,6 +545,36 @@ getenv_uint(const char *name, unsigned i
}
/*
+ * Return an int64_t value from an environment variable.
+ */
+int
+getenv_int64(const char *name, int64_t *data)
+{
+ quad_t tmp;
+ int64_t rval;
+
+ rval = getenv_quad(name, &tmp);
+ if (rval)
+ *data = (int64_t) tmp;
+ return (rval);
+}
+
+/*
+ * Return an uint64_t value from an environment variable.
+ */
+int
+getenv_uint64(const char *name, uint64_t *data)
+{
+ quad_t tmp;
+ uint64_t rval;
+
+ rval = getenv_quad(name, &tmp);
+ if (rval)
+ *data = (uint64_t) tmp;
+ return (rval);
+}
+
+/*
* Return a long value from an environment variable.
*/
int
@@ -650,6 +680,22 @@ tunable_ulong_init(void *data)
}
void
+tunable_int64_init(void *data)
+{
+ struct tunable_int64 *d = (struct tunable_int64 *)data;
+
+ TUNABLE_INT64_FETCH(d->path, d->var);
+}
+
+void
+tunable_uint64_init(void *data)
+{
+ struct tunable_uint64 *d = (struct tunable_uint64 *)data;
+
+ TUNABLE_UINT64_FETCH(d->path, d->var);
+}
+
+void
tunable_quad_init(void *data)
{
struct tunable_quad *d = (struct tunable_quad *)data;
Modified: head/sys/sys/kernel.h
==============================================================================
--- head/sys/sys/kernel.h Fri Apr 15 02:53:52 2016 (r298024)
+++ head/sys/sys/kernel.h Fri Apr 15 03:09:55 2016 (r298025)
@@ -317,6 +317,44 @@ struct tunable_ulong {
#define TUNABLE_ULONG_FETCH(path, var) getenv_ulong((path), (var))
/*
+ * int64_t
+ */
+extern void tunable_int64_init(void *);
+struct tunable_int64 {
+ const char *path;
+ int64_t *var;
+};
+#define TUNABLE_INT64(path, var) \
+ static struct tunable_int64 __CONCAT(__tunable_int64_, __LINE__) = { \
+ (path), \
+ (var), \
+ }; \
+ SYSINIT(__CONCAT(__Tunable_init_, __LINE__), \
+ SI_SUB_TUNABLES, SI_ORDER_MIDDLE, tunable_int64_init, \
+ &__CONCAT(__tunable_int64_, __LINE__))
+
+#define TUNABLE_INT64_FETCH(path, var) getenv_int64((path), (var))
+
+/*
+ * uint64_t
+ */
+extern void tunable_uint64_init(void *);
+struct tunable_uint64 {
+ const char *path;
+ uint64_t *var;
+};
+#define TUNABLE_UINT64(path, var) \
+ static struct tunable_ulong __CONCAT(__tunable_uint64_, __LINE__) = { \
+ (path), \
+ (var), \
+ }; \
+ SYSINIT(__CONCAT(__Tunable_init_, __LINE__), \
+ SI_SUB_TUNABLES, SI_ORDER_MIDDLE, tunable_uint64_init, \
+ &__CONCAT(__tunable_uint64_, __LINE__))
+
+#define TUNABLE_UINT64_FETCH(path, var) getenv_uint64((path), (var))
+
+/*
* quad
*/
extern void tunable_quad_init(void *);
Modified: head/sys/sys/systm.h
==============================================================================
--- head/sys/sys/systm.h Fri Apr 15 02:53:52 2016 (r298024)
+++ head/sys/sys/systm.h Fri Apr 15 03:09:55 2016 (r298025)
@@ -322,6 +322,8 @@ int getenv_uint(const char *name, unsign
int getenv_long(const char *name, long *data);
int getenv_ulong(const char *name, unsigned long *data);
int getenv_string(const char *name, char *data, int size);
+int getenv_int64(const char *name, int64_t *data);
+int getenv_uint64(const char *name, uint64_t *data);
int getenv_quad(const char *name, quad_t *data);
int kern_setenv(const char *name, const char *value);
int kern_unsetenv(const char *name);
More information about the svn-src-head
mailing list