From 8d35ceb98f3dbd55cf55edc3d2a814d0dd6d520d Mon Sep 17 00:00:00 2001
From: Corinna Vinschen <vinschen@redhat.com>
Date: Sat, 16 Jan 2016 19:30:48 +0100
Subject: [PATCH] Use POSIX functions on Cygwin, not Win32 function

Signed-off-by: Corinna Vinschen <vinschen@redhat.com>

Reviewed-by: Rich Salz <rsalz@openssl.org>
Reviewed-by: Richard Levitte <levitte@openssl.org>
---
 apps/speed.c                    | 10 +---------
 crypto/async/arch/async_posix.h |  2 +-
 crypto/async/arch/async_win.h   |  2 +-
 include/openssl/async.h         |  2 +-
 test/asynctest.c                |  4 ++--
 5 files changed, 6 insertions(+), 14 deletions(-)

diff --git a/apps/speed.c b/apps/speed.c
index d45a6f9beb..5bf1685e49 100644
--- a/apps/speed.c
+++ b/apps/speed.c
@@ -94,16 +94,8 @@
 # include <signal.h>
 #endif
 
-#if defined(_WIN32) || defined(__CYGWIN__)
+#if defined(_WIN32)
 # include <windows.h>
-# if defined(__CYGWIN__) && !defined(_WIN32)
-  /*
-   * <windows.h> should define _WIN32, which normally is mutually exclusive
-   * with __CYGWIN__, but if it didn't...
-   */
-#  define _WIN32
-  /* this is done because Cygwin alarm() fails sometimes. */
-# endif
 #endif
 
 #include <openssl/bn.h>
diff --git a/crypto/async/arch/async_posix.h b/crypto/async/arch/async_posix.h
index c247888b67..475b56faab 100644
--- a/crypto/async/arch/async_posix.h
+++ b/crypto/async/arch/async_posix.h
@@ -54,7 +54,7 @@
 #define OPENSSL_ASYNC_ARCH_ASYNC_POSIX_H
 #include <openssl/e_os2.h>
 
-#if defined(OPENSSL_SYS_UNIX) && defined(OPENSSL_THREADS)
+#if (defined(OPENSSL_SYS_UNIX) || defined(OPENSSL_SYS_CYGWIN)) && defined(OPENSSL_THREADS)
 
 # include <unistd.h>
 
diff --git a/crypto/async/arch/async_win.h b/crypto/async/arch/async_win.h
index b247f59e48..31f248216f 100644
--- a/crypto/async/arch/async_win.h
+++ b/crypto/async/arch/async_win.h
@@ -55,7 +55,7 @@
  * This is the same detection used in cryptlib to set up the thread local
  * storage that we depend on, so just copy that
  */
-#if defined(_WIN32) || defined(__CYGWIN__)
+#if defined(_WIN32)
 #include <openssl/async.h>
 # define ASYNC_WIN
 # define ASYNC_ARCH
diff --git a/include/openssl/async.h b/include/openssl/async.h
index de5ef89644..d130a364a7 100644
--- a/include/openssl/async.h
+++ b/include/openssl/async.h
@@ -56,7 +56,7 @@
 
 #include <stdlib.h>
 
-#if defined(_WIN32) || defined(__CYGWIN__)
+#if defined(_WIN32)
 #include <windows.h>
 #define OSSL_ASYNC_FD   HANDLE
 #else
diff --git a/test/asynctest.c b/test/asynctest.c
index 3e68b1d01b..ace52b93e4 100644
--- a/test/asynctest.c
+++ b/test/asynctest.c
@@ -62,12 +62,12 @@
 #include <openssl/crypto.h>
 #include <../apps/apps.h>
 
-#if defined(OPENSSL_SYS_UNIX) && defined(OPENSSL_THREADS)
+#if (defined(OPENSSL_SYS_UNIX) || defined(OPENSSL_SYS_CYGWIN)) && defined(OPENSSL_THREADS)
 # include <unistd.h>
 # if _POSIX_VERSION >= 200112L
 #  define ASYNC_POSIX
 # endif
-#elif defined(_WIN32) || defined(__CYGWIN__)
+#elif defined(_WIN32)
 # define ASYNC_WIN
 #endif
 
-- 
2.25.1