aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJisi Liu <liujisi@google.com>2017-11-13 10:47:29 -0800
committerGitHub <noreply@github.com>2017-11-13 10:47:29 -0800
commit2761122b810fe8861004ae785cc3ab39f384d342 (patch)
tree128a98651248f01f7b3909634669517ae98db927
parent188f18044feb1ca82ecc922f3e59e37078473ddf (diff)
parent9c197b7ecba6019b7c81c673cf100b2fad4033ad (diff)
downloadprotobuf-3.5.0.tar.gz
protobuf-3.5.0.tar.bz2
protobuf-3.5.0.zip
Merge pull request #3868 from pherl/3.5.xv3.5.0
Support win32 long path for cross compiled build
-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.cc2
-rw-r--r--src/google/protobuf/compiler/objectivec/objectivec_helpers.cc17
-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.cc4
-rw-r--r--src/google/protobuf/stubs/io_win32.h6
-rw-r--r--src/google/protobuf/stubs/io_win32_unittest.cc4
-rw-r--r--src/google/protobuf/testing/file.cc2
-rw-r--r--src/google/protobuf/testing/googletest.cc2
13 files changed, 22 insertions, 29 deletions
diff --git a/src/google/protobuf/compiler/command_line_interface.cc b/src/google/protobuf/compiler/command_line_interface.cc
index 6c2fc164..1f6d748d 100644
--- a/src/google/protobuf/compiler/command_line_interface.cc
+++ b/src/google/protobuf/compiler/command_line_interface.cc
@@ -100,7 +100,7 @@ namespace compiler {
#endif
namespace {
-#if defined(_MSC_VER)
+#if defined(_WIN32)
// 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 38d0e388..ef7579a2 100644
--- a/src/google/protobuf/compiler/command_line_interface_unittest.cc
+++ b/src/google/protobuf/compiler/command_line_interface_unittest.cc
@@ -70,7 +70,7 @@ namespace google {
namespace protobuf {
namespace compiler {
-#if defined(_MSC_VER)
+#if defined(_WIN32)
// 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 9792ffe8..a5341e0d 100644
--- a/src/google/protobuf/compiler/importer.cc
+++ b/src/google/protobuf/compiler/importer.cc
@@ -65,7 +65,7 @@ namespace google {
namespace protobuf {
namespace compiler {
-#ifdef _MSC_VER
+#ifdef _WIN32
// 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 54dc7455..14715ef6 100644
--- a/src/google/protobuf/compiler/objectivec/objectivec_helpers.cc
+++ b/src/google/protobuf/compiler/objectivec/objectivec_helpers.cc
@@ -50,11 +50,6 @@
#include <google/protobuf/stubs/io_win32.h>
#include <google/protobuf/stubs/strutil.h>
-#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;
-#endif
// NOTE: src/google/protobuf/compiler/plugin.cc makes use of cerr for some
// error cases, so it seems to be ok to use as a back door for errors.
@@ -64,6 +59,16 @@ namespace protobuf {
namespace compiler {
namespace objectivec {
+// <io.h> is transitively included in this file. Import the functions explicitly
+// in this port namespace to avoid ambiguous definition.
+namespace posix {
+#ifdef _WIN32
+using ::google::protobuf::internal::win32::open;
+#else
+using ::open;
+#endif
+} // namespace port
+
Options::Options() {
// Default is the value of the env for the package prefixes.
const char* file_path = getenv("GPB_OBJC_EXPECTED_PACKAGE_PREFIXES");
@@ -1469,7 +1474,7 @@ bool ParseSimpleFile(
const string& path, LineConsumer* line_consumer, string* out_error) {
int fd;
do {
- fd = open(path.c_str(), O_RDONLY);
+ fd = posix::open(path.c_str(), O_RDONLY);
} while (fd < 0 && errno == EINTR);
if (fd < 0) {
*out_error =
diff --git a/src/google/protobuf/compiler/plugin.cc b/src/google/protobuf/compiler/plugin.cc
index 7f975510..bde3d798 100644
--- a/src/google/protobuf/compiler/plugin.cc
+++ b/src/google/protobuf/compiler/plugin.cc
@@ -54,7 +54,7 @@ namespace google {
namespace protobuf {
namespace compiler {
-#if defined(_MSC_VER)
+#if defined(_WIN32)
// 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 83dec3e6..dd921135 100644
--- a/src/google/protobuf/io/zero_copy_stream_impl.cc
+++ b/src/google/protobuf/io/zero_copy_stream_impl.cc
@@ -56,9 +56,6 @@ 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 dfc383a3..91792f18 100644
--- a/src/google/protobuf/io/zero_copy_stream_unittest.cc
+++ b/src/google/protobuf/io/zero_copy_stream_unittest.cc
@@ -83,9 +83,6 @@ 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 d328f9dd..a27036e7 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(_MSC_VER)
+#if defined(_WIN32)
// 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 7e1cf785..fa2cb8b1 100644
--- a/src/google/protobuf/stubs/io_win32.cc
+++ b/src/google/protobuf/stubs/io_win32.cc
@@ -39,7 +39,7 @@
//
// This file is only used on Windows, it's empty on other platforms.
-#if defined(_MSC_VER)
+#if defined(_WIN32)
// 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
@@ -358,5 +358,5 @@ wstring testonly_path_to_winpath(const string& path) {
} // namespace protobuf
} // namespace google
-#endif // defined(_MSC_VER)
+#endif // defined(_WIN32)
diff --git a/src/google/protobuf/stubs/io_win32.h b/src/google/protobuf/stubs/io_win32.h
index a20e64c7..53160089 100644
--- a/src/google/protobuf/stubs/io_win32.h
+++ b/src/google/protobuf/stubs/io_win32.h
@@ -52,7 +52,6 @@
// Compilers on Windows other than MSVC (e.g. Cygwin, MinGW32) define the
// following functions already, except for mkdir.
-#ifdef _MSC_VER
namespace google {
namespace protobuf {
namespace internal {
@@ -77,9 +76,6 @@ LIBPROTOBUF_EXPORT std::wstring testonly_path_to_winpath(
} // namespace internal
} // namespace protobuf
} // namespace google
-#else // _MSC_VER
-#define mkdir(name, mode) mkdir(name)
-#endif // !_MSC_VER
#ifndef W_OK
#define W_OK 02 // not defined by MSVC for whatever reason
@@ -100,5 +96,3 @@ LIBPROTOBUF_EXPORT std::wstring testonly_path_to_winpath(
#endif // defined(_WIN32)
#endif // GOOGLE_PROTOBUF_STUBS_IO_WIN32_H__
-
-
diff --git a/src/google/protobuf/stubs/io_win32_unittest.cc b/src/google/protobuf/stubs/io_win32_unittest.cc
index 288f27ab..ce6f7162 100644
--- a/src/google/protobuf/stubs/io_win32_unittest.cc
+++ b/src/google/protobuf/stubs/io_win32_unittest.cc
@@ -34,7 +34,7 @@
//
// This file is only used on Windows, it's empty on other platforms.
-#if defined(_MSC_VER)
+#if defined(_WIN32)
#define WIN32_LEAN_AND_MEAN
#include <errno.h>
@@ -369,5 +369,5 @@ TEST_F(IoWin32Test, AsWindowsPathTest) {
} // namespace protobuf
} // namespace google
-#endif // defined(_MSC_VER)
+#endif // defined(_WIN32)
diff --git a/src/google/protobuf/testing/file.cc b/src/google/protobuf/testing/file.cc
index f68aba9a..26cb0a67 100644
--- a/src/google/protobuf/testing/file.cc
+++ b/src/google/protobuf/testing/file.cc
@@ -57,7 +57,7 @@ namespace protobuf {
// them like we do below.
#endif
-#ifdef _MSC_VER
+#ifdef _WIN32
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 91f0ef89..c329b6c1 100644
--- a/src/google/protobuf/testing/googletest.cc
+++ b/src/google/protobuf/testing/googletest.cc
@@ -52,7 +52,7 @@
namespace google {
namespace protobuf {
-#ifdef _MSC_VER
+#ifdef _WIN32
// 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;