Create wrappers for uint64_t and int64_t for the tunables. While not
strictly necessary, it is more convenient.
This commit is contained in:
parent
abea2d5a7e
commit
15be49f5a1
@ -544,6 +544,36 @@ getenv_uint(const char *name, unsigned int *data)
|
||||
return (rval);
|
||||
}
|
||||
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
@ -649,6 +679,22 @@ tunable_ulong_init(void *data)
|
||||
TUNABLE_ULONG_FETCH(d->path, d->var);
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
|
@ -316,6 +316,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
|
||||
*/
|
||||
|
@ -322,6 +322,8 @@ int getenv_uint(const char *name, unsigned int *data);
|
||||
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);
|
||||
|
Loading…
Reference in New Issue
Block a user