2017-12-21 07:45:38 +08:00
|
|
|
/*
|
2022-09-09 21:19:21 +08:00
|
|
|
* Copyright (C) 2020-2022 Intel Corporation
|
2017-12-21 07:45:38 +08:00
|
|
|
*
|
2018-09-18 15:11:08 +08:00
|
|
|
* SPDX-License-Identifier: MIT
|
2017-12-21 07:45:38 +08:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2020-06-08 22:19:52 +08:00
|
|
|
#include "shared/source/os_interface/debug_env_reader.h"
|
2017-12-21 07:45:38 +08:00
|
|
|
|
2020-06-08 22:19:52 +08:00
|
|
|
#include "shared/source/utilities/io_functions.h"
|
2017-12-21 07:45:38 +08:00
|
|
|
|
2020-06-08 22:19:52 +08:00
|
|
|
namespace NEO {
|
2017-12-21 07:45:38 +08:00
|
|
|
|
2018-10-10 22:02:19 +08:00
|
|
|
const char *EnvironmentVariableReader::appSpecificLocation(const std::string &name) {
|
|
|
|
return name.c_str();
|
|
|
|
}
|
|
|
|
|
2017-12-21 07:45:38 +08:00
|
|
|
bool EnvironmentVariableReader::getSetting(const char *settingName, bool defaultValue) {
|
2020-03-27 14:47:16 +08:00
|
|
|
return getSetting(settingName, static_cast<int64_t>(defaultValue)) ? true : false;
|
2017-12-21 07:45:38 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
int32_t EnvironmentVariableReader::getSetting(const char *settingName, int32_t defaultValue) {
|
2020-03-27 14:47:16 +08:00
|
|
|
return static_cast<int32_t>(getSetting(settingName, static_cast<int64_t>(defaultValue)));
|
|
|
|
}
|
|
|
|
|
|
|
|
int64_t EnvironmentVariableReader::getSetting(const char *settingName, int64_t defaultValue) {
|
|
|
|
int64_t value = defaultValue;
|
2017-12-21 07:45:38 +08:00
|
|
|
char *envValue;
|
|
|
|
|
2020-06-08 22:19:52 +08:00
|
|
|
envValue = IoFunctions::getenvPtr(settingName);
|
2017-12-21 07:45:38 +08:00
|
|
|
if (envValue) {
|
2022-09-09 21:19:21 +08:00
|
|
|
value = atoll(envValue);
|
2017-12-21 07:45:38 +08:00
|
|
|
}
|
|
|
|
return value;
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string EnvironmentVariableReader::getSetting(const char *settingName, const std::string &value) {
|
|
|
|
char *envValue;
|
|
|
|
std::string keyValue;
|
|
|
|
keyValue.assign(value);
|
|
|
|
|
2020-06-08 22:19:52 +08:00
|
|
|
envValue = IoFunctions::getenvPtr(settingName);
|
2017-12-21 07:45:38 +08:00
|
|
|
if (envValue) {
|
|
|
|
keyValue.assign(envValue);
|
|
|
|
}
|
|
|
|
return keyValue;
|
|
|
|
}
|
2019-03-26 18:59:46 +08:00
|
|
|
} // namespace NEO
|