Skip to content

Commit ea4eb21

Browse files
authored
[STF] Remove dead MSVC setenv polyfill from core.cuh (#8192)
STF is explicitly disabled on MSVC in CMakeLists.txt, so this setenv shim can never be compiled. Remove it along with the now-unused <string> include.
1 parent 68f5e41 commit ea4eb21

File tree

1 file changed

+0
-41
lines changed
  • cudax/include/cuda/experimental/__stf/utility

1 file changed

+0
-41
lines changed

cudax/include/cuda/experimental/__stf/utility/core.cuh

Lines changed: 0 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -33,47 +33,6 @@
3333

3434
namespace cuda::experimental::stf
3535
{
36-
// Hack setenv on Windows
37-
#if _CCCL_COMPILER(MSVC)
38-
/**
39-
* @brief Sets an environment variable, mimicking the behavior of `std::setenv` on Windows.
40-
*
41-
* This function attempts to set the value of the environment variable `name` to `value`.
42-
* If `overwrite` is 0 and the variable already exists, the function does nothing.
43-
*
44-
* @param name The name of the environment variable.
45-
* @param value The value to assign to the environment variable.
46-
* @param overwrite If non-zero, the function will overwrite the existing value of the variable.
47-
* @return 0 on success, or -1 on failure (invalid input or memory allocation failure).
48-
* @note This function is designed for MSVC, which lacks a standard `setenv` function.
49-
*/
50-
inline int setenv(const char* name, const char* value, int overwrite)
51-
{
52-
if (!name || !value || !name[0])
53-
{
54-
// Invalid input: name or value is null, or name is an empty string
55-
return -1;
56-
}
57-
58-
// Check if the variable already exists and if overwrite is allowed
59-
if (!overwrite && ::std::getenv(name) != nullptr)
60-
{
61-
return 0; // Variable exists, and we're not allowed to overwrite it
62-
}
63-
64-
// Construct the string in the form "NAME=VALUE"
65-
auto env_var = ::std::string(name) + "=" + value;
66-
67-
// Use _putenv to set the environment variable in MSVC
68-
if (_putenv(env_var.c_str()) != 0)
69-
{
70-
return -1; // _putenv failed
71-
}
72-
73-
return 0; // Success
74-
}
75-
#endif
76-
7736
#ifndef _CCCL_DOXYGEN_INVOKED // FIXME Doxygen is lost with decltype(auto)
7837
/**
7938
* @brief Custom move function that performs checks on the argument type.

0 commit comments

Comments
 (0)