Implement an alternative setenv/unsetenv, as it is not available on windows.
Switch uses of setenv/unsetenv to the new one. PiperOrigin-RevId: 288738669 Change-Id: I689d0222c1dfcceeb5eef38c57bfb8524fd1c9b1
This commit is contained in:
parent
43e41f42dd
commit
2a66ce6f09
@ -16,7 +16,9 @@ limitations under the License.
|
|||||||
#include "tensorflow/core/framework/run_handler_util.h"
|
#include "tensorflow/core/framework/run_handler_util.h"
|
||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "tensorflow/core/lib/strings/strcat.h"
|
#include "tensorflow/core/lib/strings/strcat.h"
|
||||||
|
#include "tensorflow/core/platform/env.h"
|
||||||
#include "tensorflow/core/platform/logging.h"
|
#include "tensorflow/core/platform/logging.h"
|
||||||
#include "tensorflow/core/platform/test.h"
|
#include "tensorflow/core/platform/test.h"
|
||||||
namespace tensorflow {
|
namespace tensorflow {
|
||||||
|
@ -39,6 +39,7 @@ limitations under the License.
|
|||||||
#include "tensorflow/core/lib/core/notification.h"
|
#include "tensorflow/core/lib/core/notification.h"
|
||||||
#include "tensorflow/core/lib/core/status_test_util.h"
|
#include "tensorflow/core/lib/core/status_test_util.h"
|
||||||
#include "tensorflow/core/lib/strings/strcat.h"
|
#include "tensorflow/core/lib/strings/strcat.h"
|
||||||
|
#include "tensorflow/core/platform/env.h"
|
||||||
#include "tensorflow/core/platform/test.h"
|
#include "tensorflow/core/platform/test.h"
|
||||||
#include "tensorflow/core/public/session_options.h"
|
#include "tensorflow/core/public/session_options.h"
|
||||||
#include "tensorflow/core/public/version.h"
|
#include "tensorflow/core/public/version.h"
|
||||||
|
@ -26,6 +26,7 @@ limitations under the License.
|
|||||||
#include "tensorflow/core/graph/node_builder.h"
|
#include "tensorflow/core/graph/node_builder.h"
|
||||||
#include "tensorflow/core/kernels/ops_testutil.h"
|
#include "tensorflow/core/kernels/ops_testutil.h"
|
||||||
#include "tensorflow/core/kernels/ops_util.h"
|
#include "tensorflow/core/kernels/ops_util.h"
|
||||||
|
#include "tensorflow/core/platform/env.h"
|
||||||
#include "tensorflow/core/platform/test.h"
|
#include "tensorflow/core/platform/test.h"
|
||||||
#include "tensorflow/core/platform/test_benchmark.h"
|
#include "tensorflow/core/platform/test_benchmark.h"
|
||||||
#include "tensorflow/core/protobuf/rewriter_config.pb.h"
|
#include "tensorflow/core/protobuf/rewriter_config.pb.h"
|
||||||
|
@ -18,6 +18,7 @@ limitations under the License.
|
|||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <fnmatch.h>
|
#include <fnmatch.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
#include <sys/mman.h>
|
#include <sys/mman.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
@ -258,4 +259,10 @@ void PosixEnv::GetLocalTempDirectories(std::vector<string>* list) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int setenv(const char* name, const char* value, int overwrite) {
|
||||||
|
return ::setenv(name, value, overwrite);
|
||||||
|
}
|
||||||
|
|
||||||
|
int unsetenv(const char* name) { return ::unsetenv(name); }
|
||||||
|
|
||||||
} // namespace tensorflow
|
} // namespace tensorflow
|
||||||
|
@ -431,6 +431,15 @@ class Thread {
|
|||||||
TF_DISALLOW_COPY_AND_ASSIGN(Thread);
|
TF_DISALLOW_COPY_AND_ASSIGN(Thread);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/// \brief Cross-platform setenv.
|
||||||
|
///
|
||||||
|
/// Since setenv() is not available on windows, we provide an
|
||||||
|
/// alternative with platform specific implementations here.
|
||||||
|
int setenv(const char* name, const char* value, int overwrite);
|
||||||
|
|
||||||
|
/// Cross-platform unsetenv.
|
||||||
|
int unsetenv(const char* name);
|
||||||
|
|
||||||
/// \brief Options to configure a Thread.
|
/// \brief Options to configure a Thread.
|
||||||
///
|
///
|
||||||
/// Note that the options are all hints, and the
|
/// Note that the options are all hints, and the
|
||||||
|
@ -20,6 +20,7 @@ limitations under the License.
|
|||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#undef LoadLibrary
|
#undef LoadLibrary
|
||||||
#undef ERROR
|
#undef ERROR
|
||||||
@ -214,4 +215,16 @@ void WindowsEnv::GetLocalTempDirectories(std::vector<string>* list) {
|
|||||||
list->push_back("C:\\temp\\");
|
list->push_back("C:\\temp\\");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int setenv(const char* name, const char* value, int overwrite) {
|
||||||
|
if (!overwrite) {
|
||||||
|
char* env_val = getenv(name);
|
||||||
|
if (env_val) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return _putenv_s(name, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
int unsetenv(const char* name) { return _putenv_s(name, ""); }
|
||||||
|
|
||||||
} // namespace tensorflow
|
} // namespace tensorflow
|
||||||
|
Loading…
x
Reference in New Issue
Block a user