Fix Cygwin Newlib signal handler (Issue 315)

This commit is contained in:
Jeffrey Walton 2016-10-14 15:00:49 -04:00
parent 7ce3922b97
commit 5596f73371
No known key found for this signature in database
GPG Key ID: B36AB348921B1838
4 changed files with 12 additions and 8 deletions

View File

@ -690,7 +690,9 @@ NAMESPACE_END
# define THREADS_AVAILABLE
#endif
#if defined(CRYPTOPP_BSD_AVAILABLE) || defined(CRYPTOPP_UNIX_AVAILABLE) || defined(__CYGWIN__)
// Newlib on Cygwin is a problem. __NEWLIB__ is not defined yet; use __CYGWIN__ as a proxy
// Also see https://github.com/weidai11/cryptopp/issues/315
#if defined(CRYPTOPP_UNIX_AVAILABLE) && !defined(__CYGWIN__)
# define UNIX_SIGNALS_AVAILABLE 1
#endif

View File

@ -690,7 +690,9 @@ NAMESPACE_END
# define THREADS_AVAILABLE
#endif
#if defined(CRYPTOPP_BSD_AVAILABLE) || defined(CRYPTOPP_UNIX_AVAILABLE) || defined(__CYGWIN__)
// Newlib on Cygwin is a problem. __NEWLIB__ is not defined yet; use __CYGWIN__ as a proxy
// Also see https://github.com/weidai11/cryptopp/issues/315
#if defined(CRYPTOPP_UNIX_AVAILABLE) && !defined(__CYGWIN__)
# define UNIX_SIGNALS_AVAILABLE 1
#endif

View File

@ -126,7 +126,7 @@ RandomNumberGenerator & GlobalRNG()
}
// See misc.h and trap.h for comments and usage
#if CRYPTOPP_DEBUG && (defined(CRYPTOPP_BSD_AVAILABLE) || defined(CRYPTOPP_UNIX_AVAILABLE))
#if CRYPTOPP_DEBUG && defined(UNIX_SIGNALS_AVAILABLE)
static const SignalHandler<SIGTRAP, false> s_dummyHandler;
// static const DebugTrapHandler s_dummyHandler;
#endif

10
trap.h
View File

@ -21,9 +21,9 @@
#if CRYPTOPP_DEBUG
# include <iostream>
# include <sstream>
# if defined(CRYPTOPP_BSD_AVAILABLE) || defined(CRYPTOPP_UNIX_AVAILABLE)
# if defined(UNIX_SIGNALS_AVAILABLE)
# include "ossig.h"
# elif defined(CRYPTOPP_WIN32_AVAILABLE)
# elif defined(CRYPTOPP_WIN32_AVAILABLE) && !defined(__CYGWIN__)
# if (_MSC_VER >= 1400)
# include <intrin.h>
# endif
@ -62,7 +62,7 @@
# define CRYPTOPP_ASSERT(exp) { ... }
#endif
#if CRYPTOPP_DEBUG && (defined(CRYPTOPP_BSD_AVAILABLE) || defined(CRYPTOPP_UNIX_AVAILABLE))
#if CRYPTOPP_DEBUG && defined(UNIX_SIGNALS_AVAILABLE)
# define CRYPTOPP_ASSERT(exp) { \
if (!(exp)) { \
std::ostringstream oss; \
@ -73,7 +73,7 @@
raise(SIGTRAP); \
} \
}
#elif CRYPTOPP_DEBUG && defined(CRYPTOPP_WIN32_AVAILABLE)
#elif CRYPTOPP_DEBUG && defined(CRYPTOPP_WIN32_AVAILABLE) && !defined(__CYGWIN__)
# define CRYPTOPP_ASSERT(exp) { \
if (!(exp)) { \
std::ostringstream oss; \
@ -96,7 +96,7 @@ NAMESPACE_BEGIN(CryptoPP)
// ************** SIGTRAP handler ***************
#if (CRYPTOPP_DEBUG && (defined(CRYPTOPP_BSD_AVAILABLE) || defined(CRYPTOPP_UNIX_AVAILABLE))) || defined(CRYPTOPP_DOXYGEN_PROCESSING)
#if (CRYPTOPP_DEBUG && defined(UNIX_SIGNALS_AVAILABLE)) || defined(CRYPTOPP_DOXYGEN_PROCESSING)
//! \brief Default SIGTRAP handler
//! \details DebugTrapHandler() can be used by a program to install an empty SIGTRAP handler. If present,
//! the handler ensures there is a signal handler in place for <tt>SIGTRAP</tt> raised by