i965: Move env_var_as_boolean to intel_debug.c.
I need to use this in brw_vec4.cpp, so it can't be static anymore. Signed-off-by: Kenneth Graunke <kenneth@whitecape.org> Reviewed-by: Matt Turner <mattst88@gmail.com>
This commit is contained in:
@@ -106,3 +106,28 @@ brw_process_intel_debug_variable(struct brw_context *brw)
|
||||
if (INTEL_DEBUG & DEBUG_AUB)
|
||||
drm_intel_bufmgr_gem_set_aub_dump(brw->bufmgr, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads an environment variable and interprets its value as a boolean.
|
||||
*
|
||||
* Recognizes 0/false/no and 1/true/yes. Other values result in the default value.
|
||||
*/
|
||||
bool
|
||||
brw_env_var_as_boolean(const char *var_name, bool default_value)
|
||||
{
|
||||
const char *str = getenv(var_name);
|
||||
if (str == NULL)
|
||||
return default_value;
|
||||
|
||||
if (strcmp(str, "1") == 0 ||
|
||||
strcasecmp(str, "true") == 0 ||
|
||||
strcasecmp(str, "yes") == 0) {
|
||||
return true;
|
||||
} else if (strcmp(str, "0") == 0 ||
|
||||
strcasecmp(str, "false") == 0 ||
|
||||
strcasecmp(str, "no") == 0) {
|
||||
return false;
|
||||
} else {
|
||||
return default_value;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user