1
0
mirror of https://sourceware.org/git/glibc.git synced 2025-08-10 05:03:06 +03:00

elf: Add a way to check if tunable is set (BZ 27069)

The patch adds two new macros, TUNABLE_GET_DEFAULT and TUNABLE_IS_INITIALIZED,
here the former get the default value with a signature similar to
TUNABLE_GET, while the later returns whether the tunable was set by
the environment variable.

Checked on x86_64-linux-gnu.
Reviewed-by: DJ Delorie <dj@redhat.com>
Tested-by: Zhangfei Gao <zhangfei.gao@linaro.org>
This commit is contained in:
Adhemerval Zanella
2023-11-23 14:29:14 -03:00
parent 9469261cf1
commit a4c3f5f46e
6 changed files with 73 additions and 2 deletions

View File

@@ -145,6 +145,13 @@ tunable_initialize (tunable_t *cur, const char *strval)
do_tunable_update_val (cur, &val, NULL, NULL);
}
bool
__tunable_is_initialized (tunable_id_t id)
{
return tunable_list[id].initialized;
}
rtld_hidden_def (__tunable_is_initialized)
void
__tunable_set_val (tunable_id_t id, tunable_val_t *valp, tunable_num_t *minp,
tunable_num_t *maxp)
@@ -333,6 +340,39 @@ __tunables_print (void)
}
}
void
__tunable_get_default (tunable_id_t id, void *valp)
{
tunable_t *cur = &tunable_list[id];
switch (cur->type.type_code)
{
case TUNABLE_TYPE_UINT_64:
{
*((uint64_t *) valp) = (uint64_t) cur->def.numval;
break;
}
case TUNABLE_TYPE_INT_32:
{
*((int32_t *) valp) = (int32_t) cur->def.numval;
break;
}
case TUNABLE_TYPE_SIZE_T:
{
*((size_t *) valp) = (size_t) cur->def.numval;
break;
}
case TUNABLE_TYPE_STRING:
{
*((const char **)valp) = cur->def.strval;
break;
}
default:
__builtin_unreachable ();
}
}
rtld_hidden_def (__tunable_get_default)
/* Set the tunable value. This is called by the module that the tunable exists
in. */
void