util: Add function debug_get_option_cached os_get_option_cached

This is used to fixes DEBUG_GET_ONCE_*_OPTION macros latter

Signed-off-by: Yonggang Luo <luoyonggang@gmail.com>
Acked-by: Marek Olšák <marek.olsak@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/19554>
This commit is contained in:
Yonggang Luo
2022-11-06 04:26:38 +08:00
committed by Marge Bot
parent 397a5c1b2e
commit cdad035cfd
4 changed files with 77 additions and 1 deletions
+17
View File
@@ -166,6 +166,23 @@ debug_get_option(const char *name, const char *dfault)
}
const char *
debug_get_option_cached(const char *name, const char *dfault)
{
const char *result;
result = os_get_option_cached(name);
if (!result)
result = dfault;
if (debug_get_option_should_print())
debug_printf("%s: %s = %s\n", __FUNCTION__, name,
result ? result : "(null)");
return result;
}
/**
* Reads an environment variable and interprets its value as a boolean.
* Recognizes 0/n/no/f/false case insensitive as false.