diff --git a/src/intel/common/intel_measure.c b/src/intel/common/intel_measure.c index 7b7245b3497..7315f7e8d25 100644 --- a/src/intel/common/intel_measure.c +++ b/src/intel/common/intel_measure.c @@ -57,7 +57,7 @@ void intel_measure_init(struct intel_measure_device *device) { static bool once = false; - const char *env = getenv("INTEL_MEASURE"); + const char *env = os_get_option("INTEL_MEASURE"); if (unlikely(!once)) { once = true; memset(&config, 0, sizeof(struct intel_measure_config)); diff --git a/src/intel/compiler/elk/elk_eu.c b/src/intel/compiler/elk/elk_eu.c index 9bbd6d15813..6f63c68cda5 100644 --- a/src/intel/compiler/elk/elk_eu.c +++ b/src/intel/compiler/elk/elk_eu.c @@ -409,7 +409,7 @@ void elk_dump_shader_bin(void *assembly, int start_offset, int end_offset, bool elk_try_override_assembly(struct elk_codegen *p, int start_offset, const char *identifier) { - const char *read_path = getenv("INTEL_SHADER_ASM_READ_PATH"); + const char *read_path = os_get_option("INTEL_SHADER_ASM_READ_PATH"); if (!read_path) { return false; } diff --git a/src/intel/compiler/elk/elk_test_eu_validate.cpp b/src/intel/compiler/elk/elk_test_eu_validate.cpp index 33ae6938182..d1bea26b44b 100644 --- a/src/intel/compiler/elk/elk_test_eu_validate.cpp +++ b/src/intel/compiler/elk/elk_test_eu_validate.cpp @@ -94,7 +94,7 @@ INSTANTIATE_TEST_SUITE_P( static bool validate(struct elk_codegen *p) { - const bool print = getenv("TEST_DEBUG"); + const bool print = os_get_option("TEST_DEBUG"); struct elk_disasm_info *disasm = elk_disasm_initialize(p->isa, NULL); if (print) { diff --git a/src/intel/compiler/elk/elk_test_fs_cmod_propagation.cpp b/src/intel/compiler/elk/elk_test_fs_cmod_propagation.cpp index fc1bc24ee25..453128d43e9 100644 --- a/src/intel/compiler/elk/elk_test_fs_cmod_propagation.cpp +++ b/src/intel/compiler/elk/elk_test_fs_cmod_propagation.cpp @@ -110,7 +110,7 @@ instruction(elk_bblock_t *block, int num) static bool cmod_propagation(elk_fs_visitor *v) { - const bool print = getenv("TEST_DEBUG"); + const bool print = os_get_option("TEST_DEBUG"); if (print) { fprintf(stderr, "= Before =\n"); diff --git a/src/intel/compiler/elk/elk_test_fs_combine_constants.cpp b/src/intel/compiler/elk/elk_test_fs_combine_constants.cpp index 8b6ce625812..f4f79ffd14f 100644 --- a/src/intel/compiler/elk/elk_test_fs_combine_constants.cpp +++ b/src/intel/compiler/elk/elk_test_fs_combine_constants.cpp @@ -48,7 +48,7 @@ struct FSCombineConstantsTest : public ::testing::Test { elk_fs_visitor *shader; bool opt_combine_constants(elk_fs_visitor *s) { - const bool print = getenv("TEST_DEBUG"); + const bool print = os_get_option("TEST_DEBUG"); if (print) { fprintf(stderr, "= Before =\n"); diff --git a/src/intel/compiler/elk/elk_test_fs_copy_propagation.cpp b/src/intel/compiler/elk/elk_test_fs_copy_propagation.cpp index cd2429882a3..b7762359f7f 100644 --- a/src/intel/compiler/elk/elk_test_fs_copy_propagation.cpp +++ b/src/intel/compiler/elk/elk_test_fs_copy_propagation.cpp @@ -99,7 +99,7 @@ instruction(elk_bblock_t *block, int num) static bool copy_propagation(elk_fs_visitor *v) { - const bool print = getenv("TEST_DEBUG"); + const bool print = os_get_option("TEST_DEBUG"); if (print) { fprintf(stderr, "= Before =\n"); diff --git a/src/intel/compiler/elk/elk_test_predicated_break.cpp b/src/intel/compiler/elk/elk_test_predicated_break.cpp index 5d038999c81..5f2a3de4c6c 100644 --- a/src/intel/compiler/elk/elk_test_predicated_break.cpp +++ b/src/intel/compiler/elk/elk_test_predicated_break.cpp @@ -32,7 +32,7 @@ public: void PredicatedBreakTest::SetUp() { - debug = getenv("TEST_DEBUG"); + debug = os_get_option("TEST_DEBUG"); mem_ctx = ralloc_context(NULL); @@ -69,7 +69,7 @@ PredicatedBreakTest::TearDown() bool PredicatedBreakTest::elk_opt_predicated_break(elk_fs_visitor *s) { - const bool print = getenv("TEST_DEBUG"); + const bool print = os_get_option("TEST_DEBUG"); if (print) { fprintf(stderr, "= Before =\n"); diff --git a/src/intel/compiler/elk/elk_test_vec4_cmod_propagation.cpp b/src/intel/compiler/elk/elk_test_vec4_cmod_propagation.cpp index 7d555ea74eb..f21a9dd2cc6 100644 --- a/src/intel/compiler/elk/elk_test_vec4_cmod_propagation.cpp +++ b/src/intel/compiler/elk/elk_test_vec4_cmod_propagation.cpp @@ -137,7 +137,7 @@ instruction(elk_bblock_t *block, int num) static bool cmod_propagation(vec4_visitor *v) { - const bool print = getenv("TEST_DEBUG"); + const bool print = os_get_option("TEST_DEBUG"); if (print) { fprintf(stderr, "= Before =\n"); diff --git a/src/intel/compiler/elk/elk_test_vec4_copy_propagation.cpp b/src/intel/compiler/elk/elk_test_vec4_copy_propagation.cpp index 2fa3e12282f..652fd4b88cc 100644 --- a/src/intel/compiler/elk/elk_test_vec4_copy_propagation.cpp +++ b/src/intel/compiler/elk/elk_test_vec4_copy_propagation.cpp @@ -118,7 +118,7 @@ void copy_propagation_vec4_test::TearDown() static void copy_propagation(vec4_visitor *v) { - const bool print = getenv("TEST_DEBUG"); + const bool print = os_get_option("TEST_DEBUG"); if (print) { fprintf(stderr, "instructions before:\n"); diff --git a/src/intel/compiler/elk/elk_test_vec4_dead_code_eliminate.cpp b/src/intel/compiler/elk/elk_test_vec4_dead_code_eliminate.cpp index 7f07e1aca09..0e431b44bd9 100644 --- a/src/intel/compiler/elk/elk_test_vec4_dead_code_eliminate.cpp +++ b/src/intel/compiler/elk/elk_test_vec4_dead_code_eliminate.cpp @@ -117,7 +117,7 @@ void dead_code_eliminate_vec4_test::TearDown() static void dead_code_eliminate(vec4_visitor *v) { - const bool print = getenv("TEST_DEBUG"); + const bool print = os_get_option("TEST_DEBUG"); if (print) { fprintf(stderr, "instructions before:\n"); diff --git a/src/intel/compiler/elk/elk_test_vec4_register_coalesce.cpp b/src/intel/compiler/elk/elk_test_vec4_register_coalesce.cpp index 25f03683e55..d6cb8e4707e 100644 --- a/src/intel/compiler/elk/elk_test_vec4_register_coalesce.cpp +++ b/src/intel/compiler/elk/elk_test_vec4_register_coalesce.cpp @@ -121,7 +121,7 @@ void register_coalesce_vec4_test::TearDown() static void _register_coalesce(vec4_visitor *v, const char *func) { - const bool print = getenv("TEST_DEBUG"); + const bool print = os_get_option("TEST_DEBUG"); if (print) { printf("%s: instructions before:\n", func); diff --git a/src/intel/compiler/test_eu_validate.cpp b/src/intel/compiler/test_eu_validate.cpp index 4f84a3906e0..51289a0e131 100644 --- a/src/intel/compiler/test_eu_validate.cpp +++ b/src/intel/compiler/test_eu_validate.cpp @@ -107,7 +107,7 @@ INSTANTIATE_TEST_SUITE_P( static bool validate(struct brw_codegen *p, char **error = nullptr) { - const bool print = getenv("TEST_DEBUG"); + const bool print = os_get_option("TEST_DEBUG"); struct disasm_info *disasm = disasm_initialize(p->isa, NULL); struct inst_group *group = disasm_new_inst_group(disasm, 0); diff --git a/src/intel/compiler/test_helpers.h b/src/intel/compiler/test_helpers.h index c1e4beaaa54..25e4155371d 100644 --- a/src/intel/compiler/test_helpers.h +++ b/src/intel/compiler/test_helpers.h @@ -43,7 +43,7 @@ EXPECT_PROGRESS_RESULT(bool should_progress, PASS pass, brw_shader *s) brw_validate(*s); - if (progress != should_progress || getenv("TEST_DEBUG")) { + if (progress != should_progress || os_get_option("TEST_DEBUG")) { fprintf(stderr, "= Before =\n" "%s\n" "\n" diff --git a/src/intel/decoder/intel_batch_decoder.c b/src/intel/decoder/intel_batch_decoder.c index e0b14fa8ea7..4754a926f7a 100644 --- a/src/intel/decoder/intel_batch_decoder.c +++ b/src/intel/decoder/intel_batch_decoder.c @@ -61,7 +61,7 @@ intel_batch_decode_ctx_init(struct intel_batch_decode_ctx *ctx, ctx->get_state_size = get_state_size; ctx->user_data = user_data; ctx->fp = fp; - ctx->flags = parse_enable_string(getenv("INTEL_DECODE"), flags, debug_control); + ctx->flags = parse_enable_string(os_get_option("INTEL_DECODE"), flags, debug_control); ctx->max_vbo_decoded_lines = -1; /* No limit! */ ctx->engine = INTEL_ENGINE_CLASS_RENDER; @@ -75,7 +75,7 @@ intel_batch_decode_ctx_init(struct intel_batch_decode_ctx *ctx, ctx->stats = _mesa_hash_table_create(NULL, _mesa_hash_string, _mesa_key_string_equal); - const char *filters = getenv("INTEL_DECODE_FILTERS"); + const char *filters = os_get_option("INTEL_DECODE_FILTERS"); if (filters != NULL) { ctx->filters = _mesa_hash_table_create(NULL, _mesa_hash_string, _mesa_key_string_equal); diff --git a/src/intel/dev/intel_debug.c b/src/intel/dev/intel_debug.c index 6c520419a8d..6fc7b3d1f9d 100644 --- a/src/intel/dev/intel_debug.c +++ b/src/intel/dev/intel_debug.c @@ -254,9 +254,9 @@ static void process_intel_debug_variable_once(void) { BITSET_ZERO(intel_debug); - parse_debug_bitset(getenv("INTEL_DEBUG"), debug_control); + parse_debug_bitset(os_get_option("INTEL_DEBUG"), debug_control); - intel_simd = parse_debug_string(getenv("INTEL_SIMD_DEBUG"), simd_control); + intel_simd = parse_debug_string(os_get_option("INTEL_SIMD_DEBUG"), simd_control); intel_debug_batch_frame_start = debug_get_num_option("INTEL_DEBUG_BATCH_FRAME_START", 0); intel_debug_batch_frame_stop = diff --git a/src/intel/dev/intel_device_info.c b/src/intel/dev/intel_device_info.c index 5105697d35c..57cf6333113 100644 --- a/src/intel/dev/intel_device_info.c +++ b/src/intel/dev/intel_device_info.c @@ -1441,7 +1441,7 @@ scan_for_force_probe(int pci_id, bool *force_on, bool *force_off) *force_on = false; *force_off = false; - const char *env = getenv("INTEL_FORCE_PROBE"); + const char *env = os_get_option("INTEL_FORCE_PROBE"); if (env == NULL) return; @@ -1860,7 +1860,7 @@ intel_device_info_update_after_hwconfig(struct intel_device_info *devinfo) bool intel_get_device_info_from_fd(int fd, struct intel_device_info *devinfo, int min_ver, int max_ver) { - if (NULL != getenv("INTEL_STUB_GPU_JSON")) { + if (NULL != os_get_option("INTEL_STUB_GPU_JSON")) { /* This call will succeed when shim-drm has been initialized with a * serialized intel_device_info structure. */ diff --git a/src/intel/ds/intel_pps_driver.cc b/src/intel/ds/intel_pps_driver.cc index 758ca223060..54aaae9b172 100644 --- a/src/intel/ds/intel_pps_driver.cc +++ b/src/intel/ds/intel_pps_driver.cc @@ -77,7 +77,7 @@ bool IntelDriver::init_perfcnt() perf = std::make_unique(drm_device.fd); - const char *metric_set_name = getenv("INTEL_PERFETTO_METRIC_SET"); + const char *metric_set_name = os_get_option("INTEL_PERFETTO_METRIC_SET"); struct intel_perf_query_info *default_query = nullptr; selected_query = nullptr; diff --git a/src/intel/isl/isl_drm.c b/src/intel/isl/isl_drm.c index a2524f919e4..d0161636031 100644 --- a/src/intel/isl/isl_drm.c +++ b/src/intel/isl/isl_drm.c @@ -208,7 +208,7 @@ isl_drm_modifier_get_score(const struct intel_device_info *devinfo, * and don't want to provide a default value either, so we don't * use debug_get_num_option() here. */ - const char *mod_str = getenv("INTEL_MODIFIER_OVERRIDE"); + const char *mod_str = os_get_option("INTEL_MODIFIER_OVERRIDE"); if (mod_str != NULL) { return modifier == strtoul(mod_str, NULL, 0); } diff --git a/src/intel/mda/mda.c b/src/intel/mda/mda.c index 6bec2f78180..5a6446a755c 100644 --- a/src/intel/mda/mda.c +++ b/src/intel/mda/mda.c @@ -14,6 +14,7 @@ #include #include "util/os_file.h" +#include "util/os_misc.h" #include "util/ralloc.h" #include "util/u_dynarray.h" @@ -126,7 +127,7 @@ diff(context *ctx, slice a, slice b) fclose(file_a.f); fclose(file_b.f); - const char *diff_cmd = getenv("MDA_DIFF_COMMAND"); + const char *diff_cmd = os_get_option("MDA_DIFF_COMMAND"); if (!diff_cmd) { if (ctx->diff.mode == DIFF_UNIFIED) { diff_cmd = ralloc_asprintf(mem_ctx, "git diff --no-index --color-words -U%d -- %%s %%s | tail -n +5", ctx->diff.param); @@ -1092,10 +1093,10 @@ static pid_t setup_pager() { if (!isatty(STDOUT_FILENO) || - getenv("NO_PAGER")) + os_get_option("NO_PAGER")) return 0; - const char *term = getenv("TERM"); + const char *term = os_get_option("TERM"); if (!term || !strcmp(term, "dumb")) return 0; @@ -1119,7 +1120,7 @@ setup_pager() dup2(pipefd[0], STDIN_FILENO); close(pipefd[0]); - const char *pager = getenv("PAGER"); + const char *pager = os_get_option("PAGER"); if (pager && *pager) execlp(pager, pager, NULL); diff --git a/src/intel/tools/intel_dump_gpu.c b/src/intel/tools/intel_dump_gpu.c index 46cf4467598..a4f6f75c90a 100644 --- a/src/intel/tools/intel_dump_gpu.c +++ b/src/intel/tools/intel_dump_gpu.c @@ -428,7 +428,7 @@ maybe_init(int fd) initialized = true; - const char *config_path = getenv("INTEL_DUMP_GPU_CONFIG"); + const char *config_path = os_get_option("INTEL_DUMP_GPU_CONFIG"); fail_if(config_path == NULL, "INTEL_DUMP_GPU_CONFIG is not set\n"); config = fopen(config_path, "r"); diff --git a/src/intel/tools/intel_noop_drm_shim.c b/src/intel/tools/intel_noop_drm_shim.c index 318a648579d..7ccc05f87ad 100644 --- a/src/intel/tools/intel_noop_drm_shim.c +++ b/src/intel/tools/intel_noop_drm_shim.c @@ -557,20 +557,20 @@ void drm_shim_driver_init(void) { i915.device_id = 0; - const char *json_dev_str = getenv("INTEL_STUB_GPU_JSON"); + const char *json_dev_str = os_get_option("INTEL_STUB_GPU_JSON"); if (json_dev_str != NULL) { if (!intel_device_info_from_json(json_dev_str, &i915.devinfo)) return; i915.device_id = i915.devinfo.pci_device_id; i915_device_from_json = true; } else { - const char *device_id_str = getenv("INTEL_STUB_GPU_DEVICE_ID"); + const char *device_id_str = os_get_option("INTEL_STUB_GPU_DEVICE_ID"); if (device_id_str != NULL) { /* Set as 0 if strtoul fails */ i915.device_id = strtoul(device_id_str, NULL, 16); } if (i915.device_id == 0) { - const char *user_platform = getenv("INTEL_STUB_GPU_PLATFORM"); + const char *user_platform = os_get_option("INTEL_STUB_GPU_PLATFORM"); /* Use SKL if nothing is specified. */ i915.device_id = intel_device_name_to_pci_device_id(user_platform ?: "skl"); }