From 94343b6b8eb0c90a76c504e689d840634af5241f Mon Sep 17 00:00:00 2001 From: Ivan Shynkarenka <chronoxor@gmail.com> Date: Thu, 19 Apr 2018 22:24:23 +0300 Subject: [PATCH] Cygwin build failed MinGW 7.2 (x86_64) build failed --- c++/src/capnp/compiler/capnp.c++ | 4 ++++ c++/src/capnp/compiler/capnpc-capnp.c++ | 4 ++++ c++/src/capnp/compiler/evolution-test.c++ | 4 ++++ c++/src/capnp/fuzz-test.c++ | 4 ++++ c++/src/capnp/serialize-async-test.c++ | 4 ++++ c++/src/capnp/serialize-test.c++ | 4 ++++ c++/src/kj/async-io-unix.c++ | 4 ++++ c++/src/kj/debug-test.c++ | 4 ++++ c++/src/kj/exception.c++ | 4 ++++ c++/src/kj/filesystem-disk-unix.c++ | 8 ++++++-- c++/src/kj/filesystem-disk-win32.c++ | 2 +- c++/src/kj/io-test.c++ | 4 ++++ c++/src/kj/io.c++ | 4 ++++ c++/src/kj/main.c++ | 4 ++++ c++/src/kj/test.c++ | 4 ++++ 15 files changed, 59 insertions(+), 3 deletions(-) diff --git a/c++/src/capnp/compiler/capnp.c++ b/c++/src/capnp/compiler/capnp.c++ index 9633f6bb..cac176dc 100644 --- a/c++/src/capnp/compiler/capnp.c++ +++ b/c++/src/capnp/compiler/capnp.c++ @@ -19,6 +19,10 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. +#if __CYGWIN__ +#define _GNU_SOURCE +#endif + #include "lexer.h" #include "parser.h" #include "compiler.h" diff --git a/c++/src/capnp/compiler/capnpc-capnp.c++ b/c++/src/capnp/compiler/capnpc-capnp.c++ index df4dcd94..a742f770 100644 --- a/c++/src/capnp/compiler/capnpc-capnp.c++ +++ b/c++/src/capnp/compiler/capnpc-capnp.c++ @@ -22,6 +22,10 @@ // This program is a code generator plugin for `capnp compile` which writes the schema back to // stdout in roughly capnpc format. +#if __CYGWIN__ +#define _GNU_SOURCE +#endif + #include <capnp/schema.capnp.h> #include "../serialize.h" #include <kj/debug.h> diff --git a/c++/src/capnp/compiler/evolution-test.c++ b/c++/src/capnp/compiler/evolution-test.c++ index b1daec42..41d4dba0 100644 --- a/c++/src/capnp/compiler/evolution-test.c++ +++ b/c++/src/capnp/compiler/evolution-test.c++ @@ -26,6 +26,10 @@ // the types are expected to be compatible, the test also constructs an instance of the old // type and reads it as the new type, and vice versa. +#if __CYGWIN__ +#define _GNU_SOURCE +#endif + #include <capnp/compiler/grammar.capnp.h> #include <capnp/schema-loader.h> #include <capnp/message.h> diff --git a/c++/src/capnp/fuzz-test.c++ b/c++/src/capnp/fuzz-test.c++ index 6c1e2af7..4758655e 100644 --- a/c++/src/capnp/fuzz-test.c++ +++ b/c++/src/capnp/fuzz-test.c++ @@ -19,6 +19,10 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. +#if __CYGWIN__ +#define _GNU_SOURCE +#endif + #include <capnp/test-import.capnp.h> #include <capnp/test-import2.capnp.h> #include "message.h" diff --git a/c++/src/capnp/serialize-async-test.c++ b/c++/src/capnp/serialize-async-test.c++ index d1532466..6af41d1d 100644 --- a/c++/src/capnp/serialize-async-test.c++ +++ b/c++/src/capnp/serialize-async-test.c++ @@ -19,6 +19,10 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. +#if __CYGWIN__ +#define _GNU_SOURCE +#endif + #include "serialize-async.h" #include "serialize.h" #include <kj/debug.h> diff --git a/c++/src/capnp/serialize-test.c++ b/c++/src/capnp/serialize-test.c++ index 76433194..a5d4cb74 100644 --- a/c++/src/capnp/serialize-test.c++ +++ b/c++/src/capnp/serialize-test.c++ @@ -19,6 +19,10 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. +#if __CYGWIN__ +#define _GNU_SOURCE +#endif + #include "serialize.h" #include <kj/debug.h> #include <kj/compat/gtest.h> diff --git a/c++/src/kj/async-io-unix.c++ b/c++/src/kj/async-io-unix.c++ index 04a4fbed..1966c6ec 100644 --- a/c++/src/kj/async-io-unix.c++ +++ b/c++/src/kj/async-io-unix.c++ @@ -22,6 +22,10 @@ #if !_WIN32 // For Win32 implementation, see async-io-win32.c++. +#if __CYGWIN__ +#define _GNU_SOURCE +#endif + #include "async-io.h" #include "async-io-internal.h" #include "async-unix.h" diff --git a/c++/src/kj/debug-test.c++ b/c++/src/kj/debug-test.c++ index 8bf32a2e..5516c5a3 100644 --- a/c++/src/kj/debug-test.c++ +++ b/c++/src/kj/debug-test.c++ @@ -19,6 +19,10 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. +#if __CYGWIN__ +#define _GNU_SOURCE +#endif + #include "debug.h" #include "exception.h" #include <kj/compat/gtest.h> diff --git a/c++/src/kj/exception.c++ b/c++/src/kj/exception.c++ index ad7dce68..dd0abfda 100644 --- a/c++/src/kj/exception.c++ +++ b/c++/src/kj/exception.c++ @@ -19,6 +19,10 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. +#if __CYGWIN__ +#define _GNU_SOURCE +#endif + #include "exception.h" #include "string.h" #include "debug.h" diff --git a/c++/src/kj/filesystem-disk-unix.c++ b/c++/src/kj/filesystem-disk-unix.c++ index 2588d8fd..feddd49d 100644 --- a/c++/src/kj/filesystem-disk-unix.c++ +++ b/c++/src/kj/filesystem-disk-unix.c++ @@ -21,6 +21,10 @@ #if !_WIN32 +#if __CYGWIN__ +#define _GNU_SOURCE +#endif + #include "filesystem.h" #include "debug.h" #include <sys/types.h> @@ -385,8 +389,8 @@ public: static const byte ZEROS[4096] = { 0 }; -#if __APPLE__ - // Mac doesn't have pwritev(). +#if __APPLE__ || __CYGWIN__ + // Mac & Cygwin doesn't have pwritev(). while (size > sizeof(ZEROS)) { write(offset, ZEROS); size -= sizeof(ZEROS); diff --git a/c++/src/kj/filesystem-disk-win32.c++ b/c++/src/kj/filesystem-disk-win32.c++ index d328c89f..3de773b4 100644 --- a/c++/src/kj/filesystem-disk-win32.c++ +++ b/c++/src/kj/filesystem-disk-win32.c++ @@ -1094,7 +1094,7 @@ public: } KJ_DEFER({ if (kj::isSameType<T, Directory>()) { - HANDLE newHandle; + HANDLE newHandle = nullptr; KJ_WIN32(newHandle = CreateFileW( committed ? parentDirectory.nativePath(path).begin() : tempPath.begin(), GENERIC_READ, diff --git a/c++/src/kj/io-test.c++ b/c++/src/kj/io-test.c++ index 0eee98ea..2edc13fe 100644 --- a/c++/src/kj/io-test.c++ +++ b/c++/src/kj/io-test.c++ @@ -19,6 +19,10 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. +#if __CYGWIN__ +#define _GNU_SOURCE +#endif + #include "io.h" #include "debug.h" #include "miniposix.h" diff --git a/c++/src/kj/io.c++ b/c++/src/kj/io.c++ index 1db4c486..1456f60a 100644 --- a/c++/src/kj/io.c++ +++ b/c++/src/kj/io.c++ @@ -19,6 +19,10 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. +#if __CYGWIN__ +#define _GNU_SOURCE +#endif + #include "io.h" #include "debug.h" #include "miniposix.h" diff --git a/c++/src/kj/main.c++ b/c++/src/kj/main.c++ index d25369f4..78917e54 100644 --- a/c++/src/kj/main.c++ +++ b/c++/src/kj/main.c++ @@ -19,6 +19,10 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. +#if __CYGWIN__ +#define _GNU_SOURCE +#endif + #include "main.h" #include "debug.h" #include "arena.h" diff --git a/c++/src/kj/test.c++ b/c++/src/kj/test.c++ index 33f1bdb7..8efb0b51 100644 --- a/c++/src/kj/test.c++ +++ b/c++/src/kj/test.c++ @@ -19,6 +19,10 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. +#if __CYGWIN__ +#define _GNU_SOURCE +#endif + #include "test.h" #include "main.h" #include "io.h" -- 2.18.0