Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions cmake/Config.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,19 @@ if(SMP)
add_definitions(-D_GLIBCXX_USE_NANOSLEEP)
endif(SMP)

######################################################################################
### MSVC specific compiler options
######################################################################################

if(MSVC)
# Add /Zc:__cplusplus compiler option to enable correct __cplusplus macro
add_compile_options(/Zc:__cplusplus)
# Add utf8
add_compile_options(/utf-8)
# Add HAVE_UINT32_T=1 preprocessor definition
add_definitions(-DHAVE_UINT32_T=1)
endif(MSVC)

######################################################################################
### 1) Define installation type
######################################################################################
Expand Down
5 changes: 4 additions & 1 deletion deprecated/eo/src/utils/eoRNG.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/** Random number generator adapted from (see comments below)
/** Random number generator adapted from (see comments below)

The random number generator is modified into a class
by Maarten Keijzer (mak@dhi.dk). Also added the Box-Muller
Expand Down Expand Up @@ -37,7 +37,10 @@ Old contact information: todos@geneura.ugr.es, http://geneura.ugr.es
optimization levels so feel free to try your options and see what's best for
you.
*/
#if HAVE_UINT32_T
typedef unsigned long uint32_t;
#endif // HAVE_UINT32_T

#else
#if (! defined __sun)
// The C99-standard defines uint32_t to be declared in stdint.h, but some
Expand Down
2 changes: 0 additions & 2 deletions eo/src/do/make_checkpoint.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ eoCheckPoint<EOT>& do_make_checkpoint(eoParser& _parser, eoState& _state, eoValu
// Signal monitoring
////////////////////

#ifndef _MSC_VER
// the CtrlC monitoring interception
eoSignal<EOT> *mon_ctrlCCont = nullptr;
eoValueParam<bool>& mon_ctrlCParam = _parser.createParam(false, "monitor-with-CtrlC", "Monitor current generation upon Ctrl C",0, "Stopping criterion");
Expand All @@ -75,7 +74,6 @@ eoCheckPoint<EOT>& do_make_checkpoint(eoParser& _parser, eoState& _state, eoValu
// add to checkpoint
checkpoint->add(*mon_ctrlCCont);
}
#endif

///////////////////
// Counters
Expand Down
5 changes: 3 additions & 2 deletions eo/src/es/CMAState.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*
/*
* C++ification of Nikolaus Hansen's original C-source code for the
* CMA-ES
*
Expand Down Expand Up @@ -66,7 +66,8 @@ using namespace std;

namespace eo {

struct CMAStateImpl {
class CMAStateImpl {
public:

CMAParams p;

Expand Down
7 changes: 6 additions & 1 deletion eo/src/utils/eoRNG.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/** Random number generator adapted from (see comments below)
/** Random number generator adapted from (see comments below)

The random number generator is modified into a class
by Maarten Keijzer (mak@dhi.dk). Also added the Box-Muller
Expand Down Expand Up @@ -37,7 +37,12 @@ Old contact information: todos@geneura.ugr.es, http://geneura.ugr.es
optimization levels so feel free to try your options and see what's best for
you.
*/
#if HAVE_UINT32_T
#include <cstdint>
#else
typedef unsigned long uint32_t;
#endif // HAVE_UINT32_T

#else
#if (! defined __sun)
// The C99-standard defines uint32_t to be declared in stdint.h, but some
Expand Down
42 changes: 40 additions & 2 deletions eo/src/utils/eoSignal.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,37 @@
#include <map>
#include <vector>

#ifdef _WINDOWS
#define NOMINMAX
#include <Windows.h>
#endif // _WINDOWS

/**
* @addtogroup Continuators
* @{
*/

extern std::map< int, bool > signals_called;

#ifdef _WINDOWS
// Windows console control handler - process level handler
// Returns TRUE if the signal was handled, FALSE otherwise
inline BOOL WINAPI ConsoleCtrlHandler(DWORD dwCtrlType)
{
if (dwCtrlType == CTRL_C_EVENT || dwCtrlType == CTRL_BREAK_EVENT)
{
// Map Windows control event to SIGINT for compatibility
::signals_called[SIGINT] = true;
eo::log << eo::logging << "Signal wished…" << std::endl;
return TRUE; // Signal handled, don't terminate the process
}
return FALSE;
}

// Track if console handler is already installed
static bool console_handler_installed = false;
#endif // _WINDOWS

/** eoSignal inherits from eoCheckPoint including signals handling (see signal(7))
*
* @ingroup Utilities
Expand All @@ -53,7 +77,14 @@ public :
{
::signals_called[_sig] = false;

#ifndef _WINDOWS
#ifdef _WINDOWS
// Install Windows console control handler (only once per process)
if (!console_handler_installed)
{
SetConsoleCtrlHandler(ConsoleCtrlHandler, TRUE);
console_handler_installed = true;
}
#else
#ifdef SIGQUIT
::signal( _sig, handler );
#endif // !SIGQUIT
Expand All @@ -64,7 +95,14 @@ public :
{
::signals_called[_sig] = false;

#ifndef _WINDOWS
#ifdef _WINDOWS
// Install Windows console control handler (only once per process)
if (!console_handler_installed)
{
SetConsoleCtrlHandler(ConsoleCtrlHandler, TRUE);
console_handler_installed = true;
}
#else
#ifdef SIGQUIT
::signal( _sig, handler );
#endif // !SIGQUIT
Expand Down