So I can drop env2u() helper from freedreno_util.h and get rid of one
small ir3 dependency on gallium/freedreno
Signed-off-by: Rob Clark <robdclark@gmail.com>
* IN THE SOFTWARE.
*/
+#include <errno.h>
#include <string.h>
#include "main/macros.h"
#include "debug.h"
return default_value;
}
}
+
+/**
+ * Reads an environment variable and interprets its value as a unsigned.
+ */
+unsigned
+env_var_as_unsigned(const char *var_name, unsigned default_value)
+{
+ char *str = getenv(var_name);
+ if (str) {
+ char *end;
+ unsigned long result;
+
+ errno = 0;
+ result = strtoul(str, &end, 0);
+ if (errno == 0 && end != str && *end == '\0')
+ return result;
+ }
+ return default_value;
+}
const struct debug_control *control);
bool
env_var_as_boolean(const char *var_name, bool default_value);
+unsigned
+env_var_as_unsigned(const char *var_name, unsigned default_value);
#ifdef __cplusplus
} /* extern C */