[Mesa-dev] [PATCH v2 04/19] swr: [rasterizer core] utility function for getenv

Rowley, Timothy O timothy.o.rowley at intel.com
Tue May 17 23:53:38 UTC 2016


This utility function is used by code not in the open source view of the swr rasterizer.

Microsoft’s documentation for getenv seems to suggest that their implementation has limitations:  https://msdn.microsoft.com/en-us/library/tehxacec.aspx (under “Remarks”).

-Tim

> On May 17, 2016, at 6:08 PM, Ian Romanick <idr at freedesktop.org> wrote:
> 
> This doesn't appear to be used anywhere.  Maybe I missed it in some late
> patch?  As far as I can tell, getenv works on Windows (core Mesa uses it
> all over the place), so the added value isn't clear to me.
> 
> On 05/17/2016 03:36 PM, Tim Rowley wrote:
>> ---
>> src/gallium/drivers/swr/rasterizer/core/utils.h | 17 +++++++++++++++++
>> 1 file changed, 17 insertions(+)
>> 
>> diff --git a/src/gallium/drivers/swr/rasterizer/core/utils.h b/src/gallium/drivers/swr/rasterizer/core/utils.h
>> index e3c534d..1c4780a 100644
>> --- a/src/gallium/drivers/swr/rasterizer/core/utils.h
>> +++ b/src/gallium/drivers/swr/rasterizer/core/utils.h
>> @@ -866,3 +866,20 @@ struct TemplateArgUnroller
>>     }
>> };
>> 
>> +//////////////////////////////////////////////////////////////////////////
>> +/// Helper used to get an environment variable
>> +//////////////////////////////////////////////////////////////////////////
>> +static INLINE std::string GetEnv(const std::string& variableName)
>> +{
>> +    std::string output;
>> +#if defined(_WIN32)
>> +    DWORD valueSize = GetEnvironmentVariableA(variableName.c_str(), nullptr, 0);
>> +    if (!valueSize) return output;
>> +    output.resize(valueSize - 1); // valueSize includes null, output.resize() does not
>> +    GetEnvironmentVariableA(variableName.c_str(), &output[0], valueSize);
>> +#else
>> +    output = getenv(variableName.c_str());
>> +#endif
>> +
>> +    return output;
>> +}
>> \ No newline at end of file
>> 
> 



More information about the mesa-dev mailing list