From a1274ff01b3ccce2185d53a3126478c9700f0566 Mon Sep 17 00:00:00 2001 From: Joel Shapiro Date: Mon, 17 Jun 2019 15:24:14 -0500 Subject: [PATCH 1/3] change usage of 'fileno' to allow for msvc implementation --- tensorflow/lite/allocation.cc | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/tensorflow/lite/allocation.cc b/tensorflow/lite/allocation.cc index f9a34322f0c..6904be9b7a1 100644 --- a/tensorflow/lite/allocation.cc +++ b/tensorflow/lite/allocation.cc @@ -17,6 +17,9 @@ limitations under the License. #include #include +#ifdef _WIN32 +#include +#endif #include #include #include @@ -42,10 +45,18 @@ FileCopyAllocation::FileCopyAllocation(const char* filename, // TODO(ahentz): Why did you think using fseek here was better for finding // the size? struct stat sb; - if (fstat(fileno(file.get()), &sb) != 0) { + +// support usage of msvc's posix-like fileno symbol +#ifdef _WIN32 +#define FILENO(_x) _fileno(_x) +#else +#define FILENO(_x) fileno(_x) +#endif + if (fstat(FILENO(file.get()), &sb) != 0) { error_reporter_->Report("Failed to get file size of '%s'.", filename); return; } +#undef FILENO buffer_size_bytes_ = sb.st_size; std::unique_ptr buffer(new char[buffer_size_bytes_]); if (!buffer) { From c2b45ed7acf8bd94b0ce0d00bbc3641d9e010847 Mon Sep 17 00:00:00 2001 From: Joel Shapiro Date: Fri, 21 Jun 2019 18:02:00 -0500 Subject: [PATCH 2/3] swap c header for cpp one --- tensorflow/lite/allocation.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tensorflow/lite/allocation.cc b/tensorflow/lite/allocation.cc index 6904be9b7a1..98ce16d5865 100644 --- a/tensorflow/lite/allocation.cc +++ b/tensorflow/lite/allocation.cc @@ -17,12 +17,12 @@ limitations under the License. #include #include -#ifdef _WIN32 -#include -#endif #include #include #include +#ifdef _WIN32 +#include +#endif #include #include From 8c192f367f74c945b5949b0f353db3e0bbcd37da Mon Sep 17 00:00:00 2001 From: Joel Shapiro Date: Mon, 24 Jun 2019 14:35:33 -0500 Subject: [PATCH 3/3] remove include conditionals --- tensorflow/lite/allocation.cc | 2 -- 1 file changed, 2 deletions(-) diff --git a/tensorflow/lite/allocation.cc b/tensorflow/lite/allocation.cc index 98ce16d5865..ee000dd5eea 100644 --- a/tensorflow/lite/allocation.cc +++ b/tensorflow/lite/allocation.cc @@ -20,9 +20,7 @@ limitations under the License. #include #include #include -#ifdef _WIN32 #include -#endif #include #include