aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJisi Liu <jisi.liu@gmail.com>2017-08-11 12:08:00 -0700
committerJisi Liu <jisi.liu@gmail.com>2017-08-11 12:08:00 -0700
commit564f02c91ec0e983806762de4b842a762e21bb47 (patch)
tree52a4a64303c8426f487f08624e5059b977b078cc
parent7afa796bb914c911cc3d40aeeba1ce63b2f83f99 (diff)
downloadprotobuf-564f02c91ec0e983806762de4b842a762e21bb47.tar.gz
protobuf-564f02c91ec0e983806762de4b842a762e21bb47.tar.bz2
protobuf-564f02c91ec0e983806762de4b842a762e21bb47.zip
Make win32_io only for MSVC
This excludes cygwin and mingw from using the self implemented functions.
-rw-r--r--src/google/protobuf/compiler/command_line_interface.cc2
-rw-r--r--src/google/protobuf/compiler/command_line_interface_unittest.cc2
-rw-r--r--src/google/protobuf/compiler/importer.cc3
-rw-r--r--src/google/protobuf/compiler/objectivec/objectivec_helpers.cc2
-rw-r--r--src/google/protobuf/compiler/plugin.cc2
-rw-r--r--src/google/protobuf/io/zero_copy_stream_impl.cc3
-rw-r--r--src/google/protobuf/io/zero_copy_stream_unittest.cc3
-rw-r--r--src/google/protobuf/message_unittest.cc2
-rw-r--r--src/google/protobuf/stubs/io_win32.cc6
-rw-r--r--src/google/protobuf/stubs/io_win32.h4
-rw-r--r--src/google/protobuf/testing/file.cc3
-rw-r--r--src/google/protobuf/testing/googletest.cc2
12 files changed, 22 insertions, 12 deletions
diff --git a/src/google/protobuf/compiler/command_line_interface.cc b/src/google/protobuf/compiler/command_line_interface.cc
index 5707d72c..5f864041 100644
--- a/src/google/protobuf/compiler/command_line_interface.cc
+++ b/src/google/protobuf/compiler/command_line_interface.cc
@@ -108,7 +108,7 @@ namespace compiler {
#endif
namespace {
-#if defined(_WIN32) && !defined(__CYGWIN__)
+#if defined(_MSC_VER)
// DO NOT include <io.h>, instead create functions in io_win32.{h,cc} and import
// them like we do below.
using google::protobuf::internal::win32::access;
diff --git a/src/google/protobuf/compiler/command_line_interface_unittest.cc b/src/google/protobuf/compiler/command_line_interface_unittest.cc
index 64cdbcd2..73d3e4c9 100644
--- a/src/google/protobuf/compiler/command_line_interface_unittest.cc
+++ b/src/google/protobuf/compiler/command_line_interface_unittest.cc
@@ -69,7 +69,7 @@ namespace google {
namespace protobuf {
namespace compiler {
-#if defined(_WIN32)
+#if defined(_MSC_VER)
// DO NOT include <io.h>, instead create functions in io_win32.{h,cc} and import
// them like we do below.
using google::protobuf::internal::win32::access;
diff --git a/src/google/protobuf/compiler/importer.cc b/src/google/protobuf/compiler/importer.cc
index 4e86d787..4c357aa0 100644
--- a/src/google/protobuf/compiler/importer.cc
+++ b/src/google/protobuf/compiler/importer.cc
@@ -59,6 +59,9 @@
#ifdef _WIN32
#include <ctype.h>
+#endif
+
+#ifdef _MSC_VER
// DO NOT include <io.h>, instead create functions in io_win32.{h,cc} and import
// them like we do below.
using google::protobuf::internal::win32::access;
diff --git a/src/google/protobuf/compiler/objectivec/objectivec_helpers.cc b/src/google/protobuf/compiler/objectivec/objectivec_helpers.cc
index 72b5d5f5..54dc7455 100644
--- a/src/google/protobuf/compiler/objectivec/objectivec_helpers.cc
+++ b/src/google/protobuf/compiler/objectivec/objectivec_helpers.cc
@@ -50,7 +50,7 @@
#include <google/protobuf/stubs/io_win32.h>
#include <google/protobuf/stubs/strutil.h>
-#if defined(_WIN32)
+#if defined(_MSC_VER)
// DO NOT include <io.h>, instead create functions in io_win32.{h,cc} and import
// them like we do below.
using google::protobuf::internal::win32::open;
diff --git a/src/google/protobuf/compiler/plugin.cc b/src/google/protobuf/compiler/plugin.cc
index fcb08551..cb5e37bb 100644
--- a/src/google/protobuf/compiler/plugin.cc
+++ b/src/google/protobuf/compiler/plugin.cc
@@ -49,7 +49,7 @@
#include <google/protobuf/descriptor.h>
#include <google/protobuf/io/zero_copy_stream_impl.h>
-#if defined(_WIN32)
+#if defined(_MSC_VER)
// DO NOT include <io.h>, instead create functions in io_win32.{h,cc} and import
// them like we do below.
using google::protobuf::internal::win32::setmode;
diff --git a/src/google/protobuf/io/zero_copy_stream_impl.cc b/src/google/protobuf/io/zero_copy_stream_impl.cc
index f72add41..81fb5033 100644
--- a/src/google/protobuf/io/zero_copy_stream_impl.cc
+++ b/src/google/protobuf/io/zero_copy_stream_impl.cc
@@ -56,6 +56,9 @@ namespace io {
// Win32 lseek is broken: If invoked on a non-seekable file descriptor, its
// return value is undefined. We re-define it to always produce an error.
#define lseek(fd, offset, origin) ((off_t)-1)
+#endif
+
+#ifdef _MSC_VER
// DO NOT include <io.h>, instead create functions in io_win32.{h,cc} and import
// them like we do below.
using google::protobuf::internal::win32::access;
diff --git a/src/google/protobuf/io/zero_copy_stream_unittest.cc b/src/google/protobuf/io/zero_copy_stream_unittest.cc
index f3754087..2bca6a90 100644
--- a/src/google/protobuf/io/zero_copy_stream_unittest.cc
+++ b/src/google/protobuf/io/zero_copy_stream_unittest.cc
@@ -83,6 +83,9 @@ namespace {
#ifdef _WIN32
#define pipe(fds) _pipe(fds, 4096, O_BINARY)
+#endif
+
+#ifdef _MSC_VER
// DO NOT include <io.h>, instead create functions in io_win32.{h,cc} and import
// them like we do below.
using google::protobuf::internal::win32::access;
diff --git a/src/google/protobuf/message_unittest.cc b/src/google/protobuf/message_unittest.cc
index 362000c7..fe456677 100644
--- a/src/google/protobuf/message_unittest.cc
+++ b/src/google/protobuf/message_unittest.cc
@@ -63,7 +63,7 @@
namespace google {
namespace protobuf {
-#if defined(_WIN32)
+#if defined(_MSC_VER)
// DO NOT include <io.h>, instead create functions in io_win32.{h,cc} and import
// them like we do below.
using google::protobuf::internal::win32::close;
diff --git a/src/google/protobuf/stubs/io_win32.cc b/src/google/protobuf/stubs/io_win32.cc
index 25f672cc..d1ad6761 100644
--- a/src/google/protobuf/stubs/io_win32.cc
+++ b/src/google/protobuf/stubs/io_win32.cc
@@ -39,15 +39,13 @@
//
// This file is only used on Windows, it's empty on other platforms.
-#if defined(_WIN32)
+#if defined(_MSC_VER)
// Comment this out to fall back to using the ANSI versions (open, mkdir, ...)
// instead of the Unicode ones (_wopen, _wmkdir, ...). Doing so can be useful to
// debug failing tests if that's caused by the long path support.
// Long path support is disabled in MinGW
-#ifndef __MINGW32__
#define SUPPORT_LONGPATHS
-#endif // !__MINGW32__
#include <ctype.h>
#include <direct.h>
@@ -361,5 +359,5 @@ wstring testonly_path_to_winpath(const string& path) {
} // namespace protobuf
} // namespace google
-#endif // defined(_WIN32)
+#endif // defined(_MSC_VER)
diff --git a/src/google/protobuf/stubs/io_win32.h b/src/google/protobuf/stubs/io_win32.h
index 3699945b..2cd53a5e 100644
--- a/src/google/protobuf/stubs/io_win32.h
+++ b/src/google/protobuf/stubs/io_win32.h
@@ -45,7 +45,7 @@
#ifndef GOOGLE_PROTOBUF_STUBS_IO_WIN32_H__
#define GOOGLE_PROTOBUF_STUBS_IO_WIN32_H__
-#if defined(_WIN32)
+#if defined(_MSC_VER)
#include <string>
#include <google/protobuf/stubs/port.h>
@@ -91,7 +91,7 @@ LIBPROTOBUF_EXPORT std::wstring testonly_path_to_winpath(
#define STDOUT_FILENO 1
#endif
-#endif // defined(_WIN32)
+#endif // defined(_MSC_VER)
#endif // GOOGLE_PROTOBUF_STUBS_IO_WIN32_H__
diff --git a/src/google/protobuf/testing/file.cc b/src/google/protobuf/testing/file.cc
index a1850e44..f32222b7 100644
--- a/src/google/protobuf/testing/file.cc
+++ b/src/google/protobuf/testing/file.cc
@@ -55,6 +55,9 @@ namespace protobuf {
#define lstat stat
// DO NOT include <io.h>, instead create functions in io_win32.{h,cc} and import
// them like we do below.
+#endif
+
+#ifdef _MSC_VER
using google::protobuf::internal::win32::access;
using google::protobuf::internal::win32::chdir;
using google::protobuf::internal::win32::fopen;
diff --git a/src/google/protobuf/testing/googletest.cc b/src/google/protobuf/testing/googletest.cc
index c6fb00d4..33a75ed6 100644
--- a/src/google/protobuf/testing/googletest.cc
+++ b/src/google/protobuf/testing/googletest.cc
@@ -52,7 +52,7 @@
namespace google {
namespace protobuf {
-#ifdef _WIN32
+#ifdef _MSC_VER
// DO NOT include <io.h>, instead create functions in io_win32.{h,cc} and import
// them like we do below.
using google::protobuf::internal::win32::close;